summaryrefslogtreecommitdiff
path: root/include/llvm/Instruction.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-30 23:03:27 +0000
committerChris Lattner <sabre@nondot.org>2010-03-30 23:03:27 +0000
commitec39f095f5abaf1ec90d7c6c46454032cda36e1c (patch)
tree2d3a0f5e859ac6ba680bb055b87a6e7191190097 /include/llvm/Instruction.h
parentbfcd61b907e1ec7e6b21fafa7c362e3002ddf3c1 (diff)
downloadllvm-ec39f095f5abaf1ec90d7c6c46454032cda36e1c.tar.gz
llvm-ec39f095f5abaf1ec90d7c6c46454032cda36e1c.tar.bz2
llvm-ec39f095f5abaf1ec90d7c6c46454032cda36e1c.tar.xz
Fix a major source of compile-time slowness at -O0 -g by optimizing
the storage of !dbg metadata kinds in the instruction themselves. The on-the-side hash table works great for metadata that not-all instructions get, or for metadata that only exists when optimizing. But when compile-time is everything, it isn't great. I'm not super thrilled with the fact that this plops a TrackingVH in Instruction, because it grows it by 3 words. I'm investigating alternatives, but this should be a step in the right direction in any case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Instruction.h')
-rw-r--r--include/llvm/Instruction.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index cf9dc4456f..41841126b3 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -17,6 +17,7 @@
#include "llvm/User.h"
#include "llvm/ADT/ilist_node.h"
+#include "llvm/Support/ValueHandle.h"
namespace llvm {
@@ -31,6 +32,7 @@ class Instruction : public User, public ilist_node<Instruction> {
Instruction(const Instruction &); // Do not implement
BasicBlock *Parent;
+ TrackingVH<MDNode> DbgInfo; // 'dbg' Metadata cache.
enum {
/// HasMetadataBit - This is a bit stored in the SubClassData field which
@@ -123,7 +125,7 @@ public:
/// hasMetadata() - Return true if this instruction has any metadata attached
/// to it.
bool hasMetadata() const {
- return (getSubclassDataFromValue() & HasMetadataBit) != 0;
+ return DbgInfo != 0 || hasMetadataHashEntry();
}
/// getMetadata - Get the metadata of given kind attached to this Instruction.
@@ -155,6 +157,12 @@ public:
void setMetadata(const char *Kind, MDNode *Node);
private:
+ /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side
+ /// metadata hash.
+ bool hasMetadataHashEntry() const {
+ return (getSubclassDataFromValue() & HasMetadataBit) != 0;
+ }
+
// These are all implemented in Metadata.cpp.
MDNode *getMetadataImpl(unsigned KindID) const;
MDNode *getMetadataImpl(const char *Kind) const;
@@ -315,7 +323,7 @@ private:
return Value::getSubclassDataFromValue();
}
- void setHasMetadata(bool V) {
+ void setHasMetadataHashEntry(bool V) {
setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) |
(V ? HasMetadataBit : 0));
}