|
@@ -2387,6 +2387,7 @@ void CollectCtorFunctions(llvm::Module &M, llvm::StringRef globalName,
|
|
|
|
|
|
DenseSet<Function *> Callers = CollectExternalFunctionCallers(M);
|
|
DenseSet<Function *> Callers = CollectExternalFunctionCallers(M);
|
|
|
|
|
|
|
|
+ bool allEvaluated = true;
|
|
for (User::op_iterator i = CA->op_begin(), e = CA->op_end(); i != e; ++i) {
|
|
for (User::op_iterator i = CA->op_begin(), e = CA->op_end(); i != e; ++i) {
|
|
if (isa<ConstantAggregateZero>(*i))
|
|
if (isa<ConstantAggregateZero>(*i))
|
|
continue;
|
|
continue;
|
|
@@ -2407,6 +2408,7 @@ void CollectCtorFunctions(llvm::Module &M, llvm::StringRef globalName,
|
|
// Try to build imm initilizer.
|
|
// Try to build imm initilizer.
|
|
// If not work, add global call to entry func.
|
|
// If not work, add global call to entry func.
|
|
if (BuildImmInit(F) == false) {
|
|
if (BuildImmInit(F) == false) {
|
|
|
|
+ allEvaluated = false;
|
|
if (IsValidCtorFunction(F, Callers)) {
|
|
if (IsValidCtorFunction(F, Callers)) {
|
|
Ctors.emplace_back(F);
|
|
Ctors.emplace_back(F);
|
|
} else {
|
|
} else {
|
|
@@ -2419,6 +2421,12 @@ void CollectCtorFunctions(llvm::Module &M, llvm::StringRef globalName,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // If all globals constructors are replaced with initializers, just get rid
|
|
|
|
+ // of the GV.
|
|
|
|
+ if (allEvaluated) {
|
|
|
|
+ GV->eraseFromParent();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void ProcessCtorFunctions(llvm::Module &M,
|
|
void ProcessCtorFunctions(llvm::Module &M,
|