[llvm-commits] [llvm] r123558 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Chris Lattner
sabre at nondot.org
Sat Jan 15 18:05:10 PST 2011
Author: lattner
Date: Sat Jan 15 20:05:10 2011
New Revision: 123558
URL: http://llvm.org/viewvc/llvm-project?rev=123558&view=rev
Log:
simplify this code, it is still broken but will follow up on llvm-commits.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=123558&r1=123557&r2=123558&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Sat Jan 15 20:05:10 2011
@@ -2169,16 +2169,10 @@
// and we know how to evaluate it by moving the bitcast from the pointer
// operand to the value operand.
} else if (CE->getOpcode() == Instruction::BitCast &&
- isa<GlobalVariable>(CE->getOperand(0)) &&
- CE->getType()->isPointerTy() &&
- CE->getOperand(0)->getType()->isPointerTy()) {
- GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
+ isa<GlobalVariable>(CE->getOperand(0))) {
// Do not allow weak/*_odr/linkonce/dllimport/dllexport linkage or
// external globals.
- if (!GV->hasUniqueInitializer())
- return false;
-
- return true;
+ return cast<GlobalVariable>(CE->getOperand(0))->hasUniqueInitializer();
}
}
@@ -2360,12 +2354,9 @@
// If we're evaluating a store through a bitcast, then we need
// to pull the bitcast off the pointer type and push it onto the
// stored value.
- Ptr = dyn_cast<Constant>(Ptr->getOperand(0));
- if (!Ptr) return false;
+ Ptr = CE->getOperand(0);
- const PointerType *Ty = dyn_cast<PointerType>(Ptr->getType());
- if (!Ty) return false;
- const Type *NewTy = Ty->getElementType();
+ const Type *NewTy=cast<PointerType>(Ptr->getType())->getElementType();
// A bitcast'd pointer implicitly points to the first field of a
// struct. Insert implicity "gep @x, 0, 0, ..." until we get down
@@ -2374,8 +2365,7 @@
while (const StructType *STy = dyn_cast<StructType>(NewTy)) {
NewTy = STy->getTypeAtIndex(0U);
- const IntegerType *IdxTy =
- IntegerType::get(NewTy->getContext(), 32);
+ const IntegerType *IdxTy =IntegerType::get(NewTy->getContext(), 32);
Constant *IdxZero = ConstantInt::get(IdxTy, 0, false);
Constant * const IdxList[] = {IdxZero, IdxZero};
More information about the llvm-commits
mailing list