[PATCH] D33621: Fix for -wrap linker option and LTO, PR 33145
Dmitry Mikulin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 11:05:16 PDT 2017
dmikulin added inline comments.
================
Comment at: lld/ELF/SymbolTable.cpp:159-163
+ Twine WrappedName = "__wrap_" + Name;
+ Twine RealName = "__real_" + Name;
+ RenamedSymbols[WrappedName.str()] = true;
+ RenamedSymbols[RealName.str()] = true;
+ RenamedSymbols[Name] = true;
----------------
davide wrote:
> Can you explain why you need all three?
We need all three if we want to match non-LTO behavior.
* _wrap_bar is needed for the case where it is defined by the user but may be eliminated during LTO.
* _real_bar is needed for the test case in the PR: the direct call to _real_bar() from foo() will be bound and inlined by LTO to the user-defined _real_bar() instead of bar() if _real_bar() is not on the list.
* similarly, if bar() is not on the list, the call to bar() from foo() will be inlined instead of being routed to _wrap_bar().
================
Comment at: lld/ELF/SymbolTable.cpp:338-340
+ if ((postLTO && B->isBitcode()) &&
+ Binding == STB_WEAK && S->Binding != STB_WEAK)
+ ;
----------------
davide wrote:
> empty ifs are not really common in llvm.
I'll fix this. Negating the condition seamed counter-intuitive...
================
Comment at: lld/ELF/SymbolTable.h:140
std::unique_ptr<BitcodeCompiler> LTO;
+ llvm::StringMap<bool> RenamedSymbols;
+ bool PostLTO = false;
----------------
davide wrote:
> A `StringMap<bool>` is a little silly.
> If you really want a set container, you should use a proper one.
Is a set container like SmallSet good enough in this case? What's the worst case for the number of -wrap functions? I picked a map because we have to do a lookup in this container for every symbol.
================
Comment at: llvm/include/llvm/LTO/LTO.h:385
+ /// option.
+ unsigned IsRenamed : 1;
};
----------------
davide wrote:
> I'd say, `LinkerRedefined`.
I'll change this.
================
Comment at: llvm/lib/LTO/LTO.cpp:423
Partition == GlobalResolution::RegularLTO);
+ GlobalRes.IsRenamed = Res.IsRenamed;
}
----------------
davide wrote:
> why do you need this being part of GlobalResolution?
> If you do, please add a test showing that you fail switching the linkage earlier.
You're right, I can do it sooner, in addRegularLTO(). I'll take out the GlobalRes stuff.
https://reviews.llvm.org/D33621
More information about the llvm-commits
mailing list