summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2018-12-18 09:29:39 +0000
committerTim Northover <tnorthover@apple.com>2018-12-18 09:29:39 +0000
commit856628f707f193acee7d620c38f76b22eb583e7f (patch)
tree59860ee8018b005af45b93d8722f024250dc54fb /llvm/test
parent1ac38ba73f6210993563803b460dd9fb4449ea41 (diff)
downloadbcm5719-llvm-856628f707f193acee7d620c38f76b22eb583e7f.tar.gz
bcm5719-llvm-856628f707f193acee7d620c38f76b22eb583e7f.zip
SROA: preserve alignment tags on loads and stores.
When splitting up an alloca's uses we were dropping any explicit alignment tags, which means they default to the ABI-required default alignment and this can cause miscompiles if the real value was smaller. Also refactor the TBAA metadata into a parent class since it's shared by both children anyway. llvm-svn: 349465
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/SROA/alignment.ll47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SROA/alignment.ll b/llvm/test/Transforms/SROA/alignment.ll
index 8bc90181246..cbae6be018c 100644
--- a/llvm/test/Transforms/SROA/alignment.ll
+++ b/llvm/test/Transforms/SROA/alignment.ll
@@ -181,3 +181,50 @@ entry:
ret void
; CHECK: ret void
}
+
+define void @test8() {
+; CHECK-LABEL: @test8(
+; CHECK: load i32, {{.*}}, align 1
+; CHECK: load i32, {{.*}}, align 1
+; CHECK: load i32, {{.*}}, align 1
+; CHECK: load i32, {{.*}}, align 1
+; CHECK: load i32, {{.*}}, align 1
+
+ %ptr = alloca [5 x i32], align 1
+ %ptr.8 = bitcast [5 x i32]* %ptr to i8*
+ call void @populate(i8* %ptr.8)
+ %val = load [5 x i32], [5 x i32]* %ptr, align 1
+ ret void
+}
+
+define void @test9() {
+; CHECK-LABEL: @test9(
+; CHECK: load i32, {{.*}}, align 8
+; CHECK: load i32, {{.*}}, align 4
+; CHECK: load i32, {{.*}}, align 8
+; CHECK: load i32, {{.*}}, align 4
+; CHECK: load i32, {{.*}}, align 8
+
+ %ptr = alloca [5 x i32], align 8
+ %ptr.8 = bitcast [5 x i32]* %ptr to i8*
+ call void @populate(i8* %ptr.8)
+ %val = load [5 x i32], [5 x i32]* %ptr, align 8
+ ret void
+}
+
+define void @test10() {
+; CHECK-LABEL: @test10(
+; CHECK: load i32, {{.*}}, align 2
+; CHECK: load i8, {{.*}}, align 2
+; CHECK: load i8, {{.*}}, align 1
+; CHECK: load i8, {{.*}}, align 2
+; CHECK: load i16, {{.*}}, align 2
+
+ %ptr = alloca {i32, i8, i8, {i8, i16}}, align 2
+ %ptr.8 = bitcast {i32, i8, i8, {i8, i16}}* %ptr to i8*
+ call void @populate(i8* %ptr.8)
+ %val = load {i32, i8, i8, {i8, i16}}, {i32, i8, i8, {i8, i16}}* %ptr, align 2
+ ret void
+}
+
+declare void @populate(i8*)
OpenPOWER on IntegriCloud