[llvm] r232299 - DbgIntrinsicInst: Downcast to specialized MDNodes in accessors
Duncan P. N. Exon Smith
dexonsmith at apple.com
Sat Mar 14 18:23:20 PDT 2015
Author: dexonsmith
Date: Sat Mar 14 20:23:20 2015
New Revision: 232299
URL: http://llvm.org/viewvc/llvm-project?rev=232299&view=rev
Log:
DbgIntrinsicInst: Downcast to specialized MDNodes in accessors
Change accessors to downcast to `MDLocalVariable` and `MDExpression`,
now that we have -verify checks in place to confirm that it's safe.
Modified:
llvm/trunk/include/llvm/IR/IntrinsicInst.h
llvm/trunk/include/llvm/IR/Metadata.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=232299&r1=232298&r2=232299&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IntrinsicInst.h (original)
+++ llvm/trunk/include/llvm/IR/IntrinsicInst.h Sat Mar 14 20:23:20 2015
@@ -82,8 +82,12 @@ namespace llvm {
class DbgDeclareInst : public DbgInfoIntrinsic {
public:
Value *getAddress() const;
- MDNode *getVariable() const { return cast<MDNode>(getRawVariable()); }
- MDNode *getExpression() const { return cast<MDNode>(getRawExpression()); }
+ MDLocalVariable *getVariable() const {
+ return cast<MDLocalVariable>(getRawVariable());
+ }
+ MDExpression *getExpression() const {
+ return cast<MDExpression>(getRawExpression());
+ }
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
@@ -111,8 +115,12 @@ namespace llvm {
return cast<ConstantInt>(
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
}
- MDNode *getVariable() const { return cast<MDNode>(getRawVariable()); }
- MDNode *getExpression() const { return cast<MDNode>(getRawExpression()); }
+ MDLocalVariable *getVariable() const {
+ return cast<MDLocalVariable>(getRawVariable());
+ }
+ MDExpression *getExpression() const {
+ return cast<MDExpression>(getRawExpression());
+ }
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=232299&r1=232298&r2=232299&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Sat Mar 14 20:23:20 2015
@@ -128,6 +128,16 @@ public:
#define HANDLE_METADATA(CLASS) class CLASS;
#include "llvm/IR/Metadata.def"
+// Provide specializations of isa so that we don't need definitions of
+// subclasses to see if the metadata is a subclass.
+#define HANDLE_METADATA_LEAF(CLASS) \
+ template <> struct isa_impl<CLASS, Metadata> { \
+ static inline bool doit(const Metadata &MD) { \
+ return MD.getMetadataID() == Metadata::CLASS##Kind; \
+ } \
+ };
+#include "llvm/IR/Metadata.def"
+
inline raw_ostream &operator<<(raw_ostream &OS, const Metadata &MD) {
MD.print(OS);
return OS;
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=232299&r1=232298&r2=232299&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sat Mar 14 20:23:20 2015
@@ -3032,8 +3032,8 @@ void Verifier::visitDbgIntrinsic(StringR
DII.getRawExpression());
// Don't call visitMDNode(), since that will recurse through operands.
- visitMDLocalVariable(*cast<MDLocalVariable>(DII.getVariable()));
- visitMDExpression(*cast<MDExpression>(DII.getExpression()));
+ visitMDLocalVariable(*DII.getVariable());
+ visitMDExpression(*DII.getExpression());
}
void DebugInfoVerifier::verifyDebugInfo() {
More information about the llvm-commits
mailing list