[llvm-branch-commits] [llvm-branch] r99971 - in /llvm/branches/Apple/Morbo: ./ include/llvm/Instruction.h include/llvm/LLVMContext.h include/llvm/Support/ValueHandle.h lib/Transforms/IPO/FunctionAttrs.cpp lib/VMCore/Instruction.cpp lib/VMCore/LLVMContext.cpp lib/VMCore/Metadata.cpp
Devang Patel
dpatel at apple.com
Tue Mar 30 17:32:03 PDT 2010
Author: dpatel
Date: Tue Mar 30 19:32:03 2010
New Revision: 99971
URL: http://llvm.org/viewvc/llvm-project?rev=99971&view=rev
Log:
merge r99957 from mainline.
Modified:
llvm/branches/Apple/Morbo/ (props changed)
llvm/branches/Apple/Morbo/include/llvm/Instruction.h
llvm/branches/Apple/Morbo/include/llvm/LLVMContext.h
llvm/branches/Apple/Morbo/include/llvm/Support/ValueHandle.h
llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp (props changed)
llvm/branches/Apple/Morbo/lib/VMCore/Instruction.cpp
llvm/branches/Apple/Morbo/lib/VMCore/LLVMContext.cpp
llvm/branches/Apple/Morbo/lib/VMCore/Metadata.cpp
Propchange: llvm/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 30 19:32:03 2010
@@ -1,2 +1,2 @@
/llvm/branches/Apple/Hermes:96832,96835,96858,96870,96876,96879
-/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99537,99539,99544,99570,99575,99629-99630,99671,99692,99695,99697,99699,99722,99846,99850,99910
+/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99537,99539,99544,99570,99575,99629-99630,99671,99692,99695,99697,99699,99722,99846,99850,99910,99957
Modified: llvm/branches/Apple/Morbo/include/llvm/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/Instruction.h?rev=99971&r1=99970&r2=99971&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/Instruction.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/Instruction.h Tue Mar 30 19:32:03 2010
@@ -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 @@
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 @@
/// 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 @@
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 @@
return Value::getSubclassDataFromValue();
}
- void setHasMetadata(bool V) {
+ void setHasMetadataHashEntry(bool V) {
setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) |
(V ? HasMetadataBit : 0));
}
Modified: llvm/branches/Apple/Morbo/include/llvm/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/LLVMContext.h?rev=99971&r1=99970&r2=99971&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/LLVMContext.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/LLVMContext.h Tue Mar 30 19:32:03 2010
@@ -36,6 +36,12 @@
LLVMContext();
~LLVMContext();
+ // Pinned metadata names, which always have the same value. This is a
+ // compile-time performance optimization, not a correctness optimization.
+ enum {
+ MD_dbg = 1 // "dbg" -> 1.
+ };
+
/// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
/// This ID is uniqued across modules in the current LLVMContext.
unsigned getMDKindID(StringRef Name) const;
Modified: llvm/branches/Apple/Morbo/include/llvm/Support/ValueHandle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/Support/ValueHandle.h?rev=99971&r1=99970&r2=99971&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/Support/ValueHandle.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/Support/ValueHandle.h Tue Mar 30 19:32:03 2010
@@ -302,7 +302,7 @@
ValueTy *getValPtr() const {
CheckValidity();
- return static_cast<ValueTy*>(ValueHandleBase::getValPtr());
+ return (ValueTy*)ValueHandleBase::getValPtr();
}
void setValPtr(ValueTy *P) {
CheckValidity();
Propchange: llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 30 19:32:03 2010
@@ -1 +1 @@
-/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99492,99539,99699,99836,99846,99850,99910
+/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99492,99539,99699,99836,99846,99850,99910,99957
Modified: llvm/branches/Apple/Morbo/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/VMCore/Instruction.cpp?rev=99971&r1=99970&r2=99971&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/VMCore/Instruction.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/VMCore/Instruction.cpp Tue Mar 30 19:32:03 2010
@@ -22,7 +22,7 @@
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
Instruction *InsertBefore)
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0), DbgInfo(0) {
// Make sure that we get added to a basicblock
LeakDetector::addGarbageObject(this);
@@ -36,7 +36,7 @@
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
BasicBlock *InsertAtEnd)
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0), DbgInfo(0) {
// Make sure that we get added to a basicblock
LeakDetector::addGarbageObject(this);
Modified: llvm/branches/Apple/Morbo/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/VMCore/LLVMContext.cpp?rev=99971&r1=99970&r2=99971&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/VMCore/LLVMContext.cpp Tue Mar 30 19:32:03 2010
@@ -26,7 +26,11 @@
return *GlobalContext;
}
-LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
+LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
+ // Create the first metadata kind, which is always 'dbg'.
+ unsigned DbgID = getMDKindID("dbg");
+ assert(DbgID == MD_dbg && "dbg kind id drifted"); (void)DbgID;
+}
LLVMContext::~LLVMContext() { delete pImpl; }
GetElementPtrConstantExpr::GetElementPtrConstantExpr
Modified: llvm/branches/Apple/Morbo/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/VMCore/Metadata.cpp?rev=99971&r1=99970&r2=99971&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/VMCore/Metadata.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/VMCore/Metadata.cpp Tue Mar 30 19:32:03 2010
@@ -474,12 +474,19 @@
void Instruction::setMetadata(unsigned KindID, MDNode *Node) {
if (Node == 0 && !hasMetadata()) return;
+ // Handle 'dbg' as a special case since it is not stored in the hash table.
+ if (KindID == LLVMContext::MD_dbg) {
+ DbgInfo = Node;
+ return;
+ }
+
// Handle the case when we're adding/updating metadata on an instruction.
if (Node) {
LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
- assert(!Info.empty() == hasMetadata() && "HasMetadata bit is wonked");
+ assert(!Info.empty() == hasMetadataHashEntry() &&
+ "HasMetadata bit is wonked");
if (Info.empty()) {
- setHasMetadata(true);
+ setHasMetadataHashEntry(true);
} else {
// Handle replacement of an existing value.
for (unsigned i = 0, e = Info.size(); i != e; ++i)
@@ -495,18 +502,19 @@
}
// Otherwise, we're removing metadata from an instruction.
- assert(hasMetadata() && getContext().pImpl->MetadataStore.count(this) &&
+ assert(hasMetadataHashEntry() &&
+ getContext().pImpl->MetadataStore.count(this) &&
"HasMetadata bit out of date!");
LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
// Common case is removing the only entry.
if (Info.size() == 1 && Info[0].first == KindID) {
getContext().pImpl->MetadataStore.erase(this);
- setHasMetadata(false);
+ setHasMetadataHashEntry(false);
return;
}
- // Handle replacement of an existing value.
+ // Handle removal of an existing value.
for (unsigned i = 0, e = Info.size(); i != e; ++i)
if (Info[i].first == KindID) {
Info[i] = Info.back();
@@ -518,8 +526,14 @@
}
MDNode *Instruction::getMetadataImpl(unsigned KindID) const {
+ // Handle 'dbg' as a special case since it is not stored in the hash table.
+ if (KindID == LLVMContext::MD_dbg)
+ return DbgInfo;
+
+ if (!hasMetadataHashEntry()) return 0;
+
LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
- assert(hasMetadata() && !Info.empty() && "Shouldn't have called this");
+ assert(!Info.empty() && "bit out of sync with hash table");
for (LLVMContextImpl::MDMapTy::iterator I = Info.begin(), E = Info.end();
I != E; ++I)
@@ -529,14 +543,22 @@
}
void Instruction::getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,
- MDNode*> > &Result)const {
- assert(hasMetadata() && getContext().pImpl->MetadataStore.count(this) &&
+ MDNode*> > &Result) const {
+ Result.clear();
+
+ // Handle 'dbg' as a special case since it is not stored in the hash table.
+ if (DbgInfo) {
+ Result.push_back(std::make_pair((unsigned)LLVMContext::MD_dbg, DbgInfo));
+ if (!hasMetadataHashEntry()) return;
+ }
+
+ assert(hasMetadataHashEntry() &&
+ getContext().pImpl->MetadataStore.count(this) &&
"Shouldn't have called this");
const LLVMContextImpl::MDMapTy &Info =
getContext().pImpl->MetadataStore.find(this)->second;
assert(!Info.empty() && "Shouldn't have called this");
- Result.clear();
Result.append(Info.begin(), Info.end());
// Sort the resulting array so it is stable.
@@ -547,7 +569,10 @@
/// removeAllMetadata - Remove all metadata from this instruction.
void Instruction::removeAllMetadata() {
assert(hasMetadata() && "Caller should check");
- getContext().pImpl->MetadataStore.erase(this);
- setHasMetadata(false);
+ DbgInfo = 0;
+ if (hasMetadataHashEntry()) {
+ getContext().pImpl->MetadataStore.erase(this);
+ setHasMetadataHashEntry(false);
+ }
}
More information about the llvm-branch-commits
mailing list