mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[DebugInfo] Refactor DbgInfoIntrinsic class hierarchy.
In the past, DbgInfoIntrinsic has a strong assumption that these intrinsics all have variables and expressions attached to them. However, it is too strong to derive the class for other debug entities. Now, it has problems for debug labels. In order to make DbgInfoIntrinsic as a base class for 'debug info', I create a class for 'variable debug info', DbgVariableIntrinsic. DbgDeclareInst, DbgAddrIntrinsic, and DbgValueInst will be derived from it. Differential Revision: https://reviews.llvm.org/D50220 llvm-svn: 338984
This commit is contained in:
parent
54514a9035
commit
fd20113dad
@ -1417,7 +1417,9 @@ LLVMTypeRef LLVMX86MMXType(void);
|
|||||||
macro(CallInst) \
|
macro(CallInst) \
|
||||||
macro(IntrinsicInst) \
|
macro(IntrinsicInst) \
|
||||||
macro(DbgInfoIntrinsic) \
|
macro(DbgInfoIntrinsic) \
|
||||||
macro(DbgDeclareInst) \
|
macro(DbgVariableIntrinsic) \
|
||||||
|
macro(DbgDeclareInst) \
|
||||||
|
macro(DbgLabelInst) \
|
||||||
macro(MemIntrinsic) \
|
macro(MemIntrinsic) \
|
||||||
macro(MemCpyInst) \
|
macro(MemCpyInst) \
|
||||||
macro(MemMoveInst) \
|
macro(MemMoveInst) \
|
||||||
|
@ -211,10 +211,12 @@ public:
|
|||||||
RetTy visitCatchPadInst(CatchPadInst &I) { DELEGATE(FuncletPadInst); }
|
RetTy visitCatchPadInst(CatchPadInst &I) { DELEGATE(FuncletPadInst); }
|
||||||
|
|
||||||
// Handle the special instrinsic instruction classes.
|
// Handle the special instrinsic instruction classes.
|
||||||
RetTy visitDbgDeclareInst(DbgDeclareInst &I) { DELEGATE(DbgInfoIntrinsic);}
|
RetTy visitDbgDeclareInst(DbgDeclareInst &I) { DELEGATE(DbgVariableIntrinsic);}
|
||||||
RetTy visitDbgValueInst(DbgValueInst &I) { DELEGATE(DbgInfoIntrinsic);}
|
RetTy visitDbgValueInst(DbgValueInst &I) { DELEGATE(DbgVariableIntrinsic);}
|
||||||
|
RetTy visitDbgVariableIntrinsic(DbgVariableIntrinsic &I)
|
||||||
|
{ DELEGATE(DbgInfoIntrinsic);}
|
||||||
RetTy visitDbgLabelInst(DbgLabelInst &I) { DELEGATE(DbgInfoIntrinsic);}
|
RetTy visitDbgLabelInst(DbgLabelInst &I) { DELEGATE(DbgInfoIntrinsic);}
|
||||||
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I) { DELEGATE(IntrinsicInst); }
|
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I){ DELEGATE(IntrinsicInst); }
|
||||||
RetTy visitMemSetInst(MemSetInst &I) { DELEGATE(MemIntrinsic); }
|
RetTy visitMemSetInst(MemSetInst &I) { DELEGATE(MemIntrinsic); }
|
||||||
RetTy visitMemCpyInst(MemCpyInst &I) { DELEGATE(MemTransferInst); }
|
RetTy visitMemCpyInst(MemCpyInst &I) { DELEGATE(MemTransferInst); }
|
||||||
RetTy visitMemMoveInst(MemMoveInst &I) { DELEGATE(MemTransferInst); }
|
RetTy visitMemMoveInst(MemMoveInst &I) { DELEGATE(MemTransferInst); }
|
||||||
|
@ -65,6 +65,27 @@ namespace llvm {
|
|||||||
|
|
||||||
/// This is the common base class for debug info intrinsics.
|
/// This is the common base class for debug info intrinsics.
|
||||||
class DbgInfoIntrinsic : public IntrinsicInst {
|
class DbgInfoIntrinsic : public IntrinsicInst {
|
||||||
|
public:
|
||||||
|
/// \name Casting methods
|
||||||
|
/// @{
|
||||||
|
static bool classof(const IntrinsicInst *I) {
|
||||||
|
switch (I->getIntrinsicID()) {
|
||||||
|
case Intrinsic::dbg_declare:
|
||||||
|
case Intrinsic::dbg_value:
|
||||||
|
case Intrinsic::dbg_addr:
|
||||||
|
case Intrinsic::dbg_label:
|
||||||
|
return true;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static bool classof(const Value *V) {
|
||||||
|
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
|
||||||
|
}
|
||||||
|
/// @}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// This is the common base class for debug info intrinsics for variables.
|
||||||
|
class DbgVariableIntrinsic : public DbgInfoIntrinsic {
|
||||||
public:
|
public:
|
||||||
/// Get the location corresponding to the variable referenced by the debug
|
/// Get the location corresponding to the variable referenced by the debug
|
||||||
/// info intrinsic. Depending on the intrinsic, this could be the
|
/// info intrinsic. Depending on the intrinsic, this could be the
|
||||||
@ -104,7 +125,6 @@ namespace llvm {
|
|||||||
case Intrinsic::dbg_declare:
|
case Intrinsic::dbg_declare:
|
||||||
case Intrinsic::dbg_value:
|
case Intrinsic::dbg_value:
|
||||||
case Intrinsic::dbg_addr:
|
case Intrinsic::dbg_addr:
|
||||||
case Intrinsic::dbg_label:
|
|
||||||
return true;
|
return true;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
@ -116,7 +136,7 @@ namespace llvm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// This represents the llvm.dbg.declare instruction.
|
/// This represents the llvm.dbg.declare instruction.
|
||||||
class DbgDeclareInst : public DbgInfoIntrinsic {
|
class DbgDeclareInst : public DbgVariableIntrinsic {
|
||||||
public:
|
public:
|
||||||
Value *getAddress() const { return getVariableLocation(); }
|
Value *getAddress() const { return getVariableLocation(); }
|
||||||
|
|
||||||
@ -132,7 +152,7 @@ namespace llvm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// This represents the llvm.dbg.addr instruction.
|
/// This represents the llvm.dbg.addr instruction.
|
||||||
class DbgAddrIntrinsic : public DbgInfoIntrinsic {
|
class DbgAddrIntrinsic : public DbgVariableIntrinsic {
|
||||||
public:
|
public:
|
||||||
Value *getAddress() const { return getVariableLocation(); }
|
Value *getAddress() const { return getVariableLocation(); }
|
||||||
|
|
||||||
@ -147,7 +167,7 @@ namespace llvm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// This represents the llvm.dbg.value instruction.
|
/// This represents the llvm.dbg.value instruction.
|
||||||
class DbgValueInst : public DbgInfoIntrinsic {
|
class DbgValueInst : public DbgVariableIntrinsic {
|
||||||
public:
|
public:
|
||||||
Value *getValue() const {
|
Value *getValue() const {
|
||||||
return getVariableLocation(/* AllowNullOp = */ false);
|
return getVariableLocation(/* AllowNullOp = */ false);
|
||||||
@ -168,17 +188,13 @@ namespace llvm {
|
|||||||
class DbgLabelInst : public DbgInfoIntrinsic {
|
class DbgLabelInst : public DbgInfoIntrinsic {
|
||||||
public:
|
public:
|
||||||
DILabel *getLabel() const {
|
DILabel *getLabel() const {
|
||||||
return cast<DILabel>(getRawVariable());
|
return cast<DILabel>(getRawLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata *getRawVariable() const {
|
Metadata *getRawLabel() const {
|
||||||
return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
|
return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata *getRawExpression() const {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
/// @{
|
/// @{
|
||||||
static bool classof(const IntrinsicInst *I) {
|
static bool classof(const IntrinsicInst *I) {
|
||||||
|
@ -44,7 +44,7 @@ class AssumptionCache;
|
|||||||
class BasicBlock;
|
class BasicBlock;
|
||||||
class BranchInst;
|
class BranchInst;
|
||||||
class CallInst;
|
class CallInst;
|
||||||
class DbgInfoIntrinsic;
|
class DbgVariableIntrinsic;
|
||||||
class DbgValueInst;
|
class DbgValueInst;
|
||||||
class DIBuilder;
|
class DIBuilder;
|
||||||
class Function;
|
class Function;
|
||||||
@ -270,17 +270,17 @@ inline unsigned getKnownAlignment(Value *V, const DataLayout &DL,
|
|||||||
|
|
||||||
/// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
|
/// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
|
||||||
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
||||||
void ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
|
||||||
StoreInst *SI, DIBuilder &Builder);
|
StoreInst *SI, DIBuilder &Builder);
|
||||||
|
|
||||||
/// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
|
/// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
|
||||||
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
||||||
void ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
|
||||||
LoadInst *LI, DIBuilder &Builder);
|
LoadInst *LI, DIBuilder &Builder);
|
||||||
|
|
||||||
/// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
|
/// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
|
||||||
/// llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
/// llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
||||||
void ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
|
||||||
PHINode *LI, DIBuilder &Builder);
|
PHINode *LI, DIBuilder &Builder);
|
||||||
|
|
||||||
/// Lowers llvm.dbg.declare intrinsics into appropriate set of
|
/// Lowers llvm.dbg.declare intrinsics into appropriate set of
|
||||||
@ -294,13 +294,13 @@ void insertDebugValuesForPHIs(BasicBlock *BB,
|
|||||||
/// Finds all intrinsics declaring local variables as living in the memory that
|
/// Finds all intrinsics declaring local variables as living in the memory that
|
||||||
/// 'V' points to. This may include a mix of dbg.declare and
|
/// 'V' points to. This may include a mix of dbg.declare and
|
||||||
/// dbg.addr intrinsics.
|
/// dbg.addr intrinsics.
|
||||||
TinyPtrVector<DbgInfoIntrinsic *> FindDbgAddrUses(Value *V);
|
TinyPtrVector<DbgVariableIntrinsic *> FindDbgAddrUses(Value *V);
|
||||||
|
|
||||||
/// Finds the llvm.dbg.value intrinsics describing a value.
|
/// Finds the llvm.dbg.value intrinsics describing a value.
|
||||||
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V);
|
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V);
|
||||||
|
|
||||||
/// Finds the debug info intrinsics describing a value.
|
/// Finds the debug info intrinsics describing a value.
|
||||||
void findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgInsts, Value *V);
|
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V);
|
||||||
|
|
||||||
/// Replaces llvm.dbg.declare instruction when the address it
|
/// Replaces llvm.dbg.declare instruction when the address it
|
||||||
/// describes is replaced with a new value. If Deref is true, an
|
/// describes is replaced with a new value. If Deref is true, an
|
||||||
|
@ -5176,7 +5176,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
|
|||||||
}
|
}
|
||||||
case Intrinsic::dbg_addr:
|
case Intrinsic::dbg_addr:
|
||||||
case Intrinsic::dbg_declare: {
|
case Intrinsic::dbg_declare: {
|
||||||
const DbgInfoIntrinsic &DI = cast<DbgInfoIntrinsic>(I);
|
const auto &DI = cast<DbgVariableIntrinsic>(I);
|
||||||
DILocalVariable *Variable = DI.getVariable();
|
DILocalVariable *Variable = DI.getVariable();
|
||||||
DIExpression *Expression = DI.getExpression();
|
DIExpression *Expression = DI.getExpression();
|
||||||
dropDanglingDebugInfo(Variable, Expression);
|
dropDanglingDebugInfo(Variable, Expression);
|
||||||
|
@ -32,10 +32,11 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// DbgInfoIntrinsic - This is the common base class for debug info intrinsics
|
/// DbgVariableIntrinsic - This is the common base class for debug info
|
||||||
|
/// intrinsics for variables.
|
||||||
///
|
///
|
||||||
|
|
||||||
Value *DbgInfoIntrinsic::getVariableLocation(bool AllowNullOp) const {
|
Value *DbgVariableIntrinsic::getVariableLocation(bool AllowNullOp) const {
|
||||||
Value *Op = getArgOperand(0);
|
Value *Op = getArgOperand(0);
|
||||||
if (AllowNullOp && !Op)
|
if (AllowNullOp && !Op)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -45,14 +46,11 @@ Value *DbgInfoIntrinsic::getVariableLocation(bool AllowNullOp) const {
|
|||||||
return V->getValue();
|
return V->getValue();
|
||||||
|
|
||||||
// When the value goes to null, it gets replaced by an empty MDNode.
|
// When the value goes to null, it gets replaced by an empty MDNode.
|
||||||
assert((isa<DbgLabelInst>(this)
|
assert(!cast<MDNode>(MD)->getNumOperands() && "Expected an empty MDNode");
|
||||||
|| !cast<MDNode>(MD)->getNumOperands())
|
|
||||||
&& "DbgValueInst Expected an empty MDNode");
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<uint64_t> DbgInfoIntrinsic::getFragmentSizeInBits() const {
|
Optional<uint64_t> DbgVariableIntrinsic::getFragmentSizeInBits() const {
|
||||||
if (auto Fragment = getExpression()->getFragmentInfo())
|
if (auto Fragment = getExpression()->getFragmentInfo())
|
||||||
return Fragment->SizeInBits;
|
return Fragment->SizeInBits;
|
||||||
return getVariable()->getSizeInBits();
|
return getVariable()->getSizeInBits();
|
||||||
|
@ -467,7 +467,7 @@ private:
|
|||||||
void visitUserOp2(Instruction &I) { visitUserOp1(I); }
|
void visitUserOp2(Instruction &I) { visitUserOp1(I); }
|
||||||
void visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS);
|
void visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS);
|
||||||
void visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI);
|
void visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI);
|
||||||
void visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII);
|
void visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII);
|
||||||
void visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI);
|
void visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI);
|
||||||
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI);
|
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI);
|
||||||
void visitAtomicRMWInst(AtomicRMWInst &RMWI);
|
void visitAtomicRMWInst(AtomicRMWInst &RMWI);
|
||||||
@ -505,12 +505,12 @@ private:
|
|||||||
void verifyFrameRecoverIndices();
|
void verifyFrameRecoverIndices();
|
||||||
void verifySiblingFuncletUnwinds();
|
void verifySiblingFuncletUnwinds();
|
||||||
|
|
||||||
void verifyFragmentExpression(const DbgInfoIntrinsic &I);
|
void verifyFragmentExpression(const DbgVariableIntrinsic &I);
|
||||||
template <typename ValueOrMetadata>
|
template <typename ValueOrMetadata>
|
||||||
void verifyFragmentExpression(const DIVariable &V,
|
void verifyFragmentExpression(const DIVariable &V,
|
||||||
DIExpression::FragmentInfo Fragment,
|
DIExpression::FragmentInfo Fragment,
|
||||||
ValueOrMetadata *Desc);
|
ValueOrMetadata *Desc);
|
||||||
void verifyFnArgs(const DbgInfoIntrinsic &I);
|
void verifyFnArgs(const DbgVariableIntrinsic &I);
|
||||||
|
|
||||||
/// Module-level debug info verification...
|
/// Module-level debug info verification...
|
||||||
void verifyCompileUnits();
|
void verifyCompileUnits();
|
||||||
@ -3984,7 +3984,7 @@ void Verifier::visitInstruction(Instruction &I) {
|
|||||||
visitMDNode(*N);
|
visitMDNode(*N);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto *DII = dyn_cast<DbgInfoIntrinsic>(&I))
|
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I))
|
||||||
verifyFragmentExpression(*DII);
|
verifyFragmentExpression(*DII);
|
||||||
|
|
||||||
InstsInThisBlock.insert(&I);
|
InstsInThisBlock.insert(&I);
|
||||||
@ -4090,13 +4090,13 @@ void Verifier::visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS) {
|
|||||||
case Intrinsic::dbg_declare: // llvm.dbg.declare
|
case Intrinsic::dbg_declare: // llvm.dbg.declare
|
||||||
Assert(isa<MetadataAsValue>(CS.getArgOperand(0)),
|
Assert(isa<MetadataAsValue>(CS.getArgOperand(0)),
|
||||||
"invalid llvm.dbg.declare intrinsic call 1", CS);
|
"invalid llvm.dbg.declare intrinsic call 1", CS);
|
||||||
visitDbgIntrinsic("declare", cast<DbgInfoIntrinsic>(*CS.getInstruction()));
|
visitDbgIntrinsic("declare", cast<DbgVariableIntrinsic>(*CS.getInstruction()));
|
||||||
break;
|
break;
|
||||||
case Intrinsic::dbg_addr: // llvm.dbg.addr
|
case Intrinsic::dbg_addr: // llvm.dbg.addr
|
||||||
visitDbgIntrinsic("addr", cast<DbgInfoIntrinsic>(*CS.getInstruction()));
|
visitDbgIntrinsic("addr", cast<DbgVariableIntrinsic>(*CS.getInstruction()));
|
||||||
break;
|
break;
|
||||||
case Intrinsic::dbg_value: // llvm.dbg.value
|
case Intrinsic::dbg_value: // llvm.dbg.value
|
||||||
visitDbgIntrinsic("value", cast<DbgInfoIntrinsic>(*CS.getInstruction()));
|
visitDbgIntrinsic("value", cast<DbgVariableIntrinsic>(*CS.getInstruction()));
|
||||||
break;
|
break;
|
||||||
case Intrinsic::dbg_label: // llvm.dbg.label
|
case Intrinsic::dbg_label: // llvm.dbg.label
|
||||||
visitDbgLabelIntrinsic("label", cast<DbgLabelInst>(*CS.getInstruction()));
|
visitDbgLabelIntrinsic("label", cast<DbgLabelInst>(*CS.getInstruction()));
|
||||||
@ -4491,7 +4491,7 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
|
|||||||
"invalid exception behavior argument", &FPI);
|
"invalid exception behavior argument", &FPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Verifier::visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII) {
|
void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) {
|
||||||
auto *MD = cast<MetadataAsValue>(DII.getArgOperand(0))->getMetadata();
|
auto *MD = cast<MetadataAsValue>(DII.getArgOperand(0))->getMetadata();
|
||||||
AssertDI(isa<ValueAsMetadata>(MD) ||
|
AssertDI(isa<ValueAsMetadata>(MD) ||
|
||||||
(isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
|
(isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
|
||||||
@ -4531,9 +4531,9 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) {
|
void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) {
|
||||||
AssertDI(isa<DILabel>(DLI.getRawVariable()),
|
AssertDI(isa<DILabel>(DLI.getRawLabel()),
|
||||||
"invalid llvm.dbg." + Kind + " intrinsic variable", &DLI,
|
"invalid llvm.dbg." + Kind + " intrinsic variable", &DLI,
|
||||||
DLI.getRawVariable());
|
DLI.getRawLabel());
|
||||||
|
|
||||||
// Ignore broken !dbg attachments; they're checked elsewhere.
|
// Ignore broken !dbg attachments; they're checked elsewhere.
|
||||||
if (MDNode *N = DLI.getDebugLoc().getAsMDNode())
|
if (MDNode *N = DLI.getDebugLoc().getAsMDNode())
|
||||||
@ -4560,10 +4560,7 @@ void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) {
|
|||||||
Loc->getScope()->getSubprogram());
|
Loc->getScope()->getSubprogram());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Verifier::verifyFragmentExpression(const DbgInfoIntrinsic &I) {
|
void Verifier::verifyFragmentExpression(const DbgVariableIntrinsic &I) {
|
||||||
if (dyn_cast<DbgLabelInst>(&I))
|
|
||||||
return;
|
|
||||||
|
|
||||||
DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(I.getRawVariable());
|
DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(I.getRawVariable());
|
||||||
DIExpression *E = dyn_cast_or_null<DIExpression>(I.getRawExpression());
|
DIExpression *E = dyn_cast_or_null<DIExpression>(I.getRawExpression());
|
||||||
|
|
||||||
@ -4605,7 +4602,7 @@ void Verifier::verifyFragmentExpression(const DIVariable &V,
|
|||||||
AssertDI(FragSize != *VarSize, "fragment covers entire variable", Desc, &V);
|
AssertDI(FragSize != *VarSize, "fragment covers entire variable", Desc, &V);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Verifier::verifyFnArgs(const DbgInfoIntrinsic &I) {
|
void Verifier::verifyFnArgs(const DbgVariableIntrinsic &I) {
|
||||||
// This function does not take the scope of noninlined function arguments into
|
// This function does not take the scope of noninlined function arguments into
|
||||||
// account. Don't run it if current function is nodebug, because it may
|
// account. Don't run it if current function is nodebug, because it may
|
||||||
// contain inlined debug intrinsics.
|
// contain inlined debug intrinsics.
|
||||||
|
@ -2144,7 +2144,7 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
|
|||||||
|
|
||||||
// If we are removing an alloca with a dbg.declare, insert dbg.value calls
|
// If we are removing an alloca with a dbg.declare, insert dbg.value calls
|
||||||
// before each store.
|
// before each store.
|
||||||
TinyPtrVector<DbgInfoIntrinsic *> DIIs;
|
TinyPtrVector<DbgVariableIntrinsic *> DIIs;
|
||||||
std::unique_ptr<DIBuilder> DIB;
|
std::unique_ptr<DIBuilder> DIB;
|
||||||
if (isa<AllocaInst>(MI)) {
|
if (isa<AllocaInst>(MI)) {
|
||||||
DIIs = FindDbgAddrUses(&MI);
|
DIIs = FindDbgAddrUses(&MI);
|
||||||
@ -2934,7 +2934,7 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
|
|||||||
|
|
||||||
// Also sink all related debug uses from the source basic block. Otherwise we
|
// Also sink all related debug uses from the source basic block. Otherwise we
|
||||||
// get debug use before the def.
|
// get debug use before the def.
|
||||||
SmallVector<DbgInfoIntrinsic *, 1> DbgUsers;
|
SmallVector<DbgVariableIntrinsic *, 1> DbgUsers;
|
||||||
findDbgUsers(DbgUsers, I);
|
findDbgUsers(DbgUsers, I);
|
||||||
for (auto *DII : DbgUsers) {
|
for (auto *DII : DbgUsers) {
|
||||||
if (DII->getParent() == SrcBlock) {
|
if (DII->getParent() == SrcBlock) {
|
||||||
|
@ -508,7 +508,7 @@ bool AggressiveDeadCodeElimination::removeDeadInstructions() {
|
|||||||
if (isLive(&I))
|
if (isLive(&I))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (auto *DII = dyn_cast<DbgInfoIntrinsic>(&I)) {
|
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) {
|
||||||
// Check if the scope of this variable location is alive.
|
// Check if the scope of this variable location is alive.
|
||||||
if (AliveScopes.count(DII->getDebugLoc()->getScope()))
|
if (AliveScopes.count(DII->getDebugLoc()->getScope()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -788,7 +788,7 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I,
|
|||||||
// Discard any debug info related to the expressions that has changed (we
|
// Discard any debug info related to the expressions that has changed (we
|
||||||
// can leave debug infor related to the root, since the result of the
|
// can leave debug infor related to the root, since the result of the
|
||||||
// expression tree should be the same even after reassociation).
|
// expression tree should be the same even after reassociation).
|
||||||
SmallVector<DbgInfoIntrinsic *, 1> DbgUsers;
|
SmallVector<DbgVariableIntrinsic *, 1> DbgUsers;
|
||||||
findDbgUsers(DbgUsers, ExpressionChanged);
|
findDbgUsers(DbgUsers, ExpressionChanged);
|
||||||
for (auto *DII : DbgUsers) {
|
for (auto *DII : DbgUsers) {
|
||||||
Value *Undef = UndefValue::get(ExpressionChanged->getType());
|
Value *Undef = UndefValue::get(ExpressionChanged->getType());
|
||||||
|
@ -4212,7 +4212,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
|
|||||||
|
|
||||||
// Migrate debug information from the old alloca to the new alloca(s)
|
// Migrate debug information from the old alloca to the new alloca(s)
|
||||||
// and the individual partitions.
|
// and the individual partitions.
|
||||||
TinyPtrVector<DbgInfoIntrinsic *> DbgDeclares = FindDbgAddrUses(&AI);
|
TinyPtrVector<DbgVariableIntrinsic *> DbgDeclares = FindDbgAddrUses(&AI);
|
||||||
if (!DbgDeclares.empty()) {
|
if (!DbgDeclares.empty()) {
|
||||||
auto *Var = DbgDeclares.front()->getVariable();
|
auto *Var = DbgDeclares.front()->getVariable();
|
||||||
auto *Expr = DbgDeclares.front()->getExpression();
|
auto *Expr = DbgDeclares.front()->getExpression();
|
||||||
@ -4264,7 +4264,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove any existing intrinsics describing the same alloca.
|
// Remove any existing intrinsics describing the same alloca.
|
||||||
for (DbgInfoIntrinsic *OldDII : FindDbgAddrUses(Fragment.Alloca))
|
for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(Fragment.Alloca))
|
||||||
OldDII->eraseFromParent();
|
OldDII->eraseFromParent();
|
||||||
|
|
||||||
DIB.insertDeclare(Fragment.Alloca, Var, FragmentExpr,
|
DIB.insertDeclare(Fragment.Alloca, Var, FragmentExpr,
|
||||||
@ -4379,7 +4379,7 @@ bool SROA::deleteDeadInstructions(
|
|||||||
// not be able to find it.
|
// not be able to find it.
|
||||||
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
|
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
|
||||||
DeletedAllocas.insert(AI);
|
DeletedAllocas.insert(AI);
|
||||||
for (DbgInfoIntrinsic *OldDII : FindDbgAddrUses(AI))
|
for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(AI))
|
||||||
OldDII->eraseFromParent();
|
OldDII->eraseFromParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,7 +1244,7 @@ static bool PhiHasDebugValue(DILocalVariable *DIVar,
|
|||||||
/// alloc size of the value when doing the comparison. E.g. an i1 value will be
|
/// alloc size of the value when doing the comparison. E.g. an i1 value will be
|
||||||
/// identified as covering an n-bit fragment, if the store size of i1 is at
|
/// identified as covering an n-bit fragment, if the store size of i1 is at
|
||||||
/// least n bits.
|
/// least n bits.
|
||||||
static bool valueCoversEntireFragment(Type *ValTy, DbgInfoIntrinsic *DII) {
|
static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
|
||||||
const DataLayout &DL = DII->getModule()->getDataLayout();
|
const DataLayout &DL = DII->getModule()->getDataLayout();
|
||||||
uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
|
uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
|
||||||
if (auto FragmentSize = DII->getFragmentSizeInBits())
|
if (auto FragmentSize = DII->getFragmentSizeInBits())
|
||||||
@ -1262,7 +1262,7 @@ static bool valueCoversEntireFragment(Type *ValTy, DbgInfoIntrinsic *DII) {
|
|||||||
|
|
||||||
/// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
|
/// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
|
||||||
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
||||||
void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
|
||||||
StoreInst *SI, DIBuilder &Builder) {
|
StoreInst *SI, DIBuilder &Builder) {
|
||||||
assert(DII->isAddressOfVariable());
|
assert(DII->isAddressOfVariable());
|
||||||
auto *DIVar = DII->getVariable();
|
auto *DIVar = DII->getVariable();
|
||||||
@ -1319,7 +1319,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
|||||||
|
|
||||||
/// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
|
/// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value
|
||||||
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
||||||
void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
|
||||||
LoadInst *LI, DIBuilder &Builder) {
|
LoadInst *LI, DIBuilder &Builder) {
|
||||||
auto *DIVar = DII->getVariable();
|
auto *DIVar = DII->getVariable();
|
||||||
auto *DIExpr = DII->getExpression();
|
auto *DIExpr = DII->getExpression();
|
||||||
@ -1348,7 +1348,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
|||||||
|
|
||||||
/// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
|
/// Inserts a llvm.dbg.value intrinsic after a phi that has an associated
|
||||||
/// llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
/// llvm.dbg.declare or llvm.dbg.addr intrinsic.
|
||||||
void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII,
|
void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
|
||||||
PHINode *APN, DIBuilder &Builder) {
|
PHINode *APN, DIBuilder &Builder) {
|
||||||
auto *DIVar = DII->getVariable();
|
auto *DIVar = DII->getVariable();
|
||||||
auto *DIExpr = DII->getExpression();
|
auto *DIExpr = DII->getExpression();
|
||||||
@ -1450,7 +1450,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB,
|
|||||||
// Map existing PHI nodes to their dbg.values.
|
// Map existing PHI nodes to their dbg.values.
|
||||||
ValueToValueMapTy DbgValueMap;
|
ValueToValueMapTy DbgValueMap;
|
||||||
for (auto &I : *BB) {
|
for (auto &I : *BB) {
|
||||||
if (auto DbgII = dyn_cast<DbgInfoIntrinsic>(&I)) {
|
if (auto DbgII = dyn_cast<DbgVariableIntrinsic>(&I)) {
|
||||||
if (auto *Loc = dyn_cast_or_null<PHINode>(DbgII->getVariableLocation()))
|
if (auto *Loc = dyn_cast_or_null<PHINode>(DbgII->getVariableLocation()))
|
||||||
DbgValueMap.insert({Loc, DbgII});
|
DbgValueMap.insert({Loc, DbgII});
|
||||||
}
|
}
|
||||||
@ -1471,7 +1471,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB,
|
|||||||
for (auto VI : PHI->operand_values()) {
|
for (auto VI : PHI->operand_values()) {
|
||||||
auto V = DbgValueMap.find(VI);
|
auto V = DbgValueMap.find(VI);
|
||||||
if (V != DbgValueMap.end()) {
|
if (V != DbgValueMap.end()) {
|
||||||
auto *DbgII = cast<DbgInfoIntrinsic>(V->second);
|
auto *DbgII = cast<DbgVariableIntrinsic>(V->second);
|
||||||
Instruction *NewDbgII = DbgII->clone();
|
Instruction *NewDbgII = DbgII->clone();
|
||||||
NewDbgII->setOperand(0, PhiMAV);
|
NewDbgII->setOperand(0, PhiMAV);
|
||||||
auto InsertionPt = Parent->getFirstInsertionPt();
|
auto InsertionPt = Parent->getFirstInsertionPt();
|
||||||
@ -1485,7 +1485,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB,
|
|||||||
/// Finds all intrinsics declaring local variables as living in the memory that
|
/// Finds all intrinsics declaring local variables as living in the memory that
|
||||||
/// 'V' points to. This may include a mix of dbg.declare and
|
/// 'V' points to. This may include a mix of dbg.declare and
|
||||||
/// dbg.addr intrinsics.
|
/// dbg.addr intrinsics.
|
||||||
TinyPtrVector<DbgInfoIntrinsic *> llvm::FindDbgAddrUses(Value *V) {
|
TinyPtrVector<DbgVariableIntrinsic *> llvm::FindDbgAddrUses(Value *V) {
|
||||||
// This function is hot. Check whether the value has any metadata to avoid a
|
// This function is hot. Check whether the value has any metadata to avoid a
|
||||||
// DenseMap lookup.
|
// DenseMap lookup.
|
||||||
if (!V->isUsedByMetadata())
|
if (!V->isUsedByMetadata())
|
||||||
@ -1497,9 +1497,9 @@ TinyPtrVector<DbgInfoIntrinsic *> llvm::FindDbgAddrUses(Value *V) {
|
|||||||
if (!MDV)
|
if (!MDV)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
TinyPtrVector<DbgInfoIntrinsic *> Declares;
|
TinyPtrVector<DbgVariableIntrinsic *> Declares;
|
||||||
for (User *U : MDV->users()) {
|
for (User *U : MDV->users()) {
|
||||||
if (auto *DII = dyn_cast<DbgInfoIntrinsic>(U))
|
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||||
if (DII->isAddressOfVariable())
|
if (DII->isAddressOfVariable())
|
||||||
Declares.push_back(DII);
|
Declares.push_back(DII);
|
||||||
}
|
}
|
||||||
@ -1519,7 +1519,7 @@ void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V) {
|
|||||||
DbgValues.push_back(DVI);
|
DbgValues.push_back(DVI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void llvm::findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgUsers,
|
void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
|
||||||
Value *V) {
|
Value *V) {
|
||||||
// This function is hot. Check whether the value has any metadata to avoid a
|
// This function is hot. Check whether the value has any metadata to avoid a
|
||||||
// DenseMap lookup.
|
// DenseMap lookup.
|
||||||
@ -1528,7 +1528,7 @@ void llvm::findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgUsers,
|
|||||||
if (auto *L = LocalAsMetadata::getIfExists(V))
|
if (auto *L = LocalAsMetadata::getIfExists(V))
|
||||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L))
|
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L))
|
||||||
for (User *U : MDV->users())
|
for (User *U : MDV->users())
|
||||||
if (DbgInfoIntrinsic *DII = dyn_cast<DbgInfoIntrinsic>(U))
|
if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||||
DbgUsers.push_back(DII);
|
DbgUsers.push_back(DII);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1536,7 +1536,7 @@ bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress,
|
|||||||
Instruction *InsertBefore, DIBuilder &Builder,
|
Instruction *InsertBefore, DIBuilder &Builder,
|
||||||
bool DerefBefore, int Offset, bool DerefAfter) {
|
bool DerefBefore, int Offset, bool DerefAfter) {
|
||||||
auto DbgAddrs = FindDbgAddrUses(Address);
|
auto DbgAddrs = FindDbgAddrUses(Address);
|
||||||
for (DbgInfoIntrinsic *DII : DbgAddrs) {
|
for (DbgVariableIntrinsic *DII : DbgAddrs) {
|
||||||
DebugLoc Loc = DII->getDebugLoc();
|
DebugLoc Loc = DII->getDebugLoc();
|
||||||
auto *DIVar = DII->getVariable();
|
auto *DIVar = DII->getVariable();
|
||||||
auto *DIExpr = DII->getExpression();
|
auto *DIExpr = DII->getExpression();
|
||||||
@ -1604,7 +1604,7 @@ static MetadataAsValue *wrapValueInMetadata(LLVMContext &C, Value *V) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool llvm::salvageDebugInfo(Instruction &I) {
|
bool llvm::salvageDebugInfo(Instruction &I) {
|
||||||
SmallVector<DbgInfoIntrinsic *, 1> DbgUsers;
|
SmallVector<DbgVariableIntrinsic *, 1> DbgUsers;
|
||||||
findDbgUsers(DbgUsers, &I);
|
findDbgUsers(DbgUsers, &I);
|
||||||
if (DbgUsers.empty())
|
if (DbgUsers.empty())
|
||||||
return false;
|
return false;
|
||||||
@ -1614,7 +1614,7 @@ bool llvm::salvageDebugInfo(Instruction &I) {
|
|||||||
auto &Ctx = I.getContext();
|
auto &Ctx = I.getContext();
|
||||||
auto wrapMD = [&](Value *V) { return wrapValueInMetadata(Ctx, V); };
|
auto wrapMD = [&](Value *V) { return wrapValueInMetadata(Ctx, V); };
|
||||||
|
|
||||||
auto doSalvage = [&](DbgInfoIntrinsic *DII, SmallVectorImpl<uint64_t> &Ops) {
|
auto doSalvage = [&](DbgVariableIntrinsic *DII, SmallVectorImpl<uint64_t> &Ops) {
|
||||||
auto *DIExpr = DII->getExpression();
|
auto *DIExpr = DII->getExpression();
|
||||||
if (!Ops.empty()) {
|
if (!Ops.empty()) {
|
||||||
// Do not add DW_OP_stack_value for DbgDeclare and DbgAddr, because they
|
// Do not add DW_OP_stack_value for DbgDeclare and DbgAddr, because they
|
||||||
@ -1628,13 +1628,13 @@ bool llvm::salvageDebugInfo(Instruction &I) {
|
|||||||
LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n');
|
LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
auto applyOffset = [&](DbgInfoIntrinsic *DII, uint64_t Offset) {
|
auto applyOffset = [&](DbgVariableIntrinsic *DII, uint64_t Offset) {
|
||||||
SmallVector<uint64_t, 8> Ops;
|
SmallVector<uint64_t, 8> Ops;
|
||||||
DIExpression::appendOffset(Ops, Offset);
|
DIExpression::appendOffset(Ops, Offset);
|
||||||
doSalvage(DII, Ops);
|
doSalvage(DII, Ops);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto applyOps = [&](DbgInfoIntrinsic *DII,
|
auto applyOps = [&](DbgVariableIntrinsic *DII,
|
||||||
std::initializer_list<uint64_t> Opcodes) {
|
std::initializer_list<uint64_t> Opcodes) {
|
||||||
SmallVector<uint64_t, 8> Ops(Opcodes);
|
SmallVector<uint64_t, 8> Ops(Opcodes);
|
||||||
doSalvage(DII, Ops);
|
doSalvage(DII, Ops);
|
||||||
@ -1733,16 +1733,16 @@ using DbgValReplacement = Optional<DIExpression *>;
|
|||||||
/// changes are made.
|
/// changes are made.
|
||||||
static bool rewriteDebugUsers(
|
static bool rewriteDebugUsers(
|
||||||
Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT,
|
Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT,
|
||||||
function_ref<DbgValReplacement(DbgInfoIntrinsic &DII)> RewriteExpr) {
|
function_ref<DbgValReplacement(DbgVariableIntrinsic &DII)> RewriteExpr) {
|
||||||
// Find debug users of From.
|
// Find debug users of From.
|
||||||
SmallVector<DbgInfoIntrinsic *, 1> Users;
|
SmallVector<DbgVariableIntrinsic *, 1> Users;
|
||||||
findDbgUsers(Users, &From);
|
findDbgUsers(Users, &From);
|
||||||
if (Users.empty())
|
if (Users.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Prevent use-before-def of To.
|
// Prevent use-before-def of To.
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
SmallPtrSet<DbgInfoIntrinsic *, 1> DeleteOrSalvage;
|
SmallPtrSet<DbgVariableIntrinsic *, 1> DeleteOrSalvage;
|
||||||
if (isa<Instruction>(&To)) {
|
if (isa<Instruction>(&To)) {
|
||||||
bool DomPointAfterFrom = From.getNextNonDebugInstruction() == &DomPoint;
|
bool DomPointAfterFrom = From.getNextNonDebugInstruction() == &DomPoint;
|
||||||
|
|
||||||
@ -1831,7 +1831,7 @@ bool llvm::replaceAllDbgUsesWith(Instruction &From, Value &To,
|
|||||||
Type *FromTy = From.getType();
|
Type *FromTy = From.getType();
|
||||||
Type *ToTy = To.getType();
|
Type *ToTy = To.getType();
|
||||||
|
|
||||||
auto Identity = [&](DbgInfoIntrinsic &DII) -> DbgValReplacement {
|
auto Identity = [&](DbgVariableIntrinsic &DII) -> DbgValReplacement {
|
||||||
return DII.getExpression();
|
return DII.getExpression();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1855,7 +1855,7 @@ bool llvm::replaceAllDbgUsesWith(Instruction &From, Value &To,
|
|||||||
|
|
||||||
// The width of the result has shrunk. Use sign/zero extension to describe
|
// The width of the result has shrunk. Use sign/zero extension to describe
|
||||||
// the source variable's high bits.
|
// the source variable's high bits.
|
||||||
auto SignOrZeroExt = [&](DbgInfoIntrinsic &DII) -> DbgValReplacement {
|
auto SignOrZeroExt = [&](DbgVariableIntrinsic &DII) -> DbgValReplacement {
|
||||||
DILocalVariable *Var = DII.getVariable();
|
DILocalVariable *Var = DII.getVariable();
|
||||||
|
|
||||||
// Without knowing signedness, sign/zero extension isn't possible.
|
// Without knowing signedness, sign/zero extension isn't possible.
|
||||||
|
@ -304,13 +304,13 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
|
|||||||
// Record all debug intrinsics preceding LoopEntryBranch to avoid duplication.
|
// Record all debug intrinsics preceding LoopEntryBranch to avoid duplication.
|
||||||
using DbgIntrinsicHash =
|
using DbgIntrinsicHash =
|
||||||
std::pair<std::pair<Value *, DILocalVariable *>, DIExpression *>;
|
std::pair<std::pair<Value *, DILocalVariable *>, DIExpression *>;
|
||||||
auto makeHash = [](DbgInfoIntrinsic *D) -> DbgIntrinsicHash {
|
auto makeHash = [](DbgVariableIntrinsic *D) -> DbgIntrinsicHash {
|
||||||
return {{D->getVariableLocation(), D->getVariable()}, D->getExpression()};
|
return {{D->getVariableLocation(), D->getVariable()}, D->getExpression()};
|
||||||
};
|
};
|
||||||
SmallDenseSet<DbgIntrinsicHash, 8> DbgIntrinsics;
|
SmallDenseSet<DbgIntrinsicHash, 8> DbgIntrinsics;
|
||||||
for (auto I = std::next(OrigPreheader->rbegin()), E = OrigPreheader->rend();
|
for (auto I = std::next(OrigPreheader->rbegin()), E = OrigPreheader->rend();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (auto *DII = dyn_cast<DbgInfoIntrinsic>(&*I))
|
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&*I))
|
||||||
DbgIntrinsics.insert(makeHash(DII));
|
DbgIntrinsics.insert(makeHash(DII));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
@ -340,7 +340,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
|
|||||||
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
|
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
|
||||||
|
|
||||||
// Avoid inserting the same intrinsic twice.
|
// Avoid inserting the same intrinsic twice.
|
||||||
if (auto *DII = dyn_cast<DbgInfoIntrinsic>(C))
|
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(C))
|
||||||
if (DbgIntrinsics.count(makeHash(DII))) {
|
if (DbgIntrinsics.count(makeHash(DII))) {
|
||||||
C->deleteValue();
|
C->deleteValue();
|
||||||
continue;
|
continue;
|
||||||
|
@ -116,7 +116,7 @@ struct AllocaInfo {
|
|||||||
bool OnlyUsedInOneBlock;
|
bool OnlyUsedInOneBlock;
|
||||||
|
|
||||||
Value *AllocaPointerVal;
|
Value *AllocaPointerVal;
|
||||||
TinyPtrVector<DbgInfoIntrinsic *> DbgDeclares;
|
TinyPtrVector<DbgVariableIntrinsic *> DbgDeclares;
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
DefiningBlocks.clear();
|
DefiningBlocks.clear();
|
||||||
@ -263,7 +263,7 @@ struct PromoteMem2Reg {
|
|||||||
/// For each alloca, we keep track of the dbg.declare intrinsic that
|
/// For each alloca, we keep track of the dbg.declare intrinsic that
|
||||||
/// describes it, if any, so that we can convert it to a dbg.value
|
/// describes it, if any, so that we can convert it to a dbg.value
|
||||||
/// intrinsic if the alloca gets promoted.
|
/// intrinsic if the alloca gets promoted.
|
||||||
SmallVector<TinyPtrVector<DbgInfoIntrinsic *>, 8> AllocaDbgDeclares;
|
SmallVector<TinyPtrVector<DbgVariableIntrinsic *>, 8> AllocaDbgDeclares;
|
||||||
|
|
||||||
/// The set of basic blocks the renamer has already visited.
|
/// The set of basic blocks the renamer has already visited.
|
||||||
SmallPtrSet<BasicBlock *, 16> Visited;
|
SmallPtrSet<BasicBlock *, 16> Visited;
|
||||||
@ -426,7 +426,7 @@ static bool rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info,
|
|||||||
|
|
||||||
// Record debuginfo for the store and remove the declaration's
|
// Record debuginfo for the store and remove the declaration's
|
||||||
// debuginfo.
|
// debuginfo.
|
||||||
for (DbgInfoIntrinsic *DII : Info.DbgDeclares) {
|
for (DbgVariableIntrinsic *DII : Info.DbgDeclares) {
|
||||||
DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false);
|
DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false);
|
||||||
ConvertDebugDeclareToDebugValue(DII, Info.OnlyStore, DIB);
|
ConvertDebugDeclareToDebugValue(DII, Info.OnlyStore, DIB);
|
||||||
DII->eraseFromParent();
|
DII->eraseFromParent();
|
||||||
@ -527,7 +527,7 @@ static bool promoteSingleBlockAlloca(AllocaInst *AI, const AllocaInfo &Info,
|
|||||||
while (!AI->use_empty()) {
|
while (!AI->use_empty()) {
|
||||||
StoreInst *SI = cast<StoreInst>(AI->user_back());
|
StoreInst *SI = cast<StoreInst>(AI->user_back());
|
||||||
// Record debuginfo for the store before removing it.
|
// Record debuginfo for the store before removing it.
|
||||||
for (DbgInfoIntrinsic *DII : Info.DbgDeclares) {
|
for (DbgVariableIntrinsic *DII : Info.DbgDeclares) {
|
||||||
DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false);
|
DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false);
|
||||||
ConvertDebugDeclareToDebugValue(DII, SI, DIB);
|
ConvertDebugDeclareToDebugValue(DII, SI, DIB);
|
||||||
}
|
}
|
||||||
@ -539,7 +539,7 @@ static bool promoteSingleBlockAlloca(AllocaInst *AI, const AllocaInfo &Info,
|
|||||||
LBI.deleteValue(AI);
|
LBI.deleteValue(AI);
|
||||||
|
|
||||||
// The alloca's debuginfo can be removed as well.
|
// The alloca's debuginfo can be removed as well.
|
||||||
for (DbgInfoIntrinsic *DII : Info.DbgDeclares) {
|
for (DbgVariableIntrinsic *DII : Info.DbgDeclares) {
|
||||||
DII->eraseFromParent();
|
DII->eraseFromParent();
|
||||||
LBI.deleteValue(DII);
|
LBI.deleteValue(DII);
|
||||||
}
|
}
|
||||||
@ -932,7 +932,7 @@ NextIteration:
|
|||||||
|
|
||||||
// The currently active variable for this block is now the PHI.
|
// The currently active variable for this block is now the PHI.
|
||||||
IncomingVals[AllocaNo] = APN;
|
IncomingVals[AllocaNo] = APN;
|
||||||
for (DbgInfoIntrinsic *DII : AllocaDbgDeclares[AllocaNo])
|
for (DbgVariableIntrinsic *DII : AllocaDbgDeclares[AllocaNo])
|
||||||
ConvertDebugDeclareToDebugValue(DII, APN, DIB);
|
ConvertDebugDeclareToDebugValue(DII, APN, DIB);
|
||||||
|
|
||||||
// Get the next phi node.
|
// Get the next phi node.
|
||||||
@ -992,7 +992,7 @@ NextIteration:
|
|||||||
|
|
||||||
// Record debuginfo for the store before removing it.
|
// Record debuginfo for the store before removing it.
|
||||||
IncomingLocs[AllocaNo] = SI->getDebugLoc();
|
IncomingLocs[AllocaNo] = SI->getDebugLoc();
|
||||||
for (DbgInfoIntrinsic *DII : AllocaDbgDeclares[ai->second])
|
for (DbgVariableIntrinsic *DII : AllocaDbgDeclares[ai->second])
|
||||||
ConvertDebugDeclareToDebugValue(DII, SI, DIB);
|
ConvertDebugDeclareToDebugValue(DII, SI, DIB);
|
||||||
BB->getInstList().erase(SI);
|
BB->getInstList().erase(SI);
|
||||||
}
|
}
|
||||||
|
@ -683,25 +683,25 @@ TEST(Local, ReplaceAllDbgUsesWith) {
|
|||||||
// Simulate i32* <-> i64* conversion.
|
// Simulate i32* <-> i64* conversion.
|
||||||
EXPECT_TRUE(replaceAllDbgUsesWith(D, C, C, DT));
|
EXPECT_TRUE(replaceAllDbgUsesWith(D, C, C, DT));
|
||||||
|
|
||||||
SmallVector<DbgInfoIntrinsic *, 2> CDbgVals;
|
SmallVector<DbgVariableIntrinsic *, 2> CDbgVals;
|
||||||
findDbgUsers(CDbgVals, &C);
|
findDbgUsers(CDbgVals, &C);
|
||||||
EXPECT_EQ(2U, CDbgVals.size());
|
EXPECT_EQ(2U, CDbgVals.size());
|
||||||
EXPECT_TRUE(any_of(CDbgVals, [](DbgInfoIntrinsic *DII) {
|
EXPECT_TRUE(any_of(CDbgVals, [](DbgVariableIntrinsic *DII) {
|
||||||
return isa<DbgAddrIntrinsic>(DII);
|
return isa<DbgAddrIntrinsic>(DII);
|
||||||
}));
|
}));
|
||||||
EXPECT_TRUE(any_of(CDbgVals, [](DbgInfoIntrinsic *DII) {
|
EXPECT_TRUE(any_of(CDbgVals, [](DbgVariableIntrinsic *DII) {
|
||||||
return isa<DbgDeclareInst>(DII);
|
return isa<DbgDeclareInst>(DII);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
EXPECT_TRUE(replaceAllDbgUsesWith(C, D, D, DT));
|
EXPECT_TRUE(replaceAllDbgUsesWith(C, D, D, DT));
|
||||||
|
|
||||||
SmallVector<DbgInfoIntrinsic *, 2> DDbgVals;
|
SmallVector<DbgVariableIntrinsic *, 2> DDbgVals;
|
||||||
findDbgUsers(DDbgVals, &D);
|
findDbgUsers(DDbgVals, &D);
|
||||||
EXPECT_EQ(2U, DDbgVals.size());
|
EXPECT_EQ(2U, DDbgVals.size());
|
||||||
EXPECT_TRUE(any_of(DDbgVals, [](DbgInfoIntrinsic *DII) {
|
EXPECT_TRUE(any_of(DDbgVals, [](DbgVariableIntrinsic *DII) {
|
||||||
return isa<DbgAddrIntrinsic>(DII);
|
return isa<DbgAddrIntrinsic>(DII);
|
||||||
}));
|
}));
|
||||||
EXPECT_TRUE(any_of(DDbgVals, [](DbgInfoIntrinsic *DII) {
|
EXPECT_TRUE(any_of(DDbgVals, [](DbgVariableIntrinsic *DII) {
|
||||||
return isa<DbgDeclareInst>(DII);
|
return isa<DbgDeclareInst>(DII);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user