[PATCH] D11819: [RewriteStatepointsForGC] Avoid using unrelocated pointers after safepoints

Chen Li via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 15:41:07 PDT 2015


chenli added inline comments.

================
Comment at: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:2424
@@ +2423,3 @@
+        return dyn_cast<Instruction>(BI->getCondition());
+    if (auto *SI = dyn_cast<SwitchInst>(TI))
+      return dyn_cast<Instruction>(SI->getCondition());
----------------
sanjoy wrote:
> A `switch` on an `icmp` is equivalent to a `br`; perhaps we should just teach LLVM to transform
> 
> 
> ```
>   %c = icmp slt i32 %x, 0
>   switch i1 %c, label %def [ i1 0, label %f
>                              i1 1, label %t ]
> ```
> 
> to
> 
> ```
>   %c = icmp slt i32 %x, 0
>   br i1 %c, label %t, label %f
> ```
>  
> so that we don't have to deal with `switch` separately here?
> 
> (Right now LLVM does not do the said transform, which surprised me).
> 
> 
> If you remove the `switch` case (pun intended!) here then you should be able to use a simple expression from PatternMatch.h to match a conditional `br` on an `icmp`.
Hmm, I think -simplifycfg should do the transformation. Do we ever see SwitchInst in practice?


http://reviews.llvm.org/D11819





More information about the llvm-commits mailing list