65 lines · plain
1; RUN: opt -S -passes=separate-const-offset-from-gep < %s | FileCheck %s2 3; Check that SeparateConstOffsetFromGEP's reuniteExts() propagates the debug location4; to the new sext instruction, which replaces the old add/sub instruction (`%add.sext`/`%sub.sext`).5 6define i64 @add_sext__dominating_add_nsw(i32 %arg0, i32 %arg1) !dbg !5 {7; CHECK-LABEL: define i64 @add_sext__dominating_add_nsw(8; CHECK: entry:9; CHECK: [[ADD_SEXT:%.*]] = sext i32 [[ADD_NSW:%.*]] to i64, !dbg [[DBG9:![0-9]+]]10;11entry:12 %add.nsw = add nsw i32 %arg0, %arg1, !dbg !813 %arg0.sext = sext i32 %arg0 to i64, !dbg !914 %arg1.sext = sext i32 %arg1 to i64, !dbg !1015 %add.sext = add i64 %arg0.sext, %arg1.sext, !dbg !1116 call void @use.i32(i32 %add.nsw), !dbg !1217 ret i64 %add.sext, !dbg !1318}19 20define i64 @sub_sext__dominating_sub_nsw(i32 %arg0, i32 %arg1) !dbg !14 {21; CHECK-LABEL: define i64 @sub_sext__dominating_sub_nsw(22; CHECK: entry:23; CHECK: [[SUB_SEXT:%.*]] = sext i32 [[SUB_NSW:%.*]] to i64, !dbg [[DBG14:![0-9]+]]24 25;26entry:27 %sub.nsw = sub nsw i32 %arg0, %arg1, !dbg !1528 %arg0.sext = sext i32 %arg0 to i64, !dbg !1629 %arg1.sext = sext i32 %arg1 to i64, !dbg !1730 %sub.sext = sub i64 %arg0.sext, %arg1.sext, !dbg !1831 call void @use.i32(i32 %sub.nsw), !dbg !1932 ret i64 %sub.sext, !dbg !2033}34 35declare void @use.i32(i32 noundef)36 37!llvm.dbg.cu = !{!0}38!llvm.debugify = !{!2, !3}39!llvm.module.flags = !{!4}40 41; CHECK: [[DBG9]] = !DILocation(line: 4,42; CHECK: [[DBG14]] = !DILocation(line: 10,43 44!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)45!1 = !DIFile(filename: "test.ll", directory: "/")46!2 = !{i32 12}47!3 = !{i32 0}48!4 = !{i32 2, !"Debug Info Version", i32 3}49!5 = distinct !DISubprogram(name: "add_sext__dominating_add_nsw", linkageName: "add_sext__dominating_add_nsw", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)50!6 = !DISubroutineType(types: !7)51!7 = !{}52!8 = !DILocation(line: 1, column: 1, scope: !5)53!9 = !DILocation(line: 2, column: 1, scope: !5)54!10 = !DILocation(line: 3, column: 1, scope: !5)55!11 = !DILocation(line: 4, column: 1, scope: !5)56!12 = !DILocation(line: 5, column: 1, scope: !5)57!13 = !DILocation(line: 6, column: 1, scope: !5)58!14 = distinct !DISubprogram(name: "sub_sext__dominating_sub_nsw", linkageName: "sub_sext__dominating_sub_nsw", scope: null, file: !1, line: 7, type: !6, scopeLine: 7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)59!15 = !DILocation(line: 7, column: 1, scope: !14)60!16 = !DILocation(line: 8, column: 1, scope: !14)61!17 = !DILocation(line: 9, column: 1, scope: !14)62!18 = !DILocation(line: 10, column: 1, scope: !14)63!19 = !DILocation(line: 11, column: 1, scope: !14)64!20 = !DILocation(line: 12, column: 1, scope: !14)65