summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-25 06:48:06 +0000
committerChris Lattner <sabre@nondot.org>2012-01-25 06:48:06 +0000
commit6705883ad823b9b8575600fcd4dc2cce55c9f2c9 (patch)
tree88614a259c8b110267d20c977b631fdaa1e0e560 /llvm/lib/Linker/LinkModules.cpp
parent783490095000f20a61f18918132eeea7fd15eb80 (diff)
downloadbcm5719-llvm-6705883ad823b9b8575600fcd4dc2cce55c9f2c9.tar.gz
bcm5719-llvm-6705883ad823b9b8575600fcd4dc2cce55c9f2c9.zip
use Constant::getAggregateElement to simplify a bunch of code.
llvm-svn: 148934
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 563aed5daa0..60fa9a76e2a 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -844,21 +844,10 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) {
}
static void getArrayElements(Constant *C, SmallVectorImpl<Constant*> &Dest) {
- if (ConstantArray *I = dyn_cast<ConstantArray>(C)) {
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- Dest.push_back(I->getOperand(i));
- return;
- }
-
- if (ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(C)) {
- for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
- Dest.push_back(CDS->getElementAsConstant(i));
- return;
- }
-
- ConstantAggregateZero *CAZ = cast<ConstantAggregateZero>(C);
- Dest.append(cast<ArrayType>(C->getType())->getNumElements(),
- CAZ->getSequentialElement());
+ unsigned NumElements = cast<ArrayType>(C->getType())->getNumElements();
+
+ for (unsigned i = 0; i != NumElements; ++i)
+ Dest.push_back(C->getAggregateElement(i));
}
void ModuleLinker::linkAppendingVarInit(const AppendingVarInfo &AVI) {
OpenPOWER on IntegriCloud