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