https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104236
Bug ID: 104236 Summary: asm statements containing %= assembler templates getting merged Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: ndesaulniers at google dot com CC: bp at alien8 dot de, jpoimboe at redhat dot com, pinskia at gcc dot gnu.org, segher at kernel dot crashing.org Target Milestone: --- https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile and https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#AssemblerTemplate mention > 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) may help resolve > this problem. > > ‘%=’ Outputs a number that is unique to each instance of the asm > statement in the entire compilation. This option is useful when > creating local labels and referring to them multiple times in a single > template that generates multiple assembler instructions. I think I might have found a case where GCC is folding two asm strings that look identical, but technically contain a %= assembler template. Perhaps there's somewhere that checks for parameter equality, and misses checking whether an asm string contains %= ? (or perhaps %= needs to be expanded sooner?) Test files are in: https://gist.github.com/nickdesaulniers/c2c37edcdbaf3a2deb914d2ea8011a96 I would have expected the inline asm string containing `.Lreachable%=:` (in media_request_object_complete()) to appear twice in the emitted asm output. If I modify one of the two `.Lreachable` asm strings by one character, then I see both emitted.