1# RUN: llc -mtriple=x86_64-pc-linux %s -run-pass=branch-folder -o - | FileCheck %s 2 3--- | 4 ; ModuleID = 'case3.c' 5 source_filename = "case3.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 4 10 @q2 = dso_local local_unnamed_addr global i32 6, align 4 11 @g1 = dso_local local_unnamed_addr global i32 0, align 4 12 @g2 = dso_local local_unnamed_addr global i32 0, align 4 13 14 ; Function Attrs: nounwind uwtable 15 define dso_local i32 @multiple_inl_funcs() local_unnamed_addr #0 !dbg !9 { 16 entry: 17 %0 = load i32, ptr @q1, align 4, !dbg !12, !tbaa !13 18 %cmp.i = icmp sgt i32 %0, 3, !dbg !17 19 br i1 %cmp.i, label %if.then.i, label %inl3.exit, !dbg !20 20 21 if.then.i: ; preds = %entry 22 tail call void @abort() #2, !dbg !21 23 unreachable, !dbg !21 24 25 inl3.exit: ; preds = %entry 26 %mul.i = mul nsw i32 %0, 152, !dbg !22 27 %add.i = add nsw i32 %mul.i, 100, !dbg !23 28 store i32 %add.i, ptr @g1, align 4, !dbg !24, !tbaa !13 29 %1 = load i32, ptr @q2, align 4, !dbg !25, !tbaa !13 30 %cmp.i2 = icmp sgt i32 %1, 5, !dbg !26 31 br i1 %cmp.i2, label %if.then.i3, label %inl4.exit, !dbg !29 32 33 if.then.i3: ; preds = %inl3.exit 34 tail call void @abort() #2, !dbg !30 35 unreachable, !dbg !30 36 37 inl4.exit: ; preds = %inl3.exit 38 %mul.i4 = mul nsw i32 %1, %1, !dbg !31 39 %add.i5 = add nuw nsw i32 %mul.i4, 200, !dbg !32 40 store i32 %add.i5, ptr @g2, align 4, !dbg !33, !tbaa !13 41 ret i32 0, !dbg !34 42 } 43 44 ; Function Attrs: noreturn nounwind 45 declare !dbg !35 void @abort() local_unnamed_addr #1 46 47 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" } 48 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" } 49 attributes #2 = { noreturn nounwind } 50 51 !llvm.dbg.cu = !{!0} 52 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7} 53 !llvm.ident = !{!8} 54 55 !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) 56 !1 = !DIFile(filename: "case3.c", directory: "/", checksumkind: CSK_MD5, checksum: "53e9893099480164de1f5ee265c0cf01") 57 !2 = !{i32 7, !"Dwarf Version", i32 5} 58 !3 = !{i32 2, !"Debug Info Version", i32 3} 59 !4 = !{i32 1, !"wchar_size", i32 4} 60 !5 = !{i32 8, !"PIC Level", i32 2} 61 !6 = !{i32 7, !"PIE Level", i32 2} 62 !7 = !{i32 7, !"uwtable", i32 2} 63 !8 = !{!"clang version 16.0.0.prerel"} 64 !9 = distinct !DISubprogram(name: "multiple_inl_funcs", scope: !1, file: !1, line: 18, type: !10, scopeLine: 19, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) 65 !10 = !DISubroutineType(types: !11) 66 !11 = !{} 67 !12 = !DILocation(line: 20, column: 13, scope: !9) 68 !13 = !{!14, !14, i64 0} 69 !14 = !{!"int", !15, i64 0} 70 !15 = !{!"omnipotent char", !16, i64 0} 71 !16 = !{!"Simple C/C++ TBAA"} 72 !17 = !DILocation(line: 4, column: 9, scope: !18, inlinedAt: !19) 73 !18 = distinct !DISubprogram(name: "inl3", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) 74 !19 = distinct !DILocation(line: 20, column: 8, scope: !9) 75 !20 = !DILocation(line: 4, column: 7, scope: !18, inlinedAt: !19) 76 !21 = !DILocation(line: 5, column: 5, scope: !18, inlinedAt: !19) 77 !22 = !DILocation(line: 6, column: 12, scope: !18, inlinedAt: !19) 78 !23 = !DILocation(line: 6, column: 18, scope: !18, inlinedAt: !19) 79 !24 = !DILocation(line: 20, column: 6, scope: !9) 80 !25 = !DILocation(line: 21, column: 13, scope: !9) 81 !26 = !DILocation(line: 10, column: 9, scope: !27, inlinedAt: !28) 82 !27 = distinct !DISubprogram(name: "inl4", scope: !1, file: !1, line: 9, type: !10, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) 83 !28 = distinct !DILocation(line: 21, column: 8, scope: !9) 84 !29 = !DILocation(line: 10, column: 7, scope: !27, inlinedAt: !28) 85 !30 = !DILocation(line: 11, column: 5, scope: !27, inlinedAt: !28) 86 !31 = !DILocation(line: 12, column: 12, scope: !27, inlinedAt: !28) 87 !32 = !DILocation(line: 12, column: 16, scope: !27, inlinedAt: !28) 88 !33 = !DILocation(line: 21, column: 6, scope: !9) 89 !34 = !DILocation(line: 22, column: 3, scope: !9) 90 !35 = !DISubprogram(name: "abort", scope: !36, file: !36, line: 514, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !11) 91 !36 = !DIFile(filename: "/usr/include/stdlib.h", directory: "", checksumkind: CSK_MD5, checksum: "f7a1412d75d9e3df251dfc21b02d59ef") 92 93... 94--- 95name: multiple_inl_funcs 96alignment: 16 97tracksRegLiveness: true 98tracksDebugUserValues: true 99frameInfo: 100 stackSize: 8 101 offsetAdjustment: -8 102 maxAlignment: 1 103 adjustsStack: true 104 hasCalls: true 105 maxCallFrameSize: 0 106machineFunctionInfo: {} 107body: | 108 bb.0.entry: 109 successors: %bb.1(0x00000800), %bb.2(0x7ffff800) 110 111 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp 112 frame-setup CFI_INSTRUCTION def_cfa_offset 16 113 renamable $eax = MOV32rm $rip, 1, $noreg, @q1, $noreg, debug-location !12 :: (dereferenceable load (s32) from @q1, !tbaa !13) 114 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !17 115 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !20 116 JMP_1 %bb.1, debug-location !20 117 118 bb.1.if.then.i: 119 successors: 120 121 CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !21 122 123 bb.2.inl3.exit: 124 successors: %bb.3(0x00000800), %bb.4(0x7ffff800) 125 liveins: $eax 126 127 renamable $eax = nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !22 128 renamable $eax = nsw ADD32ri8 killed renamable $eax, 100, implicit-def dead $eflags, debug-location !23 129 MOV32mr $rip, 1, $noreg, @g1, $noreg, killed renamable $eax, debug-location !24 :: (store (s32) into @g1, !tbaa !13) 130 renamable $eax = MOV32rm $rip, 1, $noreg, @q2, $noreg, debug-location !25 :: (dereferenceable load (s32) from @q2, !tbaa !13) 131 CMP32ri8 renamable $eax, 6, implicit-def $eflags, debug-location !26 132 JCC_1 %bb.4, 12, implicit killed $eflags, debug-location !29 133 JMP_1 %bb.3, debug-location !29 134 135 bb.3.if.then.i3: 136 successors: 137 138 CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !30 139 140 bb.4.inl4.exit: 141 liveins: $eax 142 143 renamable $eax = nsw IMUL32rr killed renamable $eax, renamable $eax, implicit-def dead $eflags, debug-location !31 144 renamable $eax = nuw nsw ADD32ri killed renamable $eax, 200, implicit-def dead $eflags, debug-location !32 145 MOV32mr $rip, 1, $noreg, @g2, $noreg, killed renamable $eax, debug-location !33 :: (store (s32) into @g2, !tbaa !13) 146 $eax = MOV32r0 implicit-def dead $eflags, debug-location !34 147 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34 148 frame-destroy CFI_INSTRUCTION def_cfa_offset 8, debug-location !34 149 RET 0, $eax, debug-location !34 150 151... 152 153# In this case we get a single abort call originated from two separate 154# inlined functions: 155# 156# 1 | #include <stdlib.h> 157# 2 | 158# 3 | static inline int inl3(int q, int n) { 159# 4 | if (q > 3) 160# 5 | abort(); 161# 6 | return q * 152 + n; 162# 7 | } 163# 8 | 164# 9 | static inline int inl4(int q, int n) { 165# 10 | if (q > 5) 166# 11 | abort(); 167# 12 | return q * q + n; 168# 13 | } 169# 14 | 170# 15 | int q1 = 1, q2 = 6; 171# 16 | int g1, g2; 172# 17 | 173# 18 | int multiple_inl_funcs() 174# 19 | { 175# 20 | g1 = inl3(q1, 100); 176# 21 | g2 = inl4(q2, 200); 177# 22 | return 0; 178# 23 | } 179# 180# We should produce a location at line 0 in the most common scope, 181# multiple_inl_funcs(), without any inline information. 182 183# CHECK: [[INLINER:![0-9]+]] = distinct !DISubprogram(name: "multiple_inl_funcs" 184 185# CHECK-NOT: CALL64pcrel32 186# CHECK: CALL64pcrel32 target-flags(x86-plt) @abort, {{.*}} debug-location !DILocation(line: 0, scope: [[INLINER]]) 187# CHECK-NOT: CALL64pcrel32 188