Commit 248fcab
[InstCombine] Do not use operand info in
Consider the following case:
```
%cmp = icmp eq ptr %p, null
%load = load i32, ptr %p, align 4
%sel = select i1 %cmp, i32 %load, i32 0
```
`foldSelectValueEquivalence` converts `load i32, ptr %p, align 4` into
`load i32, ptr null, align 4`, which causes immediate UB. `%load` is
speculatable, but it doesn't hold after operand substitution.
This patch introduces a new helper
`isSafeToSpeculativelyExecuteWithVariableReplaced`. It ignores operand
info in these instructions since their operands will be replaced later.
Fixes #99436.
---------
Co-authored-by: Nikita Popov <[email protected]>replaceInInstruction (#99492)1 parent 76321b9 commit 248fcab
File tree
5 files changed
+60
-14
lines changed- llvm
- include/llvm/Analysis
- lib
- Analysis
- Transforms/InstCombine
- test/Transforms/InstCombine
5 files changed
+60
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
826 | 837 | | |
| 838 | + | |
| 839 | + | |
827 | 840 | | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
834 | 844 | | |
835 | 845 | | |
836 | 846 | | |
| |||
853 | 863 | | |
854 | 864 | | |
855 | 865 | | |
856 | | - | |
| 866 | + | |
857 | 867 | | |
858 | 868 | | |
859 | 869 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6771 | 6771 | | |
6772 | 6772 | | |
6773 | 6773 | | |
6774 | | - | |
| 6774 | + | |
| 6775 | + | |
6775 | 6776 | | |
6776 | | - | |
| 6777 | + | |
6777 | 6778 | | |
6778 | 6779 | | |
6779 | 6780 | | |
6780 | 6781 | | |
6781 | | - | |
6782 | | - | |
| 6782 | + | |
| 6783 | + | |
6783 | 6784 | | |
6784 | 6785 | | |
6785 | 6786 | | |
| |||
6831 | 6832 | | |
6832 | 6833 | | |
6833 | 6834 | | |
| 6835 | + | |
| 6836 | + | |
| 6837 | + | |
6834 | 6838 | | |
6835 | 6839 | | |
6836 | 6840 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1247 | 1247 | | |
1248 | 1248 | | |
1249 | 1249 | | |
| 1250 | + | |
| 1251 | + | |
1250 | 1252 | | |
1251 | | - | |
| 1253 | + | |
| 1254 | + | |
1252 | 1255 | | |
1253 | 1256 | | |
1254 | 1257 | | |
| |||
1331 | 1334 | | |
1332 | 1335 | | |
1333 | 1336 | | |
1334 | | - | |
| 1337 | + | |
1335 | 1338 | | |
1336 | 1339 | | |
1337 | 1340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1315 | 1315 | | |
1316 | 1316 | | |
1317 | 1317 | | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
1318 | 1331 | | |
1319 | 1332 | | |
1320 | 1333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4713 | 4713 | | |
4714 | 4714 | | |
4715 | 4715 | | |
| 4716 | + | |
| 4717 | + | |
| 4718 | + | |
| 4719 | + | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
| 4723 | + | |
| 4724 | + | |
| 4725 | + | |
| 4726 | + | |
| 4727 | + | |
| 4728 | + | |
| 4729 | + | |
| 4730 | + | |
| 4731 | + | |
0 commit comments