[cfe-dev] Serializing conflicting replacements
Roman Popov via cfe-dev
cfe-dev at lists.llvm.org
Thu Sep 28 11:11:12 PDT 2017
Thanks for response!
Yes, this was my impression that I will have to track dependencies and
merge them myself.
So I will start with simplest option of running a tool multiple times. And
If it works will later look on single-pass solution.
2017-09-28 1:10 GMT-07:00 Manuel Klimek <klimek at google.com>:
> On Wed, Sep 27, 2017 at 8:06 PM Roman Popov via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> Hi all,
>> I need to write a tool that will convert stackful coroutine to stackless.
>> One of the required refactorings is inlining all functions that call yield
>> into a coroutine body.
>>
>> Here is an example of required refactoring:
>>
>> Input source code:
>>
>> void foo() { /*foo*/ yield(); }
>>
>> void bar() { /*bar*/ foo(); }
>>
>> void coroutine_body() {
>> bar();
>> }
>>
>> Expected output code from tool:
>>
>> void coroutine_body() {
>> /*bar*/
>> /*foo*/
>> yield();
>> }
>>
>>
>> So when I run the tool it will create two conflicting replacements:
>>
>> - inline foo into bar
>> - inline bar into coroutine_body
>>
>>
>> Is it possible to apply them one after another using current Clang
>> libraries? Or it is not supported out-of-the-box and I should better run
>> tool N times to inline all functions one-by-one without generating
>> conflicting replacements?
>>
>
> We do have Replacements::merge(), but the merged replacements need to be
> relative to the new code after applying the original replacements, so
> that's not fully helping.
> I think running the tool multiple times is probably simplest, but it's
> also possible to build up the dependency chain of your replacements
> yourself, and then creating one large replacement in the end from the dep
> tree.
>
>
>>
>> Thanks,
>> Roman
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170928/cc00b7e6/attachment.html>
More information about the cfe-dev
mailing list