Skip to content

[DebugInfo][RemoveDIs] Remove debug-intrinsic printing cmdline options #131855

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 7 commits into from
Apr 1, 2025
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
8 changes: 4 additions & 4 deletions flang/test/Integration/debug-local-var-2.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --write-experimental-debuginfo=false -o - | FileCheck %s --check-prefixes=BOTH,INTRINSICS
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --write-experimental-debuginfo=true -o - | FileCheck %s --check-prefixes=BOTH,RECORDS
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --write-experimental-debuginfo=false -o - | FileCheck --check-prefix=LINEONLY %s
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --write-experimental-debuginfo=true -o - | FileCheck --check-prefix=LINEONLY %s
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --experimental-debuginfo-iterators=false -o - | FileCheck %s --check-prefixes=BOTH,INTRINSICS
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --experimental-debuginfo-iterators=true -o - | FileCheck %s --check-prefixes=BOTH,RECORDS
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --experimental-debuginfo-iterators=false -o - | FileCheck --check-prefix=LINEONLY %s
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --experimental-debuginfo-iterators=true -o - | FileCheck --check-prefix=LINEONLY %s

! This tests checks the debug information for local variables in llvm IR.

Expand Down
2 changes: 1 addition & 1 deletion llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13407,7 +13407,7 @@ an extra level of indentation. As an example:
%inst2 = op2 %inst1, %c

These debug records replace the prior :ref:`debug intrinsics<dbg_intrinsics>`.
Debug records will be disabled if ``--write-experimental-debuginfo=false`` is
Debug records will be disabled if ``--experimental-debuginfo-iterators=false`` is
passed to LLVM; it is an error for both records and intrinsics to appear in the
same module. More information about debug records can be found in the `LLVM
Source Level Debugging <SourceLevelDebugging.html#format-common-intrinsics>`_
Expand Down
4 changes: 0 additions & 4 deletions llvm/lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ static cl::opt<bool> AllowIncompleteIR(

extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
extern cl::opt<cl::boolOrDefault> PreserveInputDbgFormat;
extern bool WriteNewDbgInfoFormatToBitcode;
extern cl::opt<bool> WriteNewDbgInfoFormat;

static std::string getTypeString(Type *T) {
std::string Result;
Expand Down Expand Up @@ -213,8 +211,6 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
"Mixed debug intrinsics/records seen without a parsing error?");
if (PreserveInputDbgFormat == cl::boolOrDefault::BOU_TRUE) {
UseNewDbgInfoFormat = SeenNewDbgInfoFormat;
WriteNewDbgInfoFormatToBitcode = SeenNewDbgInfoFormat;
WriteNewDbgInfoFormat = SeenNewDbgInfoFormat;
M->setNewDbgInfoFormatFlag(SeenNewDbgInfoFormat);
}

Expand Down
23 changes: 3 additions & 20 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,8 @@ static cl::opt<bool> ExpandConstantExprs(
cl::desc(
"Expand constant expressions to instructions for testing purposes"));

/// Load bitcode directly into RemoveDIs format (use debug records instead
/// of debug intrinsics). UNSET is treated as FALSE, so the default action
/// is to do nothing. Individual tools can override this to incrementally add
/// support for the RemoveDIs format.
cl::opt<cl::boolOrDefault> LoadBitcodeIntoNewDbgInfoFormat(
"load-bitcode-into-experimental-debuginfo-iterators", cl::Hidden,
cl::desc("Load bitcode directly into the new debug info format (regardless "
"of input format)"));
extern cl::opt<bool> UseNewDbgInfoFormat;
extern cl::opt<cl::boolOrDefault> PreserveInputDbgFormat;
extern bool WriteNewDbgInfoFormatToBitcode;
extern cl::opt<bool> WriteNewDbgInfoFormat;

namespace {

Expand Down Expand Up @@ -4494,14 +4484,9 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord(
Error BitcodeReader::parseModule(uint64_t ResumeBit,
bool ShouldLazyLoadMetadata,
ParserCallbacks Callbacks) {
// Load directly into RemoveDIs format if LoadBitcodeIntoNewDbgInfoFormat
// has been set to true and we aren't attempting to preserve the existing
// format in the bitcode (default action: load into the old debug format).
if (PreserveInputDbgFormat != cl::boolOrDefault::BOU_TRUE) {
TheModule->IsNewDbgInfoFormat =
UseNewDbgInfoFormat &&
LoadBitcodeIntoNewDbgInfoFormat != cl::boolOrDefault::BOU_FALSE;
}
// In preparation for the deletion of debug-intrinsics, don't allow module
// loading to escape intrinsics being autoupgraded to debug records.
TheModule->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

this->ValueTypeCallback = std::move(Callbacks.ValueType);
if (ResumeBit) {
Expand Down Expand Up @@ -7028,8 +7013,6 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
SeenAnyDebugInfo ? SeenDebugRecord : F->getParent()->IsNewDbgInfoFormat;
if (SeenAnyDebugInfo) {
UseNewDbgInfoFormat = SeenDebugRecord;
WriteNewDbgInfoFormatToBitcode = SeenDebugRecord;
WriteNewDbgInfoFormat = SeenDebugRecord;
}
// If the module's debug info format doesn't match the observed input
// format, then set its format now; we don't need to call the conversion
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ namespace llvm {
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
}

extern bool WriteNewDbgInfoFormatToBitcode;
extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

namespace {
Expand Down Expand Up @@ -3678,7 +3677,7 @@ void ModuleBitcodeWriter::writeFunction(
// they come after the instruction so that it's easy to attach them again
// when reading the bitcode, even though conceptually the debug locations
// start "before" the instruction.
if (I.hasDbgRecords() && WriteNewDbgInfoFormatToBitcode) {
if (I.hasDbgRecords()) {
/// Try to push the value only (unwrapped), otherwise push the
/// metadata wrapped value. Returns true if the value was pushed
/// without the ValueAsMetadata wrapper.
Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#include "llvm/Pass.h"
using namespace llvm;

extern bool WriteNewDbgInfoFormatToBitcode;

PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat &&
WriteNewDbgInfoFormatToBitcode);
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat);
if (M.IsNewDbgInfoFormat)
M.removeDebugIntrinsicDeclarations();

Expand Down Expand Up @@ -54,8 +51,7 @@ namespace {
StringRef getPassName() const override { return "Bitcode Writer"; }

bool runOnModule(Module &M) override {
ScopedDbgInfoFormatSetter FormatSetter(
M, M.IsNewDbgInfoFormat && WriteNewDbgInfoFormatToBitcode);
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat);
if (M.IsNewDbgInfoFormat)
M.removeDebugIntrinsicDeclarations();

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/MIRPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static cl::opt<bool> SimplifyMIR(
static cl::opt<bool> PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true),
cl::desc("Print MIR debug-locations"));

extern cl::opt<bool> WriteNewDbgInfoFormat;
extern cl::opt<bool> UseNewDbgInfoFormat;

namespace {

Expand Down Expand Up @@ -1050,7 +1050,7 @@ void MIRFormatter::printIRValue(raw_ostream &OS, const Value &V,

void llvm::printMIR(raw_ostream &OS, const Module &M) {
ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M),
WriteNewDbgInfoFormat);
UseNewDbgInfoFormat);

yaml::Output Out(OS);
Out << const_cast<Module &>(M);
Expand All @@ -1061,7 +1061,7 @@ void llvm::printMIR(raw_ostream &OS, const MachineModuleInfo &MMI,
// RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
// in dbg.value format.
ScopedDbgInfoFormatSetter FormatSetter(
const_cast<Function &>(MF.getFunction()), WriteNewDbgInfoFormat);
const_cast<Function &>(MF.getFunction()), UseNewDbgInfoFormat);

MIRPrinter Printer(OS, MMI);
Printer.print(MF);
Expand Down
5 changes: 0 additions & 5 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ cl::opt<cl::boolOrDefault> PreserveInputDbgFormat(
"contain debug records or intrinsics. Ignored in llvm-link, "
"llvm-lto, and llvm-lto2."));

bool WriteNewDbgInfoFormatToBitcode /*set default value in cl::init() below*/;
cl::opt<bool, true> WriteNewDbgInfoFormatToBitcode2(
"write-experimental-debuginfo-iterators-to-bitcode", cl::Hidden,
cl::location(WriteNewDbgInfoFormatToBitcode), cl::init(true));

DbgMarker *BasicBlock::createMarker(Instruction *I) {
assert(IsNewDbgInfoFormat &&
"Tried to create a marker in a non new debug-info block!");
Expand Down
16 changes: 4 additions & 12 deletions llvm/lib/IR/IRPrintingPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@

using namespace llvm;

cl::opt<bool> WriteNewDbgInfoFormat(
"write-experimental-debuginfo",
cl::desc("Write debug info in the new non-intrinsic format. Has no effect "
"if --preserve-input-debuginfo-format=true."),
cl::init(true));
extern cl::opt<bool> UseNewDbgInfoFormat;

namespace {

Expand All @@ -45,13 +41,11 @@ class PrintModulePassWrapper : public ModulePass {
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}

bool runOnModule(Module &M) override {
// RemoveDIs: Regardless of the format we've processed this module in, use
// `WriteNewDbgInfoFormat` to determine which format we use to write it.
ScopedDbgInfoFormatSetter FormatSetter(M, WriteNewDbgInfoFormat);
ScopedDbgInfoFormatSetter FormatSetter(M, UseNewDbgInfoFormat);
// Remove intrinsic declarations when printing in the new format.
// TODO: Move this into Module::setIsNewDbgInfoFormat when we're ready to
// update test output.
if (WriteNewDbgInfoFormat)
if (UseNewDbgInfoFormat)
M.removeDebugIntrinsicDeclarations();

if (llvm::isFunctionInPrintList("*")) {
Expand Down Expand Up @@ -93,9 +87,7 @@ class PrintFunctionPassWrapper : public FunctionPass {

// This pass just prints a banner followed by the function as it's processed.
bool runOnFunction(Function &F) override {
// RemoveDIs: Regardless of the format we've processed this function in, use
// `WriteNewDbgInfoFormat` to determine which format we use to write it.
ScopedDbgInfoFormatSetter FormatSetter(F, WriteNewDbgInfoFormat);
ScopedDbgInfoFormatSetter FormatSetter(F, UseNewDbgInfoFormat);

if (isFunctionInPrintList(F.getName())) {
if (forcePrintModuleIR())
Expand Down
12 changes: 4 additions & 8 deletions llvm/lib/IRPrinter/IRPrintingPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

using namespace llvm;

extern cl::opt<bool> WriteNewDbgInfoFormat;
extern cl::opt<bool> UseNewDbgInfoFormat;

PrintModulePass::PrintModulePass() : OS(dbgs()) {}
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
Expand All @@ -33,13 +33,11 @@ PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
EmitSummaryIndex(EmitSummaryIndex) {}

PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
// RemoveDIs: Regardless of the format we've processed this module in, use
// `WriteNewDbgInfoFormat` to determine which format we use to write it.
ScopedDbgInfoFormatSetter FormatSetter(M, WriteNewDbgInfoFormat);
ScopedDbgInfoFormatSetter FormatSetter(M, UseNewDbgInfoFormat);
// Remove intrinsic declarations when printing in the new format.
// TODO: Move this into Module::setIsNewDbgInfoFormat when we're ready to
// update test output.
if (WriteNewDbgInfoFormat)
if (UseNewDbgInfoFormat)
M.removeDebugIntrinsicDeclarations();

if (llvm::isFunctionInPrintList("*")) {
Expand Down Expand Up @@ -77,9 +75,7 @@ PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)

PreservedAnalyses PrintFunctionPass::run(Function &F,
FunctionAnalysisManager &) {
// RemoveDIs: Regardless of the format we've processed this function in, use
// `WriteNewDbgInfoFormat` to determine which format we use to write it.
ScopedDbgInfoFormatSetter FormatSetter(F, WriteNewDbgInfoFormat);
ScopedDbgInfoFormatSetter FormatSetter(F, UseNewDbgInfoFormat);

if (isFunctionInPrintList(F.getName())) {
if (forcePrintModuleIR())
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,13 @@ bool writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS,
}

} // anonymous namespace
extern bool WriteNewDbgInfoFormatToBitcode;

PreservedAnalyses
llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
FunctionAnalysisManager &FAM =
AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();

ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat &&
WriteNewDbgInfoFormatToBitcode);
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat);
if (M.IsNewDbgInfoFormat)
M.removeDebugIntrinsicDeclarations();

Expand Down
21 changes: 2 additions & 19 deletions llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
;; Pin this test to not use "RemoveDIs" non-intrinsic debug-info. We get the
;; correct output in that mode, but it generates spurious test changes, so
;; avoid that for the moment.
; RUN: opt -mtriple=x86_64-- -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=code-size %s -S -o - --experimental-debuginfo-iterators=false | FileCheck %s --check-prefix=CHECK-SIZE
; RUN: opt -mtriple=x86_64-- -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=throughput %s -S -o - --experimental-debuginfo-iterators=false | FileCheck %s --check-prefix=CHECK-THROUGHPUT
; RUN: opt -mtriple=x86_64-- -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=code-size %s -S -o - | FileCheck %s --check-prefix=CHECK-SIZE
; RUN: opt -mtriple=x86_64-- -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=throughput %s -S -o - | FileCheck %s --check-prefix=CHECK-THROUGHPUT

define i32 @trivially_free() {
; CHECK-SIZE-LABEL: 'trivially_free'
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = call i32 @llvm.annotation.i32.p0(i32 undef, ptr undef, ptr undef, i32 undef)
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.assume(i1 undef)
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.experimental.noalias.scope.decl(metadata !3)
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.sideeffect()
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.dbg.assign(metadata ptr undef, metadata !6, metadata !DIExpression(), metadata !8, metadata ptr undef, metadata !DIExpression()), !dbg !9
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.dbg.declare(metadata ptr undef, metadata !6, metadata !DIExpression()), !dbg !9
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.dbg.label(metadata !10), !dbg !9
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = call ptr @llvm.invariant.start.p0(i64 1, ptr undef)
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.invariant.end.p0(ptr undef, i64 1, ptr undef)
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = call ptr @llvm.launder.invariant.group.p0(ptr undef)
Expand All @@ -31,9 +25,6 @@ define i32 @trivially_free() {
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.assume(i1 undef)
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.experimental.noalias.scope.decl(metadata !3)
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.sideeffect()
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.dbg.assign(metadata ptr undef, metadata !6, metadata !DIExpression(), metadata !8, metadata ptr undef, metadata !DIExpression()), !dbg !9
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.dbg.declare(metadata ptr undef, metadata !6, metadata !DIExpression()), !dbg !9
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.dbg.label(metadata !10), !dbg !9
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = call ptr @llvm.invariant.start.p0(i64 1, ptr undef)
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.invariant.end.p0(ptr undef, i64 1, ptr undef)
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = call ptr @llvm.launder.invariant.group.p0(ptr undef)
Expand All @@ -50,10 +41,6 @@ define i32 @trivially_free() {
call void @llvm.assume(i1 undef)
call void @llvm.experimental.noalias.scope.decl(metadata !4)
call void @llvm.sideeffect()
call void @llvm.dbg.assign(metadata ptr undef, metadata !0, metadata !DIExpression(), metadata !10, metadata ptr undef, metadata !DIExpression()), !dbg !8
call void @llvm.dbg.declare(metadata ptr undef, metadata !0, metadata !DIExpression()), !dbg !8
call void @llvm.dbg.value(metadata i64 undef, i64 undef, metadata !DIExpression(), metadata !DIExpression()), !dbg !8
call void @llvm.dbg.label(metadata !2), !dbg !8
%a1 = call ptr @llvm.invariant.start.p0(i64 1, ptr undef)
call void @llvm.invariant.end.p0(ptr undef, i64 1, ptr undef)
%a2 = call ptr @llvm.launder.invariant.group.p0(ptr undef)
Expand All @@ -71,10 +58,6 @@ declare i32 @llvm.annotation.i32(i32, ptr, ptr, i32)
declare void @llvm.assume(i1)
declare void @llvm.experimental.noalias.scope.decl(metadata)
declare void @llvm.sideeffect()
declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
declare void @llvm.dbg.declare(metadata, metadata, metadata)
declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
declare void @llvm.dbg.label(metadata)
declare ptr @llvm.invariant.start.p0(i64, ptr)
declare void @llvm.invariant.end.p0(ptr, i64, ptr)
declare ptr @llvm.launder.invariant.group.p0(ptr)
Expand Down
Loading
Loading