Commit 8faeed0
authored
[SROA] Add Stored Value Size Check for Tree-Structured Merge (llvm#162921)
The change fixes a bug in the SROA where tree-structured merge
optimization was incorrectly applied when the size of the stored value
was not a multiple of the new allocated element type size. The original
change is llvm#152793. A simple
repro would be
```
define <1 x i32> @foo(<1 x i16> %a, <1 x i16> %b) {
entry:
%alloca = alloca [1 x i32]
%ptr0 = getelementptr inbounds [2 x i16], ptr %alloca, i32 0, i32 0
store <1 x i16> %a, ptr %ptr0
%ptr1 = getelementptr inbounds [2 x i16], ptr %alloca, i32 0, i32 1
store <1 x i16> %b, ptr %ptr1
%result = load <1 x i32>, ptr %alloca
ret <1 x i32> %result
}
```
Currently, this will lead to a compile time crash.
In this change, we will skip the tree-structured merge for this case and
fall back to normal SROA.1 parent d3233e8 commit 8faeed0
File tree
2 files changed
+22
-0
lines changed- llvm
- lib/Transforms/Scalar
- test/Transforms/SROA
2 files changed
+22
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2961 | 2961 | | |
2962 | 2962 | | |
2963 | 2963 | | |
| 2964 | + | |
2964 | 2965 | | |
2965 | 2966 | | |
2966 | 2967 | | |
| |||
2991 | 2992 | | |
2992 | 2993 | | |
2993 | 2994 | | |
| 2995 | + | |
| 2996 | + | |
2994 | 2997 | | |
2995 | 2998 | | |
2996 | 2999 | | |
2997 | 3000 | | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
2998 | 3006 | | |
2999 | 3007 | | |
3000 | 3008 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
222 | 236 | | |
0 commit comments