Skip to content

Commit

Permalink
Revert "[DebugInfo][RemoveDIs] Convert debug-info modes when loading …
Browse files Browse the repository at this point in the history
…bitcode (#78967)"

This reverts commit 215b8f1.

Numerous builders exploded from this X_X, for example

  https://lab.llvm.org/buildbot/#/builders/46/builds/62657
  • Loading branch information
jmorse committed Jan 25, 2024
1 parent a04d4a0 commit c3f7fb1
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 111 deletions.
23 changes: 0 additions & 23 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ static cl::opt<bool> ExpandConstantExprs(
cl::desc(
"Expand constant expressions to instructions for testing purposes"));

// Declare external flag for whether we're using the new debug-info format.
extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

namespace {

enum {
Expand Down Expand Up @@ -6632,9 +6629,6 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
if (Error Err = materializeMetadata())
return Err;

bool NewDebugInfoRequested = F->IsNewDbgInfoFormat;
F->IsNewDbgInfoFormat = false;

// Move the bit stream to the saved position of the deferred function body.
if (Error JumpFailed = Stream.JumpToBit(DFII->second))
return JumpFailed;
Expand Down Expand Up @@ -6710,14 +6704,6 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
// Look for functions that rely on old function attribute behavior.
UpgradeFunctionAttributes(*F);

// If we've materialized a function set up in "new" debug-info mode, the
// contents just loaded will still be in dbg.value mode. Switch to the new
// mode now. NB: we can add more complicated logic here in the future to
// correctly identify when we do and don't need to autoupgrade.
if (NewDebugInfoRequested) {
F->convertToNewDbgValues();
}

// Bring in any functions that this function forward-referenced via
// blockaddresses.
return materializeForwardReferencedFunctions();
Expand Down Expand Up @@ -8041,15 +8027,6 @@ BitcodeModule::getModuleImpl(LLVMContext &Context, bool MaterializeAll,
if (Error Err = R->materializeForwardReferencedFunctions())
return std::move(Err);
}

// If we are operating in a "new debug-info" context, upgrade the debug-info
// in the loaded module. This is a transitional approach as we enable "new"
// debug-info in LLVM, which will eventually be pushed down into the
// autoupgrade path once the bitcode-encoding is finalised. Non-materialised
// functions will be upgraded in the materialize method.
if (UseNewDbgInfoFormat && !M->IsNewDbgInfoFormat)
M->convertToNewDbgValues();

return std::move(M);
}

Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/IR/LegacyPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,7 @@ bool PassManagerImpl::run(Module &M) {

// RemoveDIs: if a command line flag is given, convert to the DPValue
// representation of debug-info for the duration of these passes.
bool shouldConvertDbgInfo = UseNewDbgInfoFormat && !M.IsNewDbgInfoFormat;
if (shouldConvertDbgInfo)
if (UseNewDbgInfoFormat)
M.convertToNewDbgValues();

for (ImmutablePass *ImPass : getImmutablePasses())
Expand All @@ -546,8 +545,7 @@ bool PassManagerImpl::run(Module &M) {
for (ImmutablePass *ImPass : getImmutablePasses())
Changed |= ImPass->doFinalization(M);

if (shouldConvertDbgInfo)
M.convertFromNewDbgValues();
M.convertFromNewDbgValues();

return Changed;
}
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Linker/IRMover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ Function *IRLinker::copyFunctionProto(const Function *SF) {
SF->getAddressSpace(), SF->getName(), &DstM);
F->copyAttributesFrom(SF);
F->setAttributes(mapAttributeTypes(F->getContext(), F->getAttributes()));
F->IsNewDbgInfoFormat = SF->IsNewDbgInfoFormat;
return F;
}

Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/Transforms/Utils/ValueMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,13 +1056,9 @@ void Mapper::remapFunction(Function &F) {
A.mutateType(TypeMapper->remapType(A.getType()));

// Remap the instructions.
for (BasicBlock &BB : F) {
for (Instruction &I : BB) {
for (BasicBlock &BB : F)
for (Instruction &I : BB)
remapInstruction(&I);
for (DPValue &DPV : I.DbgMarker->getDbgValueRange())
remapDPValue(DPV);
}
}
}

void Mapper::mapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix,
Expand Down
8 changes: 0 additions & 8 deletions llvm/test/LTO/X86/pr38046.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
; RUN: llvm-dis %t.lto.o.0.2.internalize.bc >/dev/null 2>%t.dis.stderr || true
; RUN: FileCheck -allow-empty %s < %t.dis.stderr

;; Re-run with "new" debug-info mode to ensure the variable location information
;; is handled gracefully.
; RUN: llvm-lto2 run -save-temps -o %t.lto.o %t.o \
; RUN: -r=%t.o,foo,plx \
; RUN: -r=%t.o,get,pl --try-experimental-debuginfo-iterators
; RUN: llvm-dis %t.lto.o.0.2.internalize.bc >/dev/null 2>%t.dis.stderr || true
; RUN: FileCheck -allow-empty %s < %t.dis.stderr

; CHECK-NOT: Global is external, but doesn't have external or weak linkage

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
Expand Down
1 change: 0 additions & 1 deletion llvm/test/Linker/debug-info-use-before-def.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
; RUN: llvm-link -S %s | FileCheck %s
; RUN: llvm-link -S %s --try-experimental-debuginfo-iterators | FileCheck %s

; Test that when a debug metadata use-before-def is run through llvm-link, the
; value reference is preserved. Tests both singular uses and DIArgList uses of
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/Linker/thinlto_funcimport_debug.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
; If we import func1 and not func2 we should only link DISubprogram for func1
; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=func1:%t.bc -S | FileCheck %s

;; Repeat runlines using "new" debuginfo iterators mode.
; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc --try-experimental-debuginfo-iterators
; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=func1:%t.bc -S --try-experimental-debuginfo-iterators | FileCheck %s

; CHECK: declare i32 @func2
; CHECK: define available_externally i32 @func1

Expand Down
4 changes: 0 additions & 4 deletions llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
; CHECK-NOT: DICompileUnit{{.*}} globals:
; CHECK-NOT: DICompileUnit{{.*}} imports:

;; Repeat test in RemoveDIs debug-info mode to check that bitcode is loaded and
;; converted correctly.
; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - --try-experimental-debuginfo-iterators | llvm-dis -o - | FileCheck %s

; ModuleID = 'debuginfo-cu-import.c'
source_filename = "debuginfo-cu-import.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
Expand Down
6 changes: 0 additions & 6 deletions llvm/test/ThinLTO/X86/pr35472.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOa
; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOb

;; Re-run with "new" debug-info mode, checking that we load / convert / emit
;; the dbg.declares below correctly.
; RUN: llvm-lto -thinlto-action=run %t1.bc %t2.bc -exported-symbol=_Z5Alphav --try-experimental-debuginfo-iterators
; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOa
; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOb

; ThinLTOa-DAG: T _Z5Bravov
; ThinLTOa-DAG: W _ZN4EchoD2Ev
; ThinLTOb-DAG: T _Z5Alphav
Expand Down
18 changes: 0 additions & 18 deletions llvm/tools/llvm-link/llvm-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ static cl::opt<bool> IgnoreNonBitcode(
cl::desc("Do not report an error for non-bitcode files in archives"),
cl::Hidden);

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;

static ExitOnError ExitOnErr;

// Read the specified bitcode file in and return it. This routine searches the
Expand Down Expand Up @@ -472,17 +465,6 @@ int main(int argc, char **argv) {
cl::HideUnrelatedOptions({&LinkCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");

// RemoveDIs debug-info transition: tests may request that we /try/ to use the
// new debug-info format, if it's built in.
#ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
if (TryUseNewDbgInfoFormat) {
// If LLVM was built with support for this, turn the new debug-info format
// on.
UseNewDbgInfoFormat = true;
}
#endif
(void)TryUseNewDbgInfoFormat;

LLVMContext Context;
Context.setDiagnosticHandler(std::make_unique<LLVMLinkDiagnosticHandler>(),
true);
Expand Down
18 changes: 0 additions & 18 deletions llvm/tools/llvm-lto/llvm-lto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,6 @@ static cl::opt<bool>
LTOSaveBeforeOpt("lto-save-before-opt", cl::init(false),
cl::desc("Save the IR before running optimizations"));

static cl::opt<bool> TryUseNewDbgInfoFormat(
"try-experimental-debuginfo-iterators",
cl::desc("Enable debuginfo iterator positions, if they're built in"),
cl::init(false), cl::Hidden);

extern cl::opt<bool> UseNewDbgInfoFormat;

namespace {

struct ModuleInfo {
Expand Down Expand Up @@ -944,17 +937,6 @@ int main(int argc, char **argv) {
cl::HideUnrelatedOptions({&LTOCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n");

// RemoveDIs debug-info transition: tests may request that we /try/ to use the
// new debug-info format, if it's built in.
#ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
if (TryUseNewDbgInfoFormat) {
// If LLVM was built with support for this, turn the new debug-info format
// on.
UseNewDbgInfoFormat = true;
}
#endif
(void)TryUseNewDbgInfoFormat;

if (OptLevel < '0' || OptLevel > '3')
error("optimization level must be between 0 and 3");

Expand Down
18 changes: 0 additions & 18 deletions llvm/tools/llvm-lto2/llvm-lto2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ static cl::opt<bool> EnableFreestanding(
cl::desc("Enable Freestanding (disable builtins / TLI) during LTO"),
cl::Hidden);

static cl::opt<bool> TryUseNewDbgInfoFormat(
"try-experimental-debuginfo-iterators",
cl::desc("Enable debuginfo iterator positions, if they're built in"),
cl::init(false), cl::Hidden);

extern cl::opt<bool> UseNewDbgInfoFormat;

static void check(Error E, std::string Msg) {
if (!E)
return;
Expand Down Expand Up @@ -229,17 +222,6 @@ static int usage() {
static int run(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "Resolution-based LTO test harness");

// RemoveDIs debug-info transition: tests may request that we /try/ to use the
// new debug-info format, if it's built in.
#ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
if (TryUseNewDbgInfoFormat) {
// If LLVM was built with support for this, turn the new debug-info format
// on.
UseNewDbgInfoFormat = true;
}
#endif
(void)TryUseNewDbgInfoFormat;

// FIXME: Workaround PR30396 which means that a symbol can appear
// more than once if it is defined in module-level assembly and
// has a GV declaration. We allow (file, symbol) pairs to have multiple
Expand Down

0 comments on commit c3f7fb1

Please sign in to comment.