Skip to content

[RemoveDIs] Preserve debug info format in llvm-reduce #89220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions llvm/test/tools/llvm-reduce/remove-dp-values.ll
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding another set of RUNs and CHECKs that convert the input file to debug intrinsics, and test they stay as intrinsics. E.g., write to temp file, then pass that to --input-file=?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have said that this should be covered by existing tests, but apparently we don't have any tests that explicitly test removing debug intrinsics (since they're just like any other instruction) - for the sake of ensuring coverage as we transition to using records by default, I've added such a test here!


; 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:
Expand All @@ -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
}
Expand Down
15 changes: 2 additions & 13 deletions llvm/tools/llvm-reduce/llvm-reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down