InstCombine: Can't fold a phi arg load into the phi if the load is from a swifterror...
authorArnold Schwaighofer <aschwaighofer@apple.com>
Tue, 8 Mar 2022 15:19:58 +0000 (07:19 -0800)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Tue, 8 Mar 2022 17:09:51 +0000 (09:09 -0800)
commitdcdc1f29bb0cae41d5681183fdf57af8c51de907
tree0277afb1150c481420d37b1f4bfe6ce9ffd6e9f0
parent50bc945a8fc539894fdbf618ace28085c1e19534
InstCombine: Can't fold a phi arg load into the phi if the  load is from a swifterror address

`swifterror` addresses are only allowed as operands to load, store, and
calls.

The following transformation is not allowed. It would create a phi with a
`swifterror` address operand.

```
 %addr = alloca swifterror i8*
 br %cond, label %bb1, label %b22

 bb1:
   %val1 = load i8*, i8** %addr
   br exit

 bb2:
   %val2 = load i8*, i8** %addr
   br exit

 exit:
   %val = phi [%val1, %bb1] [%val2, %bb2]
```

=>

```
 %addr = alloca swifterror i8*
 br %cond, label %bb1, label %b22

 bb1:
   br exit

 bb2:
   br exit

 exit:
   %val_addr = phi [%addr, %bb1] [%addr, %bb2]
   %val2 = load i8*, i8** %val_addr
```

rdar://89865485

Differential Revision: https://reviews.llvm.org/D121217
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
llvm/test/Transforms/InstCombine/phi-equal-incoming-pointers.ll