223 lines · plain
1# RUN: llc -mtriple=x86_64-pc-linux %s -run-pass=branch-folder -o - | FileCheck %s2 3--- |4 ; ModuleID = 'case1.c'5 source_filename = "case1.c"6 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"7 target triple = "x86_64-unknown-linux-gnu"8 9 @q1 = dso_local local_unnamed_addr global i32 1, align 410 @q2 = dso_local local_unnamed_addr global i32 4, align 411 @q3 = dso_local local_unnamed_addr global i32 2, align 412 @g1 = dso_local local_unnamed_addr global i32 0, align 413 @g2 = dso_local local_unnamed_addr global i32 0, align 414 @g3 = dso_local local_unnamed_addr global i32 0, align 415 16 ; Function Attrs: nounwind uwtable17 define dso_local i32 @multiple_inl_one_loc() local_unnamed_addr #0 !dbg !9 {18 entry:19 %0 = load i32, ptr @q1, align 4, !dbg !12, !tbaa !1320 %cmp.i = icmp sgt i32 %0, 3, !dbg !1721 br i1 %cmp.i, label %if.then.i, label %inl1.exit, !dbg !2022 23 if.then.i: ; preds = %entry24 tail call void @abort() #2, !dbg !2125 unreachable, !dbg !2126 27 inl1.exit: ; preds = %entry28 %mul.i = mul nsw i32 %0, 152, !dbg !2229 %add.i = add nsw i32 %mul.i, 100, !dbg !2330 store i32 %add.i, ptr @g1, align 4, !dbg !24, !tbaa !1331 %1 = load i32, ptr @q2, align 4, !dbg !25, !tbaa !1332 %cmp.i3 = icmp sgt i32 %1, 3, !dbg !2633 br i1 %cmp.i3, label %if.then.i4, label %inl1.exit7, !dbg !2834 35 if.then.i4: ; preds = %inl1.exit36 tail call void @abort() #2, !dbg !2937 unreachable, !dbg !2938 39 inl1.exit7: ; preds = %inl1.exit40 %mul.i5 = mul nsw i32 %1, 152, !dbg !3041 %add.i6 = add nsw i32 %mul.i5, 200, !dbg !3142 store i32 %add.i6, ptr @g2, align 4, !dbg !32, !tbaa !1343 %2 = load i32, ptr @q3, align 4, !dbg !33, !tbaa !1344 %cmp.i8 = icmp sgt i32 %2, 3, !dbg !3445 br i1 %cmp.i8, label %if.then.i9, label %inl1.exit12, !dbg !3646 47 if.then.i9: ; preds = %inl1.exit748 tail call void @abort() #2, !dbg !3749 unreachable, !dbg !3750 51 inl1.exit12: ; preds = %inl1.exit752 %mul.i10 = mul nsw i32 %2, 152, !dbg !3853 %add.i11 = add nsw i32 %mul.i10, 300, !dbg !3954 store i32 %add.i11, ptr @q3, align 4, !dbg !40, !tbaa !1355 ret i32 0, !dbg !4156 }57 58 ; Function Attrs: noreturn nounwind59 declare !dbg !42 void @abort() local_unnamed_addr #160 61 attributes #0 = { nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }62 attributes #1 = { noreturn nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }63 attributes #2 = { noreturn nounwind }64 65 !llvm.dbg.cu = !{!0}66 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7}67 !llvm.ident = !{!8}68 69 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 16.0.0.prerel", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)70 !1 = !DIFile(filename: "case1.c", directory: "/", checksumkind: CSK_MD5, checksum: "36d7da9616644fc8b011f5c49108ab31")71 !2 = !{i32 7, !"Dwarf Version", i32 5}72 !3 = !{i32 2, !"Debug Info Version", i32 3}73 !4 = !{i32 1, !"wchar_size", i32 4}74 !5 = !{i32 8, !"PIC Level", i32 2}75 !6 = !{i32 7, !"PIE Level", i32 2}76 !7 = !{i32 7, !"uwtable", i32 2}77 !8 = !{!"clang version 16.0.0.prerel"}78 !9 = distinct !DISubprogram(name: "multiple_inl_one_loc", scope: !1, file: !1, line: 13, type: !10, scopeLine: 14, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)79 !10 = !DISubroutineType(types: !11)80 !11 = !{}81 !12 = !DILocation(line: 15, column: 13, scope: !9)82 !13 = !{!14, !14, i64 0}83 !14 = !{!"int", !15, i64 0}84 !15 = !{!"omnipotent char", !16, i64 0}85 !16 = !{!"Simple C/C++ TBAA"}86 !17 = !DILocation(line: 5, column: 9, scope: !18, inlinedAt: !19)87 !18 = distinct !DISubprogram(name: "inl1", scope: !1, file: !1, line: 3, type: !10, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)88 !19 = distinct !DILocation(line: 15, column: 8, scope: !9)89 !20 = !DILocation(line: 5, column: 7, scope: !18, inlinedAt: !19)90 !21 = !DILocation(line: 6, column: 5, scope: !18, inlinedAt: !19)91 !22 = !DILocation(line: 7, column: 12, scope: !18, inlinedAt: !19)92 !23 = !DILocation(line: 7, column: 18, scope: !18, inlinedAt: !19)93 !24 = !DILocation(line: 15, column: 6, scope: !9)94 !25 = !DILocation(line: 16, column: 13, scope: !9)95 !26 = !DILocation(line: 5, column: 9, scope: !18, inlinedAt: !27)96 !27 = distinct !DILocation(line: 16, column: 8, scope: !9)97 !28 = !DILocation(line: 5, column: 7, scope: !18, inlinedAt: !27)98 !29 = !DILocation(line: 6, column: 5, scope: !18, inlinedAt: !27)99 !30 = !DILocation(line: 7, column: 12, scope: !18, inlinedAt: !27)100 !31 = !DILocation(line: 7, column: 18, scope: !18, inlinedAt: !27)101 !32 = !DILocation(line: 16, column: 6, scope: !9)102 !33 = !DILocation(line: 17, column: 13, scope: !9)103 !34 = !DILocation(line: 5, column: 9, scope: !18, inlinedAt: !35)104 !35 = distinct !DILocation(line: 17, column: 8, scope: !9)105 !36 = !DILocation(line: 5, column: 7, scope: !18, inlinedAt: !35)106 !37 = !DILocation(line: 6, column: 5, scope: !18, inlinedAt: !35)107 !38 = !DILocation(line: 7, column: 12, scope: !18, inlinedAt: !35)108 !39 = !DILocation(line: 7, column: 18, scope: !18, inlinedAt: !35)109 !40 = !DILocation(line: 17, column: 6, scope: !9)110 !41 = !DILocation(line: 18, column: 3, scope: !9)111 !42 = !DISubprogram(name: "abort", scope: !43, file: !43, line: 514, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !11)112 !43 = !DIFile(filename: "/usr/include/stdlib.h", directory: "", checksumkind: CSK_MD5, checksum: "f7a1412d75d9e3df251dfc21b02d59ef")113 114...115---116name: multiple_inl_one_loc117alignment: 16118tracksRegLiveness: true119tracksDebugUserValues: true120frameInfo:121 stackSize: 8122 offsetAdjustment: -8123 maxAlignment: 1124 adjustsStack: true125 hasCalls: true126 maxCallFrameSize: 0127machineFunctionInfo: {}128body: |129 bb.0.entry:130 successors: %bb.1(0x00000800), %bb.2(0x7ffff800)131 132 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp133 frame-setup CFI_INSTRUCTION def_cfa_offset 16134 renamable $eax = MOV32rm $rip, 1, $noreg, @q1, $noreg, debug-location !12 :: (dereferenceable load (s32) from @q1, !tbaa !13)135 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !17136 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !20137 JMP_1 %bb.1, debug-location !20138 139 bb.1.if.then.i:140 successors:141 142 CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !21143 144 bb.2.inl1.exit:145 successors: %bb.3(0x00000800), %bb.4(0x7ffff800)146 liveins: $eax147 148 renamable $eax = nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !22149 renamable $eax = nsw ADD32ri8 killed renamable $eax, 100, implicit-def dead $eflags, debug-location !23150 MOV32mr $rip, 1, $noreg, @g1, $noreg, killed renamable $eax, debug-location !24 :: (store (s32) into @g1, !tbaa !13)151 renamable $eax = MOV32rm $rip, 1, $noreg, @q2, $noreg, debug-location !25 :: (dereferenceable load (s32) from @q2, !tbaa !13)152 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !26153 JCC_1 %bb.4, 12, implicit killed $eflags, debug-location !28154 JMP_1 %bb.3, debug-location !28155 156 bb.3.if.then.i4:157 successors:158 159 CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !29160 161 bb.4.inl1.exit7:162 successors: %bb.5(0x00000800), %bb.6(0x7ffff800)163 liveins: $eax164 165 renamable $eax = nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !30166 renamable $eax = nsw ADD32ri killed renamable $eax, 200, implicit-def dead $eflags, debug-location !31167 MOV32mr $rip, 1, $noreg, @g2, $noreg, killed renamable $eax, debug-location !32 :: (store (s32) into @g2, !tbaa !13)168 renamable $eax = MOV32rm $rip, 1, $noreg, @q3, $noreg, debug-location !33 :: (dereferenceable load (s32) from @q3, !tbaa !13)169 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !34170 JCC_1 %bb.6, 12, implicit killed $eflags, debug-location !36171 JMP_1 %bb.5, debug-location !36172 173 bb.5.if.then.i9:174 successors:175 176 CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !37177 178 bb.6.inl1.exit12:179 liveins: $eax180 181 renamable $eax = nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !38182 renamable $eax = nsw ADD32ri killed renamable $eax, 300, implicit-def dead $eflags, debug-location !39183 MOV32mr $rip, 1, $noreg, @q3, $noreg, killed renamable $eax, debug-location !40 :: (store (s32) into @q3, !tbaa !13)184 $eax = MOV32r0 implicit-def dead $eflags, debug-location !41185 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !41186 frame-destroy CFI_INSTRUCTION def_cfa_offset 8, debug-location !41187 RET 0, $eax, debug-location !41188 189...190 191# In this case we have a abort call block folded from one single location in192# three inlined instances of inl1():193#194# 1 | #include <stdlib.h>195# 2 |196# 3 | static inline int inl1(int q, int n)197# 4 | {198# 5 | if (q > 3)199# 6 | abort();200# 7 | return q * 152 + n;201# 8 | }202# 9 |203# 10 | int q1 = 1, q2 = 4, q3 = 2;204# 11 | int g1, g2, g3;205# 12 |206# 13 | int multiple_inl_one_loc()207# 14 | {208# 15 | g1 = inl1(q1, 100);209# 16 | g2 = inl1(q2, 200);210# 17 | q3 = inl1(q3, 300);211# 18 | return 0;212# 19 | }213#214# We should produce a merged location describing that the abort call is located215# at line 6 in inl1() inlined at line 0.216 217# CHECK-DAG: [[INLINER:![0-9]+]] = distinct !DISubprogram(name: "multiple_inl_one_loc"218# CHECK-DAG: [[INLINEE:![0-9]+]] = distinct !DISubprogram(name: "inl1"219 220# CHECK-NOT: CALL64pcrel32221# CHECK: CALL64pcrel32 target-flags(x86-plt) @abort, {{.*}} debug-location !DILocation(line: 6, column: 5, scope: [[INLINEE]], inlinedAt: !DILocation(line: 0, scope: [[INLINER]]))222# CHECK-NOT: CALL64pcrel32223