diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-17 21:00:22 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-17 21:00:22 +0000 |
commit | e7a6c2f1dfca147cdedb9683f7193882b548753d (patch) | |
tree | fe794197fc41adfe1cdbc404047e99968443a7ca /lib/IR | |
parent | fbd8cc09269d6c7c5ca615a4757e41899a18283f (diff) | |
download | llvm-e7a6c2f1dfca147cdedb9683f7193882b548753d.tar.gz llvm-e7a6c2f1dfca147cdedb9683f7193882b548753d.tar.bz2 llvm-e7a6c2f1dfca147cdedb9683f7193882b548753d.tar.xz |
Handle ConstantAggregateZero when upgrading global_ctors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/AutoUpgrade.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index d0fb71f341..e255113aab 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -191,16 +191,19 @@ static bool UpgradeGlobalStructors(GlobalVariable *GV) { StructType::get(GV->getContext(), Tys, /*isPacked=*/false); // Build new constants with a null third field filled in. - ConstantArray *OldInit = dyn_cast<ConstantArray>(GV->getInitializer()); - if (!OldInit) + Constant *OldInitC = GV->getInitializer(); + ConstantArray *OldInit = dyn_cast<ConstantArray>(OldInitC); + if (!OldInit && !isa<ConstantAggregateZero>(OldInitC)) return false; std::vector<Constant *> Initializers; - for (Use &U : OldInit->operands()) { - ConstantStruct *Init = cast<ConstantStruct>(&U); - Constant *NewInit = + if (OldInit) { + for (Use &U : OldInit->operands()) { + ConstantStruct *Init = cast<ConstantStruct>(&U); + Constant *NewInit = ConstantStruct::get(NewTy, Init->getOperand(0), Init->getOperand(1), Constant::getNullValue(VoidPtrTy), nullptr); - Initializers.push_back(NewInit); + Initializers.push_back(NewInit); + } } assert(Initializers.size() == ATy->getNumElements()); |