1 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
2 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -S | FileCheck -check-prefix=CHECK-GVN %s
4 ; The input *.ll had been adapted from bug 37458:
6 ; struct A { virtual void f(); int n; };
11 ; return __builtin_launder(&a)->n;
14 %struct.A = type <{ ptr, i8 }>
16 ; CHECK: testLaunderInvariantGroupIsNotEscapeSource
17 ; CHECK-GVN: testLaunderInvariantGroupIsNotEscapeSource
18 define i8 @testLaunderInvariantGroupIsNotEscapeSource() {
19 ; CHECK-DAG: MustAlias: i8* %a, %struct.A* %a
20 ; CHECK-DAG: PartialAlias (off 8): %struct.A* %a, i8* %n
21 ; CHECK-DAG: NoAlias: i8* %a, i8* %n
22 ; CHECK-DAG: MustAlias: %struct.A* %a, i8* %a.laundered
23 ; CHECK-DAG: MustAlias: i8* %a, i8* %a.laundered
24 ; CHECK-DAG: NoAlias: i8* %a.laundered, i8* %n
25 ; CHECK-DAG: PartialAlias (off 8): %struct.A* %a, i8* %n.laundered
26 ; CHECK-DAG: NoAlias: i8* %a, i8* %n.laundered
27 ; CHECK-DAG: MustAlias: i8* %n, i8* %n.laundered
28 ; CHECK-DAG: NoAlias: i8* %a.laundered, i8* %n.laundered
29 ; CHECK-DAG: NoModRef: Ptr: %struct.A* %a <-> %a.laundered = call ptr @llvm.launder.invariant.group.p0(ptr nonnull %a)
30 ; CHECK-DAG: NoModRef: Ptr: i8* %a <-> %a.laundered = call ptr @llvm.launder.invariant.group.p0(ptr nonnull %a)
31 ; CHECK-DAG: NoModRef: Ptr: i8* %n <-> %a.laundered = call ptr @llvm.launder.invariant.group.p0(ptr nonnull %a)
32 ; CHECK-DAG: NoModRef: Ptr: i8* %a.laundered <-> %a.laundered = call ptr @llvm.launder.invariant.group.p0(ptr nonnull %a)
33 ; CHECK-DAG: NoModRef: Ptr: i8* %n.laundered <-> %a.laundered = call ptr @llvm.launder.invariant.group.p0(ptr nonnull %a)
36 %a = alloca %struct.A, align 8
37 load %struct.A, ptr %a
39 %n = getelementptr inbounds %struct.A, ptr %a, i64 0, i32 1
41 %a.laundered = call ptr @llvm.launder.invariant.group.p0(ptr nonnull %a)
42 load i8, ptr %a.laundered
43 %n.laundered = getelementptr inbounds i8, ptr %a.laundered, i64 8
44 %v = load i8, ptr %n.laundered
45 ; make sure that the load from %n.laundered to %v aliases the store of 42 to %n
46 ; CHECK-GVN: ret i8 42
50 declare ptr @llvm.launder.invariant.group.p0(ptr)