[llvm] r312754 - Move duplicate helpers from DbgValueInst / DbgDeclareInst to DbgInfoIntrinsic
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 15:46:24 PDT 2017
Author: rnk
Date: Thu Sep 7 15:46:24 2017
New Revision: 312754
URL: http://llvm.org/viewvc/llvm-project?rev=312754&view=rev
Log:
Move duplicate helpers from DbgValueInst / DbgDeclareInst to DbgInfoIntrinsic
NFC
Modified:
llvm/trunk/include/llvm/IR/IntrinsicInst.h
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/IR/IntrinsicInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IntrinsicInst.h?rev=312754&r1=312753&r2=312754&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IntrinsicInst.h (original)
+++ llvm/trunk/include/llvm/IR/IntrinsicInst.h Thu Sep 7 15:46:24 2017
@@ -71,6 +71,22 @@ namespace llvm {
/// variable's value or its address.
Value *getVariableLocation(bool AllowNullOp = true) const;
+ DILocalVariable *getVariable() const {
+ return cast<DILocalVariable>(getRawVariable());
+ }
+
+ DIExpression *getExpression() const {
+ return cast<DIExpression>(getRawExpression());
+ }
+
+ Metadata *getRawVariable() const {
+ return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
+ }
+
+ Metadata *getRawExpression() const {
+ return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
+ }
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const IntrinsicInst *I) {
switch (I->getIntrinsicID()) {
@@ -90,22 +106,6 @@ namespace llvm {
public:
Value *getAddress() const { return getVariableLocation(); }
- DILocalVariable *getVariable() const {
- return cast<DILocalVariable>(getRawVariable());
- }
-
- DIExpression *getExpression() const {
- return cast<DIExpression>(getRawExpression());
- }
-
- Metadata *getRawVariable() const {
- return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
- }
-
- Metadata *getRawExpression() const {
- return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
- }
-
// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const IntrinsicInst *I) {
return I->getIntrinsicID() == Intrinsic::dbg_declare;
@@ -122,22 +122,6 @@ namespace llvm {
return getVariableLocation(/* AllowNullOp = */ false);
}
- DILocalVariable *getVariable() const {
- return cast<DILocalVariable>(getRawVariable());
- }
-
- DIExpression *getExpression() const {
- return cast<DIExpression>(getRawExpression());
- }
-
- Metadata *getRawVariable() const {
- return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
- }
-
- Metadata *getRawExpression() const {
- return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
- }
-
// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const IntrinsicInst *I) {
return I->getIntrinsicID() == Intrinsic::dbg_value;
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=312754&r1=312753&r2=312754&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Sep 7 15:46:24 2017
@@ -468,8 +468,7 @@ private:
void visitUserOp2(Instruction &I) { visitUserOp1(I); }
void visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS);
void visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI);
- template <class DbgIntrinsicTy>
- void visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII);
+ void visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII);
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI);
void visitAtomicRMWInst(AtomicRMWInst &RMWI);
void visitFenceInst(FenceInst &FI);
@@ -4000,10 +3999,10 @@ void Verifier::visitIntrinsicCallSite(In
case Intrinsic::dbg_declare: // llvm.dbg.declare
Assert(isa<MetadataAsValue>(CS.getArgOperand(0)),
"invalid llvm.dbg.declare intrinsic call 1", CS);
- visitDbgIntrinsic("declare", cast<DbgDeclareInst>(*CS.getInstruction()));
+ visitDbgIntrinsic("declare", cast<DbgInfoIntrinsic>(*CS.getInstruction()));
break;
case Intrinsic::dbg_value: // llvm.dbg.value
- visitDbgIntrinsic("value", cast<DbgValueInst>(*CS.getInstruction()));
+ visitDbgIntrinsic("value", cast<DbgInfoIntrinsic>(*CS.getInstruction()));
break;
case Intrinsic::memcpy:
case Intrinsic::memmove:
@@ -4455,8 +4454,7 @@ void Verifier::visitConstrainedFPIntrins
"invalid exception behavior argument", &FPI);
}
-template <class DbgIntrinsicTy>
-void Verifier::visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII) {
+void Verifier::visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII) {
auto *MD = cast<MetadataAsValue>(DII.getArgOperand(0))->getMetadata();
AssertDI(isa<ValueAsMetadata>(MD) ||
(isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
@@ -4519,16 +4517,8 @@ static uint64_t getVariableSize(const DI
}
void Verifier::verifyFragmentExpression(const DbgInfoIntrinsic &I) {
- DILocalVariable *V;
- DIExpression *E;
- if (auto *DVI = dyn_cast<DbgValueInst>(&I)) {
- V = dyn_cast_or_null<DILocalVariable>(DVI->getRawVariable());
- E = dyn_cast_or_null<DIExpression>(DVI->getRawExpression());
- } else {
- auto *DDI = cast<DbgDeclareInst>(&I);
- V = dyn_cast_or_null<DILocalVariable>(DDI->getRawVariable());
- E = dyn_cast_or_null<DIExpression>(DDI->getRawExpression());
- }
+ DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(I.getRawVariable());
+ DIExpression *E = dyn_cast_or_null<DIExpression>(I.getRawExpression());
// We don't know whether this intrinsic verified correctly.
if (!V || !E || !E->isValid())
@@ -4575,18 +4565,11 @@ void Verifier::verifyFnArgs(const DbgInf
if (!HasDebugInfo)
return;
- DILocalVariable *Var;
- if (auto *DV = dyn_cast<DbgValueInst>(&I)) {
- // For performance reasons only check non-inlined ones.
- if (DV->getDebugLoc()->getInlinedAt())
- return;
- Var = DV->getVariable();
- } else {
- auto *DD = cast<DbgDeclareInst>(&I);
- if (DD->getDebugLoc()->getInlinedAt())
- return;
- Var = DD->getVariable();
- }
+ // For performance reasons only check non-inlined ones.
+ if (I.getDebugLoc()->getInlinedAt())
+ return;
+
+ DILocalVariable *Var = I.getVariable();
AssertDI(Var, "dbg intrinsic without variable");
unsigned ArgNo = Var->getArg();
More information about the llvm-commits
mailing list