diff options
| author | Dan Gohman <gohman@apple.com> | 2010-08-20 22:02:26 +0000 | 
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-08-20 22:02:26 +0000 | 
| commit | 16a5d98c3ad695cc5a181b2f495324ced027e7be (patch) | |
| tree | 1673dcfeecd28b5f499fe4325d181336a2ad66fc /llvm/lib/Analysis/DebugInfo.cpp | |
| parent | 662f05a035a0443a9f0c6b9f75309373c7da7792 (diff) | |
| download | llvm-16a5d98c3ad695cc5a181b2f495324ced027e7be.zip llvm-16a5d98c3ad695cc5a181b2f495324ced027e7be.tar.gz llvm-16a5d98c3ad695cc5a181b2f495324ced027e7be.tar.bz2  | |
Introduce a new temporary MDNode concept. Temporary MDNodes are
not part of the IR, are not uniqued, and may be safely RAUW'd.
This replaces a variety of alternate mechanisms for achieving
the same effect.
llvm-svn: 111681
Diffstat (limited to 'llvm/lib/Analysis/DebugInfo.cpp')
| -rw-r--r-- | llvm/lib/Analysis/DebugInfo.cpp | 16 | 
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index 1b9008c..065a00a 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -22,6 +22,7 @@  #include "llvm/Analysis/ValueTracking.h"  #include "llvm/ADT/SmallPtrSet.h"  #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/STLExtras.h"  #include "llvm/Support/Debug.h"  #include "llvm/Support/Dwarf.h"  #include "llvm/Support/raw_ostream.h" @@ -260,7 +261,7 @@ unsigned DIArray::getNumElements() const {  /// replaceAllUsesWith - Replace all uses of debug info referenced by  /// this descriptor. -void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) { +void DIType::replaceAllUsesWith(DIDescriptor &D) {    if (!DbgNode)      return; @@ -274,6 +275,7 @@ void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) {      const MDNode *DN = D;      const Value *V = cast_or_null<Value>(DN);      Node->replaceAllUsesWith(const_cast<Value*>(V)); +    MDNode::deleteTemporary(Node);    }  } @@ -934,6 +936,18 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag,  } +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIFactory::CreateTemporaryType(DIDescriptor Context) { +  // Give the temporary MDNode a tag. It doesn't matter what tag we +  // use here as long as DIType accepts it. +  Value *Elts[] = { +    GetTagConstant(DW_TAG_base_type) +  }; +  MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); +  return DIType(Node); +} + +  /// CreateCompositeType - Create a composite type like array, struct, etc.  DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag,                                                   DIDescriptor Context,  | 
