Skip to content

Commit 2dc2290

Browse files
committed
Revert new debug info format commits:
"[Flang] Update test to not check for tail calls on debug intrinsics" & "Reapply#3 "[RemoveDIs] Load into new debug info format by default in LLVM (#89799)" Recent updates to flang have added debug info generation via MLIR, a path which currently does not support debug records. The patch that enables debug records by default (and a small followup patch) are thus being reverted until the MLIR path has been fixed. This reverts commits: 21396be c5aeca7
1 parent fc6e97c commit 2dc2290

File tree

21 files changed

+260
-245
lines changed

21 files changed

+260
-245
lines changed

clang/test/CodeGen/instrument-objc-method.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ @implementation ObjCClass
1111
+ (void)initialize {
1212
}
1313

14-
// BARE: @"\01+[ObjCClass load]"{{\(.*\)}} #1
14+
// PREINLINE: declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
15+
// BARE: @"\01+[ObjCClass load]"{{\(.*\)}} #2
1516
+ (void)load __attribute__((no_instrument_function)) {
1617
}
1718

18-
// PREINLINE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #1
19-
// BARE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #1
19+
// PREINLINE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #2
20+
// BARE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #2
2021
- (void)dealloc __attribute__((no_instrument_function)) {
2122
}
2223

23-
// PREINLINE: declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
2424
// PREINLINE: attributes #0 = { {{.*}}"instrument-function-entry"="__cyg_profile_func_enter"
2525
// PREINLINE-NOT: attributes #0 = { {{.*}}"instrument-function-entry"="__cyg_profile_func_enter_bare"
2626
// PREINLINE-NOT: attributes #2 = { {{.*}}"__cyg_profile_func_enter"

flang/test/Transforms/debug-local-var-2.f90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020

2121
! CHECK-LABEL: define {{.*}}i64 @_QFPfn1
2222
! CHECK-SAME: (ptr %[[ARG1:.*]], ptr %[[ARG2:.*]], ptr %[[ARG3:.*]])
23-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG1]], metadata ![[A1:.*]], metadata !DIExpression())
24-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG2]], metadata ![[B1:.*]], metadata !DIExpression())
25-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG3]], metadata ![[C1:.*]], metadata !DIExpression())
23+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[ARG1]], metadata ![[A1:.*]], metadata !DIExpression())
24+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[ARG2]], metadata ![[B1:.*]], metadata !DIExpression())
25+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[ARG3]], metadata ![[C1:.*]], metadata !DIExpression())
2626
! CHECK-DAG: %[[AL2:.*]] = alloca i64
27-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL2]], metadata ![[RES1:.*]], metadata !DIExpression())
27+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[AL2]], metadata ![[RES1:.*]], metadata !DIExpression())
2828
! CHECK-LABEL: }
2929

3030
! CHECK-LABEL: define {{.*}}i32 @_QFPfn2
3131
! CHECK-SAME: (ptr %[[FN2ARG1:.*]], ptr %[[FN2ARG2:.*]], ptr %[[FN2ARG3:.*]])
32-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG1]], metadata ![[A2:.*]], metadata !DIExpression())
33-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG2]], metadata ![[B2:.*]], metadata !DIExpression())
34-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG3]], metadata ![[C2:.*]], metadata !DIExpression())
32+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[FN2ARG1]], metadata ![[A2:.*]], metadata !DIExpression())
33+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[FN2ARG2]], metadata ![[B2:.*]], metadata !DIExpression())
34+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[FN2ARG3]], metadata ![[C2:.*]], metadata !DIExpression())
3535
! CHECK-DAG: %[[AL3:.*]] = alloca i32
36-
! CHECK-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL3]], metadata ![[RES2:.*]], metadata !DIExpression())
36+
! CHECK-DAG: tail call void @llvm.dbg.declare(metadata ptr %[[AL3]], metadata ![[RES2:.*]], metadata !DIExpression())
3737
! CHECK-LABEL: }
3838

3939
program mn

llvm/docs/ReleaseNotes.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,6 @@ Changes to the Metadata Info
226226
Changes to the Debug Info
227227
---------------------------------
228228

229-
* LLVM has switched from using debug intrinsics internally to using debug
230-
records by default. This should happen transparently when using the DIBuilder
231-
to construct debug variable information, but will require changes for any code
232-
that interacts with debug intrinsics directly. Debug intrinsics will only be
233-
supported on a best-effort basis from here onwards; for more information, see
234-
the `migration docs <https://llvm.org/docs/RemoveDIsDebugInfo.html>`_.
235-
236229
Changes to the LLVM tools
237230
---------------------------------
238231
* llvm-nm and llvm-objdump can now print symbol information from linked

llvm/include/llvm/AsmParser/LLParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ namespace llvm {
337337

338338
// Top-Level Entities
339339
bool parseTopLevelEntities();
340+
bool finalizeDebugInfoFormat(Module *M);
340341
void dropUnknownMetadataReferences();
341342
bool validateEndOfModule(bool UpgradeDebugInfo);
342343
bool validateEndOfIndex();

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@ static std::string getTypeString(Type *T) {
7474
return Tmp.str();
7575
}
7676

77+
// Whatever debug info format we parsed, we should convert to the expected debug
78+
// info format immediately afterwards.
79+
bool LLParser::finalizeDebugInfoFormat(Module *M) {
80+
// We should have already returned an error if we observed both intrinsics and
81+
// records in this IR.
82+
assert(!(SeenNewDbgInfoFormat && SeenOldDbgInfoFormat) &&
83+
"Mixed debug intrinsics/records seen without a parsing error?");
84+
if (PreserveInputDbgFormat == cl::boolOrDefault::BOU_TRUE) {
85+
UseNewDbgInfoFormat = SeenNewDbgInfoFormat;
86+
WriteNewDbgInfoFormatToBitcode = SeenNewDbgInfoFormat;
87+
WriteNewDbgInfoFormat = SeenNewDbgInfoFormat;
88+
} else if (M) {
89+
M->setIsNewDbgInfoFormat(false);
90+
}
91+
return false;
92+
}
93+
7794
/// Run: module ::= toplevelentity*
7895
bool LLParser::Run(bool UpgradeDebugInfo,
7996
DataLayoutCallbackTy DataLayoutCallback) {
@@ -91,7 +108,7 @@ bool LLParser::Run(bool UpgradeDebugInfo,
91108
}
92109

93110
return parseTopLevelEntities() || validateEndOfModule(UpgradeDebugInfo) ||
94-
validateEndOfIndex();
111+
validateEndOfIndex() || finalizeDebugInfoFormat(M);
95112
}
96113

97114
bool LLParser::parseStandaloneConstantValue(Constant *&C,
@@ -190,18 +207,6 @@ void LLParser::dropUnknownMetadataReferences() {
190207
bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
191208
if (!M)
192209
return false;
193-
194-
// We should have already returned an error if we observed both intrinsics and
195-
// records in this IR.
196-
assert(!(SeenNewDbgInfoFormat && SeenOldDbgInfoFormat) &&
197-
"Mixed debug intrinsics/records seen without a parsing error?");
198-
if (PreserveInputDbgFormat == cl::boolOrDefault::BOU_TRUE) {
199-
UseNewDbgInfoFormat = SeenNewDbgInfoFormat;
200-
WriteNewDbgInfoFormatToBitcode = SeenNewDbgInfoFormat;
201-
WriteNewDbgInfoFormat = SeenNewDbgInfoFormat;
202-
M->setNewDbgInfoFormatFlag(SeenNewDbgInfoFormat);
203-
}
204-
205210
// Handle any function attribute group forward references.
206211
for (const auto &RAG : ForwardRefAttrGroups) {
207212
Value *V = RAG.first;
@@ -434,9 +439,6 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
434439
UpgradeModuleFlags(*M);
435440
UpgradeSectionAttributes(*M);
436441

437-
if (PreserveInputDbgFormat != cl::boolOrDefault::BOU_TRUE)
438-
M->setIsNewDbgInfoFormat(UseNewDbgInfoFormat);
439-
440442
if (!Slots)
441443
return false;
442444
// Initialize the slot mapping.

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4357,7 +4357,7 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
43574357
if (PreserveInputDbgFormat != cl::boolOrDefault::BOU_TRUE) {
43584358
TheModule->IsNewDbgInfoFormat =
43594359
UseNewDbgInfoFormat &&
4360-
LoadBitcodeIntoNewDbgInfoFormat != cl::boolOrDefault::BOU_FALSE;
4360+
LoadBitcodeIntoNewDbgInfoFormat == cl::boolOrDefault::BOU_TRUE;
43614361
}
43624362

43634363
this->ValueTypeCallback = std::move(Callbacks.ValueType);

llvm/lib/IR/BasicBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ template class llvm::SymbolTableListTraits<Instruction,
181181
BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
182182
BasicBlock *InsertBefore)
183183
: Value(Type::getLabelTy(C), Value::BasicBlockVal),
184-
IsNewDbgInfoFormat(UseNewDbgInfoFormat), Parent(nullptr) {
184+
IsNewDbgInfoFormat(false), Parent(nullptr) {
185185

186186
if (NewParent)
187187
insertInto(NewParent, InsertBefore);

llvm/lib/IR/DebugProgramInstruction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ void DbgVariableRecord::setKillLocation() {
366366
}
367367

368368
bool DbgVariableRecord::isKillLocation() const {
369-
return (!hasArgList() && isa<MDNode>(getRawLocation())) ||
370-
(getNumVariableLocationOps() == 0 && !getExpression()->isComplex()) ||
369+
return (getNumVariableLocationOps() == 0 &&
370+
!getExpression()->isComplex()) ||
371371
any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
372372
}
373373

llvm/lib/IR/Function.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ static cl::opt<int> NonGlobalValueMaxNameSize(
8383
"non-global-value-max-name-size", cl::Hidden, cl::init(1024),
8484
cl::desc("Maximum size for the name of non-global values."));
8585

86-
extern cl::opt<bool> UseNewDbgInfoFormat;
87-
8886
void Function::convertToNewDbgValues() {
8987
IsNewDbgInfoFormat = true;
9088
for (auto &BB : *this) {
@@ -443,7 +441,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
443441
: GlobalObject(Ty, Value::FunctionVal,
444442
OperandTraits<Function>::op_begin(this), 0, Linkage, name,
445443
computeAddrSpace(AddrSpace, ParentModule)),
446-
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
444+
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(false) {
447445
assert(FunctionType::isValidReturnType(getReturnType()) &&
448446
"invalid return type");
449447
setGlobalObjectSubClassData(0);

llvm/lib/IR/Module.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454

5555
using namespace llvm;
5656

57-
extern cl::opt<bool> UseNewDbgInfoFormat;
58-
5957
//===----------------------------------------------------------------------===//
6058
// Methods to implement the globals and functions lists.
6159
//
@@ -74,7 +72,7 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>;
7472
Module::Module(StringRef MID, LLVMContext &C)
7573
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
7674
ModuleID(std::string(MID)), SourceFileName(std::string(MID)), DL(""),
77-
IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
75+
IsNewDbgInfoFormat(false) {
7876
Context.addModule(this);
7977
}
8078

0 commit comments

Comments
 (0)