188 lines · plain
1# RUN: llc -mtriple=x86_64-pc-linux %s -run-pass=branch-folder -o - | FileCheck %s2 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 410 @q2 = dso_local local_unnamed_addr global i32 6, align 411 @g1 = dso_local local_unnamed_addr global i32 0, align 412 @g2 = dso_local local_unnamed_addr global i32 0, align 413 14 ; Function Attrs: nounwind uwtable15 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 !1318 %cmp.i = icmp sgt i32 %0, 3, !dbg !1719 br i1 %cmp.i, label %if.then.i, label %inl3.exit, !dbg !2020 21 if.then.i: ; preds = %entry22 tail call void @abort() #2, !dbg !2123 unreachable, !dbg !2124 25 inl3.exit: ; preds = %entry26 %mul.i = mul nsw i32 %0, 152, !dbg !2227 %add.i = add nsw i32 %mul.i, 100, !dbg !2328 store i32 %add.i, ptr @g1, align 4, !dbg !24, !tbaa !1329 %1 = load i32, ptr @q2, align 4, !dbg !25, !tbaa !1330 %cmp.i2 = icmp sgt i32 %1, 5, !dbg !2631 br i1 %cmp.i2, label %if.then.i3, label %inl4.exit, !dbg !2932 33 if.then.i3: ; preds = %inl3.exit34 tail call void @abort() #2, !dbg !3035 unreachable, !dbg !3036 37 inl4.exit: ; preds = %inl3.exit38 %mul.i4 = mul nsw i32 %1, %1, !dbg !3139 %add.i5 = add nuw nsw i32 %mul.i4, 200, !dbg !3240 store i32 %add.i5, ptr @g2, align 4, !dbg !33, !tbaa !1341 ret i32 0, !dbg !3442 }43 44 ; Function Attrs: noreturn nounwind45 declare !dbg !35 void @abort() local_unnamed_addr #146 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_funcs96alignment: 1697tracksRegLiveness: true98tracksDebugUserValues: true99frameInfo:100 stackSize: 8101 offsetAdjustment: -8102 maxAlignment: 1103 adjustsStack: true104 hasCalls: true105 maxCallFrameSize: 0106machineFunctionInfo: {}107body: |108 bb.0.entry:109 successors: %bb.1(0x00000800), %bb.2(0x7ffff800)110 111 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp112 frame-setup CFI_INSTRUCTION def_cfa_offset 16113 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 !17115 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !20116 JMP_1 %bb.1, debug-location !20117 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 !21122 123 bb.2.inl3.exit:124 successors: %bb.3(0x00000800), %bb.4(0x7ffff800)125 liveins: $eax126 127 renamable $eax = nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !22128 renamable $eax = nsw ADD32ri8 killed renamable $eax, 100, implicit-def dead $eflags, debug-location !23129 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 !26132 JCC_1 %bb.4, 12, implicit killed $eflags, debug-location !29133 JMP_1 %bb.3, debug-location !29134 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 !30139 140 bb.4.inl4.exit:141 liveins: $eax142 143 renamable $eax = nsw IMUL32rr killed renamable $eax, renamable $eax, implicit-def dead $eflags, debug-location !31144 renamable $eax = nuw nsw ADD32ri killed renamable $eax, 200, implicit-def dead $eflags, debug-location !32145 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 !34147 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34148 frame-destroy CFI_INSTRUCTION def_cfa_offset 8, debug-location !34149 RET 0, $eax, debug-location !34150 151...152 153# In this case we get a single abort call originated from two separate154# 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: CALL64pcrel32186# CHECK: CALL64pcrel32 target-flags(x86-plt) @abort, {{.*}} debug-location !DILocation(line: 0, scope: [[INLINER]])187# CHECK-NOT: CALL64pcrel32188