Skip to content

Commit b3f98df

Browse files
authored
[RemoveDIs] Load into new debug info format by default in llvm-lto and llvm-lto2 (#86271)
Directly load all bitcode into the new debug info format in `llvm-lto` and `llvm-lto2`. This means that new-mode bitcode no longer round-trips back to old-mode after parsing, and that old-mode bitcode gets auto-upgraded to new-mode debug info (which is the current in-memory default in LLVM).
1 parent 3b3de48 commit b3f98df

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

llvm/lib/LTO/LTO.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
579579
const Config &Conf)
580580
: ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
581581
Ctx(Conf), CombinedModule(std::make_unique<Module>("ld-temp.o", Ctx)),
582-
Mover(std::make_unique<IRMover>(*CombinedModule)) {}
582+
Mover(std::make_unique<IRMover>(*CombinedModule)) {
583+
CombinedModule->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
584+
}
583585

584586
LTO::ThinLTOState::ThinLTOState(ThinBackend Backend)
585587
: Backend(Backend), CombinedIndex(/*HaveGVs*/ false) {

llvm/tools/llvm-lto/llvm-lto.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ static cl::opt<bool> TryUseNewDbgInfoFormat(
270270
cl::init(false), cl::Hidden);
271271

272272
extern cl::opt<bool> UseNewDbgInfoFormat;
273+
extern cl::opt<cl::boolOrDefault> LoadBitcodeIntoNewDbgInfoFormat;
273274

274275
namespace {
275276

@@ -943,6 +944,9 @@ int main(int argc, char **argv) {
943944
InitLLVM X(argc, argv);
944945
cl::HideUnrelatedOptions({&LTOCategory, &getColorCategory()});
945946
cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n");
947+
// Load bitcode into the new debug info format by default.
948+
if (LoadBitcodeIntoNewDbgInfoFormat == cl::boolOrDefault::BOU_UNSET)
949+
LoadBitcodeIntoNewDbgInfoFormat = cl::boolOrDefault::BOU_TRUE;
946950

947951
// RemoveDIs debug-info transition: tests may request that we /try/ to use the
948952
// new debug-info format.

llvm/tools/llvm-lto2/llvm-lto2.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static cl::opt<bool> TryUseNewDbgInfoFormat(
193193
cl::init(false), cl::Hidden);
194194

195195
extern cl::opt<bool> UseNewDbgInfoFormat;
196+
extern cl::opt<cl::boolOrDefault> LoadBitcodeIntoNewDbgInfoFormat;
196197

197198
static void check(Error E, std::string Msg) {
198199
if (!E)
@@ -228,6 +229,9 @@ static int usage() {
228229

229230
static int run(int argc, char **argv) {
230231
cl::ParseCommandLineOptions(argc, argv, "Resolution-based LTO test harness");
232+
// Load bitcode into the new debug info format by default.
233+
if (LoadBitcodeIntoNewDbgInfoFormat == cl::boolOrDefault::BOU_UNSET)
234+
LoadBitcodeIntoNewDbgInfoFormat = cl::boolOrDefault::BOU_TRUE;
231235

232236
// RemoveDIs debug-info transition: tests may request that we /try/ to use the
233237
// new debug-info format.

0 commit comments

Comments
 (0)