brintos

brintos / llvm-project-archived public Read only

0
0
Text · 16.8 KiB · 0564b49 Raw
340 lines · plain
1# RUN: llc -mtriple=x86_64-pc-linux %s -run-pass=branch-folder -o - | FileCheck %s2 3--- |4  ; ModuleID = 'case2.c'5  source_filename = "case2.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, !dbg !010  @q2 = dso_local local_unnamed_addr global i32 4, align 4, !dbg !511  @q3 = dso_local local_unnamed_addr global i32 2, align 4, !dbg !812  @g1 = dso_local local_unnamed_addr global i32 0, align 4, !dbg !1013  @g2 = dso_local local_unnamed_addr global i32 0, align 4, !dbg !1214  @g3 = dso_local local_unnamed_addr global i32 0, align 4, !dbg !1415 16  ; Function Attrs: nounwind uwtable17  define dso_local i32 @multiple_inl_multiple_loc() local_unnamed_addr #0 !dbg !23 {18  entry:19    %0 = load i32, ptr @q1, align 4, !dbg !27, !tbaa !2820    call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !3821    call void @llvm.dbg.value(metadata i32 100, metadata !37, metadata !DIExpression()), !dbg !3822    %cmp.i = icmp sgt i32 %0, 3, !dbg !4023    br i1 %cmp.i, label %if.then.i, label %if.end.i, !dbg !4224 25  if.then.i:                                        ; preds = %entry26    tail call void @abort() #3, !dbg !4327    unreachable, !dbg !4328 29  if.end.i:                                         ; preds = %entry30    %cmp1.i = icmp slt i32 %0, 1, !dbg !4431    br i1 %cmp1.i, label %if.then2.i, label %inl2.exit, !dbg !4632 33  if.then2.i:                                       ; preds = %if.end.i34    tail call void @abort() #3, !dbg !4735    unreachable, !dbg !4736 37  inl2.exit:                                        ; preds = %if.end.i38    %mul.i = mul nuw nsw i32 %0, 152, !dbg !4839    %add.i = add nuw nsw i32 %mul.i, 100, !dbg !4940    store i32 %add.i, ptr @g1, align 4, !dbg !50, !tbaa !2841    %1 = load i32, ptr @q2, align 4, !dbg !51, !tbaa !2842    call void @llvm.dbg.value(metadata i32 %1, metadata !32, metadata !DIExpression()), !dbg !5243    call void @llvm.dbg.value(metadata i32 200, metadata !37, metadata !DIExpression()), !dbg !5244    %cmp.i3 = icmp sgt i32 %1, 3, !dbg !5445    br i1 %cmp.i3, label %if.then.i4, label %if.end.i6, !dbg !5546 47  if.then.i4:                                       ; preds = %inl2.exit48    tail call void @abort() #3, !dbg !5649    unreachable, !dbg !5650 51  if.end.i6:                                        ; preds = %inl2.exit52    %cmp1.i5 = icmp slt i32 %1, 1, !dbg !5753    br i1 %cmp1.i5, label %if.then2.i7, label %inl2.exit10, !dbg !5854 55  if.then2.i7:                                      ; preds = %if.end.i656    tail call void @abort() #3, !dbg !5957    unreachable, !dbg !5958 59  inl2.exit10:                                      ; preds = %if.end.i660    %mul.i8 = mul nuw nsw i32 %1, 152, !dbg !6061    %add.i9 = add nuw nsw i32 %mul.i8, 200, !dbg !6162    store i32 %add.i9, ptr @g2, align 4, !dbg !62, !tbaa !2863    %2 = load i32, ptr @q3, align 4, !dbg !63, !tbaa !2864    call void @llvm.dbg.value(metadata i32 %2, metadata !32, metadata !DIExpression()), !dbg !6465    call void @llvm.dbg.value(metadata i32 300, metadata !37, metadata !DIExpression()), !dbg !6466    %cmp.i11 = icmp sgt i32 %2, 3, !dbg !6667    br i1 %cmp.i11, label %if.then.i12, label %if.end.i14, !dbg !6768 69  if.then.i12:                                      ; preds = %inl2.exit1070    tail call void @abort() #3, !dbg !6871    unreachable, !dbg !6872 73  if.end.i14:                                       ; preds = %inl2.exit1074    %cmp1.i13 = icmp slt i32 %2, 1, !dbg !6975    br i1 %cmp1.i13, label %if.then2.i15, label %inl2.exit18, !dbg !7076 77  if.then2.i15:                                     ; preds = %if.end.i1478    tail call void @abort() #3, !dbg !7179    unreachable, !dbg !7180 81  inl2.exit18:                                      ; preds = %if.end.i1482    %mul.i16 = mul nuw nsw i32 %2, 152, !dbg !7283    %add.i17 = add nuw nsw i32 %mul.i16, 300, !dbg !7384    store i32 %add.i17, ptr @q3, align 4, !dbg !74, !tbaa !2885    ret i32 0, !dbg !7586  }87 88  ; Function Attrs: noreturn nounwind89  declare !dbg !76 void @abort() local_unnamed_addr #190 91  ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)92  declare void @llvm.dbg.value(metadata, metadata, metadata) #293 94  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" }95  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" }96  attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }97  attributes #3 = { noreturn nounwind }98 99  !llvm.dbg.cu = !{!2}100  !llvm.module.flags = !{!16, !17, !18, !19, !20, !21}101  !llvm.ident = !{!22}102 103  !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())104  !1 = distinct !DIGlobalVariable(name: "q1", scope: !2, file: !3, line: 12, type: !7, isLocal: false, isDefinition: true)105  !2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 16.0.0.prerel", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)106  !3 = !DIFile(filename: "case2.c", directory: "/", checksumkind: CSK_MD5, checksum: "5093c50294e57eaa7f9ed00bfd62075c")107  !4 = !{!0, !5, !8, !10, !12, !14}108  !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())109  !6 = distinct !DIGlobalVariable(name: "q2", scope: !2, file: !3, line: 12, type: !7, isLocal: false, isDefinition: true)110  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)111  !8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())112  !9 = distinct !DIGlobalVariable(name: "q3", scope: !2, file: !3, line: 12, type: !7, isLocal: false, isDefinition: true)113  !10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())114  !11 = distinct !DIGlobalVariable(name: "g1", scope: !2, file: !3, line: 13, type: !7, isLocal: false, isDefinition: true)115  !12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression())116  !13 = distinct !DIGlobalVariable(name: "g2", scope: !2, file: !3, line: 13, type: !7, isLocal: false, isDefinition: true)117  !14 = !DIGlobalVariableExpression(var: !15, expr: !DIExpression())118  !15 = distinct !DIGlobalVariable(name: "g3", scope: !2, file: !3, line: 13, type: !7, isLocal: false, isDefinition: true)119  !16 = !{i32 7, !"Dwarf Version", i32 5}120  !17 = !{i32 2, !"Debug Info Version", i32 3}121  !18 = !{i32 1, !"wchar_size", i32 4}122  !19 = !{i32 8, !"PIC Level", i32 2}123  !20 = !{i32 7, !"PIE Level", i32 2}124  !21 = !{i32 7, !"uwtable", i32 2}125  !22 = !{!"clang version 16.0.0.prerel"}126  !23 = distinct !DISubprogram(name: "multiple_inl_multiple_loc", scope: !3, file: !3, line: 15, type: !24, scopeLine: 16, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !26)127  !24 = !DISubroutineType(types: !25)128  !25 = !{!7}129  !26 = !{}130  !27 = !DILocation(line: 17, column: 13, scope: !23)131  !28 = !{!29, !29, i64 0}132  !29 = !{!"int", !30, i64 0}133  !30 = !{!"omnipotent char", !31, i64 0}134  !31 = !{!"Simple C/C++ TBAA"}135  !32 = !DILocalVariable(name: "q", arg: 1, scope: !33, file: !3, line: 3, type: !7)136  !33 = distinct !DISubprogram(name: "inl2", scope: !3, file: !3, line: 3, type: !34, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !36)137  !34 = !DISubroutineType(types: !35)138  !35 = !{!7, !7, !7}139  !36 = !{!32, !37}140  !37 = !DILocalVariable(name: "n", arg: 2, scope: !33, file: !3, line: 3, type: !7)141  !38 = !DILocation(line: 0, scope: !33, inlinedAt: !39)142  !39 = distinct !DILocation(line: 17, column: 8, scope: !23)143  !40 = !DILocation(line: 5, column: 9, scope: !41, inlinedAt: !39)144  !41 = distinct !DILexicalBlock(scope: !33, file: !3, line: 5, column: 7)145  !42 = !DILocation(line: 5, column: 7, scope: !33, inlinedAt: !39)146  !43 = !DILocation(line: 6, column: 5, scope: !41, inlinedAt: !39)147  !44 = !DILocation(line: 7, column: 9, scope: !45, inlinedAt: !39)148  !45 = distinct !DILexicalBlock(scope: !33, file: !3, line: 7, column: 7)149  !46 = !DILocation(line: 7, column: 7, scope: !33, inlinedAt: !39)150  !47 = !DILocation(line: 8, column: 5, scope: !45, inlinedAt: !39)151  !48 = !DILocation(line: 9, column: 12, scope: !33, inlinedAt: !39)152  !49 = !DILocation(line: 9, column: 18, scope: !33, inlinedAt: !39)153  !50 = !DILocation(line: 17, column: 6, scope: !23)154  !51 = !DILocation(line: 18, column: 13, scope: !23)155  !52 = !DILocation(line: 0, scope: !33, inlinedAt: !53)156  !53 = distinct !DILocation(line: 18, column: 8, scope: !23)157  !54 = !DILocation(line: 5, column: 9, scope: !41, inlinedAt: !53)158  !55 = !DILocation(line: 5, column: 7, scope: !33, inlinedAt: !53)159  !56 = !DILocation(line: 6, column: 5, scope: !41, inlinedAt: !53)160  !57 = !DILocation(line: 7, column: 9, scope: !45, inlinedAt: !53)161  !58 = !DILocation(line: 7, column: 7, scope: !33, inlinedAt: !53)162  !59 = !DILocation(line: 8, column: 5, scope: !45, inlinedAt: !53)163  !60 = !DILocation(line: 9, column: 12, scope: !33, inlinedAt: !53)164  !61 = !DILocation(line: 9, column: 18, scope: !33, inlinedAt: !53)165  !62 = !DILocation(line: 18, column: 6, scope: !23)166  !63 = !DILocation(line: 19, column: 13, scope: !23)167  !64 = !DILocation(line: 0, scope: !33, inlinedAt: !65)168  !65 = distinct !DILocation(line: 19, column: 8, scope: !23)169  !66 = !DILocation(line: 5, column: 9, scope: !41, inlinedAt: !65)170  !67 = !DILocation(line: 5, column: 7, scope: !33, inlinedAt: !65)171  !68 = !DILocation(line: 6, column: 5, scope: !41, inlinedAt: !65)172  !69 = !DILocation(line: 7, column: 9, scope: !45, inlinedAt: !65)173  !70 = !DILocation(line: 7, column: 7, scope: !33, inlinedAt: !65)174  !71 = !DILocation(line: 8, column: 5, scope: !45, inlinedAt: !65)175  !72 = !DILocation(line: 9, column: 12, scope: !33, inlinedAt: !65)176  !73 = !DILocation(line: 9, column: 18, scope: !33, inlinedAt: !65)177  !74 = !DILocation(line: 19, column: 6, scope: !23)178  !75 = !DILocation(line: 20, column: 3, scope: !23)179  !76 = !DISubprogram(name: "abort", scope: !77, file: !77, line: 514, type: !78, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagOptimized, retainedNodes: !26)180  !77 = !DIFile(filename: "/usr/include/stdlib.h", directory: "", checksumkind: CSK_MD5, checksum: "f7a1412d75d9e3df251dfc21b02d59ef")181  !78 = !DISubroutineType(types: !79)182  !79 = !{null}183 184...185---186name:            multiple_inl_multiple_loc187alignment:       16188tracksRegLiveness: true189tracksDebugUserValues: true190frameInfo:191  stackSize:       8192  offsetAdjustment: -8193  maxAlignment:    1194  adjustsStack:    true195  hasCalls:        true196  maxCallFrameSize: 0197machineFunctionInfo: {}198body:             |199  bb.0.entry:200    successors: %bb.1(0x00000800), %bb.2(0x7ffff800)201 202    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp203    frame-setup CFI_INSTRUCTION def_cfa_offset 16204    renamable $eax = MOV32rm $rip, 1, $noreg, @q1, $noreg, debug-instr-number 1, debug-location !27 :: (dereferenceable load (s32) from @q1, !tbaa !28)205    DBG_INSTR_REF !32, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !38206    DBG_VALUE 100, $noreg, !37, !DIExpression(), debug-location !38207    CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !40208    JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !42209    JMP_1 %bb.1, debug-location !42210 211  bb.1.if.then.i:212    successors:213 214    CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !43215 216  bb.2.if.end.i:217    successors: %bb.3(0x00000800), %bb.4(0x7ffff800)218    liveins: $eax219 220    TEST32rr renamable $eax, renamable $eax, implicit-def $eflags, debug-location !44221    JCC_1 %bb.4, 15, implicit killed $eflags, debug-location !46222    JMP_1 %bb.3, debug-location !46223 224  bb.3.if.then2.i:225    successors:226 227    CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !47228 229  bb.4.inl2.exit:230    successors: %bb.5(0x00000800), %bb.6(0x7ffff800)231    liveins: $eax232 233    renamable $eax = nuw nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !48234    renamable $eax = nuw nsw ADD32ri8 killed renamable $eax, 100, implicit-def dead $eflags, debug-location !49235    MOV32mr $rip, 1, $noreg, @g1, $noreg, killed renamable $eax, debug-location !50 :: (store (s32) into @g1, !tbaa !28)236    renamable $eax = MOV32rm $rip, 1, $noreg, @q2, $noreg, debug-instr-number 2, debug-location !51 :: (dereferenceable load (s32) from @q2, !tbaa !28)237    DBG_INSTR_REF !32, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !52238    DBG_VALUE 200, $noreg, !37, !DIExpression(), debug-location !52239    CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !54240    JCC_1 %bb.6, 12, implicit killed $eflags, debug-location !55241    JMP_1 %bb.5, debug-location !55242 243  bb.5.if.then.i4:244    successors:245 246    CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !56247 248  bb.6.if.end.i6:249    successors: %bb.7(0x00000800), %bb.8(0x7ffff800)250    liveins: $eax251 252    TEST32rr renamable $eax, renamable $eax, implicit-def $eflags, debug-location !57253    JCC_1 %bb.8, 15, implicit killed $eflags, debug-location !58254    JMP_1 %bb.7, debug-location !58255 256  bb.7.if.then2.i7:257    successors:258 259    CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !59260 261  bb.8.inl2.exit10:262    successors: %bb.9(0x00000800), %bb.10(0x7ffff800)263    liveins: $eax264 265    renamable $eax = nuw nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !60266    renamable $eax = nuw nsw ADD32ri killed renamable $eax, 200, implicit-def dead $eflags, debug-location !61267    MOV32mr $rip, 1, $noreg, @g2, $noreg, killed renamable $eax, debug-location !62 :: (store (s32) into @g2, !tbaa !28)268    renamable $eax = MOV32rm $rip, 1, $noreg, @q3, $noreg, debug-instr-number 3, debug-location !63 :: (dereferenceable load (s32) from @q3, !tbaa !28)269    DBG_INSTR_REF !32, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !64270    DBG_VALUE 300, $noreg, !37, !DIExpression(), debug-location !64271    CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !66272    JCC_1 %bb.10, 12, implicit killed $eflags, debug-location !67273    JMP_1 %bb.9, debug-location !67274 275  bb.9.if.then.i12:276    successors:277 278    CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !68279 280  bb.10.if.end.i14:281    successors: %bb.11(0x00000800), %bb.12(0x7ffff800)282    liveins: $eax283 284    TEST32rr renamable $eax, renamable $eax, implicit-def $eflags, debug-location !69285    JCC_1 %bb.12, 15, implicit killed $eflags, debug-location !70286    JMP_1 %bb.11, debug-location !70287 288  bb.11.if.then2.i15:289    successors:290 291    CALL64pcrel32 target-flags(x86-plt) @abort, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !71292 293  bb.12.inl2.exit18:294    liveins: $eax295 296    renamable $eax = nuw nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !72297    renamable $eax = nuw nsw ADD32ri killed renamable $eax, 300, implicit-def dead $eflags, debug-location !73298    MOV32mr $rip, 1, $noreg, @q3, $noreg, killed renamable $eax, debug-location !74 :: (store (s32) into @q3, !tbaa !28)299    $eax = MOV32r0 implicit-def dead $eflags, debug-location !75300    $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !75301    frame-destroy CFI_INSTRUCTION def_cfa_offset 8, debug-location !75302    RET 0, $eax, debug-location !75303 304...305 306# In this case we have a abort call block folded from two locations in307# three inlined instances of inl1():308#309#  1 | #include <stdlib.h>310#  2 |311#  3 | static inline int inl2(int q, int n)312#  4 | {313#  5 |   if (q > 3)314#  6 |     abort();315#  7 |   if (q < 1)316#  8 |     abort();317#  9 |   return q * 152 + n;318# 10 | }319# 11 |320# 12 | int q1 = 1, q2 = 4, q3 = 2;321# 13 | int g1, g2, g3;322# 14 |323# 15 | int multiple_inl_multiple_loc()324# 16 | {325# 17 |   g1 = inl2(q1, 100);326# 18 |   g2 = inl2(q2, 200);327# 19 |   q3 = inl2(q3, 300);328# 20 |   return 0;329# 21 | }330#331# We should produce a merged location describing that the abort call is located332# at line 0 in inl2() inlined at line 0 in multiple_inl_multiple_loc().333 334# CHECK-DAG: [[INLINER:![0-9]+]] = distinct !DISubprogram(name: "multiple_inl_multiple_loc"335# CHECK-DAG: [[INLINEE:![0-9]+]] = distinct !DISubprogram(name: "inl2"336 337# CHECK-NOT: CALL64pcrel32338# CHECK: CALL64pcrel32 target-flags(x86-plt) @abort, {{.*}} debug-location !DILocation(line: 0, scope: [[INLINEE]], inlinedAt: !DILocation(line: 0, scope: [[INLINER]]))339# CHECK-NOT: CALL64pcrel32340