[llvm] 8128d4b - [RemoveDIs] Preserve debug info format in llvm-reduce (#89220)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 10:04:19 PDT 2024
Author: Stephen Tozer
Date: 2024-04-22T18:04:15+01:00
New Revision: 8128d4b1229203c2ab20d3136410c149ea3652cf
URL: https://github.com/llvm/llvm-project/commit/8128d4b1229203c2ab20d3136410c149ea3652cf
DIFF: https://github.com/llvm/llvm-project/commit/8128d4b1229203c2ab20d3136410c149ea3652cf.diff
LOG: [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
https://github.com/llvm/llvm-project/pull/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.
Added:
Modified:
llvm/test/tools/llvm-reduce/remove-dp-values.ll
llvm/tools/llvm-reduce/llvm-reduce.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-reduce/remove-dp-values.ll b/llvm/test/tools/llvm-reduce/remove-dp-values.ll
index d137b279f4ea01..ab9cff4ae76865 100644
--- a/llvm/test/tools/llvm-reduce/remove-dp-values.ll
+++ b/llvm/test/tools/llvm-reduce/remove-dp-values.ll
@@ -1,17 +1,21 @@
-; 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
-; RUN: FileCheck --check-prefixes=CHECK-FINAL --input-file=%t %s --implicit-check-not=dbg.value
+; 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
+; RUN: FileCheck --check-prefixes=CHECK-FINAL --input-file=%t %s --implicit-check-not=#dbg_value
+
+; RUN: opt < %s -S --write-experimental-debuginfo=false > %t.intrinsics.ll
+; 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
+; RUN: FileCheck --check-prefixes=INTRINSIC-FINAL --input-file=%t %s --implicit-check-not=#dbg_value
; Test that we can, in RemoveDIs mode / DbgVariableRecords mode (where variable location
; information isn't an instruction), remove one variable location assignment
; but not another.
-; CHECK-INTERESTINGNESS: call void @llvm.dbg.value(metadata i32 %added,
-
-; CHECK-FINAL: declare void @llvm.dbg.value(metadata,
-; CHECK-FINAL: %added = add
-; CHECK-FINAL-NEXT: call void @llvm.dbg.value(metadata i32 %added,
+; CHECK-INTERESTINGNESS: #dbg_value(i32 %added,
+; INTRINSIC-INTERESTINGNESS: llvm.dbg.value(metadata i32 %added,
-declare void @llvm.dbg.value(metadata, metadata, metadata)
+; CHECK-FINAL: %added = add
+; CHECK-FINAL-NEXT: #dbg_value(i32 %added,
+; INTRINSIC-FINAL: %added = add
+; INTRINSIC-FINAL-NEXT: llvm.dbg.value(metadata i32 %added,
define i32 @main() !dbg !7 {
entry:
@@ -22,10 +26,10 @@ entry:
store i32 0, ptr %interesting, align 4
%0 = load i32, ptr %interesting, align 4
%added = add nsw i32 %0, 1
- tail call void @llvm.dbg.value(metadata i32 %added, metadata !13, metadata !DIExpression()), !dbg !14
+ #dbg_value(i32 %added, !13, !DIExpression(), !14)
store i32 %added, ptr %interesting, align 4
%alsoloaded = load i32, ptr %interesting, align 4
- tail call void @llvm.dbg.value(metadata i32 %alsoloaded, metadata !13, metadata !DIExpression()), !dbg !14
+ #dbg_value(i32 %alsoloaded, !13, !DIExpression(), !14)
store i32 %alsoloaded, ptr %uninteresting2, align 4
ret i32 0
}
diff --git a/llvm/tools/llvm-reduce/llvm-reduce.cpp b/llvm/tools/llvm-reduce/llvm-reduce.cpp
index f913771487afe1..288a384c2ed498 100644
--- a/llvm/tools/llvm-reduce/llvm-reduce.cpp
+++ b/llvm/tools/llvm-reduce/llvm-reduce.cpp
@@ -100,12 +100,7 @@ static cl::opt<int>
"of delta passes (default=5)"),
cl::init(5), cl::cat(LLVMReduceOptions));
-static cl::opt<bool> TryUseNewDbgInfoFormat(
- "try-experimental-debuginfo-iterators",
- cl::desc("Enable debuginfo iterator positions, if they're built in"),
- cl::init(false));
-
-extern cl::opt<bool> UseNewDbgInfoFormat;
+extern cl::opt<cl::boolOrDefault> PreserveInputDbgFormat;
static codegen::RegisterCodeGenFlags CGF;
@@ -146,17 +141,11 @@ static std::pair<StringRef, bool> determineOutputType(bool IsMIR,
int main(int Argc, char **Argv) {
InitLLVM X(Argc, Argv);
const StringRef ToolName(Argv[0]);
+ PreserveInputDbgFormat = cl::boolOrDefault::BOU_TRUE;
cl::HideUnrelatedOptions({&LLVMReduceOptions, &getColorCategory()});
cl::ParseCommandLineOptions(Argc, Argv, "LLVM automatic testcase reducer.\n");
- // RemoveDIs debug-info transition: tests may request that we /try/ to use the
- // new debug-info format.
- if (TryUseNewDbgInfoFormat) {
- // Turn the new debug-info format on.
- UseNewDbgInfoFormat = true;
- }
-
if (Argc == 1) {
cl::PrintHelpMessage();
return 0;
More information about the llvm-commits
mailing list