[llvm] [SimplifyCFG][JumpThreading] Don't duplicate inline-asm instructions (PR #71571)

Cameron McInally via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 07:18:20 PST 2023


mcinally wrote:

> We've seen this in the Linux kernel before, pretty sure `\@` should be used on the label to make it unique per instantiation. Let me see if I can find the kernel commit I'm thinking of.
> 
> (Cant find the kernel commit I'm thinking of). Sorry `%=` is the sigil. This problem is why it exists.
> 
> > Under certain circumstances, GCC may duplicate (or remove duplicates of) your assembly code when optimizing. This can lead to unexpected duplicate symbol errors during compilation if your asm code defines symbols or labels. Using ‘%=’ (see [AssemblerTemplate](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#AssemblerTemplate)) may help resolve this problem.
> 
> `\@` is for asm .macro expansion, but same idea. https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html#SEC109

Ah, that's compelling. Thanks, Nick!

Closing this issue...

https://github.com/llvm/llvm-project/pull/71571


More information about the llvm-commits mailing list