[Patch] Options: use TableGen to build PrefixesUnion (Was: Re: [cfe-commits] r166444 - in /cfe/trunk: include/clang/Driver/ lib/Driver/ lib/Frontend/ utils/TableGen/)

Hans Wennborg hans at chromium.org
Mon Jul 15 14:20:25 PDT 2013


Adding a patch for lld, which is the other user of OptTable.

Thanks,
Hans

On Thu, Jul 11, 2013 at 5:26 PM, Hans Wennborg <hans at chromium.org> wrote:
> Hi,
>
> I have a patch (split into three steps since it goes across
> clang/llvm) that fixes this.
>
> Please take a look!
>
> Thanks,
> Hans
>
> On Fri, Mar 15, 2013 at 12:16 PM, Daniel Dunbar <daniel at zuster.org> wrote:
>> Hi Michael,
>>
>> I just happened to notice one thing about this patch that is suboptimal.
>> This code:
>> --
>>   // Build prefixes.
>>   for (unsigned i = FirstSearchableIndex + 1, e = getNumOptions() + 1;
>>                 i != e; ++i) {
>>     if (const char *const *P = getInfo(i).Prefixes) {
>>       for (; *P != 0; ++P) {
>>         PrefixesUnion.insert(*P);
>>       }
>>     }
>>   }
>> --
>> does a lot of runtime computation (relatively) for very little value.
>>
>> Could you fix these two structures (PrefixesUnion and PrefixChars) to be
>> computed by the tblgen pass?
>>
>>  - Daniel
>>
>>
>>
>> On Mon, Oct 22, 2012 at 3:13 PM, Michael J. Spencer <bigcheesegs at gmail.com>
>> wrote:
>>>
>>> Author: mspencer
>>> Date: Mon Oct 22 17:13:48 2012
>>> New Revision: 166444
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=166444&view=rev
>>> Log:
>>> [Options] Add prefixes to options.
>>>
>>> Each option has a set of prefixes. When matching an argument such as
>>> -funroll-loops. First the leading - is removed as it is a prefix. Then
>>> a lower_bound search for "funroll-loops" is done against the option table
>>> by
>>> option name. From there each option prefix + option name combination is
>>> tested
>>> against the argument.
>>>
>>> This allows us to support Microsoft style options where both / and - are
>>> valid
>>> prefixes. It also simplifies the cases we already have where options come
>>> in
>>> both - and -- forms. Almost every option for gnu-ld happens to have this
>>> form.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2b-lld-pass-in-tablegenned-prefixesunion.patch
Type: application/octet-stream
Size: 4084 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130715/95bd7841/attachment.obj>


More information about the cfe-commits mailing list