[PATCH] D127712: Prevent crash when TurnSwitchRangeIntoICmp recieves default null dest

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 02:22:53 PDT 2022


hans added a comment.

Nice!



================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5222
   }
+  // All destinations are the same and the default is undef
+  if (!DestB) {
----------------
aeubanks wrote:
> this comment makes it sound like at this point your comment is always true
Also, should it be "unreachable" rather than "undef"?


================
Comment at: llvm/test/Transforms/SimplifyCFG/switch-default-undef.ll:1
+; RUN: opt -passes=simplifycfg"<switch-range-to-icmp>" -S %s | FileCheck %s
+
----------------
aeubanks wrote:
> can you use `llvm/utils/update_test_checks.py`?
Instead of creating a new file, could you add this as a test case to llvm/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll instead?


================
Comment at: llvm/test/Transforms/SimplifyCFG/switch-default-undef.ll:9
+define void @0(i8 %sw, i32* %p0) {
+  switch i8 %sw, label %group3 [
+    i8 0, label %group1
----------------
In this switch, the default destination doesn't look unreachable. Is it made unreachable by some other transformation that happens before TurnSwitchRangeIntoICmp()? Can you make the test show the input that TurnSwitchRangeIntoICmp operates on directly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127712



More information about the llvm-commits mailing list