Skip to content

Commit 2b02e6f

Browse files
committed
Test for alias analysis of views
1 parent 15b8dd9 commit 2b02e6f

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
; RUN: opt -O1 -S < %s | FileCheck %s
2+
; ModuleID = 'injective.c'
3+
; Check for alias analysis of hyperobject views and CSE of
4+
; multiple calls to llvm.tapir.frame within a spindle.
5+
source_filename = "injective.c"
6+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7+
target triple = "x86_64-unknown-freebsd13.2"
8+
9+
@x = external dso_local global i32, align 4
10+
@y = external dso_local global i32, align 4
11+
12+
; CHECK-LABEL: @alter
13+
; Function Attrs: nounwind uwtable
14+
define dso_local i32 @alter() #0 {
15+
entry:
16+
; One frame lookup remains.
17+
; CHECK: %frame = notail call ptr @llvm.tapir.frame()
18+
%frame = notail call ptr @llvm.tapir.frame()
19+
; CHECK: %viewx = notail call ptr @llvm.hyper.lookup.i64(ptr %frame, ptr hyper_view injective @x, i64 4, ptr nonnull @zero, ptr nonnull @plus)
20+
%viewx = notail call ptr @llvm.hyper.lookup.i64(ptr %frame, ptr hyper_view injective @x, i64 4, ptr nonnull @zero, ptr nonnull @plus)
21+
; CHECK: %0 = load i32, ptr %viewx, align 4, !tbaa !4
22+
%0 = load i32, ptr %viewx, align 4, !tbaa !4
23+
%inc = add nsw i32 %0, 1
24+
store i32 %inc, ptr %viewx, align 4, !tbaa !4
25+
%1 = call ptr @llvm.tapir.frame()
26+
; The frame lookups should have been CSE-ed.
27+
; CHECK-NOT: call ptr @llvm.tapir.frame()
28+
; CHECK: notail call ptr @llvm.hyper.lookup.i64(ptr %frame, ptr hyper_view injective @y, i64 4, ptr nonnull @zero, ptr nonnull @plus)
29+
; CHECK-NOT: @llvm.tapir.frame()
30+
; CHECK-NOT: @llvm.hyper.lookup.i64
31+
%viewy = notail call ptr @llvm.hyper.lookup.i64(ptr %1, ptr hyper_view injective @y, i64 4, ptr nonnull @zero, ptr nonnull @plus)
32+
; CHECK: %yinit = load i32, ptr %viewy, align 4, !tbaa !4
33+
%yinit = load i32, ptr %viewy, align 4, !tbaa !4
34+
; CHECK-NOT: load
35+
; CHECK-NOT: @llvm.tapir.frame()
36+
; CHECK-NOT: @llvm.hyper.lookup.i64
37+
%inc1 = add nsw i32 %yinit, 1
38+
store i32 %inc1, ptr %viewy, align 4, !tbaa !4
39+
%2 = call ptr @llvm.tapir.frame()
40+
%3 = notail call ptr @llvm.hyper.lookup.i64(ptr %2, ptr hyper_view injective @x, i64 4, ptr nonnull @zero, ptr nonnull @plus)
41+
%4 = load i32, ptr %3, align 4, !tbaa !4
42+
%5 = call ptr @llvm.tapir.frame()
43+
%6 = notail call ptr @llvm.hyper.lookup.i64(ptr %5, ptr hyper_view injective @y, i64 4, ptr nonnull @zero, ptr nonnull @plus)
44+
%7 = load i32, ptr %6, align 4, !tbaa !4
45+
%add = add nsw i32 %4, %7
46+
; CHECK: ret i32 %add
47+
ret i32 %add
48+
}
49+
50+
; Function Attrs: nounwind strand_pure willreturn memory(read)
51+
declare ptr @llvm.tapir.frame() #1
52+
53+
; Function Attrs: nounwind strand_pure willreturn memory(inaccessiblemem: read)
54+
declare ptr @llvm.hyper.lookup.i64(ptr, ptr align 1 injective, i64, ptr, ptr) #2
55+
56+
declare dso_local void @zero(ptr noundef) #3
57+
58+
declare dso_local void @plus(ptr noundef, ptr noundef) #3
59+
60+
attributes #0 = { nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
61+
attributes #1 = { nounwind strand_pure willreturn memory(read) }
62+
attributes #2 = { nounwind strand_pure willreturn memory(inaccessiblemem: read) }
63+
attributes #3 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
64+
65+
!llvm.module.flags = !{!0, !1, !2}
66+
!llvm.ident = !{!3}
67+
68+
!0 = !{i32 1, !"wchar_size", i32 4}
69+
!1 = !{i32 7, !"uwtable", i32 2}
70+
!2 = !{i32 7, !"frame-pointer", i32 2}
71+
!3 = !{!"clang version 16.0.6 (git@github.com:OpenCilk/opencilk-project.git 0ae760ffead5cd23cdd587da515c256f2c0570d6)"}
72+
!4 = !{!5, !5, i64 0}
73+
!5 = !{!"int", !6, i64 0}
74+
!6 = !{!"omnipotent char", !7, i64 0}
75+
!7 = !{!"Simple C/C++ TBAA"}

0 commit comments

Comments
 (0)