176 lines · plain
1; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=ASM2; RUN: llc -mtriple=x86_64-windows-msvc < %s -filetype=obj | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ3 4; This test attempts to exercise gaps in local variables. The local variable 'p'5; will end up in some CSR (esi), which will be used in both the BB scheduled6; discontiguously out of line and the normal return BB. The best way to encode7; this is to use a LocalVariableAddrGap. If the gap is too large, multiple8; ranges should be emitted.9 10; Source to regenerate:11; int barrier();12; int vardef();13; void use(int);14; void __declspec(noreturn) call_noreturn(int);15; int f() {16; if (barrier()) {17; int p = vardef();18; if (barrier()) // Unlikely, will be placed after return19; call_noreturn(p);20; use(p);21; } else {22; barrier();23; }24; return 0;25; }26 27; ASM: f: # @f28; ASM: pushq %rsi29; ASM: subq $32, %rsp30; ASM: callq barrier31; ASM: testl %eax, %eax32; ASM: je .LBB0_333; ASM: callq vardef34; ASM: movl %eax, %esi35; ASM: [[p_b1:\.Ltmp[0-9]+]]:36; ASM: #DEBUG_VALUE: p <- $esi37; ASM: callq barrier38; ASM: movl %esi, %ecx39; ASM: testl %eax, %eax40; ASM: jne .LBB0_541; ASM: # %bb.2: # %if.end42; ASM: #DEBUG_VALUE: p <- $esi43; ASM: callq use44; ASM: jmp .LBB0_445; ASM: [[p_e1:\.Ltmp[0-9]+]]:46; ASM: .LBB0_3: # %if.else47; ASM: callq barrier48; ASM: .LBB0_4: # %if.end649; ASM: xorl %eax, %eax50; ASM: addq $32, %rsp51; ASM: popq %rsi52; ASM: retq53; ASM: .LBB0_5: # %if.then454; ASM: [[p_b2:\.Ltmp[0-9]+]]:55; ASM: #DEBUG_VALUE: p <- $esi56; ASM: callq call_noreturn57; ASM: int358; ASM: .Lfunc_end0:59 60; ASM: .short {{.*}} # Record length61; ASM: .short 4414 # Record kind: S_LOCAL62; ASM: .long 116 # TypeIndex63; ASM: .short 0 # Flags64; ASM: .asciz "p"65; ASM: .cv_def_range [[p_b1]] [[p_e1]] [[p_b2]] .Lfunc_end0, reg, 2366; ASM: .short 2 # Record length67; ASM: .short 4431 # Record kind: S_PROC_ID_END68 69; OBJ: LocalSym {70; OBJ: Type: int (0x74)71; OBJ: VarName: p72; OBJ: }73; OBJ-NOT: LocalSym {74; OBJ: DefRangeRegisterSym {75; OBJ-NEXT: Kind:76; OBJ-NEXT: Register: ESI (0x17)77; OBJ-NEXT: MayHaveNoName: 078; OBJ-NEXT: LocalVariableAddrRange {79; OBJ-NEXT: OffsetStart: .text+0x{{.*}}80; OBJ-NEXT: ISectStart: 0x081; OBJ-NEXT: Range: 0x{{.*}}82; OBJ-NEXT: }83; OBJ-NEXT: LocalVariableAddrGap [84; OBJ-NEXT: GapStartOffset: 0x{{.*}}85; OBJ-NEXT: Range: 0x{{.*}}86; OBJ-NEXT: ]87; OBJ-NEXT: }88 89; ModuleID = 't.cpp'90source_filename = "t.cpp"91target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"92target triple = "x86_64-pc-windows-msvc19.0.24210"93 94; Function Attrs: nounwind uwtable95define i32 @f() local_unnamed_addr #0 !dbg !7 {96entry:97 %call = tail call i32 @barrier() #4, !dbg !1598 %tobool = icmp eq i32 %call, 0, !dbg !1599 br i1 %tobool, label %if.else, label %if.then, !dbg !16100 101if.then: ; preds = %entry102 %call1 = tail call i32 @vardef() #4, !dbg !17103 tail call void @llvm.dbg.value(metadata i32 %call1, metadata !12, metadata !18), !dbg !19104 %call2 = tail call i32 @barrier() #4, !dbg !20105 %tobool3 = icmp eq i32 %call2, 0, !dbg !20106 br i1 %tobool3, label %if.end, label %if.then4, !dbg !22107 108if.then4: ; preds = %if.then109 tail call void @call_noreturn(i32 %call1) #5, !dbg !23110 unreachable, !dbg !23111 112if.end: ; preds = %if.then113 tail call void @use(i32 %call1) #4, !dbg !24114 br label %if.end6, !dbg !25115 116if.else: ; preds = %entry117 %call5 = tail call i32 @barrier() #4, !dbg !26118 br label %if.end6119 120if.end6: ; preds = %if.else, %if.end121 ret i32 0, !dbg !28122}123 124declare i32 @barrier(...) local_unnamed_addr #1125 126declare i32 @vardef(...) local_unnamed_addr #1127 128; Function Attrs: noreturn129declare void @call_noreturn(i32) local_unnamed_addr #2130 131declare void @use(i32) local_unnamed_addr #1132 133; Function Attrs: nounwind readnone134declare void @llvm.dbg.value(metadata, metadata, metadata) #3135 136attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }137attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }138attributes #2 = { noreturn "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float"="false" }139attributes #3 = { nounwind readnone }140attributes #4 = { nounwind }141attributes #5 = { noreturn nounwind }142 143!llvm.dbg.cu = !{!0}144!llvm.module.flags = !{!3, !4, !5}145!llvm.ident = !{!6}146 147!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)148!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm\5Cbuild")149!2 = !{}150!3 = !{i32 2, !"CodeView", i32 1}151!4 = !{i32 2, !"Debug Info Version", i32 3}152!5 = !{i32 1, !"PIC Level", i32 2}153!6 = !{!"clang version 4.0.0 "}154!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 19, type: !8, isLocal: false, isDefinition: true, scopeLine: 19, isOptimized: true, unit: !0, retainedNodes: !11)155!8 = !DISubroutineType(types: !9)156!9 = !{!10}157!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)158!11 = !{!12}159!12 = !DILocalVariable(name: "p", scope: !13, file: !1, line: 21, type: !10)160!13 = distinct !DILexicalBlock(scope: !14, file: !1, line: 20, column: 18)161!14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 20, column: 7)162!15 = !DILocation(line: 20, column: 7, scope: !14)163!16 = !DILocation(line: 20, column: 7, scope: !7)164!17 = !DILocation(line: 21, column: 13, scope: !13)165!18 = !DIExpression()166!19 = !DILocation(line: 21, column: 9, scope: !13)167!20 = !DILocation(line: 22, column: 9, scope: !21)168!21 = distinct !DILexicalBlock(scope: !13, file: !1, line: 22, column: 9)169!22 = !DILocation(line: 22, column: 9, scope: !13)170!23 = !DILocation(line: 23, column: 7, scope: !21)171!24 = !DILocation(line: 24, column: 5, scope: !13)172!25 = !DILocation(line: 25, column: 3, scope: !13)173!26 = !DILocation(line: 26, column: 5, scope: !27)174!27 = distinct !DILexicalBlock(scope: !14, file: !1, line: 25, column: 10)175!28 = !DILocation(line: 28, column: 3, scope: !7)176