Skip to content

Commit e8b28ac

Browse files
committed
Merge amd-debug into amd-staging
Includes currently unmerged changes in https://github.com/AMD-Lightning-Internal/llvm-project/pull/3157 to reland: * ba650b8 Revert "[DebugInfo] Delete debug-intrinsic verifier checks (llvm#149066)" * 8c7c451 Revert "[DebugInfo] Delete a now-unused function after 5328c73" * 8d23754 Revert "[DebugInfo] Strip more debug-intrinsic code from local utils (llvm#149037)"
1 parent 2d5db9c commit e8b28ac

File tree

5 files changed

+13
-338
lines changed

5 files changed

+13
-338
lines changed

clang/include/clang/Basic/DebugOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0, Compatible) ///< Omit unreferenced
5555

5656
/// Control DWARF extensions for heterogeneous debugging enablement and approach.
5757
ENUM_DEBUGOPT(HeterogeneousDwarfMode, HeterogeneousDwarfOpts, 2,
58-
HeterogeneousDwarfOpts::Disabled, Benign)
58+
HeterogeneousDwarfOpts::Disabled, Benign)
5959

6060
/// Control the Assignment Tracking debug info feature.
6161
ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5173,7 +5173,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
51735173
// Use VarDecl's Tag, Scope and Line number.
51745174
auto FieldAlign = getDeclAlignIfRequired(Field, CGM.getContext());
51755175
auto *D = DBuilder.createAutoVariable(
5176-
Scope, FieldName, Unit, Line, FieldTy, CGM.getCodeGenOpts().OptimizationLevel != 0,
5176+
Scope, FieldName, Unit, Line, FieldTy,
5177+
CGM.getCodeGenOpts().OptimizationLevel != 0,
51775178
Flags | llvm::DINode::FlagArtificial, MS, FieldAlign);
51785179

51795180
// Insert an llvm.dbg.declare into the current block.
@@ -5199,9 +5200,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
51995200
llvm::DILocalVariable *D = nullptr;
52005201
if (ArgNo) {
52015202
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(VD);
5202-
D = DBuilder.createParameterVariable(Scope, Name, *ArgNo, Unit, Line, Ty,
5203-
CGM.getCodeGenOpts().OptimizationLevel != 0, Flags, MS,
5204-
Annotations);
5203+
D = DBuilder.createParameterVariable(
5204+
Scope, Name, *ArgNo, Unit, Line, Ty,
5205+
CGM.getCodeGenOpts().OptimizationLevel != 0, Flags, MS, Annotations);
52055206
} else {
52065207
// For normal local variable, we will try to find out whether 'VD' is the
52075208
// copy parameter of coroutine.
@@ -5242,9 +5243,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
52425243
D = RemapCoroArgToLocalVar();
52435244
// Or we will create a new DIVariable for this Decl if D dose not exists.
52445245
if (!D)
5245-
D = DBuilder.createAutoVariable(Scope, Name, Unit, Line, Ty,
5246-
CGM.getCodeGenOpts().OptimizationLevel != 0, Flags, MS,
5247-
Align);
5246+
D = DBuilder.createAutoVariable(
5247+
Scope, Name, Unit, Line, Ty,
5248+
CGM.getCodeGenOpts().OptimizationLevel != 0, Flags, MS, Align);
52485249
}
52495250
// Insert an llvm.dbg.declare into the current block.
52505251
DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),

llvm/include/llvm-c/DebugInfo.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,9 @@ LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(
964964
* \param AddressSpace DWARF address space. (optional, pass 0 to ignore)
965965
* \param MemorySpace DWARF memory space (optional, pass 0 for none).
966966
*/
967-
LLVM_C_ABI LLVMMetadataRef
968-
LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag,
969-
LLVMMetadataRef Type, unsigned AddressSpace,
970-
LLVMDWARFMemorySpace MemorySpace);
967+
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateReferenceType(
968+
LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type,
969+
unsigned AddressSpace, LLVMDWARFMemorySpace MemorySpace);
971970

972971
/**
973972
* Create C++11 nullptr type.

llvm/lib/IR/Verifier.cpp

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -7136,134 +7136,6 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
71367136
}
71377137
}
71387138

7139-
<<<<<<< HEAD
7140-
void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) {
7141-
auto *MD = DII.getRawLocation();
7142-
CheckDI(isa<ValueAsMetadata>(MD) || isa<DIArgList>(MD) ||
7143-
(isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
7144-
"invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD);
7145-
CheckDI(isa<DILocalVariable>(DII.getRawVariable()),
7146-
"invalid llvm.dbg." + Kind + " intrinsic variable", &DII,
7147-
DII.getRawVariable());
7148-
CheckDI(isa<DIExpression>(DII.getRawExpression()),
7149-
"invalid llvm.dbg." + Kind + " intrinsic expression", &DII,
7150-
DII.getRawExpression());
7151-
7152-
// This is redundant with the preprocessor-generated check, but here we
7153-
// can include arguments for DIOp-based expression checking.
7154-
SmallVector<const Value *> Arguments{DII.location_ops()};
7155-
DIExpressionEnv Env{DII.getVariable(), Arguments, DL};
7156-
CheckDI(DII.getExpression()->isValid(Env, dbgs()),
7157-
"invalid DIExpression in llvm.dbg." + Kind + " intrinsic", &DII,
7158-
DII.getRawExpression());
7159-
7160-
if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&DII)) {
7161-
CheckDI(isa<DIAssignID>(DAI->getRawAssignID()),
7162-
"invalid llvm.dbg.assign intrinsic DIAssignID", &DII,
7163-
DAI->getRawAssignID());
7164-
const auto *RawAddr = DAI->getRawAddress();
7165-
CheckDI(
7166-
isa<ValueAsMetadata>(RawAddr) ||
7167-
(isa<MDNode>(RawAddr) && !cast<MDNode>(RawAddr)->getNumOperands()),
7168-
"invalid llvm.dbg.assign intrinsic address", &DII,
7169-
DAI->getRawAddress());
7170-
CheckDI(isa<DIExpression>(DAI->getRawAddressExpression()),
7171-
"invalid llvm.dbg.assign intrinsic address expression", &DII,
7172-
DAI->getRawAddressExpression());
7173-
// All of the linked instructions should be in the same function as DII.
7174-
for (Instruction *I : at::getAssignmentInsts(DAI))
7175-
CheckDI(DAI->getFunction() == I->getFunction(),
7176-
"inst not in same function as dbg.assign", I, DAI);
7177-
}
7178-
7179-
// Ignore broken !dbg attachments; they're checked elsewhere.
7180-
if (MDNode *N = DII.getDebugLoc().getAsMDNode())
7181-
if (!isa<DILocation>(N))
7182-
return;
7183-
7184-
BasicBlock *BB = DII.getParent();
7185-
Function *F = BB ? BB->getParent() : nullptr;
7186-
7187-
// The scopes for variables and !dbg attachments must agree.
7188-
DILocalVariable *Var = DII.getVariable();
7189-
DILocation *Loc = DII.getDebugLoc();
7190-
CheckDI(Loc, "llvm.dbg." + Kind + " intrinsic requires a !dbg attachment",
7191-
&DII, BB, F);
7192-
7193-
DISubprogram *VarSP = getSubprogram(Var->getRawScope());
7194-
DISubprogram *LocSP = getSubprogram(Loc->getRawScope());
7195-
if (!VarSP || !LocSP)
7196-
return; // Broken scope chains are checked elsewhere.
7197-
7198-
CheckDI(VarSP == LocSP,
7199-
"mismatched subprogram between llvm.dbg." + Kind +
7200-
" variable and !dbg attachment",
7201-
&DII, BB, F, Var, Var->getScope()->getSubprogram(), Loc,
7202-
Loc->getScope()->getSubprogram());
7203-
7204-
// This check is redundant with one in visitLocalVariable().
7205-
CheckDI(isType(Var->getRawType()), "invalid type ref", Var,
7206-
Var->getRawType());
7207-
verifyFnArgs(DII);
7208-
}
7209-
7210-
void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) {
7211-
CheckDI(isa<DILabel>(DLI.getRawLabel()),
7212-
"invalid llvm.dbg." + Kind + " intrinsic variable", &DLI,
7213-
DLI.getRawLabel());
7214-
7215-
// Ignore broken !dbg attachments; they're checked elsewhere.
7216-
if (MDNode *N = DLI.getDebugLoc().getAsMDNode())
7217-
if (!isa<DILocation>(N))
7218-
return;
7219-
7220-
BasicBlock *BB = DLI.getParent();
7221-
Function *F = BB ? BB->getParent() : nullptr;
7222-
7223-
// The scopes for variables and !dbg attachments must agree.
7224-
DILabel *Label = DLI.getLabel();
7225-
DILocation *Loc = DLI.getDebugLoc();
7226-
Check(Loc, "llvm.dbg." + Kind + " intrinsic requires a !dbg attachment", &DLI,
7227-
BB, F);
7228-
7229-
DISubprogram *LabelSP = getSubprogram(Label->getRawScope());
7230-
DISubprogram *LocSP = getSubprogram(Loc->getRawScope());
7231-
if (!LabelSP || !LocSP)
7232-
return;
7233-
7234-
CheckDI(LabelSP == LocSP,
7235-
"mismatched subprogram between llvm.dbg." + Kind +
7236-
" label and !dbg attachment",
7237-
&DLI, BB, F, Label, Label->getScope()->getSubprogram(), Loc,
7238-
Loc->getScope()->getSubprogram());
7239-
}
7240-
7241-
void Verifier::verifyFragmentExpression(const DbgVariableIntrinsic &I) {
7242-
DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(I.getRawVariable());
7243-
DIExpression *E = dyn_cast_or_null<DIExpression>(I.getRawExpression());
7244-
7245-
// We don't know whether this intrinsic verified correctly.
7246-
if (!V || !E || !E->isValid())
7247-
return;
7248-
7249-
// Nothing to do if this isn't a DW_OP_LLVM_fragment expression.
7250-
auto Fragment = E->getFragmentInfo();
7251-
if (!Fragment)
7252-
return;
7253-
7254-
// The frontend helps out GDB by emitting the members of local anonymous
7255-
// unions as artificial local variables with shared storage. When SROA splits
7256-
// the storage for artificial local variables that are smaller than the entire
7257-
// union, the overhang piece will be outside of the allotted space for the
7258-
// variable and this check fails.
7259-
// FIXME: Remove this check as soon as clang stops doing this; it hides bugs.
7260-
if (V->isArtificial())
7261-
return;
7262-
7263-
verifyFragmentExpression(*V, *Fragment, &I);
7264-
}
7265-
=======
7266-
>>>>>>> 7caa0c9a55b3
72677139
void Verifier::verifyFragmentExpression(const DbgVariableRecord &DVR) {
72687140
DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(DVR.getRawVariable());
72697141
DIExpression *E = dyn_cast_or_null<DIExpression>(DVR.getRawExpression());

0 commit comments

Comments
 (0)