summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authoraqjune <aqjune@gmail.com>2019-11-07 01:17:49 +0900
committeraqjune <aqjune@gmail.com>2019-11-12 10:49:00 +0900
commite87d71668e10f51abe4b2f1f3c44591aca783750 (patch)
treec33db0298cc2ef75a9c7fd30bf082f6e150c527a /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentc46b3a2abd38d6fecd389c97dfa7df54af77fdb9 (diff)
downloadbcm5719-llvm-e87d71668e10f51abe4b2f1f3c44591aca783750.tar.gz
bcm5719-llvm-e87d71668e10f51abe4b2f1f3c44591aca783750.zip
[IR] Redefine Freeze instruction
Summary: This patch redefines freeze instruction from being UnaryOperator to a subclass of UnaryInstruction. ConstantExpr freeze is removed, as discussed in the previous review. FreezeOperator is not added because there's no ConstantExpr freeze. `freeze i8* null` test is added to `test/Bindings/llvm-c/freeze.ll` as well, because the null pointer-related bug in `tools/llvm-c/echo.cpp` is now fixed. InstVisitor has visitFreeze now because freeze is not unaryop anymore. Reviewers: whitequark, deadalnix, craig.topper, jdoerfert, lebedev.ri Reviewed By: craig.topper, lebedev.ri Subscribers: regehr, nlopes, mehdi_amini, hiraditya, steven_wu, dexonsmith, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69932
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 92c3e1d2dd8..b99ade6a785 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1056,13 +1056,16 @@ static int getDecodedCastOpcode(unsigned Val) {
}
static int getDecodedUnaryOpcode(unsigned Val, Type *Ty) {
+ bool IsFP = Ty->isFPOrFPVectorTy();
+ // UnOps are only valid for int/fp or vector of int/fp types
+ if (!IsFP && !Ty->isIntOrIntVectorTy())
+ return -1;
+
switch (Val) {
default:
return -1;
case bitc::UNOP_FNEG:
- return Ty->isFPOrFPVectorTy() ? Instruction::FNeg : -1;
- case bitc::UNOP_FREEZE:
- return Instruction::Freeze;
+ return IsFP ? Instruction::FNeg : -1;
}
}
@@ -3863,7 +3866,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
case bitc::FUNC_CODE_INST_UNOP: { // UNOP: [opval, ty, opcode]
unsigned OpNum = 0;
Value *LHS;
- if (getValueTypePair(Record, OpNum, NextValueNo, LHS, &FullTy) ||
+ if (getValueTypePair(Record, OpNum, NextValueNo, LHS) ||
OpNum+1 > Record.size())
return error("Invalid record");
@@ -5116,6 +5119,19 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
OperandBundles.emplace_back(BundleTags[Record[0]], std::move(Inputs));
continue;
}
+
+ case bitc::FUNC_CODE_INST_FREEZE: { // FREEZE: [opty,opval]
+ unsigned OpNum = 0;
+ Value *Op = nullptr;
+ if (getValueTypePair(Record, OpNum, NextValueNo, Op, &FullTy))
+ return error("Invalid record");
+ if (OpNum != Record.size())
+ return error("Invalid record");
+
+ I = new FreezeInst(Op);
+ InstructionList.push_back(I);
+ break;
+ }
}
// Add instruction to end of current BB. If there is no current BB, reject
OpenPOWER on IntegriCloud