summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/FunctionAttrs
diff options
context:
space:
mode:
authorHideto Ueno <uenoku.tokotoko@gmail.com>2019-11-26 07:51:59 +0000
committerHideto Ueno <uenoku.tokotoko@gmail.com>2019-11-26 07:55:28 +0000
commit78a750276f442726193b007a0010432765abe9d4 (patch)
tree860342977c1ae9747ee0ace3fcb3a509b2c79200 /llvm/test/Transforms/FunctionAttrs
parent1b20908334847f4dc7b283f0493f4c59f1c62858 (diff)
downloadbcm5719-llvm-78a750276f442726193b007a0010432765abe9d4.tar.gz
bcm5719-llvm-78a750276f442726193b007a0010432765abe9d4.zip
[Attributor] Track a GEP Instruction in align deduction
Summary: This patch enables us to track GEP instruction in align deduction. If a pointer `B` is defined as `A+Offset` and known to have alignment `C`, there exists some integer Q such that ``` A + Offset = C * Q = B ``` So we can say that the maximum power of two which is a divisor of gcd(Offset, C) is an alignment. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: lebedev.ri, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70392
Diffstat (limited to 'llvm/test/Transforms/FunctionAttrs')
-rw-r--r--llvm/test/Transforms/FunctionAttrs/align.ll61
-rw-r--r--llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll3
-rw-r--r--llvm/test/Transforms/FunctionAttrs/nocapture.ll2
3 files changed, 63 insertions, 3 deletions
diff --git a/llvm/test/Transforms/FunctionAttrs/align.ll b/llvm/test/Transforms/FunctionAttrs/align.ll
index da7bd1b5cc9..b8817a44fce 100644
--- a/llvm/test/Transforms/FunctionAttrs/align.ll
+++ b/llvm/test/Transforms/FunctionAttrs/align.ll
@@ -337,5 +337,66 @@ define i64 @test11(i32* %p) {
%ret = load i64, i64* %p-cast, align 8
ret i64 %ret
}
+
+; TEST 12
+; Test for deduction using must-be-executed-context and GEP instruction
+
+; FXIME: %p should have nonnull
+; ATTRIBUTOR: define i64 @test12-1(i32* nocapture nofree readonly align 16 %p)
+define i64 @test12-1(i32* align 4 %p) {
+ %p-cast = bitcast i32* %p to i64*
+ %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1
+ %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3
+ %ret = load i64, i64* %arrayidx1, align 16
+ ret i64 %ret
+}
+
+; FXIME: %p should have nonnull
+; ATTRIBUTOR: define i64 @test12-2(i32* nocapture nofree readonly align 16 %p)
+define i64 @test12-2(i32* align 4 %p) {
+ %p-cast = bitcast i32* %p to i64*
+ %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0
+ %ret = load i64, i64* %arrayidx0, align 16
+ ret i64 %ret
+}
+
+; FXIME: %p should have nonnull
+; ATTRIBUTOR: define void @test12-3(i32* nocapture nofree writeonly align 16 %p)
+define void @test12-3(i32* align 4 %p) {
+ %p-cast = bitcast i32* %p to i64*
+ %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1
+ %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3
+ store i64 0, i64* %arrayidx1, align 16
+ ret void
+}
+
+; FXIME: %p should have nonnull
+; ATTRIBUTOR: define void @test12-4(i32* nocapture nofree writeonly align 16 %p)
+define void @test12-4(i32* align 4 %p) {
+ %p-cast = bitcast i32* %p to i64*
+ %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0
+ store i64 0, i64* %arrayidx0, align 16
+ ret void
+}
+
+declare void @use(i64*) willreturn nounwind
+
+; ATTRIBUTOR: define void @test12-5(i32* align 16 %p)
+define void @test12-5(i32* align 4 %p) {
+ %p-cast = bitcast i32* %p to i64*
+ %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1
+ %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3
+ tail call void @use(i64* align 16 %arrayidx1)
+ ret void
+}
+
+; ATTRIBUTOR: define void @test12-6(i32* align 16 %p)
+define void @test12-6(i32* align 4 %p) {
+ %p-cast = bitcast i32* %p to i64*
+ %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0
+ tail call void @use(i64* align 16 %arrayidx0)
+ ret void
+}
+
attributes #0 = { nounwind uwtable noinline }
attributes #1 = { uwtable noinline }
diff --git a/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll b/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
index fa4d984e931..79075268ed4 100644
--- a/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
+++ b/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
@@ -260,8 +260,7 @@ entry:
; }
;
; There should *not* be a no-capture attribute on %a
-; FIXME: %a should have align 8
-; CHECK: define nonnull align 8 dereferenceable(8) i64* @not_captured_but_returned_1(i64* nofree nonnull writeonly dereferenceable(16) "no-capture-maybe-returned" %a)
+; CHECK: define nonnull align 8 dereferenceable(8) i64* @not_captured_but_returned_1(i64* nofree nonnull writeonly align 8 dereferenceable(16) "no-capture-maybe-returned" %a)
define i64* @not_captured_but_returned_1(i64* %a) #0 {
entry:
%add.ptr = getelementptr inbounds i64, i64* %a, i64 1
diff --git a/llvm/test/Transforms/FunctionAttrs/nocapture.ll b/llvm/test/Transforms/FunctionAttrs/nocapture.ll
index c54559883ae..a78af104167 100644
--- a/llvm/test/Transforms/FunctionAttrs/nocapture.ll
+++ b/llvm/test/Transforms/FunctionAttrs/nocapture.ll
@@ -259,7 +259,7 @@ define void @test_atomicrmw(i32* %p) {
}
; FNATTR: define void @test_volatile(i32* %x)
-; ATTRIBUTOR: define void @test_volatile(i32* nofree %x)
+; ATTRIBUTOR: define void @test_volatile(i32* nofree align 4 %x)
define void @test_volatile(i32* %x) {
entry:
%gep = getelementptr i32, i32* %x, i64 1
OpenPOWER on IntegriCloud