1; RUN: opt %loadPolly -polly-rewrite-byref-params -S < %s \
2; RUN: | FileCheck %s
3
4
5; Verify that we rewrite the read-only by-reference into a separate alloca slot.
6; This is useful in case %j3 is an induction variable, which should be promoted
7; by -mem2reg into a register.
8
9; CHECK: define void @foo(%struct.__st_parameter_dt* %p) {
10; CHECK-NEXT: entry:
11; CHECK-NEXT:   %polly_byref_alloca_j3 = alloca i32
12; CHECK-NEXT:   %j3 = alloca i32, align 4
13; CHECK-NEXT:   %tmp = bitcast i32* %j3 to i8*
14; CHECK-NEXT:   br label %bb
15
16; CHECK: bb:                                               ; preds = %entry
17; CHECK-NEXT:   %polly_byref_load_j3 = load i32, i32* %j3
18; CHECK-NEXT:   store i32 %polly_byref_load_j3, i32* %polly_byref_alloca_j3
19; CHECK-NEXT:   %polly_byref_cast_j3 = bitcast i32* %polly_byref_alloca_j3 to i8*
20; CHECK-NEXT:   call void @_gfortran_transfer_integer_write(%struct.__st_parameter_dt* %p, i8* %polly_byref_cast_j3, i32 4)
21; CHECK-NEXT:   ret void
22; CHECK-NEXT: }
23
24target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
25target triple = "x86_64-unknown-linux-gnu"
26
27%struct.__st_parameter_dt = type { }
28
29declare void @_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8*, i32)
30
31define void @foo(%struct.__st_parameter_dt* %p) {
32entry:
33  %j3 = alloca i32, align 4
34  %tmp = bitcast i32* %j3 to i8*
35  br label %bb
36
37bb:
38  call void @_gfortran_transfer_integer_write(%struct.__st_parameter_dt* %p, i8* %tmp, i32 4)
39  ret void
40}
41