[PATCH] D25965: Utility functions for appending to llvm.used/llvm.compiler.used
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 15:10:21 PDT 2016
mehdi_amini added inline comments.
Comment at: lib/LTO/UpdateCompilerUsed.cpp:55
SmallPtrSetImpl<const GlobalValue *> &LLVMUsed;
> mehdi_amini wrote:
> > pcc wrote:
> > > mehdi_amini wrote:
> > > > pcc wrote:
> > > > > This could also be a std::vector, then there'd be no need to rebuild it.
> > > > How do you prevent duplicate?
> > > findLibCallsAndAsm is the only function that adds globals to LLVMUsed. The only call sites are in findInModule which cannot pass duplicates. We can easily change findLibCallsAndAsm to add the global at most once.
> > But this is "updating" the list, so even if `findLibCallsAndAsm` adds the globals at most once, they can already be in the list, what did I miss?
> The only user start with an empty list.
OK I see, because of the way you split it, but see below...
Comment at: lib/Transforms/Utils/ModuleUtils.cpp:104
+ for (auto *V : Values)
+ Init.push_back(ConstantExpr::getBitCast(V, Int8PtrTy));
What if some values that you add here are already in the global variable initializer?
More information about the llvm-commits