1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -inline < %s | FileCheck %s
4 ; This tests cases where instructions in the callee are simplified to
5 ; instructions in the caller, thus making VMap contain instructions from
6 ; the caller. We should not be assigning incorrect noalias metadata in
9 declare { i64* } @opaque_callee()
11 define { i64* } @callee(i64* %x) {
12 ; CHECK-LABEL: @callee(
13 ; CHECK-NEXT: [[RES:%.*]] = insertvalue { i64* } undef, i64* [[X:%.*]], 0
14 ; CHECK-NEXT: ret { i64* } [[RES]]
16 %res = insertvalue { i64* } undef, i64* %x, 0
20 ; @opaque_callee() should not receive noalias metadata here.
21 define void @caller() {
22 ; CHECK-LABEL: @caller(
23 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !0)
24 ; CHECK-NEXT: [[S:%.*]] = call { i64* } @opaque_callee()
25 ; CHECK-NEXT: [[X:%.*]] = extractvalue { i64* } [[S]], 0
26 ; CHECK-NEXT: ret void
28 call void @llvm.experimental.noalias.scope.decl(metadata !0)
29 %s = call { i64* } @opaque_callee()
30 %x = extractvalue { i64* } %s, 0
31 call { i64* } @callee(i64* %x), !noalias !0
35 ; @opaque_callee() should no the same noalias metadata as the load from the
36 ; else branch, not as the load in the if branch.
37 define { i64* } @self_caller(i1 %c, i64* %a) {
38 ; CHECK-LABEL: @self_caller(
39 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !0)
40 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
42 ; CHECK-NEXT: [[S:%.*]] = call { i64* } @opaque_callee(), !noalias !0
43 ; CHECK-NEXT: [[X:%.*]] = extractvalue { i64* } [[S]], 0
44 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !3)
45 ; CHECK-NEXT: [[TMP1:%.*]] = load volatile i64, i64* [[X]], align 4, !alias.scope !3
46 ; CHECK-NEXT: ret { i64* } [[S]]
48 ; CHECK-NEXT: [[R2:%.*]] = insertvalue { i64* } undef, i64* [[A:%.*]], 0
49 ; CHECK-NEXT: [[TMP2:%.*]] = load volatile i64, i64* [[A]], align 4, !alias.scope !0
50 ; CHECK-NEXT: ret { i64* } [[R2]]
52 call void @llvm.experimental.noalias.scope.decl(metadata !0)
53 br i1 %c, label %if, label %else
56 %s = call { i64* } @opaque_callee(), !noalias !0
57 %x = extractvalue { i64* } %s, 0
58 %r = call { i64* } @self_caller(i1 false, i64* %x)
62 %r2 = insertvalue { i64* } undef, i64* %a, 0
63 load volatile i64, i64* %a, !alias.scope !0
67 declare void @llvm.experimental.noalias.scope.decl(metadata)
70 !1 = !{!1, !2, !"scope"}