Skip to content

Commit 47b99b7

Browse files
committed
[Assignment Tracking] Do not convert variadic locations to kill locations [3/x]
Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D145914
1 parent 7d89437 commit 47b99b7

File tree

2 files changed

+68
-75
lines changed

2 files changed

+68
-75
lines changed

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,10 +1297,7 @@ void AssignmentTrackingLowering::emitDbgValue(
12971297
}
12981298

12991299
if (Kind == LocKind::Val) {
1300-
/// Get the value component, converting to Undef if it is variadic.
1301-
Value *Val =
1302-
Source->hasArgList() ? nullptr : Source->getVariableLocationOp(0);
1303-
Emit(ValueAsMetadata::get(Val), Source->getExpression());
1300+
Emit(Source->getRawLocation(), Source->getExpression());
13041301
return;
13051302
}
13061303

@@ -2126,23 +2123,11 @@ bool AssignmentTrackingLowering::emitPromotedVarLocs(
21262123
// already.
21272124
if (VarsWithStackSlot->contains(getAggregate(DVI)))
21282125
continue;
2129-
// Wrapper to get a single value (or undef) from DVI.
2130-
auto GetValue = [DVI]() -> RawLocationWrapper {
2131-
// We can't handle variadic DIExpressions yet so treat those as
2132-
// kill locations.
2133-
Value *V;
2134-
if (DVI->isKillLocation() || DVI->getValue() == nullptr ||
2135-
DVI->hasArgList())
2136-
V = PoisonValue::get(Type::getInt32Ty(DVI->getContext()));
2137-
else
2138-
V = DVI->getVariableLocationOp(0);
2139-
return RawLocationWrapper(ValueAsMetadata::get(V));
2140-
};
21412126
Instruction *InsertBefore = I.getNextNode();
21422127
assert(InsertBefore && "Unexpected: debug intrinsics after a terminator");
21432128
FnVarLocs->addVarLoc(InsertBefore, DebugVariable(DVI),
21442129
DVI->getExpression(), DVI->getDebugLoc(),
2145-
GetValue());
2130+
DVI->getWrappedLocation());
21462131
InsertedAnyIntrinsics = true;
21472132
}
21482133
}
Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,66 @@
1-
; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - | FileCheck --check-prefixes=CHECK,DAG %s
2-
; RUN: llc %s -fast-isel=true -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - | FileCheck --check-prefixes=CHECK,FAST %s
3-
; RUN: llc %s -global-isel=true -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - | FileCheck --check-prefixes=CHECK,GLOBAL %s
4-
5-
;; Test that a dbg.value that uses a DIArgList is correctly converted to a
6-
;; DBG_VALUE_LIST that uses the registers corresponding to its operands.
7-
8-
; CHECK-DAG: [[A_VAR:![0-9]+]] = !DILocalVariable(name: "a"
9-
; CHECK-DAG: [[B_VAR:![0-9]+]] = !DILocalVariable(name: "b"
10-
; CHECK-DAG: [[C_VAR:![0-9]+]] = !DILocalVariable(name: "c"
11-
; CHECK-LABEL: bb.{{(0|1)}}.entry
12-
; DAG-DAG: DBG_VALUE_LIST [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), %0, debug-location
13-
; DAG-DAG: DBG_VALUE_LIST [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), %1, debug-location
14-
; DAG: DBG_VALUE_LIST [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), %0, %1, debug-location
15-
; FAST-DAG: DBG_VALUE $noreg, $noreg, [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
16-
; FAST-DAG: DBG_VALUE $noreg, $noreg, [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
17-
; FAST: DBG_VALUE $noreg, $noreg, [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), debug-location
18-
; GLOBAL-DAG: DBG_VALUE $noreg, 0, [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
19-
; GLOBAL-DAG: DBG_VALUE $noreg, 0, [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
20-
; GLOBAL: DBG_VALUE $noreg, 0, [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), debug-location
21-
22-
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23-
target triple = "x86_64-pc-windows-msvc19.16.27034"
24-
25-
define dso_local i32 @"?foo@@YAHHH@Z"(i32 %a, i32 %b) local_unnamed_addr !dbg !8 {
26-
entry:
27-
call void @llvm.dbg.value(metadata !DIArgList(i32 %b), metadata !14, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
28-
call void @llvm.dbg.value(metadata !DIArgList(i32 %a), metadata !15, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
29-
call void @llvm.dbg.value(metadata !DIArgList(i32 %a, i32 %b), metadata !16, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !17
30-
%mul = mul nsw i32 %b, %a, !dbg !18
31-
ret i32 %mul, !dbg !18
32-
}
33-
34-
declare void @llvm.dbg.value(metadata, metadata, metadata)
35-
36-
!llvm.dbg.cu = !{!0}
37-
!llvm.module.flags = !{!3, !4, !5, !6}
38-
!llvm.ident = !{!7}
39-
40-
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
41-
!1 = !DIFile(filename: "debug_value_list_selectiondag.cpp", directory: "/")
42-
!2 = !{}
43-
!3 = !{i32 2, !"CodeView", i32 1}
44-
!4 = !{i32 2, !"Debug Info Version", i32 3}
45-
!5 = !{i32 1, !"wchar_size", i32 2}
46-
!6 = !{i32 7, !"PIC Level", i32 2}
47-
!7 = !{!"clang version 11.0.0"}
48-
!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHHH@Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
49-
!9 = !DIFile(filename: ".\\debug_value_list.cpp", directory: "/tmp")
50-
!10 = !DISubroutineType(types: !11)
51-
!11 = !{!12, !12, !12}
52-
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
53-
!13 = !{!14, !15, !16}
54-
!14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !9, line: 1, type: !12)
55-
!15 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
56-
!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
57-
!17 = !DILocation(line: 0, scope: !8)
58-
!18 = !DILocation(line: 3, scope: !8)
1+
; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - | FileCheck --check-prefixes=CHECK,DAG %s
2+
; RUN: llc %s -fast-isel=true -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - | FileCheck --check-prefixes=CHECK,FAST %s
3+
; RUN: llc %s -global-isel=true -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - | FileCheck --check-prefixes=CHECK,GLOBAL %s
4+
5+
;; Run with assignment tracking enabled (use sed to add the module flag).
6+
; RUN: sed 's/;Uncomment-with-sed//g' < %s \
7+
; RUN: | llc -global-isel=false -start-after=codegenprepare -stop-before=finalize-isel -experimental-debug-variable-locations=false -o - \
8+
; RUN: | FileCheck --check-prefixes=CHECK,DAG %s
9+
10+
;; Test that a dbg.value that uses a DIArgList is correctly converted to a
11+
;; DBG_VALUE_LIST that uses the registers corresponding to its operands.
12+
13+
; CHECK-DAG: [[A_VAR:![0-9]+]] = !DILocalVariable(name: "a"
14+
; CHECK-DAG: [[B_VAR:![0-9]+]] = !DILocalVariable(name: "b"
15+
; CHECK-DAG: [[C_VAR:![0-9]+]] = !DILocalVariable(name: "c"
16+
; CHECK-LABEL: bb.{{(0|1)}}.entry
17+
; DAG-DAG: DBG_VALUE_LIST [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), %0, debug-location
18+
; DAG-DAG: DBG_VALUE_LIST [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), %1, debug-location
19+
; DAG: DBG_VALUE_LIST [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), %0, %1, debug-location
20+
; FAST-DAG: DBG_VALUE $noreg, $noreg, [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
21+
; FAST-DAG: DBG_VALUE $noreg, $noreg, [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
22+
; FAST: DBG_VALUE $noreg, $noreg, [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), debug-location
23+
; GLOBAL-DAG: DBG_VALUE $noreg, 0, [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
24+
; GLOBAL-DAG: DBG_VALUE $noreg, 0, [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location
25+
; GLOBAL: DBG_VALUE $noreg, 0, [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), debug-location
26+
27+
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
28+
target triple = "x86_64-pc-windows-msvc19.16.27034"
29+
30+
define dso_local i32 @"?foo@@YAHHH@Z"(i32 %a, i32 %b) local_unnamed_addr !dbg !8 {
31+
entry:
32+
call void @llvm.dbg.value(metadata !DIArgList(i32 %b), metadata !14, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
33+
call void @llvm.dbg.value(metadata !DIArgList(i32 %a), metadata !15, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
34+
call void @llvm.dbg.value(metadata !DIArgList(i32 %a, i32 %b), metadata !16, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !17
35+
%mul = mul nsw i32 %b, %a, !dbg !18
36+
ret i32 %mul, !dbg !18
37+
}
38+
39+
declare void @llvm.dbg.value(metadata, metadata, metadata)
40+
41+
!llvm.dbg.cu = !{!0}
42+
!llvm.module.flags = !{!3, !4, !5,
43+
;Uncomment-with-sed !19,
44+
!6}
45+
!llvm.ident = !{!7}
46+
47+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
48+
!1 = !DIFile(filename: "debug_value_list_selectiondag.cpp", directory: "/")
49+
!2 = !{}
50+
!3 = !{i32 2, !"CodeView", i32 1}
51+
!4 = !{i32 2, !"Debug Info Version", i32 3}
52+
!5 = !{i32 1, !"wchar_size", i32 2}
53+
!6 = !{i32 7, !"PIC Level", i32 2}
54+
!7 = !{!"clang version 11.0.0"}
55+
!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHHH@Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
56+
!9 = !DIFile(filename: ".\\debug_value_list.cpp", directory: "/tmp")
57+
!10 = !DISubroutineType(types: !11)
58+
!11 = !{!12, !12, !12}
59+
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
60+
!13 = !{!14, !15, !16}
61+
!14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !9, line: 1, type: !12)
62+
!15 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
63+
!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
64+
!17 = !DILocation(line: 0, scope: !8)
65+
!18 = !DILocation(line: 3, scope: !8)
66+
!19 = !{i32 7, !"debug-info-assignment-tracking", i1 true}

0 commit comments

Comments
 (0)