[PATCH] D11819: [RewriteStatepointsForGC] Avoid using unrelocated pointers after safepoints
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 15:33:03 PDT 2015
sanjoy requested changes to this revision.
This revision now requires changes to proceed.
================
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());
----------------
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`.
================
Comment at: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:2426
@@ +2425,3 @@
+ return dyn_cast<Instruction>(SI->getCondition());
+ return (Instruction*)nullptr;
+ };
----------------
I'd prefer typing the lambda with an explicit type, like
```
[](TerminatorInst *TI) -> Instruction * {
...
```
http://reviews.llvm.org/D11819
More information about the llvm-commits
mailing list