1; RUN: opt -S -globals-aa -functionattrs < %s | FileCheck %s
2; RUN: opt -S -O3 < %s | FileCheck %s
3
4; Apart from checking for the direct cause of the bug, we also check
5; if any problematic aliasing rules have accidentally snuck into -O3.
6;
7; Since the "abc" operand bundle is not a special operand bundle that
8; LLVM knows about, all of the stores and loads in @test below have to
9; stay.
10
11declare void @foo() readnone
12
13; CHECK-LABEL: define i8* @test(i8* %p)
14; CHECK:   %a = alloca i8*, align 8
15; CHECK:   store i8* %p, i8** %a, align 8
16; CHECK:   call void @foo() [ "abc"(i8** %a) ]
17; CHECK:   %reload = load i8*, i8** %a, align 8
18; CHECK:   ret i8* %reload
19; CHECK: }
20
21define i8* @test(i8* %p) {
22  %a = alloca i8*, align 8
23  store i8* %p, i8** %a, align 8
24  call void @foo() ["abc" (i8** %a)]
25  %reload = load i8*, i8** %a, align 8
26  ret i8* %reload
27}
28