Mangler does not check for duplicate symbols?

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Mangler does not check for duplicate symbols?

Justin Holewinski-2
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?



Justin Holewinski

LLVM Developers mailing list
[hidden email]