[LLVMdev] Where does LLVM mangle characters from llvm-ir names while generating native code?
Michael Spencer
bigcheesegs at gmail.com
Fri Nov 25 07:39:59 PST 2011
So I was taking a look at Microsoft C++ ABI support while on vacation,
and ran into a major issue. Given the following llvm-ir:
$ clang++ -S -emit-llvm -O3 mangling.cpp -o - -Xclang -cxx-abi -Xclang microsoft
; ModuleID = 'mangling.cpp'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-
v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32"
target triple = "i686-pc-win32"
define i32 @"?heyimacxxfunction@@YAHXZ"() nounwind readnone {
entry:
ret i32 42
}
Note the ?heyimacxxfunction@@YAHXZ. Now if I generate assembly (using
clang or llc) I get:
$ clang++ -S -O3 mangling.cpp -o - -Xclang -cxx-abi -Xclang microsoft
.def __3F_heyimacxxfunction@@YAHXZ;
.scl 2;
.type 32;
.endef
.text
.globl __3F_heyimacxxfunction@@YAHXZ
.align 16, 0x90
__3F_heyimacxxfunction@@YAHXZ: # @"?heyimacxxfunction@@YAHXZ"
# BB#0: # %entry
movl $42, %eax
ret
It turned the ? into _3F_, and prepended _ someplace. I get the same
symbol if I use integrated-as to generate an object file.
I've been unable thus far to find out exactly where this occurs. And
once I do find it, I'm not sure of the correct fix. I assume that LLVM
mangles the '?' because it means something special in the gas syntax.
There also has to be a way to communicate to llvm from clang that this
symbol should not receive a prepended _.
Thanks,
- Michael Spencer
More information about the llvm-dev
mailing list