[llvm] 1271b8f - [Bitcode] Restore bitcast expression auto-upgrade
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 05:37:56 PDT 2022
Author: Nikita Popov
Date: 2022-06-29T14:35:56+02:00
New Revision: 1271b8f57ab95b601b75b69cd957b9ee9f0c186c
URL: https://github.com/llvm/llvm-project/commit/1271b8f57ab95b601b75b69cd957b9ee9f0c186c
DIFF: https://github.com/llvm/llvm-project/commit/1271b8f57ab95b601b75b69cd957b9ee9f0c186c.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/IR/AutoUpgrade.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/IR/AutoUpgrade.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/AutoUpgrade.h b/llvm/include/llvm/IR/AutoUpgrade.h
index 96d20a7aefb1a..12952f25cbda9 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -82,7 +82,7 @@ namespace llvm {
/// This is an auto-upgrade for bitcast constant expression between pointers
/// with
diff erent address spaces: the instruction is replaced by a pair
/// 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
/// info. Return true if module is modified.
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 7abe7c0d93dde..5e5ca96aeb552 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1442,7 +1442,9 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
if (isConstExprSupported(BC->Opcode) && ConstOps.size() == Ops.size()) {
Constant *C;
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)) {
C = ConstantExpr::get(BC->Opcode, ConstOps[0], BC->Flags);
} else if (Instruction::isBinaryOp(BC->Opcode)) {
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 2a4c31534fa46..75594f90c926b 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4179,7 +4179,7 @@ Instruction *llvm::UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
return nullptr;
}
-Value *llvm::UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy) {
+Constant *llvm::UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy) {
if (Opc != Instruction::BitCast)
return nullptr;
More information about the llvm-commits
mailing list