summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2020-02-27 17:01:09 +0100
committerHans Wennborg <hans@chromium.org>2020-02-28 11:27:33 +0100
commit7cb6829291280a2adcc260346a7a56b8bddd43db (patch)
treee83dacfb78d6bd03654c9314351dc9e39648c6bc /llvm/test/Transforms
parentdaae05af2a5d1170de6940569128dcf071db32ef (diff)
downloadbcm5719-llvm-7cb6829291280a2adcc260346a7a56b8bddd43db.tar.gz
bcm5719-llvm-7cb6829291280a2adcc260346a7a56b8bddd43db.zip
SROA: Don't drop atomic load/store alignments (PR45010)
SROA will drop the explicit alignment on allocas when the ABI guarantees enough alignment. Because the alignment on new load/store instructions are set based on the alloca's alignment, that means SROA would end up dropping the alignment from atomic loads and stores, which is not allowed (see bug). For those, make sure to always carry over the alignment from the previous instruction. Differential revision: https://reviews.llvm.org/D75266 (cherry picked from commit d48c981697a49653efff9dd14fa692d99e6fa868)
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/SROA/alignment.ll15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SROA/alignment.ll b/llvm/test/Transforms/SROA/alignment.ll
index 81f8f2a00ba..674f45fb166 100644
--- a/llvm/test/Transforms/SROA/alignment.ll
+++ b/llvm/test/Transforms/SROA/alignment.ll
@@ -228,4 +228,19 @@ define void @test10() {
ret void
}
+%struct = type { i32, i32 }
+define dso_local i32 @pr45010(%struct* %A) {
+; CHECK-LABEL: @pr45010
+; CHECK: load atomic volatile i32, {{.*}}, align 4
+
+ %B = alloca %struct, align 4
+ %A.i = getelementptr inbounds %struct, %struct* %A, i32 0, i32 0
+ %B.i = getelementptr inbounds %struct, %struct* %B, i32 0, i32 0
+ %1 = load i32, i32* %A.i, align 4
+ store atomic volatile i32 %1, i32* %B.i release, align 4
+ %2 = bitcast %struct* %B to i32*
+ %x = load atomic volatile i32, i32* %2 acquire, align 4
+ ret i32 %x
+}
+
declare void @populate(i8*)
OpenPOWER on IntegriCloud