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

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 19:26:35 PDT 2022


arsenm accepted this revision.
arsenm added inline comments.
This revision is now accepted and ready to land.


================
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);
----------------
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


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