Commit ffaca140 authored by Sami Tolvanen's avatar Sami Tolvanen Committed by Nick Desaulniers
Browse files

[IR] Value: Fix OpCode checks

Value::SubclassID cannot be directly compared to Instruction enums, such as
Instruction::{Call,Invoke,CallBr}. We have to first subtract InstructionVal
from the SubclassID to get the OpCode, similar to Instruction::getOpCode().

Reviewed By: nickdesaulniers

Differential Revision:
parent 5a1589fc
......@@ -58,10 +58,13 @@ Value::Value(Type *ty, unsigned scid)
// FIXME: Why isn't this in the subclass gunk??
// Note, we cannot call isa<CallInst> before the CallInst has been
// constructed.
if (SubclassID == Instruction::Call || SubclassID == Instruction::Invoke ||
SubclassID == Instruction::CallBr)
unsigned OpCode = 0;
if (SubclassID >= InstructionVal)
OpCode = SubclassID - InstructionVal;
if (OpCode == Instruction::Call || OpCode == Instruction::Invoke ||
OpCode == Instruction::CallBr)
assert((VTy->isFirstClassType() || VTy->isVoidTy() || VTy->isStructTy()) &&
"invalid CallInst type!");
"invalid CallBase type!");
else if (SubclassID != BasicBlockVal &&
(/*SubclassID < ConstantFirstVal ||*/ SubclassID > ConstantLastVal))
assert((VTy->isFirstClassType() || VTy->isVoidTy()) &&
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment