1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=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 { ptr } @opaque_callee()
11 define { ptr } @callee(ptr %x) {
12 ; CHECK-LABEL: @callee(
13 ; CHECK-NEXT: [[RES:%.*]] = insertvalue { ptr } poison, ptr [[X:%.*]], 0
14 ; CHECK-NEXT: ret { ptr } [[RES]]
16 %res = insertvalue { ptr } poison, ptr %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 [[META0:![0-9]+]])
24 ; CHECK-NEXT: [[S:%.*]] = call { ptr } @opaque_callee()
25 ; CHECK-NEXT: [[X:%.*]] = extractvalue { ptr } [[S]], 0
26 ; CHECK-NEXT: ret void
28 call void @llvm.experimental.noalias.scope.decl(metadata !0)
29 %s = call { ptr } @opaque_callee()
30 %x = extractvalue { ptr } %s, 0
31 call { ptr } @callee(ptr %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 { ptr } @self_caller(i1 %c, ptr %a) {
38 ; CHECK-LABEL: @self_caller(
39 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata [[META0]])
40 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
42 ; CHECK-NEXT: [[S:%.*]] = call { ptr } @opaque_callee(), !noalias !0
43 ; CHECK-NEXT: [[X:%.*]] = extractvalue { ptr } [[S]], 0
44 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata [[META3:![0-9]+]])
45 ; CHECK-NEXT: [[TMP1:%.*]] = load volatile i64, ptr [[X]], align 4, !alias.scope !3
46 ; CHECK-NEXT: ret { ptr } [[S]]
48 ; CHECK-NEXT: [[R2:%.*]] = insertvalue { ptr } poison, ptr [[A:%.*]], 0
49 ; CHECK-NEXT: [[TMP2:%.*]] = load volatile i64, ptr [[A]], align 4, !alias.scope !0
50 ; CHECK-NEXT: ret { ptr } [[R2]]
52 call void @llvm.experimental.noalias.scope.decl(metadata !0)
53 br i1 %c, label %if, label %else
56 %s = call { ptr } @opaque_callee(), !noalias !0
57 %x = extractvalue { ptr } %s, 0
58 %r = call { ptr } @self_caller(i1 false, ptr %x)
62 %r2 = insertvalue { ptr } poison, ptr %a, 0
63 load volatile i64, ptr %a, !alias.scope !0
67 declare void @llvm.experimental.noalias.scope.decl(metadata)
70 !1 = !{!1, !2, !"scope"}