<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I think that metadata / annotation preservation isn't perfect and is on a best-effort basis in general, unfortunately, as the IR spec may say that it's okay to drop them. But contributions would be welcome to improve it.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 7, 2021 at 10:17 AM Jeroen Dobbelaere via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
<a href="https://llvm.org/docs/LangRef.html#llvm-loop" rel="noreferrer" target="_blank">https://llvm.org/docs/LangRef.html#llvm-loop</a> states that a llvm.loop is put on the<br>
'branch instruction of the loop's latch block'.<br>
<br>
With 'SimplifyCFG', I have come in a situation where a !llvm.loop is associated to<br>
a basicblock that is found to be a latch block for two different loops.<br>
<br>
The original annotation of one of those loops disappeared in the process.<br>
(See <a href="https://www.godbolt.org/z/5r1T5e9fs" rel="noreferrer" target="_blank">https://www.godbolt.org/z/5r1T5e9fs</a> and look for the disappearing !llvm.loop !10 in BB 'do.cond')<br>
<br>
<br>
Then later on, 'Canonicalize natural loops' splits the latch block up, so that it now is only<br>
the latch block for a single loop, but the original annotation is moved to the wrong loop.<br>
<br>
<br>
Questions:<br>
- The branch in 'do.cond' is simplified, but I have the impression that at the same time, the loop annotation is omitted.<br>
This sounds like a bug ?<br>
- Is it a correct assumption that we should not merge blocks if both have a branch instruction with a !llvm.loop annotation set ?<br>
<br>
Thanks,<br>
<br>
Jeroen Dobbelaere<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>