This complements the fixes in r323633 and r324075 which drop the
definitions of dead functions and variables, respectively.
Fixes PR36208.
Differential D42856
[ThinLTO] Convert dead alias to declarations Authored by tejohnson on Feb 2 2018, 10:21 AM.
Details This complements the fixes in r323633 and r324075 which drop the Fixes PR36208.
Diff Detail
Event Timeline
Comment Actions LGTM, thanks !
| |||||||||||||||||||||||||||||||||||||||||||
With the new change convertToDeclaration becomes a dangerous function to use in loops.
Currently there is one more place where code iterates over aliases in a "old" way and may also fail I think:
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/IPO/FunctionImport.cpp#L670
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/IPO/FunctionImport.cpp#L689
What about if we stop calling eraseFromParent from convertToDeclatation
and do something explicit like:
static void dropDeadSymbols(Module &Mod, const GVSummaryMapTy &DefinedGlobals, const ModuleSummaryIndex &Index) { std::vector<GlobalValue *> ReplacedGlobals; for (auto &GV : Mod.global_values()) if (GlobalValueSummary *GVS = DefinedGlobals.lookup(GV.getGUID())) if (!Index.isGlobalValueLive(GVS)) if (!convertToDeclaration(GV)) ReplacedGlobals.push_back(&GV); for (GlobalValue *GV : ReplacedGlobals) GV->eraseFromParent(); }So convertToDeclaration would return true if value was converted to declaration and
false if it was replaced.
Though we can refactor this place separatelly in a followups, probably with use of
some better approach, but at least caller from FunctionImport.cpp should also be changed too then.