1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes='move-auto-init' -verify-memoryssa | FileCheck %s
4 ; Checks that auto-init memory isntruction are mot moved when writing to an sret argument.
6 target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
8 %struct.S = type { i64 }
10 @pattern = private unnamed_addr constant %struct.S { i64 -1 }, align 4
12 define void @f(ptr noalias sret(%struct.S) align 4 %0, i32 noundef %1) {
14 ; CHECK-NEXT: [[TMP3:%.*]] = alloca ptr, align 4
15 ; CHECK-NEXT: [[TMP4:%.*]] = alloca i32, align 4
16 ; CHECK-NEXT: [[TMP5:%.*]] = alloca [[STRUCT_S:%.*]], align 4
17 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast ptr [[TMP0:%.*]] to ptr
18 ; CHECK-NEXT: store ptr [[TMP6]], ptr [[TMP3]], align 4
19 ; CHECK-NEXT: store i32 [[TMP1:%.*]], ptr [[TMP4]], align 4
20 ; CHECK-NEXT: [[TMP7:%.*]] = bitcast ptr [[TMP0]] to ptr
21 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[TMP7]], ptr align 4 @pattern, i32 8, i1 false), !annotation !0
22 ; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP4]], align 4
23 ; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 42
24 ; CHECK-NEXT: br i1 [[TMP9]], label [[TMP10:%.*]], label [[TMP13:%.*]]
26 ; CHECK-NEXT: call void @g(ptr sret([[STRUCT_S]]) align 4 [[TMP5]])
27 ; CHECK-NEXT: [[TMP11:%.*]] = bitcast ptr [[TMP0]] to ptr
28 ; CHECK-NEXT: [[TMP12:%.*]] = bitcast ptr [[TMP5]] to ptr
29 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[TMP11]], ptr align 4 [[TMP12]], i32 8, i1 false)
30 ; CHECK-NEXT: br label [[TMP13]]
32 ; CHECK-NEXT: ret void
34 %3 = alloca ptr, align 4
35 %4 = alloca i32, align 4
36 %5 = alloca %struct.S, align 4
37 %6 = bitcast ptr %0 to ptr
38 store ptr %6, ptr %3, align 4
39 store i32 %1, ptr %4, align 4
40 %7 = bitcast ptr %0 to ptr
41 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %7, ptr align 4 @pattern, i32 8, i1 false), !annotation !0
42 %8 = load i32, ptr %4, align 4
43 %9 = icmp eq i32 %8, 42
44 br i1 %9, label %10, label %13
47 call void @g(ptr sret(%struct.S) align 4 %5)
48 %11 = bitcast ptr %0 to ptr
49 %12 = bitcast ptr %5 to ptr
50 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %11, ptr align 4 %12, i32 8, i1 false)
57 declare void @g(ptr sret(%struct.S) align 4, ...)
59 declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #0