[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 17 14:55:09 PDT 2004
Changes in directory llvm/lib/VMCore:
ConstantFolding.cpp updated: 1.66 -> 1.67
---
Log message:
fold gep undef, ... -> undef
This comes up many times in perlbmk and probably others.
---
Diffs of the changes: (+8 -1)
Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.66 llvm/lib/VMCore/ConstantFolding.cpp:1.67
--- llvm/lib/VMCore/ConstantFolding.cpp:1.66 Sat Oct 16 23:01:51 2004
+++ llvm/lib/VMCore/ConstantFolding.cpp Sun Oct 17 16:54:55 2004
@@ -1011,8 +1011,15 @@
if (IdxList.size() == 0 ||
(IdxList.size() == 1 && cast<Constant>(IdxList[0])->isNullValue()))
return const_cast<Constant*>(C);
- Constant *Idx0 = cast<Constant>(IdxList[0]);
+ if (isa<UndefValue>(C)) {
+ const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), IdxList,
+ true);
+ assert(Ty != 0 && "Invalid indices for GEP!");
+ return UndefValue::get(PointerType::get(Ty));
+ }
+
+ Constant *Idx0 = cast<Constant>(IdxList[0]);
if (C->isNullValue()) {
bool isNull = true;
for (unsigned i = 0, e = IdxList.size(); i != e; ++i)
More information about the llvm-commits
mailing list