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().
Details
- Reviewers
nickdesaulniers void craig.topper - Commits
- rGffaca140d01b: [IR] Value: Fix OpCode checks
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Based on the comments above Value::getValueID, this seems fine to me. ie. no such opcode == 0 and InstructionVal enumerator must be the highest valued enumerator in the ValueTy enum.
Thanks, Nick. I don't have commit access, so would you mind committing the patch? I confirmed that check-all passes for me with the patch applied.
llvm/lib/IR/Value.cpp | ||
---|---|---|
67 | Can we change this to CallBase while we're here? Only one of those opcodes is CallInst, the others are InvokeInst and CallBrInst. They all inherit from CallBase. I was hoping there was a better constructor on CallBase to stash this in to simplify things, but I don't think there is. |
llvm/lib/IR/Value.cpp | ||
---|---|---|
67 | I think there's a 4th class derived from CallBase: GCStatePointInst, though there's nothing in langref about it; seems like an intrinsic. Probably should be fine. The text of the assert can be cleaned up, too. |
Can we change this to CallBase while we're here? Only one of those opcodes is CallInst, the others are InvokeInst and CallBrInst. They all inherit from CallBase.
I was hoping there was a better constructor on CallBase to stash this in to simplify things, but I don't think there is.