forked from OSchip/llvm-project
[opaque pointer type] Constant Folding: Use GEPOperator to access the pointee source type rather than going through the first operand's pointer type
llvm-svn: 237274
This commit is contained in:
parent
3e80709ef9
commit
4c2814e5d6
|
@ -632,8 +632,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
|
|||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
if (CE->getOpcode() == Instruction::GetElementPtr &&
|
||||
CE->getOperand(0)->isNullValue()) {
|
||||
Type *Ty =
|
||||
cast<PointerType>(CE->getOperand(0)->getType())->getElementType();
|
||||
GEPOperator *GEPO = cast<GEPOperator>(CE);
|
||||
Type *Ty = GEPO->getSourceElementType();
|
||||
if (CE->getNumOperands() == 2) {
|
||||
// Handle a sizeof-like expression.
|
||||
Constant *Idx = CE->getOperand(1);
|
||||
|
|
Loading…
Reference in New Issue