<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 6, 2013 at 11:27 AM, Manman Ren <span dir="ltr"><<a href="mailto:manman.ren@gmail.com" target="_blank">manman.ren@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mren<br>
Date: Fri Sep 6 13:27:00 2013<br>
New Revision: 190188<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=190188&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=190188&view=rev</a><br>
Log:<br>
Debug Info: Move a helper function getTypeIdentifier from DIBuilder to be part<br>
of DIType.<br>
<br>
Implement DIType::generateRef to return a type reference. This function will be<br>
used in setContaintingType and in DIBuilder to generete the type reference.<br>
<br>
No functionality change.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/DebugInfo.h<br>
llvm/trunk/lib/IR/DIBuilder.cpp<br>
llvm/trunk/lib/IR/DebugInfo.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=190188&r1=190187&r2=190188&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=190188&r1=190187&r2=190188&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo.h Fri Sep 6 13:27:00 2013<br>
@@ -155,20 +155,6 @@ namespace llvm {<br>
template <><br>
DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;<br>
<br>
- /// Represents reference to a DIType, abstracts over direct and<br>
- /// identifier-based metadata type references.<br>
- class DITypeRef {<br>
- template <typename DescTy><br>
- friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const;<br>
-<br>
- /// TypeVal can be either a MDNode or a MDString, in the latter,<br>
- /// MDString specifies the type identifier.<br>
- const Value *TypeVal;<br>
- explicit DITypeRef(const Value *V);<br>
- public:<br>
- DIType resolve(const DITypeIdentifierMap &Map) const;<br>
- };<br>
-<br>
/// DISubrange - This is used to represent ranges, for array bounds.<br>
class DISubrange : public DIDescriptor {<br>
friend class DIDescriptor;<br>
@@ -285,12 +271,32 @@ namespace llvm {<br>
/// isUnsignedDIType - Return true if type encoding is unsigned.<br>
bool isUnsignedDIType();<br>
<br>
+ /// Generate a reference to this DIType. Uses the type identifier instead<br>
+ /// of the actual MDNode if possible, to help type uniquing.<br>
+ DITypeRef generateRef();<br></blockquote><div><br>'getTypeRef() const;' perhaps? (open to further/other bikeshedding)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
/// replaceAllUsesWith - Replace all uses of debug info referenced by<br>
/// this descriptor.<br>
void replaceAllUsesWith(DIDescriptor &D);<br>
void replaceAllUsesWith(MDNode *D);<br>
};<br>
<br>
+ /// Represents reference to a DIType, abstracts over direct and<br>
+ /// identifier-based metadata type references.<br>
+ class DITypeRef {<br>
+ template <typename DescTy><br>
+ friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const;<br>
+ friend DITypeRef DIType::generateRef();<br>
+<br>
+ /// TypeVal can be either a MDNode or a MDString, in the latter,<br>
+ /// MDString specifies the type identifier.<br>
+ const Value *TypeVal;<br>
+ explicit DITypeRef(const Value *V);<br>
+ public:<br>
+ DIType resolve(const DITypeIdentifierMap &Map) const;<br>
+ operator Value *() const { return const_cast<Value*>(TypeVal); }<br>
+ };<br>
+<br>
/// DIBasicType - A basic type, like 'int' or 'float'.<br>
class DIBasicType : public DIType {<br>
public:<br>
<br>
Modified: llvm/trunk/lib/IR/DIBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=190188&r1=190187&r2=190188&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=190188&r1=190187&r2=190188&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)<br>
+++ llvm/trunk/lib/IR/DIBuilder.cpp Fri Sep 6 13:27:00 2013<br>
@@ -75,18 +75,6 @@ void DIBuilder::finalize() {<br>
DIType(TempImportedModules).replaceAllUsesWith(IMs);<br>
}<br>
<br>
-/// Use the type identifier instead of the actual MDNode if possible,<br>
-/// to help type uniquing. This function returns the identifier if it<br>
-/// exists for the given type, otherwise returns the MDNode.<br>
-static Value *getTypeIdentifier(DIType T) {<br>
- if (!T.isCompositeType())<br>
- return T;<br>
- DICompositeType DTy(T);<br>
- if (!DTy.getIdentifier())<br>
- return T;<br>
- return DTy.getIdentifier();<br>
-}<br>
-<br>
/// getNonCompileUnitScope - If N is compile unit return NULL otherwise return<br>
/// N.<br>
static MDNode *getNonCompileUnitScope(MDNode *N) {<br>
@@ -334,7 +322,7 @@ DIDerivedType DIBuilder::createMemberPoi<br>
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset<br>
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags<br>
PointeeTy,<br>
- getTypeIdentifier(Base)<br>
+ Base.generateRef()<br>
};<br>
return DIDerivedType(MDNode::get(VMContext, Elts));<br>
}<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=190188&r1=190187&r2=190188&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=190188&r1=190187&r2=190188&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Fri Sep 6 13:27:00 2013<br>
@@ -707,6 +707,17 @@ void DICompositeType::addMember(DIDescri<br>
setTypeArray(DIArray(MDNode::get(DbgNode->getContext(), M)));<br>
}<br>
<br>
+/// Generate a reference to this DIType. Uses the type identifier instead<br>
+/// of the actual MDNode if possible, to help type uniquing.<br>
+DITypeRef DIType::generateRef() {<br>
+ if (!isCompositeType())<br>
+ return DITypeRef(*this);<br>
+ DICompositeType DTy(DbgNode);<br>
+ if (!DTy.getIdentifier())<br>
+ return DITypeRef(*this);<br>
+ return DITypeRef(DTy.getIdentifier());<br>
+}<br>
+<br>
/// \brief Set the containing type.<br>
void DICompositeType::setContainingType(DICompositeType ContainingType) {<br>
TrackingVH<MDNode> N(*this);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>