diff options
author | Nikita Popov <npopov@redhat.com> | 2022-09-07 11:36:19 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-09-08 10:24:55 +0200 |
commit | 96cb7c22736bdd9e6b0194c933ae3b2986eae8e2 (patch) | |
tree | 1530fb3512d42055601431f3961996980f7330b3 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 6247988e0751422fa10d70e64939c987dd3b81d9 (diff) | |
download | llvm-96cb7c22736bdd9e6b0194c933ae3b2986eae8e2.zip llvm-96cb7c22736bdd9e6b0194c933ae3b2986eae8e2.tar.gz llvm-96cb7c22736bdd9e6b0194c933ae3b2986eae8e2.tar.bz2 |
[ConstantExpr] Remove fneg expression
As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
this removes the fneg constant expression (which is, incidentally,
the only unary operator expression).
Differential Revision: https://reviews.llvm.org/D133418
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 049fc0f..0ed0614 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1385,10 +1385,15 @@ static bool isConstExprSupported(uint8_t Opcode) { if (Opcode >= BitcodeConstant::FirstSpecialOpcode) return true; + // If -expand-constant-exprs is set, we want to consider all expressions + // as unsupported. + if (ExpandConstantExprs) + return false; + if (Instruction::isBinaryOp(Opcode)) return ConstantExpr::isSupportedBinOp(Opcode); - return !ExpandConstantExprs; + return Opcode != Instruction::FNeg; } Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID, @@ -1449,8 +1454,6 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID, 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)) { C = ConstantExpr::get(BC->Opcode, ConstOps[0], ConstOps[1], BC->Flags); } else { |