diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-15 05:55:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-15 05:55:15 +0000 |
commit | 76b2ff4ded1d85efea1d6c1ddcffaa4cd64072b8 (patch) | |
tree | ff5ec44177557258085f40bc5d7a24c1626fa422 /llvm/lib/Transforms/Utils/Linker.cpp | |
parent | 7bea8084e09827613d5ca4fcb18e90fb2395d0a4 (diff) | |
download | bcm5719-llvm-76b2ff4ded1d85efea1d6c1ddcffaa4cd64072b8.tar.gz bcm5719-llvm-76b2ff4ded1d85efea1d6c1ddcffaa4cd64072b8.zip |
Adjustments to support the new ConstantAggregateZero class
llvm-svn: 11474
Diffstat (limited to 'llvm/lib/Transforms/Utils/Linker.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Linker.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/Linker.cpp b/llvm/lib/Transforms/Utils/Linker.cpp index 457a8b97b65..aa7720ece35 100644 --- a/llvm/lib/Transforms/Utils/Linker.cpp +++ b/llvm/lib/Transforms/Utils/Linker.cpp @@ -284,7 +284,8 @@ static Value *RemapOperand(const Value *In, // Check to see if it's a constant that we are interesting in transforming... if (const Constant *CPV = dyn_cast<Constant>(In)) { - if (!isa<DerivedType>(CPV->getType()) && !isa<ConstantExpr>(CPV)) + if ((!isa<DerivedType>(CPV->getType()) && !isa<ConstantExpr>(CPV)) || + isa<ConstantAggregateZero>(CPV)) return const_cast<Constant*>(CPV); // Simple constants stay identical... Constant *Result = 0; @@ -796,12 +797,24 @@ static bool LinkAppendingVars(Module *M, // Merge the initializer... Inits.reserve(NewSize); - ConstantArray *I = cast<ConstantArray>(G1->getInitializer()); - for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) - Inits.push_back(cast<Constant>(I->getValues()[i])); - I = cast<ConstantArray>(G2->getInitializer()); - for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) - Inits.push_back(cast<Constant>(I->getValues()[i])); + if (ConstantArray *I = dyn_cast<ConstantArray>(G1->getInitializer())) { + for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) + Inits.push_back(cast<Constant>(I->getValues()[i])); + } else { + assert(isa<ConstantAggregateZero>(G1->getInitializer())); + Constant *CV = Constant::getNullValue(T1->getElementType()); + for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) + Inits.push_back(CV); + } + if (ConstantArray *I = dyn_cast<ConstantArray>(G2->getInitializer())) { + for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) + Inits.push_back(cast<Constant>(I->getValues()[i])); + } else { + assert(isa<ConstantAggregateZero>(G2->getInitializer())); + Constant *CV = Constant::getNullValue(T2->getElementType()); + for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) + Inits.push_back(CV); + } NG->setInitializer(ConstantArray::get(NewType, Inits)); Inits.clear(); |