diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-01 05:23:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-01 05:23:13 +0000 |
commit | 61336ae001e07c6d68454b1494e45954d373fb51 (patch) | |
tree | 3405e69a31ba002ace3432c8b1abd2dff10fff64 /include/llvm/Instruction.h | |
parent | b45218f7c8c53ed77bc35563b2a300781be3cdd0 (diff) | |
download | external_llvm-61336ae001e07c6d68454b1494e45954d373fb51.zip external_llvm-61336ae001e07c6d68454b1494e45954d373fb51.tar.gz external_llvm-61336ae001e07c6d68454b1494e45954d373fb51.tar.bz2 |
Switch the representation of the location in instruction from
being a TrackingVH<MDNode> to a NewDebugLoc, shrinking
sizeof(Instruction) a lot, and providing clients the ability
to deal with locations in terms of NewDebugLoc instead of
having to deal with Metadata. This is still fully compatible
with all clients that *do* use MDNodes for everything of
course.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Instruction.h')
-rw-r--r-- | include/llvm/Instruction.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 472ab83..13331e6 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -17,7 +17,7 @@ #include "llvm/User.h" #include "llvm/ADT/ilist_node.h" -#include "llvm/Support/ValueHandle.h" +#include "llvm/Support/DebugLoc.h" namespace llvm { @@ -32,7 +32,7 @@ class Instruction : public User, public ilist_node<Instruction> { Instruction(const Instruction &); // Do not implement BasicBlock *Parent; - TrackingVH<MDNode> DbgInfo; // 'dbg' Metadata cache. + NewDebugLoc DbgLoc; // 'dbg' Metadata cache. enum { /// HasMetadataBit - This is a bit stored in the SubClassData field which @@ -125,7 +125,13 @@ public: /// hasMetadata() - Return true if this instruction has any metadata attached /// to it. bool hasMetadata() const { - return DbgInfo != 0 || hasMetadataHashEntry(); + return !DbgLoc.isUnknown() || hasMetadataHashEntry(); + } + + /// hasMetadataOtherThanDebugLoc - Return true if this instruction has + /// metadata attached to it other than a debug location. + bool hasMetadataOtherThanDebugLoc() const { + return hasMetadataHashEntry(); } /// getMetadata - Get the metadata of given kind attached to this Instruction. @@ -150,6 +156,14 @@ public: getAllMetadataImpl(MDs); } + /// getAllMetadataOtherThanDebugLoc - This does the same thing as + /// getAllMetadata, except that it filters out the debug location. + void getAllMetadataOtherThanDebugLoc(SmallVectorImpl<std::pair<unsigned, + MDNode*> > &MDs) const { + if (hasMetadataOtherThanDebugLoc()) + getAllMetadataOtherThanDebugLocImpl(MDs); + } + /// setMetadata - Set the metadata of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if /// Node is null. @@ -163,8 +177,14 @@ public: /// getDbgMetadata - This is just an optimized helper function that is /// equivalent to calling getMetadata("dbg"). MDNode *getDbgMetadata() const { - return DbgInfo; + return DbgLoc.getAsMDNode(getContext()); } + + /// setDebugLoc - Set the debug location information for this instruction. + void setDebugLoc(const NewDebugLoc &Loc) { DbgLoc = Loc; } + + /// getDebugLoc - Return the debug location for this node as a DebugLoc. + const NewDebugLoc &getDebugLoc() const { return DbgLoc; } private: /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side @@ -177,6 +197,8 @@ private: MDNode *getMetadataImpl(unsigned KindID) const; MDNode *getMetadataImpl(const char *Kind) const; void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const; + void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned, + MDNode*> > &) const; void removeAllMetadata(); public: //===--------------------------------------------------------------------===// |