|
2 | 2 | ; RUN: opt < %s -passes=dse -enable-dse-initializes-attr-improvement -S | FileCheck %s |
3 | 3 |
|
4 | 4 | declare void @p1_write_only(ptr nocapture noundef writeonly initializes((0, 2)) dead_on_unwind) |
| 5 | + |
5 | 6 | declare void @p1_write_then_read(ptr nocapture noundef initializes((0, 2)) dead_on_unwind) |
| 7 | + memory(argmem: readwrite, inaccessiblemem: readwrite) |
| 8 | + |
6 | 9 | declare void @p1_clobber(ptr nocapture noundef) |
| 10 | + |
7 | 11 | declare void @p2_same_range(ptr nocapture noundef initializes((0, 2)) dead_on_unwind, ptr nocapture noundef initializes((0, 2)) dead_on_unwind) |
| 12 | + memory(argmem: readwrite, inaccessiblemem: readwrite) |
| 13 | + |
8 | 14 | declare void @p2_no_init(ptr nocapture noundef initializes((0, 2)) dead_on_unwind, ptr nocapture noundef dead_on_unwind) |
| 15 | + |
9 | 16 | declare void @p2_no_dead_on_unwind(ptr nocapture noundef initializes((0, 2)) dead_on_unwind, ptr nocapture noundef initializes((0, 2))) |
| 17 | + memory(argmem: readwrite, inaccessiblemem: readwrite) |
| 18 | + |
10 | 19 | declare void @p2_no_dead_on_unwind_but_nounwind(ptr nocapture noundef initializes((0, 2)) dead_on_unwind, ptr nocapture noundef initializes((0, 2))) nounwind |
| 20 | + memory(argmem: readwrite, inaccessiblemem: readwrite) |
11 | 21 |
|
12 | 22 | ; Function Attrs: mustprogress nounwind uwtable |
13 | 23 | define i16 @p1_write_only_caller() { |
@@ -215,8 +225,12 @@ define i16 @p2_no_dead_on_unwind_but_nounwind_alias_caller() { |
215 | 225 | } |
216 | 226 |
|
217 | 227 | declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind |
| 228 | + |
218 | 229 | declare void @large_p1(ptr nocapture noundef initializes((0, 200))) nounwind |
| 230 | + memory(argmem: readwrite, inaccessiblemem: readwrite) |
| 231 | + |
219 | 232 | declare void @large_p2(ptr nocapture noundef initializes((0, 200)), ptr nocapture noundef initializes((0, 100))) nounwind |
| 233 | + memory(argmem: readwrite, inaccessiblemem: readwrite) |
220 | 234 |
|
221 | 235 | ; Function Attrs: mustprogress nounwind uwtable |
222 | 236 | define i16 @large_p1_caller() { |
@@ -299,3 +313,23 @@ define i16 @large_p2_may_or_partial_alias_caller2(ptr %base1, ptr %base2) { |
299 | 313 | ret i16 %l |
300 | 314 | } |
301 | 315 |
|
| 316 | +@g = global i16 123, align 2 |
| 317 | + |
| 318 | +declare void @read_global(ptr nocapture noundef initializes((0, 2))) |
| 319 | + memory(read, argmem: write, inaccessiblemem: none) nounwind |
| 320 | + |
| 321 | +define i16 @global_var_alias() { |
| 322 | +; CHECK-LABEL: @global_var_alias( |
| 323 | +; CHECK-NEXT: store i32 0, ptr @g, align 4 |
| 324 | +; CHECK-NEXT: [[G_ADDR:%.*]] = getelementptr i32, ptr @g, i64 1 |
| 325 | +; CHECK-NEXT: call void @read_global(ptr [[G_ADDR]]) |
| 326 | +; CHECK-NEXT: [[L:%.*]] = load i16, ptr @g, align 2 |
| 327 | +; CHECK-NEXT: ret i16 [[L]] |
| 328 | +; |
| 329 | + store i32 0, ptr @g, align 4 |
| 330 | + %g_addr = getelementptr i32, ptr @g, i64 1 |
| 331 | + call void @read_global(ptr %g_addr) |
| 332 | + %l = load i16, ptr @g |
| 333 | + ret i16 %l |
| 334 | +} |
| 335 | + |
0 commit comments