[llvm] r214112 - [Debug Info] rename getTypeArray to getElements, setTypeArray to setArrays.

Eric Christopher echristo at gmail.com
Tue Jul 29 09:38:24 PDT 2014


On Tue, Jul 29, 2014 at 9:35 AM, David Blaikie <dblaikie at gmail.com> wrote:
> On Mon, Jul 28, 2014 at 4:13 PM, Eric Christopher <echristo at gmail.com> wrote:
>> On Mon, Jul 28, 2014 at 12:14 PM, Manman Ren <manman.ren at gmail.com> wrote:
>>> Author: mren
>>> Date: Mon Jul 28 14:14:13 2014
>>> New Revision: 214112
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=214112&view=rev
>>> Log:
>>> [Debug Info] rename getTypeArray to getElements, setTypeArray to setArrays.
>>>
>>> This is the second of a series of patches to handle type uniqueing of the
>>> type array for a subroutine type.
>>>
>>> For vector and array types, getElements returns the array of subranges, so it
>>> is a better name than getTypeArray. Even for class, struct and enum types,
>>> getElements returns the members, which can be subprograms.
>>>
>>> setArrays can set up to two arrays, the second is the templates.
>>
>> setArrays as a name seems to be a bit lacking in descriptive power.
>> Can you perhaps either split the routine or maybe "setElements" or
>> something?
>
> I had the same thought, though I'm not sure setElements is an
> improvement. It would be at least symmetric with getElements (except
> that setArrays sets two different arrays). Probably splitting it into
> two and naming them setElements and setTemplateArguments would make
> the most sense for now. Maybe "elements" can be made more precise
> later if we figure out something better.
>
> The "elements" list includes base classes, fields, and member
> functions - so it's a bit of a grab bag (& maybe other things for
> other types? The subscripts in an array, is it?), hard to have a very
> precise name.
>

Yeah, my "big" function naming issue was setArrays. Not that it wasn't
like that before, but... sounds like we agree though.

-eric

>> Just thinking out loud, but it's not very clear.
>>
>> -eric
>>
>>>
>>> This commit should have no functionality change.
>>>
>>> Modified:
>>>     llvm/trunk/include/llvm/IR/DebugInfo.h
>>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>>>     llvm/trunk/lib/IR/DebugInfo.cpp
>>>     llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp
>>>
>>> Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=214112&r1=214111&r2=214112&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
>>> +++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Jul 28 14:14:13 2014
>>> @@ -425,8 +425,8 @@ class DICompositeType : public DIDerived
>>>  public:
>>>    explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {}
>>>
>>> -  DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
>>> -  void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
>>> +  DIArray getElements() const { return getFieldAs<DIArray>(10); }
>>> +  void setArrays(DIArray Elements, DIArray TParams = DIArray());
>>>    unsigned getRunTimeLang() const { return getUnsignedField(11); }
>>>    DITypeRef getContainingType() const { return getFieldAs<DITypeRef>(12); }
>>>    void setContainingType(DICompositeType ContainingType);
>>>
>>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=214112&r1=214111&r2=214112&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jul 28 14:14:13 2014
>>> @@ -150,7 +150,7 @@ DIType DbgVariable::getType() const {
>>>      if (tag == dwarf::DW_TAG_pointer_type)
>>>        subType = resolve(DIDerivedType(Ty).getTypeDerivedFrom());
>>>
>>> -    DIArray Elements = DICompositeType(subType).getTypeArray();
>>> +    DIArray Elements = DICompositeType(subType).getElements();
>>>      for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
>>>        DIDerivedType DT(Elements.getElement(i));
>>>        if (getName() == DT.getName())
>>> @@ -468,7 +468,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(
>>>
>>>      // If this is a variadic function, add an unspecified parameter.
>>>      DISubprogram SP(Scope->getScopeNode());
>>> -    DIArray FnArgs = SP.getType().getTypeArray();
>>> +    DIArray FnArgs = SP.getType().getElements();
>>>      if (FnArgs.getElement(FnArgs.getNumElements() - 1)
>>>              .isUnspecifiedParameter()) {
>>>        Children.push_back(
>>>
>>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=214112&r1=214111&r2=214112&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon Jul 28 14:14:13 2014
>>> @@ -690,7 +690,7 @@ void DwarfUnit::addBlockByrefAddress(con
>>>
>>>    // Find the __forwarding field and the variable field in the __Block_byref
>>>    // struct.
>>> -  DIArray Fields = blockStruct.getTypeArray();
>>> +  DIArray Fields = blockStruct.getElements();
>>>    DIDerivedType varField;
>>>    DIDerivedType forwardingField;
>>>
>>> @@ -1161,7 +1161,7 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
>>>      break;
>>>    case dwarf::DW_TAG_subroutine_type: {
>>>      // Add return type. A void return won't have a type.
>>> -    DIArray Elements = CTy.getTypeArray();
>>> +    DIArray Elements = CTy.getElements();
>>>      DIType RTy(Elements.getElement(0));
>>>      if (RTy)
>>>        addType(Buffer, RTy);
>>> @@ -1191,7 +1191,7 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
>>>    case dwarf::DW_TAG_union_type:
>>>    case dwarf::DW_TAG_class_type: {
>>>      // Add elements to structure type.
>>> -    DIArray Elements = CTy.getTypeArray();
>>> +    DIArray Elements = CTy.getElements();
>>>      for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
>>>        DIDescriptor Element = Elements.getElement(i);
>>>        if (Element.isSubprogram())
>>> @@ -1456,7 +1456,7 @@ void DwarfUnit::applySubprogramAttribute
>>>    assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
>>>           "the type of a subprogram should be a subroutine");
>>>
>>> -  DIArray Args = SPTy.getTypeArray();
>>> +  DIArray Args = SPTy.getElements();
>>>    // Add a return type. If this is a type like a C/C++ void type we don't add a
>>>    // return type.
>>>    if (Args.getElement(0))
>>> @@ -1740,7 +1740,7 @@ void DwarfUnit::constructArrayTypeDIE(DI
>>>    }
>>>
>>>    // Add subranges to array type.
>>> -  DIArray Elements = CTy.getTypeArray();
>>> +  DIArray Elements = CTy.getElements();
>>>    for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
>>>      DIDescriptor Element = Elements.getElement(i);
>>>      if (Element.getTag() == dwarf::DW_TAG_subrange_type)
>>> @@ -1750,7 +1750,7 @@ void DwarfUnit::constructArrayTypeDIE(DI
>>>
>>>  /// constructEnumTypeDIE - Construct an enum type DIE from DICompositeType.
>>>  void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy) {
>>> -  DIArray Elements = CTy.getTypeArray();
>>> +  DIArray Elements = CTy.getElements();
>>>
>>>    // Add enumerators to enumeration type.
>>>    for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
>>>
>>> Modified: llvm/trunk/lib/IR/DebugInfo.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=214112&r1=214111&r2=214112&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/IR/DebugInfo.cpp (original)
>>> +++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Jul 28 14:14:13 2014
>>> @@ -676,7 +676,7 @@ static void VerifySubsetOf(const MDNode
>>>  #endif
>>>
>>>  /// \brief Set the array of member DITypes.
>>> -void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
>>> +void DICompositeType::setArrays(DIArray Elements, DIArray TParams) {
>>>    assert((!TParams || DbgNode->getNumOperands() == 15) &&
>>>           "If you're setting the template parameters this should include a slot "
>>>           "for that!");
>>> @@ -1064,7 +1064,7 @@ void DebugInfoFinder::processType(DIType
>>>    if (DT.isCompositeType()) {
>>>      DICompositeType DCT(DT);
>>>      processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
>>> -    DIArray DA = DCT.getTypeArray();
>>> +    DIArray DA = DCT.getElements();
>>>      for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
>>>        DIDescriptor D = DA.getElement(i);
>>>        if (D.isType())
>>> @@ -1347,7 +1347,7 @@ void DIDerivedType::printInternal(raw_os
>>>
>>>  void DICompositeType::printInternal(raw_ostream &OS) const {
>>>    DIType::printInternal(OS);
>>> -  DIArray A = getTypeArray();
>>> +  DIArray A = getElements();
>>>    OS << " [" << A.getNumElements() << " elements]";
>>>  }
>>>
>>>
>>> Modified: llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp?rev=214112&r1=214111&r2=214112&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp (original)
>>> +++ llvm/trunk/lib/Transforms/Instrumentation/DebugIR.cpp Mon Jul 28 14:14:13 2014
>>> @@ -396,7 +396,7 @@ private:
>>>          Elements.push_back(getOrCreateType(T->getStructElementType(i)));
>>>
>>>        // set struct elements
>>> -      StructDescriptor.setTypeArray(Builder.getOrCreateArray(Elements));
>>> +      StructDescriptor.setArrays(Builder.getOrCreateArray(Elements));
>>>      } else if (T->isPointerTy()) {
>>>        Type *PointeeTy = T->getPointerElementType();
>>>        if (!(N = getType(PointeeTy)))
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list