1# RUN: llc -mtriple=x86_64-pc-linux %s -run-pass=branch-folder -o - | FileCheck %s 2 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 !0 10 @q2 = dso_local local_unnamed_addr global i32 4, align 4, !dbg !5 11 @q3 = dso_local local_unnamed_addr global i32 2, align 4, !dbg !8 12 @g1 = dso_local local_unnamed_addr global i32 0, align 4, !dbg !10 13 @g2 = dso_local local_unnamed_addr global i32 0, align 4, !dbg !12 14 @g3 = dso_local local_unnamed_addr global i32 0, align 4, !dbg !14 15 16 ; Function Attrs: nounwind uwtable 17 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 !28 20 call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !38 21 call void @llvm.dbg.value(metadata i32 100, metadata !37, metadata !DIExpression()), !dbg !38 22 %cmp.i = icmp sgt i32 %0, 3, !dbg !40 23 br i1 %cmp.i, label %if.then.i, label %if.end.i, !dbg !42 24 25 if.then.i: ; preds = %entry 26 tail call void @abort() #3, !dbg !43 27 unreachable, !dbg !43 28 29 if.end.i: ; preds = %entry 30 %cmp1.i = icmp slt i32 %0, 1, !dbg !44 31 br i1 %cmp1.i, label %if.then2.i, label %inl2.exit, !dbg !46 32 33 if.then2.i: ; preds = %if.end.i 34 tail call void @abort() #3, !dbg !47 35 unreachable, !dbg !47 36 37 inl2.exit: ; preds = %if.end.i 38 %mul.i = mul nuw nsw i32 %0, 152, !dbg !48 39 %add.i = add nuw nsw i32 %mul.i, 100, !dbg !49 40 store i32 %add.i, ptr @g1, align 4, !dbg !50, !tbaa !28 41 %1 = load i32, ptr @q2, align 4, !dbg !51, !tbaa !28 42 call void @llvm.dbg.value(metadata i32 %1, metadata !32, metadata !DIExpression()), !dbg !52 43 call void @llvm.dbg.value(metadata i32 200, metadata !37, metadata !DIExpression()), !dbg !52 44 %cmp.i3 = icmp sgt i32 %1, 3, !dbg !54 45 br i1 %cmp.i3, label %if.then.i4, label %if.end.i6, !dbg !55 46 47 if.then.i4: ; preds = %inl2.exit 48 tail call void @abort() #3, !dbg !56 49 unreachable, !dbg !56 50 51 if.end.i6: ; preds = %inl2.exit 52 %cmp1.i5 = icmp slt i32 %1, 1, !dbg !57 53 br i1 %cmp1.i5, label %if.then2.i7, label %inl2.exit10, !dbg !58 54 55 if.then2.i7: ; preds = %if.end.i6 56 tail call void @abort() #3, !dbg !59 57 unreachable, !dbg !59 58 59 inl2.exit10: ; preds = %if.end.i6 60 %mul.i8 = mul nuw nsw i32 %1, 152, !dbg !60 61 %add.i9 = add nuw nsw i32 %mul.i8, 200, !dbg !61 62 store i32 %add.i9, ptr @g2, align 4, !dbg !62, !tbaa !28 63 %2 = load i32, ptr @q3, align 4, !dbg !63, !tbaa !28 64 call void @llvm.dbg.value(metadata i32 %2, metadata !32, metadata !DIExpression()), !dbg !64 65 call void @llvm.dbg.value(metadata i32 300, metadata !37, metadata !DIExpression()), !dbg !64 66 %cmp.i11 = icmp sgt i32 %2, 3, !dbg !66 67 br i1 %cmp.i11, label %if.then.i12, label %if.end.i14, !dbg !67 68 69 if.then.i12: ; preds = %inl2.exit10 70 tail call void @abort() #3, !dbg !68 71 unreachable, !dbg !68 72 73 if.end.i14: ; preds = %inl2.exit10 74 %cmp1.i13 = icmp slt i32 %2, 1, !dbg !69 75 br i1 %cmp1.i13, label %if.then2.i15, label %inl2.exit18, !dbg !70 76 77 if.then2.i15: ; preds = %if.end.i14 78 tail call void @abort() #3, !dbg !71 79 unreachable, !dbg !71 80 81 inl2.exit18: ; preds = %if.end.i14 82 %mul.i16 = mul nuw nsw i32 %2, 152, !dbg !72 83 %add.i17 = add nuw nsw i32 %mul.i16, 300, !dbg !73 84 store i32 %add.i17, ptr @q3, align 4, !dbg !74, !tbaa !28 85 ret i32 0, !dbg !75 86 } 87 88 ; Function Attrs: noreturn nounwind 89 declare !dbg !76 void @abort() local_unnamed_addr #1 90 91 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 92 declare void @llvm.dbg.value(metadata, metadata, metadata) #2 93 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_loc 187alignment: 16 188tracksRegLiveness: true 189tracksDebugUserValues: true 190frameInfo: 191 stackSize: 8 192 offsetAdjustment: -8 193 maxAlignment: 1 194 adjustsStack: true 195 hasCalls: true 196 maxCallFrameSize: 0 197machineFunctionInfo: {} 198body: | 199 bb.0.entry: 200 successors: %bb.1(0x00000800), %bb.2(0x7ffff800) 201 202 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp 203 frame-setup CFI_INSTRUCTION def_cfa_offset 16 204 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 !38 206 DBG_VALUE 100, $noreg, !37, !DIExpression(), debug-location !38 207 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !40 208 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !42 209 JMP_1 %bb.1, debug-location !42 210 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 !43 215 216 bb.2.if.end.i: 217 successors: %bb.3(0x00000800), %bb.4(0x7ffff800) 218 liveins: $eax 219 220 TEST32rr renamable $eax, renamable $eax, implicit-def $eflags, debug-location !44 221 JCC_1 %bb.4, 15, implicit killed $eflags, debug-location !46 222 JMP_1 %bb.3, debug-location !46 223 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 !47 228 229 bb.4.inl2.exit: 230 successors: %bb.5(0x00000800), %bb.6(0x7ffff800) 231 liveins: $eax 232 233 renamable $eax = nuw nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !48 234 renamable $eax = nuw nsw ADD32ri8 killed renamable $eax, 100, implicit-def dead $eflags, debug-location !49 235 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 !52 238 DBG_VALUE 200, $noreg, !37, !DIExpression(), debug-location !52 239 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !54 240 JCC_1 %bb.6, 12, implicit killed $eflags, debug-location !55 241 JMP_1 %bb.5, debug-location !55 242 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 !56 247 248 bb.6.if.end.i6: 249 successors: %bb.7(0x00000800), %bb.8(0x7ffff800) 250 liveins: $eax 251 252 TEST32rr renamable $eax, renamable $eax, implicit-def $eflags, debug-location !57 253 JCC_1 %bb.8, 15, implicit killed $eflags, debug-location !58 254 JMP_1 %bb.7, debug-location !58 255 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 !59 260 261 bb.8.inl2.exit10: 262 successors: %bb.9(0x00000800), %bb.10(0x7ffff800) 263 liveins: $eax 264 265 renamable $eax = nuw nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !60 266 renamable $eax = nuw nsw ADD32ri killed renamable $eax, 200, implicit-def dead $eflags, debug-location !61 267 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 !64 270 DBG_VALUE 300, $noreg, !37, !DIExpression(), debug-location !64 271 CMP32ri8 renamable $eax, 4, implicit-def $eflags, debug-location !66 272 JCC_1 %bb.10, 12, implicit killed $eflags, debug-location !67 273 JMP_1 %bb.9, debug-location !67 274 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 !68 279 280 bb.10.if.end.i14: 281 successors: %bb.11(0x00000800), %bb.12(0x7ffff800) 282 liveins: $eax 283 284 TEST32rr renamable $eax, renamable $eax, implicit-def $eflags, debug-location !69 285 JCC_1 %bb.12, 15, implicit killed $eflags, debug-location !70 286 JMP_1 %bb.11, debug-location !70 287 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 !71 292 293 bb.12.inl2.exit18: 294 liveins: $eax 295 296 renamable $eax = nuw nsw IMUL32rri killed renamable $eax, 152, implicit-def dead $eflags, debug-location !72 297 renamable $eax = nuw nsw ADD32ri killed renamable $eax, 300, implicit-def dead $eflags, debug-location !73 298 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 !75 300 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !75 301 frame-destroy CFI_INSTRUCTION def_cfa_offset 8, debug-location !75 302 RET 0, $eax, debug-location !75 303 304... 305 306# In this case we have a abort call block folded from two locations in 307# 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 located 332# 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: CALL64pcrel32 338# CHECK: CALL64pcrel32 target-flags(x86-plt) @abort, {{.*}} debug-location !DILocation(line: 0, scope: [[INLINEE]], inlinedAt: !DILocation(line: 0, scope: [[INLINER]])) 339# CHECK-NOT: CALL64pcrel32 340