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 | 77bbb54fbfbc4aa03af427ce856c419a64e72b86 (patch) | |
tree | 546da3663c693d40399ff9ee0ad498ccf39803c5 /llvm/lib | |
parent | 6172277e9f3d899d588ac324e20ef80d753d277a (diff) | |
download | bcm5719-llvm-77bbb54fbfbc4aa03af427ce856c419a64e72b86.tar.gz bcm5719-llvm-77bbb54fbfbc4aa03af427ce856c419a64e72b86.zip |
Handle ConstantAggregateZero when upgrading global_ctors.
llvm-svn: 209075
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index d0fb71f341b..e255113aab7 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/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()); |