mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 17:25:21 +00:00
Don't crash when trying to constant fold a vector with some elements that can't
be folded. Instead, fail to fold the entire vector. We could also return a vector with some elements folded and some not. If anyone thinks that's a better approach, please speak up! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55689 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -238,9 +238,12 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
|
||||
std::vector<Constant*> res;
|
||||
const VectorType *DestVecTy = cast<VectorType>(DestTy);
|
||||
const Type *DstEltTy = DestVecTy->getElementType();
|
||||
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
|
||||
res.push_back(ConstantFoldCastInstruction(opc, V->getOperand(i),
|
||||
DstEltTy));
|
||||
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) {
|
||||
Constant *C = ConstantFoldCastInstruction(opc, CV->getOperand(i),
|
||||
DstEltTy);
|
||||
if (!C) return 0; // Can't fold operand.
|
||||
res.push_back(C);
|
||||
}
|
||||
return ConstantVector::get(DestVecTy, res);
|
||||
}
|
||||
return 0; // Can't fold.
|
||||
@@ -268,9 +271,12 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
|
||||
std::vector<Constant*> res;
|
||||
const VectorType *DestVecTy = cast<VectorType>(DestTy);
|
||||
const Type *DstEltTy = DestVecTy->getElementType();
|
||||
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
|
||||
res.push_back(ConstantFoldCastInstruction(opc, V->getOperand(i),
|
||||
DstEltTy));
|
||||
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) {
|
||||
Constant *C = ConstantFoldCastInstruction(opc, CV->getOperand(i),
|
||||
DstEltTy);
|
||||
if (!C) return 0; // Can't fold operand.
|
||||
res.push_back(C);
|
||||
}
|
||||
return ConstantVector::get(DestVecTy, res);
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user