Change the representation of COFF comdats so that a COFF linker
is able to accurately resolve comdats between IR and native object
files. Specifically, apply name mangling to comdat names consistently
with native object files, and do not export comdats with an internal
leader because they do not affect symbol resolution.
Details
Diff Detail
- Build Status
Buildable 12354 Build 12354: arc lint + arc unit
Event Timeline
llvm/lib/Object/IRSymtab.cpp | ||
---|---|---|
160 | Every time I see getNameWithPrefix called without a GlobalValue, I consider it a bit buggy because it won't add the @N byte suffix for __stdcall functions. However, clang always mangles extern "C" names itself for functions with non-standard conventions, so there's no way to exercise this bug from C, it has to come from LLVM IR. Do we care? Should we fatal error in AsmPrinter when a symbol in a comdat would require a suffix? Most languages that aren't C++ aren't going to care about this. |
llvm/lib/Object/IRSymtab.cpp | ||
---|---|---|
160 | Thanks. For me that raised the question of how AsmPrinter mangles comdat names. I thought it just called Mangler::getNameByPrefix on the name as I did here, but it looks like in fact we look up the leader symbol using the name of the comdat and mangle its name [1]. That seems really weird to me, but for now it seems best to be consistent with that here. We might consider making a change along the lines you suggest, but that's probably an orthogonal change. [1] http://llvm-cs.pcc.me.uk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp#1027 |
- Re-implement Builder::getComdatIndex to be consistent with AsmPrinter and add error handling
llvm/test/LTO/Resolution/X86/symtab.ll | ||
---|---|---|
61 | We should be able to test it with this IR: $f = comdat any define weak_odr x86_fastcallcc i32 @f(i32 inreg %a, i32 inreg %b) comdat { entry: %add = add nsw i32 %b, %a ret i32 %add } I guess the symtab would say @f@8. =/ |
Every time I see getNameWithPrefix called without a GlobalValue, I consider it a bit buggy because it won't add the @N byte suffix for __stdcall functions. However, clang always mangles extern "C" names itself for functions with non-standard conventions, so there's no way to exercise this bug from C, it has to come from LLVM IR.
Do we care? Should we fatal error in AsmPrinter when a symbol in a comdat would require a suffix? Most languages that aren't C++ aren't going to care about this.