<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 8, 2021 at 6:56 PM John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On 8 Jul 2021, at 20:13, Mehdi AMINI wrote:<br>
> On Thu, Jul 8, 2021 at 4:40 PM Xun Li <<a href="mailto:lxfind@gmail.com" target="_blank">lxfind@gmail.com</a>> wrote:<br>
><br>
>> Not sure if I fully understand the question. Do you have a full<br>
>> example of what you expect but doesn't work?<br>
>> Are you trying to compile C++ code that uses coroutines, or are you<br>
>> trying to use opt to compile an .ll file?<br>
>><br>
><br>
> I'm trying to compile IR (.ll or .bc) file: clang support IR as *input* as<br>
> well.<br>
><br>
> So for example with the case you mention:<br>
><br>
> clang -emit-llvm  -c    -O3  -Xclang -disable-llvm-passes<br>
> clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp -std=c++20 -o<br>
> coro.bc<br>
><br>
> This gets me a nice coro.bc file, but I have no way to compile this with<br>
> clang right now, it will always crash:<br>
><br>
> $ clang -c coro.bc<br>
> PLEASE submit a bug report to <a href="https://bugs.llvm.org/" rel="noreferrer" target="_blank">https://bugs.llvm.org/</a> and include the crash<br>
> backtrace, preprocessed source, and associated run script.<br>
> Stack dump:<br>
> 0. Program arguments: clang -c coro.bc<br>
> 1. Code generation<br>
> 2. Running pass 'Function Pass Manager' on module 'coro.bc'.<br>
> 3. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z3foov'<br>
> Segmentation fault<br>
<br>
Coroutines do push the boundaries of LLVM IR in the sense that<br>
(1) there’s a mandatory lowering sequence and (2) because of the<br>
complexity of that lowering, the IR prior to that sequence is<br>
much more of an internal representation than a stable format.<br>
With that said, I don’t know of any inherent reason why running<br>
the coroutine passes multiple times would be a problem.  It’s<br>
probably just some bit of coroutine bookkeeping (the attribute?)<br>
that we fail to remove after lowering.<br>
<br>
Also, the exact form of the crash is surprising; I don’t know<br>
why running lowering multiple times would add new things that<br>
ISel wouldn’t recognize.<br></blockquote><div><br></div><div>Right now this isn't running it multiple times, it is instead never running it, the backend crashes because ISel does not know about these intrinsics (I think we should be friendlier in the failure mode, but that's another story).</div><div><br></div><div>I use clang to emit IR without running any pass (this is the ` -Xclang -disable-llvm-passes` part of the invocation).</div><div><br></div><div> Then I'd like to use clang to "resume" compilation of this file, but clang does not allow me to have an IR input file and run these passes: this is what I'd like to fix. One option I had in the original email in this thread was to change clang to honor `-fcoroutines-ts` when the input is an IR file.</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
John.<br>
</blockquote></div></div>