<div dir="ltr"><div>The current implementation of llvm::Mangler does not check if a symbol name exists before mangling. This can cause problems if the mangled name aliases another symbol in the IR. For example, consider the following:</div>
<div><br></div><div><font face="courier new, monospace">@"a(b" = addrspace(1) global float 1.0</font></div><div><font face="courier new, monospace">@"a_28_b" = addrspace(1) global float 1.0</font></div>
<div><br></div><div><br></div><div>If I run this through the x86 backend, I get:</div><div><br></div><div><font face="courier new, monospace">llc: /scratch/jholewinski/llvm/src/llvm/lib/MC/MCAsmStreamer.cpp:351: virtual void <anonymous namespace>::MCAsmStreamer::EmitLabel(llvm::MCSymbol *): Assertion `Symbol->isUndefined() && "Cannot define a symbol twice!"' failed.</font><br>
</div><div><br></div><div><br></div><div>The backend tries to define the mangled symbol name twice, since "a(b" mangles to "a_28_b".</div><div><br></div><div>Was it a conscious design choice to do it this way? Perhaps to save the time of verifying the uniqueness of the symbol? Or is the idea that you can always de-mangle by searching for "_XX_" sequences and replacing those with the ASCII value of XX?</div>
<div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div>
</div>