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