[PATCH] D136656: [IR Verifier] didn't check if switch case is constant, align IR Verifier's check with LLParser.

Peter Rong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 20:34:43 PDT 2022


Peter marked 2 inline comments as done.
Peter added inline comments.


================
Comment at: llvm/lib/IR/Verifier.cpp:2882
   for (auto &Case : SI.cases()) {
+    Check(isa<ConstantInt>(SI.getOperand(Case.getCaseIndex() * 2 + 2)),
+          "Case value is not a constant integer.", &SI);
----------------
arsenm wrote:
> Peter wrote:
> > arsenm wrote:
> > > Is this missing a check for a consistent number of operands, or is that hidden somewhere else?
> > I don't  think there is a check for operand number consistency. 
> > 
> > The `Index * 2 + 2` is `getCaseValue()`'s default behavior. I believe `SwitchInst` manages operand number consistency when you `addCase()`.
> But the verifier's job is to ensure like that is followed. Not sure there's another way to bypass that
I reviewed the `SwitchInst` definition again and couldn't find a bypass. Will merge tomorrow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136656/new/

https://reviews.llvm.org/D136656



More information about the llvm-commits mailing list