[llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp ValueMapper.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Feb 14 23:56:01 PST 2004
Changes in directory llvm/lib/Transforms/Utils:
Linker.cpp updated: 1.66 -> 1.67
ValueMapper.cpp updated: 1.10 -> 1.11
---
Log message:
Adjustments to support the new ConstantAggregateZero class
---
Diffs of the changes: (+21 -8)
Index: llvm/lib/Transforms/Utils/Linker.cpp
diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.66 llvm/lib/Transforms/Utils/Linker.cpp:1.67
--- llvm/lib/Transforms/Utils/Linker.cpp:1.66 Mon Jan 12 13:10:58 2004
+++ llvm/lib/Transforms/Utils/Linker.cpp Sat Feb 14 23:55:12 2004
@@ -284,7 +284,8 @@
// 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 @@
// 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();
Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.10 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.11
--- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.10 Mon Jan 12 13:10:58 2004
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp Sat Feb 14 23:55:13 2004
@@ -28,7 +28,7 @@
if (Constant *C = const_cast<Constant*>(dyn_cast<Constant>(V))) {
if (isa<ConstantIntegral>(C) || isa<ConstantFP>(C) ||
- isa<ConstantPointerNull>(C))
+ isa<ConstantPointerNull>(C) || isa<ConstantAggregateZero>(C))
return VMSlot = C; // Primitive constants map directly
else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
GlobalValue *MV = cast<GlobalValue>(MapValue((Value*)CPR->getValue(),VM));
More information about the llvm-commits
mailing list