aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-06-29 14:16:30 +0200
committerNikita Popov <npopov@redhat.com>2022-06-29 14:35:56 +0200
commit1271b8f57ab95b601b75b69cd957b9ee9f0c186c (patch)
tree29cbb4ccac8c0898bafd325fa7bfb7935ca101ae /llvm/lib/Bitcode/Reader
parent30ea6a06364c4aad1175f2d1440a1ee2ffd8d3e0 (diff)
downloadllvm-1271b8f57ab95b601b75b69cd957b9ee9f0c186c.zip
llvm-1271b8f57ab95b601b75b69cd957b9ee9f0c186c.tar.gz
llvm-1271b8f57ab95b601b75b69cd957b9ee9f0c186c.tar.bz2
[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
Diffstat (limited to 'llvm/lib/Bitcode/Reader')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 7abe7c0..5e5ca96 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)) {