[PATCH] D104043: [IR] Value: Fix OpCode checks
Sami Tolvanen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 10 09:29:04 PDT 2021
samitolvanen created this revision.
Herald added subscribers: dexonsmith, hiraditya.
samitolvanen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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().
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104043
Files:
llvm/lib/IR/Value.cpp
Index: llvm/lib/IR/Value.cpp
===================================================================
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -58,8 +58,11 @@
// 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!");
else if (SubclassID != BasicBlockVal &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104043.351199.patch
Type: text/x-patch
Size: 805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210610/648c3c76/attachment.bin>
More information about the llvm-commits
mailing list