[llvm-commits] Patch to add flag in llvm-extract for including aliases in the extraction.

Jan Sjodin jan_sjodin at yahoo.com
Tue Oct 2 16:30:12 PDT 2012


It is useful for splitting modules, keeping the aliases and the functions/globals together without getting unrelated aliases in the mix. Combined with llvm-nm it becomes possible to extract a function and find out which aliases belong to it. 


- Jan


>________________________________
> From: Eric Christopher <echristo at gmail.com>
>To: Jan Sjodin <jan_sjodin at yahoo.com> 
>Cc: Chandler Carruth <chandlerc at google.com>; "llvm-commits at cs.uiuc.edu" <llvm-commits at cs.uiuc.edu> 
>Sent: Tuesday, October 2, 2012 2:34 PM
>Subject: Re: [llvm-commits] Patch to add flag in llvm-extract for including aliases in the extraction.
> 
>Seems like a bit of an odd use case. Do you have something that this would be
>useful for? (I.e. where you'd want to limit the aliases that you pull out?)
>
>-eric
>
>On Fri, Sep 28, 2012 at 3:08 PM, Jan Sjodin <jan_sjodin at yahoo.com> wrote:
>> Ok, The example is this (I just grabbed it from the test case):
>>
>> If I have the following functions and aliases:
>>
>> @a0foo = alias void ()* @foo
>>
>> define linkonce_odr void @foo() {
>>   ret void
>> }
>>
>> @a0a0bar = alias void ()* @a0bar
>> @a0bar = alias void ()* @bar
>>
>> define void @bar() {
>>   call void @foo()
>>   ret void
>> }
>>
>>
>> With llvm-extract -func bar we get:
>>
>> @a0foo = alias void ()* @foo
>> @a0a0bar = alias void ()* @a0bar
>> @a0bar = alias void ()* @bar
>>
>> define void @bar() {
>>   call void @foo()
>>   ret void
>> }
>>
>>
>> With llvm-extract -with-aliases -func bar we get:
>> @a0a0bar = alias void ()* @a0bar
>> @a0bar = alias void ()* @bar
>>
>> define void @bar() {
>>   call void @foo()
>>   ret void
>> }
>>
>> There is no a0foo since it is not an alias of something we want to extract.
>>
>> - Jan
>>
>>
>> ----- Original Message -----
>>> From: Eric Christopher <echristo at gmail.com>
>>> To: Jan Sjodin <jan_sjodin at yahoo.com>
>>> Cc: Chandler Carruth <chandlerc at google.com>; "llvm-commits at cs.uiuc.edu" <llvm-commits at cs.uiuc.edu>
>>> Sent: Friday, September 28, 2012 5:33 PM
>>> Subject: Re: [llvm-commits] Patch to add flag in llvm-extract for including aliases in the extraction.
>>>
>>>T his is what I was doing.
>>>
>>> So by documentation I mean in the llvm-extract documentation. If you
>>> could describe what you're trying to accomplish with the option by
>>> showing an example it'd be good.
>>>
>>> Thanks!
>>>
>>> -eric
>>>
>>> On Fri, Sep 28, 2012 at 2:22 PM, Jan Sjodin <jan_sjodin at yahoo.com> wrote:
>>>>  Since you diligently scan the mailing list, could you please review? :)
>>>>
>>>>  - Jan
>>>>
>>>>
>>>>  ________________________________
>>>>  From: Chandler Carruth <chandlerc at google.com>
>>>>  To: Jan Sjodin <jan_sjodin at yahoo.com>
>>>>  Cc: "Villmow, Micah" <Micah.Villmow at amd.com>; Duncan Sands
>>>>  <baldrick at free.fr>; "llvm-commits at cs.uiuc.edu"
>>> <llvm-commits at cs.uiuc.edu>
>>>>  Sent: Friday, September 28, 2012 5:07 PM
>>>>
>>>>  Subject: Re: [llvm-commits] Patch to add flag in llvm-extract for including
>>>>  aliases in the extraction.
>>>>
>>>>  On Fri, Sep 28, 2012 at 2:04 PM, Jan Sjodin <jan_sjodin at yahoo.com>
>>> wrote:
>>>>
>>>>  I don't see any complaints from anyone, so I will go ahead and commit
>>> this
>>>>  by the end of today, or tomorrow.
>>>>
>>>>
>>>>  That is *not* how commit-after-approval works. You need to get an actual
>>>>  review and explicit OK for your patches. Please don't abuse our
>>> development
>>>>  process...
>>>>
>>>>
>>>>
>>>>  - Jan
>>>>
>>>>  ________________________________
>>>>  From: Jan Sjodin <jan_sjodin at yahoo.com>
>>>>  To: "Villmow, Micah" <Micah.Villmow at amd.com>; Duncan Sands
>>>>  <baldrick at free.fr>; "llvm-commits at cs.uiuc.edu"
>>> <llvm-commits at cs.uiuc.edu>
>>>>  Sent: Tuesday, September 25, 2012 1:48 PM
>>>>
>>>>  Subject: Re: [llvm-commits] Patch to add flag in llvm-extract for including
>>>>  aliases in the extraction.
>>>>
>>>>  I tried that, but eraseFromParent makes the alias_iterator fail, since the
>>>>  underlying data structure is modified.
>>>>
>>>>
>>>>  - Jan
>>>>
>>>>
>>>>
>>>>  ----- Original Message -----
>>>>>  From: "Villmow, Micah" <Micah.Villmow at amd.com>
>>>>>  To: Jan Sjodin <jan_sjodin at yahoo.com>; Duncan Sands
>>> <baldrick at free.fr>;
>>>>>  "llvm-commits at cs.uiuc.edu" <llvm-commits at cs.uiuc.edu>
>>>>>  Cc:
>>>>>  Sent: Tuesday, September 25, 2012 11:34 AM
>>>>>  Subject: RE: [llvm-commits] Patch to add flag in llvm-extract for
>>>>>  including aliases in the extraction.
>>>>>
>>>>>  So, the patch itself looks fine in its current form, however is there
>>> not
>>>>>  a way
>>>>>  to delete the alias's without requiring to store them first?
>>>>>  Maybe something like this would work?
>>>>>  +static void extractAliases(Module* M,
>>>>>  +                           SetVector<GlobalValue *> &GVs) {+
>>>>>  +  // Find aliases to be erased
>>>>>  +  for (Module::alias_iterator I = M->alias_begin(), E =
>>> M->alias_end();
>>>>>  +       I != E; ) {
>>>>>  +    GlobalAlias *GA = I++;
>>>>>  +    GlobalValue *GV =
>>>>>  +
>>> const_cast<GlobalValue*>((GA).resolveAliasedGlobal(false));
>>>>>  +    if ((GVs.count(GV) != 0) == DeleteFn)
>>>>>  +      GA->eraseFromParent();
>>>>>  +  }
>>>>>  +}
>>>>>
>>>>>>   -----Original Message-----
>>>>>>   From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
>>>>>>  bounces at cs.uiuc.edu] On Behalf Of Jan Sjodin
>>>>>>   Sent: Tuesday, September 25, 2012 6:23 AM
>>>>>>   To: Duncan Sands; llvm-commits at cs.uiuc.edu
>>>>>>   Subject: Re: [llvm-commits] Patch to add flag in llvm-extract for
>>>>>>   including aliases in the extraction.
>>>>>>
>>>>>>   Ok. Re-ping-ping with patch!
>>>>>>
>>>>>>   - Jan
>>>>>>
>>>>>>   >________________________________
>>>>>>   > From: Duncan Sands <baldrick at free.fr>
>>>>>>   >To: llvm-commits at cs.uiuc.edu
>>>>>>   >Sent: Saturday, September 22, 2012 6:06 AM
>>>>>>   >Subject: Re: [llvm-commits] Patch to add flag in llvm-extract
>>> for
>>>>>>   including aliases in the extraction.
>>>>>>   >
>>>>>>   >On 21/09/12 17:36, Jan Sjodin wrote:
>>>>>>   >>
>>>>>>   >> Ping! Ping!
>>>>>>   >
>>>>>>   >Please supply the patch when you ping.
>>>>>>   >
>>>>>>   >Ciao, Duncan.
>>>>>>   >_______________________________________________
>>>>>>   >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
>>>>
>>>>
>>>>
>>>>  _______________________________________________
>>>>  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