forked from OSchip/llvm-project
[Bitcode] Restore bitcast expression auto-upgrade
Restore the autoupgrade from bitcast to ptrtoint+inttoptr, which was lost as part of D127729. This fixes the backwards compatibility issue noted in: https://reviews.llvm.org/D127729#inline-1236519
This commit is contained in:
parent
30ea6a0636
commit
1271b8f57a
|
@ -82,7 +82,7 @@ namespace llvm {
|
||||||
/// This is an auto-upgrade for bitcast constant expression between pointers
|
/// This is an auto-upgrade for bitcast constant expression between pointers
|
||||||
/// with different address spaces: the instruction is replaced by a pair
|
/// with different address spaces: the instruction is replaced by a pair
|
||||||
/// ptrtoint+inttoptr.
|
/// ptrtoint+inttoptr.
|
||||||
Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
|
Constant *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
|
||||||
|
|
||||||
/// Check the debug info version number, if it is out-dated, drop the debug
|
/// Check the debug info version number, if it is out-dated, drop the debug
|
||||||
/// info. Return true if module is modified.
|
/// info. Return true if module is modified.
|
||||||
|
|
|
@ -1442,7 +1442,9 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
|
||||||
if (isConstExprSupported(BC->Opcode) && ConstOps.size() == Ops.size()) {
|
if (isConstExprSupported(BC->Opcode) && ConstOps.size() == Ops.size()) {
|
||||||
Constant *C;
|
Constant *C;
|
||||||
if (Instruction::isCast(BC->Opcode)) {
|
if (Instruction::isCast(BC->Opcode)) {
|
||||||
C = ConstantExpr::getCast(BC->Opcode, ConstOps[0], BC->getType());
|
C = UpgradeBitCastExpr(BC->Opcode, ConstOps[0], BC->getType());
|
||||||
|
if (!C)
|
||||||
|
C = ConstantExpr::getCast(BC->Opcode, ConstOps[0], BC->getType());
|
||||||
} else if (Instruction::isUnaryOp(BC->Opcode)) {
|
} else if (Instruction::isUnaryOp(BC->Opcode)) {
|
||||||
C = ConstantExpr::get(BC->Opcode, ConstOps[0], BC->Flags);
|
C = ConstantExpr::get(BC->Opcode, ConstOps[0], BC->Flags);
|
||||||
} else if (Instruction::isBinaryOp(BC->Opcode)) {
|
} else if (Instruction::isBinaryOp(BC->Opcode)) {
|
||||||
|
|
|
@ -4179,7 +4179,7 @@ Instruction *llvm::UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *llvm::UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy) {
|
Constant *llvm::UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy) {
|
||||||
if (Opc != Instruction::BitCast)
|
if (Opc != Instruction::BitCast)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue