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
- Repository
- rL LLVM
Event Timeline
llvm/lib/Object/IRSymtab.cpp | ||
---|---|---|
160 ↗ | (On Diff #123707) | 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 ↗ | (On Diff #123707) | 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 ↗ | (On Diff #123828) | 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. =/ |