[cfe-dev] Compile .ll file with coroutines intrinsics

Mehdi AMINI via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 8 17:13:16 PDT 2021


On Thu, Jul 8, 2021 at 4:40 PM Xun Li <lxfind at gmail.com> wrote:

> Not sure if I fully understand the question. Do you have a full
> example of what you expect but doesn't work?
> Are you trying to compile C++ code that uses coroutines, or are you
> trying to use opt to compile an .ll file?
>

I'm trying to compile IR (.ll or .bc) file: clang support IR as *input* as
well.

So for example with the case you mention:

clang -emit-llvm  -c    -O3  -Xclang -disable-llvm-passes
clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp -std=c++20 -o
coro.bc

This gets me a nice coro.bc file, but I have no way to compile this with
clang right now, it will always crash:

$ clang -c coro.bc
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang -c coro.bc
1. Code generation
2. Running pass 'Function Pass Manager' on module 'coro.bc'.
3. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z3foov'
Segmentation fault





> There are some coroutine tests in Clang that you could also take a
> look for reference:
>
> https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp
>
> On Thu, Jul 8, 2021 at 4:15 PM Mehdi AMINI <joker.eph at gmail.com> wrote:
> >
> >
> >
> >
> > On Thu, Jul 8, 2021 at 3:55 PM David Blaikie <dblaikie at gmail.com> wrote:
> >>
> >> Guessing you might need to cc/to this to some folks who worked
> on/implemented the features - lots of folks don't read the -dev lists
> terribly much these days, unfortunately.
> >
> >
> > Good suggestion, adding a few folks here.
> >
> >>
> >>
> >> My guess would be: It's difficult because we've essentially fragmented
> the IR and now we have before-coroutines-are-lowered IR and
> after-coroutines-are-lowered IR and no way to tell the difference & I guess
> the support for IR inputs in clang is currently (probably by accident) only
> supporting after-coroutines-are-lowered.
> >
> >
> > Right: but can you feed the IR post-lowering and reprocess it through
> the coroutine lowering passes? I would expect this to be idempotent somehow.
> >
> > Even if it isn't the case, I assume that adding support for the
> -fcoroutines-ts option when processing IR files should be fine: the IR
> post-lowering can just not use the flag.
> >
> > Thanks,
> >
> > --
> > Mehdi
> >
> >>
> >>
> >> On Thu, Jul 8, 2021 at 3:23 PM Mehdi AMINI via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> >>>
> >>>
> >>>
> >>> On Fri, Jul 2, 2021 at 10:25 PM Mehdi AMINI <joker.eph at gmail.com>
> wrote:
> >>>>
> >>>> Hi all,
> >>>>
> >>>> I'm trying to figure out how to use clang to compile some piece of IR
> in a .ll generated with coroutines.
> >>>>
> >>>> I tried to use the `-fcoroutines-ts`, but it isn't even forwarded by
> the driver to CC1. And even if I use -Xclang to forward it manually it is
> then ignored because LLVM IR input is shortcut by
> CompilerInvocation::ParseLangArgs.
> >>>>
> >>>> What's the best way here? I could add support in
> CompilerInvocation::ParseLangArgs:
> >>>>
> >>>> @@ -3547,6 +3546,9 @@ bool CompilerInvocation::ParseLangArgs(L
> >>>>      parseSanitizerKinds("-fsanitize=",
> Args.getAllArgValues(OPT_fsanitize_EQ),
> >>>>                          Diags, Opts.Sanitize);
> >>>>
> >>>> +    // Allows to use -fcoroutine-ts with IR input.
> >>>> +    Opts.Coroutines = Args.hasArg(OPT_fcoroutines_ts);
> >>>> +
> >>>>      return Diags.getNumErrors() == NumErrorsBefore;
> >>>>    }
> >>>>
> >>>>
> >>>> But I still need to figure out how to have the driver propagate the
> option to cc1, any pointer?
> >>>> Is it expected to silently discard it here by the way? It is quite
> surprising to me).
> >>>
> >>>
> >>> Ping on these questions? Anyone want to chime in?
> >>>
> >>> Cheers,
> >>>
> >>> --
> >>> Mehdi
> >>> _______________________________________________
> >>> cfe-dev mailing list
> >>> cfe-dev at lists.llvm.org
> >>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
>
> --
> Xun
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210708/669d256e/attachment.html>


More information about the cfe-dev mailing list