[LLVMdev] Mangler does not check for duplicate symbols?

Justin Holewinski justin.holewinski at gmail.com
Thu Aug 22 13:32:11 PDT 2013


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:

@"a(b" = addrspace(1) global float 1.0
@"a_28_b" = addrspace(1) global float 1.0


If I run this through the x86 backend, I get:

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.


The backend tries to define the mangled symbol name twice, since "a(b"
mangles to "a_28_b".

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?

-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130822/c7be4d3c/attachment.html>


More information about the llvm-dev mailing list