[llvm] r304177 - [TableGen] Introduce DagInit::getArgs that returns an ArrayRef. Use it to fix 80 column violations in arg_begin/arg_end. Remove DagInit::args and use getArgs instead. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 11:52:54 PDT 2017


There are two sets of TrailingObject arrays in the DAGInit. I think
trailing objects doesn't traverse the hierarchy for its object tagging. So
the StringInit* and the Init* getTrailingObjects calls are getting
different arrays.

~Craig

On Mon, Jun 5, 2017 at 11:49 AM, David Blaikie <dblaikie at gmail.com> wrote:

> If the trailing objects are StringInit*, then creating an ArrayRef of
> Init* from them is, I think, equivalent to this code:
>
> StringInit* s;
> Init* const *i = s;
>
> Which, I think, isn't valid - a pointer to an Init* isn't a pointer to a
> StringInit* even though the latter can be converted to the former (eg:
> while it might not be the case here, in general a pointer to base might be
> at some offset compared to a pointer to derived (if multiple inheritance is
> used), so a base* isn't a derived* even though they can be coverted between)
>
> On Mon, Jun 5, 2017 at 11:43 AM Craig Topper <craig.topper at gmail.com>
> wrote:
>
>> I didn't follow.
>>
>> ~Craig
>>
>> On Mon, Jun 5, 2017 at 11:34 AM, David Blaikie <dblaikie at gmail.com>
>> wrote:
>>
>>>
>>>
>>> On Mon, May 29, 2017 at 2:49 PM Craig Topper via llvm-commits <
>>> llvm-commits at lists.llvm.org> wrote:
>>>
>>>> Author: ctopper
>>>> Date: Mon May 29 16:49:34 2017
>>>> New Revision: 304177
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=304177&view=rev
>>>> Log:
>>>> [TableGen] Introduce DagInit::getArgs that returns an ArrayRef. Use it
>>>> to fix 80 column violations in arg_begin/arg_end. Remove DagInit::args and
>>>> use getArgs instead. NFC
>>>>
>>>> Modified:
>>>>     llvm/trunk/include/llvm/TableGen/Record.h
>>>>     llvm/trunk/lib/TableGen/Record.cpp
>>>>     llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
>>>>
>>>> Modified: llvm/trunk/include/llvm/TableGen/Record.h
>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
>>>> llvm/TableGen/Record.h?rev=304177&r1=304176&r2=304177&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- llvm/trunk/include/llvm/TableGen/Record.h (original)
>>>> +++ llvm/trunk/include/llvm/TableGen/Record.h Mon May 29 16:49:34 2017
>>>> @@ -1189,6 +1189,9 @@ public:
>>>>      return Init ? Init->getValue() : StringRef();
>>>>    }
>>>>
>>>> +  ArrayRef<Init *> getArgs() const {
>>>> +    return makeArrayRef(getTrailingObjects<Init *>(), NumArgs);
>>>>
>>>
>>> Wouldn't this be an aliasing violation? Init* const * can't point to a
>>> StringInit*, can it?
>>>
>>>
>>>> +  }
>>>>    ArrayRef<StringInit *> getArgNames() const {
>>>>      return makeArrayRef(getTrailingObjects<StringInit *>(),
>>>> NumArgNames);
>>>>    }
>>>> @@ -1200,19 +1203,16 @@ public:
>>>>    typedef SmallVectorImpl<Init*>::const_iterator
>>>>  const_arg_iterator;
>>>>    typedef SmallVectorImpl<StringInit*>::const_iterator
>>>> const_name_iterator;
>>>>
>>>> -  inline const_arg_iterator  arg_begin() const { return
>>>> getTrailingObjects<Init *>(); }
>>>> -  inline const_arg_iterator  arg_end  () const { return arg_begin() +
>>>> NumArgs;   }
>>>> -  inline iterator_range<const_arg_iterator> args() const {
>>>> -    return llvm::make_range(arg_begin(), arg_end());
>>>> -  }
>>>> +  inline const_arg_iterator  arg_begin() const { return
>>>> getArgs().begin(); }
>>>> +  inline const_arg_iterator  arg_end  () const { return
>>>> getArgs().end(); }
>>>>
>>>> -  inline size_t              arg_size () const { return NumArgs;  }
>>>> +  inline size_t              arg_size () const { return NumArgs; }
>>>>    inline bool                arg_empty() const { return NumArgs == 0; }
>>>>
>>>> -  inline const_name_iterator name_begin() const { return
>>>> getTrailingObjects<StringInit *>(); }
>>>> -  inline const_name_iterator name_end  () const { return name_begin()
>>>> + NumArgNames;   }
>>>> +  inline const_name_iterator name_begin() const { return
>>>> getArgNames().begin();}
>>>> +  inline const_name_iterator name_end  () const { return
>>>> getArgNames().end(); }
>>>>
>>>> -  inline size_t              name_size () const { return NumArgNames;
>>>> }
>>>> +  inline size_t              name_size () const { return NumArgNames; }
>>>>    inline bool                name_empty() const { return NumArgNames
>>>> == 0; }
>>>>
>>>>    Init *getBit(unsigned Bit) const override {
>>>>
>>>> Modified: llvm/trunk/lib/TableGen/Record.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
>>>> TableGen/Record.cpp?rev=304177&r1=304176&r2=304177&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- llvm/trunk/lib/TableGen/Record.cpp (original)
>>>> +++ llvm/trunk/lib/TableGen/Record.cpp Mon May 29 16:49:34 2017
>>>> @@ -1540,7 +1540,7 @@ Init *DagInit::resolveReferences(Record
>>>>    SmallVector<Init*, 8> NewArgs;
>>>>    NewArgs.reserve(arg_size());
>>>>    bool ArgsChanged = false;
>>>> -  for (const Init *Arg : args()) {
>>>> +  for (const Init *Arg : getArgs()) {
>>>>      Init *NewArg = Arg->resolveReferences(R, RV);
>>>>      NewArgs.push_back(NewArg);
>>>>      ArgsChanged |= NewArg != Arg;
>>>>
>>>> Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/
>>>> TableGen/GlobalISelEmitter.cpp?rev=304177&r1=304176&r2=304177&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
>>>> +++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Mon May 29
>>>> 16:49:34 2017
>>>> @@ -1602,7 +1602,7 @@ Expected<BuildMIAction &> GlobalISelEmit
>>>>
>>>>  Error GlobalISelEmitter::importDefaultOperandRenderers(
>>>>      BuildMIAction &DstMIBuilder, DagInit *DefaultOps) const {
>>>> -  for (const auto *DefaultOp : DefaultOps->args()) {
>>>> +  for (const auto *DefaultOp : DefaultOps->getArgs()) {
>>>>      // Look through ValueType operators.
>>>>      if (const DagInit *DefaultDagOp = dyn_cast<DagInit>(DefaultOp)) {
>>>>        if (const DefInit *DefaultDagOperator =
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170605/385d0650/attachment.html>


More information about the llvm-commits mailing list