167 lines · plain
1# RUN: llc -mtriple=x86_64-pc-linux %s -run-pass=branch-folder -o - | FileCheck %s2 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 410 @q2 = dso_local local_unnamed_addr global i32 6, align 411 @g1 = dso_local local_unnamed_addr global i32 0, align 412 13 ; Function Attrs: nounwind uwtable14 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 !1317 %cmp.i = icmp sgt i32 %0, 3, !dbg !1718 br i1 %cmp.i, label %if.then.i, label %inl5.exit, !dbg !2019 20 if.then.i: ; preds = %entry21 tail call void @abort() #2, !dbg !2122 unreachable, !dbg !2123 24 inl5.exit: ; preds = %entry25 %mul.i = mul nsw i32 %0, 152, !dbg !2226 %add.i = add nsw i32 %mul.i, 100, !dbg !2327 store i32 %add.i, ptr @g1, align 4, !dbg !24, !tbaa !1328 %1 = load i32, ptr @q2, align 4, !dbg !25, !tbaa !1329 %cmp = icmp sgt i32 %1, 5, !dbg !2630 br i1 %cmp, label %if.then, label %if.end, !dbg !2531 32 if.then: ; preds = %inl5.exit33 tail call void @abort() #2, !dbg !2734 unreachable, !dbg !2735 36 if.end: ; preds = %inl5.exit37 ret i32 0, !dbg !2838 }39 40 ; Function Attrs: noreturn nounwind41 declare !dbg !29 void @abort() local_unnamed_addr #142 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_inl86alignment: 1687tracksRegLiveness: true88tracksDebugUserValues: true89frameInfo:90 stackSize: 891 offsetAdjustment: -892 maxAlignment: 193 adjustsStack: true94 hasCalls: true95 maxCallFrameSize: 096machineFunctionInfo: {}97body: |98 bb.0.entry:99 successors: %bb.1(0x00000800), %bb.2(0x7ffff800)100 101 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp102 frame-setup CFI_INSTRUCTION def_cfa_offset 16103 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 !17105 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !20106 JMP_1 %bb.1, debug-location !20107 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 !21112 113 bb.2.inl5.exit:114 successors: %bb.3(0x00000800), %bb.4(0x7ffff800)115 liveins: $eax116 117 renamable $eax = nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !22118 renamable $eax = nsw ADD32ri8 killed renamable $eax, 100, implicit-def dead $eflags, debug-location !23119 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 !25122 JMP_1 %bb.3, debug-location !25123 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 !27128 129 bb.4.if.end:130 $eax = MOV32r0 implicit-def dead $eflags, debug-location !28131 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !28132 frame-destroy CFI_INSTRUCTION def_cfa_offset 8, debug-location !28133 RET 0, $eax, debug-location !28134 135...136 137# In this case we get a single abort call originating from an inlined instance138# 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: CALL64pcrel32165# CHECK: CALL64pcrel32 target-flags(x86-plt) @abort, {{.*}} debug-location !DILocation(line: 0, scope: [[INLINER]])166# CHECK-NOT: CALL64pcrel32167