[PATCH] D31100: [LTO] Allow client to skip code gen

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 16:16:42 PDT 2017


On Fri, Mar 17, 2017 at 2:09 PM, Teresa Johnson <tejohnson at google.com>
wrote:

>
>
> On Fri, Mar 17, 2017 at 2:05 PM, Peter Collingbourne <peter at pcc.me.uk>
> wrote:
>
>> Can you achieve this by setting PreCodeGenModuleHook to a function that
>> returns false?
>>
>
> I thought about that, but it seemed clearer to be explicit about the
> intent. I thought the intended purpose of returning when a hook returned
> false was that it was to flag error conditions?
>

Sorry for dropping the ball on this thread.

The purpose is to allow the client to interrupt the flow for any reason.
See for example http://llvm-cs.pcc.me.uk/tools/gold/gold-plugin.cpp#757 for
how this feature is used in the gold plugin. -emit-llvm is very similar to
that use case.

Peter


>
> Teresa
>
>
>> Peter
>>
>>
>> On Mar 17, 2017 14:01, "Teresa Johnson via Phabricator" <
>> reviews at reviews.llvm.org> wrote:
>>
>> tejohnson created this revision.
>> Herald added a subscriber: mehdi_amini.
>>
>> This is useful when invoking the ThinLTO backend via clang, which
>> already has handling (immediately after the existing early return
>> when invoking the ThinLTO backend) for setting up the requested code
>> generation.
>>
>> We noticed that when invoking the thinBackend via clang (for the
>> distributed build case) that flags like -ffunction-sections and
>> -emit-llvm were not having the intended effect. This could have been
>> fixed by setting up the TargetOptions and the CodeGenFileType in the LTO
>> Config, but since clang already has handling for all of this, it is
>> straightforward to just let it do the handling.
>>
>>
>> https://reviews.llvm.org/D31100
>>
>> Files:
>>   include/llvm/LTO/Config.h
>>   lib/LTO/LTOBackend.cpp
>>
>>
>> Index: lib/LTO/LTOBackend.cpp
>> ===================================================================
>> --- lib/LTO/LTOBackend.cpp
>> +++ lib/LTO/LTOBackend.cpp
>> @@ -269,6 +269,9 @@
>>    if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task,
>> Mod))
>>      return;
>>
>> +  if (Conf.SkipCodeGen)
>> +    return;
>> +
>>    auto Stream = AddStream(Task);
>>    legacy::PassManager CodeGenPasses;
>>    if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS,
>> Conf.CGFileType))
>> Index: include/llvm/LTO/Config.h
>> ===================================================================
>> --- include/llvm/LTO/Config.h
>> +++ include/llvm/LTO/Config.h
>> @@ -49,6 +49,9 @@
>>    /// Disable entirely the optimizer, including importing for ThinLTO
>>    bool CodeGenOnly = false;
>>
>> +  /// Skip code generation, the client is responsible for it.
>> +  bool SkipCodeGen = false;
>> +
>>    /// If this field is set, the set of passes run in the middle-end
>> optimizer
>>    /// will be the one specified by the string. Only works with the new
>> pass
>>    /// manager as the old one doesn't have this ability.
>>
>>
>>
>>
>
>
> --
> Teresa Johnson |  Software Engineer |  tejohnson at google.com |
> 408-460-2413 <(408)%20460-2413>
>



-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170330/62ec25b6/attachment.html>


More information about the llvm-commits mailing list