aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Bytecode/Reader/Reader.cpp16
-rw-r--r--lib/Bytecode/Writer/Writer.cpp2
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 9286279..3cc3b1d 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -1355,14 +1355,18 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
return Result;
} else if (Opcode == Instruction::ICmp) {
if (ArgVec.size() != 2)
- error("Invalid ICmp constant expr arguments");
- unsigned short pred = read_vbr_uint();
- return ConstantExpr::getICmp(pred, ArgVec[0], ArgVec[1]);
+ error("Invalid ICmp constant expr arguments.");
+ unsigned predicate = read_vbr_uint();
+ Constant *Result = ConstantExpr::getICmp(predicate, ArgVec[0], ArgVec[1]);
+ if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
+ return Result;
} else if (Opcode == Instruction::FCmp) {
if (ArgVec.size() != 2)
- error("Invalid FCmp constant expr arguments");
- unsigned short pred = read_vbr_uint();
- return ConstantExpr::getFCmp(pred, ArgVec[0], ArgVec[1]);
+ error("Invalid FCmp constant expr arguments.");
+ unsigned predicate = read_vbr_uint();
+ Constant *Result = ConstantExpr::getFCmp(predicate, ArgVec[0], ArgVec[1]);
+ if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
+ return Result;
} else { // All other 2-operand expressions
Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]);
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 127a3ba..fdd0f3c 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -303,6 +303,8 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
Slot = Table.getSlot((*OI)->getType());
output_typeid((unsigned)Slot);
}
+ if (CE->isCompare())
+ output_vbr((unsigned)CE->getPredicate());
return;
} else if (isa<UndefValue>(CPV)) {
output_vbr(1U); // 1 -> UndefValue constant.