• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -inline < %s | FileCheck %s
2; RUN: opt -S -O3 < %s | FileCheck %s
3
4; This test checks if value returned from the launder is considered aliasing
5; with its argument.  Due to bug caused by handling launder in capture tracking
6; sometimes it would be considered noalias.
7
8%struct.A = type <{ i32 (...)**, i32, [4 x i8] }>
9
10; CHECK: define i32 @bar(%struct.A* noalias
11define i32 @bar(%struct.A* noalias) {
12; CHECK-NOT: noalias
13  %2 = bitcast %struct.A* %0 to i8*
14  %3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %2)
15  %4 = getelementptr inbounds i8, i8* %3, i64 8
16  %5 = bitcast i8* %4 to i32*
17  store i32 42, i32* %5, align 8
18  %6 = getelementptr inbounds %struct.A, %struct.A* %0, i64 0, i32 1
19  %7 = load i32, i32* %6, align 8
20  ret i32 %7
21}
22
23; CHECK-LABEL: define i32 @foo(%struct.A* noalias
24define i32 @foo(%struct.A* noalias)  {
25  ; CHECK-NOT: call i32 @bar(
26  ; CHECK-NOT: noalias
27  %2 = tail call i32 @bar(%struct.A* %0)
28  ret i32 %2
29}
30
31declare i8* @llvm.launder.invariant.group.p0i8(i8*)
32