1 # RUN: llc -mtriple=arm-linux-gnu -debug-entry-values -run-pass if-converter %s -o -| FileCheck %s
3 # Vefify that the call site info will be updated after the optimization.
4 # This test case would previously trigger an assertion when
5 # deleting the call instruction.
7 # Test case is generated from:
9 # foo (int* seg, int subseg);
10 # extern int* mri_common_symbol;
13 # baa (int* secptr, int subseg)
15 # if (! (secptr == 0 && subseg == 0))
16 # foo (secptr, subseg);
17 # mri_common_symbol = 0;
20 # With slight change of MIR - substitution of BL instruction with BL_pred
21 # in order to trigger optimization.
22 # clang -target arm-linux-gnu -g -O2 -Xclang -femit-debug-entry-values
23 # %s -stop-before=if-convert
26 # CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs:
27 # CHECK-NEXT: - { arg: 0, reg: '$r0' }
28 # CHECK-NEXT: - { arg: 1, reg: '$r1' } }
31 ; ModuleID = 'if-convert-call-site-info.c'
32 source_filename = "if-convert-call-site-info.c"
33 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
34 target triple = "armv6kz-unknown-linux-gnueabihf"
36 @mri_common_symbol = external dso_local local_unnamed_addr global i32*, align 4
38 ; Function Attrs: nounwind
39 define dso_local void @baa(i32* %secptr, i32 %subseg) local_unnamed_addr #0 !dbg !14 {
41 call void @llvm.dbg.value(metadata i32* %secptr, metadata !16, metadata !DIExpression()), !dbg !18
42 call void @llvm.dbg.value(metadata i32 %subseg, metadata !17, metadata !DIExpression()), !dbg !18
43 %cmp = icmp eq i32* %secptr, null, !dbg !19
44 %cmp1 = icmp eq i32 %subseg, 0, !dbg !21
45 %or.cond = and i1 %cmp, %cmp1, !dbg !22
46 br i1 %or.cond, label %if.end, label %if.then, !dbg !22
48 if.then: ; preds = %entry
49 tail call void @foo(i32* %secptr, i32 %subseg), !dbg !23
50 br label %if.end, !dbg !23
52 if.end: ; preds = %entry, %if.then
53 store i32* null, i32** @mri_common_symbol, align 4, !dbg !24, !tbaa !25
57 declare !dbg !4 dso_local void @foo(i32*, i32) local_unnamed_addr
59 ; Function Attrs: nounwind readnone speculatable willreturn
60 declare void @llvm.dbg.value(metadata, metadata, metadata)
62 ; Function Attrs: nounwind
63 declare void @llvm.stackprotector(i8*, i8**)
65 attributes #0 = { "frame-pointer"="all" }
68 !llvm.module.flags = !{!9, !10, !11, !12}
71 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
72 !1 = !DIFile(filename: "if-convert-call-site-info.c", directory: "/")
75 !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 10, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
76 !5 = !DISubroutineType(types: !6)
78 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32)
79 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
80 !9 = !{i32 2, !"Dwarf Version", i32 4}
81 !10 = !{i32 2, !"Debug Info Version", i32 3}
82 !11 = !{i32 1, !"wchar_size", i32 4}
83 !12 = !{i32 1, !"min_enum_size", i32 4}
84 !13 = !{!"clang version 10.0.0 "}
85 !14 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 14, type: !5, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
87 !16 = !DILocalVariable(name: "secptr", arg: 1, scope: !14, file: !1, line: 14, type: !7, flags: DIFlagArgumentNotModified)
88 !17 = !DILocalVariable(name: "subseg", arg: 2, scope: !14, file: !1, line: 14, type: !8, flags: DIFlagArgumentNotModified)
89 !18 = !DILocation(line: 0, scope: !14)
90 !19 = !DILocation(line: 16, column: 17, scope: !20)
91 !20 = distinct !DILexicalBlock(scope: !14, file: !1, line: 16, column: 7)
92 !21 = !DILocation(line: 16, column: 32, scope: !20)
93 !22 = !DILocation(line: 16, column: 22, scope: !20)
94 !23 = !DILocation(line: 17, column: 5, scope: !20)
95 !24 = !DILocation(line: 18, column: 21, scope: !14)
96 !25 = !{!26, !26, i64 0}
97 !26 = !{!"any pointer", !27, i64 0}
98 !27 = !{!"omnipotent char", !28, i64 0}
99 !28 = !{!"Simple C/C++ TBAA"}
100 !29 = !DILocation(line: 19, column: 1, scope: !14)
106 tracksRegLiveness: true
117 - { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4, callee-saved-register: '$lr',
118 callee-saved-restored: false }
119 - { id: 1, type: spill-slot, offset: -8, size: 4, alignment: 4, callee-saved-register: '$r11' }
121 - { bb: 2, offset: 0, fwdArgRegs:
122 - { arg: 0, reg: '$r0' }
123 - { arg: 1, reg: '$r1' } }
128 machineFunctionInfo: {}
131 successors: %bb.1(0x60000000), %bb.2(0x20000000)
132 liveins: $r0, $r1, $lr
134 DBG_VALUE $r0, $noreg, !16, !DIExpression(), debug-location !18
135 DBG_VALUE $r0, $noreg, !16, !DIExpression(), debug-location !18
136 DBG_VALUE $r1, $noreg, !17, !DIExpression(), debug-location !18
137 DBG_VALUE $r1, $noreg, !17, !DIExpression(), debug-location !18
138 $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r11, killed $lr
139 frame-setup CFI_INSTRUCTION def_cfa_offset 8
140 frame-setup CFI_INSTRUCTION offset $lr, -4
141 frame-setup CFI_INSTRUCTION offset $r11, -8
142 $r11 = frame-setup MOVr killed $sp, 14, $noreg, $noreg
143 frame-setup CFI_INSTRUCTION def_cfa_register $r11
144 CMPri renamable $r0, 0, 14, $noreg, implicit-def $cpsr, debug-location !22
145 Bcc %bb.2, 1, killed $cpsr, debug-location !22
148 successors: %bb.3(0x55555555), %bb.2(0x2aaaaaab)
151 CMPri renamable $r1, 0, 14, $noreg, implicit-def $cpsr, debug-location !22
152 Bcc %bb.3, 0, killed $cpsr, debug-location !22
157 BL_pred @foo, 14, $noreg, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit $r1, implicit-def $sp, debug-location !23
160 renamable $r0 = LDRi12 %const.0, 0, 14, $noreg, debug-location !24 :: (load 4 from constant-pool)
161 renamable $r1 = MOVi 0, 14, $noreg, $noreg
162 STRi12 killed renamable $r1, killed renamable $r0, 0, 14, $noreg, debug-location !24 :: (store 4 into @mri_common_symbol, !tbaa !25)
163 $sp = LDMIA_RET $sp, 14, $noreg, def $r11, def $pc, debug-location !29