Skip to content

Commit 8128d4b

Browse files
authored
[RemoveDIs] Preserve debug info format in llvm-reduce (#89220)
As the goal of LLVM reduce is to simplify the input file, it should not modify the debug info format - doing so by default would make it impossible to reduce an error that only occurs in the old format, for example (as briefly discussed at #86275). This patch uses the new "preserve debug info format" flag in llvm-reduce to prevent the input from being subtly transformed by llvm-reduce itself; this has no effect on any tools used for the interestingness check (i.e. if `opt` is invoked, it will still convert the reduced input to the new format by default), but simply ensures that the reduced file is strictly reduced rather than modified.
1 parent 330d898 commit 8128d4b

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

llvm/test/tools/llvm-reduce/remove-dp-values.ll

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
; RUN: llvm-reduce --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t --try-experimental-debuginfo-iterators
2-
; RUN: FileCheck --check-prefixes=CHECK-FINAL --input-file=%t %s --implicit-check-not=dbg.value
1+
; RUN: llvm-reduce --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
2+
; RUN: FileCheck --check-prefixes=CHECK-FINAL --input-file=%t %s --implicit-check-not=#dbg_value
3+
4+
; RUN: opt < %s -S --write-experimental-debuginfo=false > %t.intrinsics.ll
5+
; RUN: llvm-reduce --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=INTRINSIC-INTERESTINGNESS --test-arg %s --test-arg --input-file %t.intrinsics.ll -o %t
6+
; RUN: FileCheck --check-prefixes=INTRINSIC-FINAL --input-file=%t %s --implicit-check-not=#dbg_value
37

48
; Test that we can, in RemoveDIs mode / DbgVariableRecords mode (where variable location
59
; information isn't an instruction), remove one variable location assignment
610
; but not another.
711

8-
; CHECK-INTERESTINGNESS: call void @llvm.dbg.value(metadata i32 %added,
9-
10-
; CHECK-FINAL: declare void @llvm.dbg.value(metadata,
11-
; CHECK-FINAL: %added = add
12-
; CHECK-FINAL-NEXT: call void @llvm.dbg.value(metadata i32 %added,
12+
; CHECK-INTERESTINGNESS: #dbg_value(i32 %added,
13+
; INTRINSIC-INTERESTINGNESS: llvm.dbg.value(metadata i32 %added,
1314

14-
declare void @llvm.dbg.value(metadata, metadata, metadata)
15+
; CHECK-FINAL: %added = add
16+
; CHECK-FINAL-NEXT: #dbg_value(i32 %added,
17+
; INTRINSIC-FINAL: %added = add
18+
; INTRINSIC-FINAL-NEXT: llvm.dbg.value(metadata i32 %added,
1519

1620
define i32 @main() !dbg !7 {
1721
entry:
@@ -22,10 +26,10 @@ entry:
2226
store i32 0, ptr %interesting, align 4
2327
%0 = load i32, ptr %interesting, align 4
2428
%added = add nsw i32 %0, 1
25-
tail call void @llvm.dbg.value(metadata i32 %added, metadata !13, metadata !DIExpression()), !dbg !14
29+
#dbg_value(i32 %added, !13, !DIExpression(), !14)
2630
store i32 %added, ptr %interesting, align 4
2731
%alsoloaded = load i32, ptr %interesting, align 4
28-
tail call void @llvm.dbg.value(metadata i32 %alsoloaded, metadata !13, metadata !DIExpression()), !dbg !14
32+
#dbg_value(i32 %alsoloaded, !13, !DIExpression(), !14)
2933
store i32 %alsoloaded, ptr %uninteresting2, align 4
3034
ret i32 0
3135
}

llvm/tools/llvm-reduce/llvm-reduce.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ static cl::opt<int>
100100
"of delta passes (default=5)"),
101101
cl::init(5), cl::cat(LLVMReduceOptions));
102102

103-
static cl::opt<bool> TryUseNewDbgInfoFormat(
104-
"try-experimental-debuginfo-iterators",
105-
cl::desc("Enable debuginfo iterator positions, if they're built in"),
106-
cl::init(false));
107-
108-
extern cl::opt<bool> UseNewDbgInfoFormat;
103+
extern cl::opt<cl::boolOrDefault> PreserveInputDbgFormat;
109104

110105
static codegen::RegisterCodeGenFlags CGF;
111106

@@ -146,17 +141,11 @@ static std::pair<StringRef, bool> determineOutputType(bool IsMIR,
146141
int main(int Argc, char **Argv) {
147142
InitLLVM X(Argc, Argv);
148143
const StringRef ToolName(Argv[0]);
144+
PreserveInputDbgFormat = cl::boolOrDefault::BOU_TRUE;
149145

150146
cl::HideUnrelatedOptions({&LLVMReduceOptions, &getColorCategory()});
151147
cl::ParseCommandLineOptions(Argc, Argv, "LLVM automatic testcase reducer.\n");
152148

153-
// RemoveDIs debug-info transition: tests may request that we /try/ to use the
154-
// new debug-info format.
155-
if (TryUseNewDbgInfoFormat) {
156-
// Turn the new debug-info format on.
157-
UseNewDbgInfoFormat = true;
158-
}
159-
160149
if (Argc == 1) {
161150
cl::PrintHelpMessage();
162151
return 0;

0 commit comments

Comments
 (0)