[GlobalDCE, Misc] Don't remove functions referenced by ifuncs

We forgot to consider the target of ifuncs when considering if a
function was alive or dead.

N.B. Also update a few auxiliary tools like bugpoint and
verify-uselistorder.

This fixes PR27593.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2016-05-04 00:20:48 +00:00
parent 7212e1ee96
commit fea3ecb60c
7 changed files with 72 additions and 22 deletions
+7 -5
View File
@@ -47,7 +47,7 @@ static void addNonConstUser(ClusterMapType &GVtoClusterMap,
if (const Instruction *I = dyn_cast<Instruction>(U)) {
const GlobalValue *F = I->getParent()->getParent();
GVtoClusterMap.unionSets(GV, F);
} else if (isa<GlobalAlias>(U) || isa<Function>(U) ||
} else if (isa<GlobalIndirectSymbol>(U) || isa<Function>(U) ||
isa<GlobalVariable>(U)) {
GVtoClusterMap.unionSets(GV, cast<GlobalValue>(U));
} else {
@@ -107,8 +107,8 @@ static void findPartitions(Module *M, ClusterIDMapType &ClusterIDMap,
// For aliases we should not separate them from their aliasees regardless
// of linkage.
if (GlobalAlias *GA = dyn_cast<GlobalAlias>(&GV)) {
if (const GlobalObject *Base = GA->getBaseObject())
if (auto *GIS = dyn_cast<GlobalIndirectSymbol>(&GV)) {
if (const GlobalObject *Base = GIS->getBaseObject())
GVtoClusterMap.unionSets(&GV, Base);
}
@@ -205,8 +205,8 @@ static void externalize(GlobalValue *GV) {
// Returns whether GV should be in partition (0-based) I of N.
static bool isInPartition(const GlobalValue *GV, unsigned I, unsigned N) {
if (auto GA = dyn_cast<GlobalAlias>(GV))
if (const GlobalObject *Base = GA->getBaseObject())
if (auto *GIS = dyn_cast<GlobalIndirectSymbol>(GV))
if (const GlobalObject *Base = GIS->getBaseObject())
GV = Base;
StringRef Name;
@@ -236,6 +236,8 @@ void llvm::SplitModule(
externalize(&GV);
for (GlobalAlias &GA : M->aliases())
externalize(&GA);
for (GlobalIFunc &GIF : M->ifuncs())
externalize(&GIF);
}
// This performs splitting without a need for externalization, which might not