[llvm] r258285 - [WebAssembly] Don't stackify stores across instructions with side effects.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 20:21:16 PST 2016
Author: djg
Date: Tue Jan 19 22:21:16 2016
New Revision: 258285
URL: http://llvm.org/viewvc/llvm-project?rev=258285&view=rev
Log:
[WebAssembly] Don't stackify stores across instructions with side effects.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll
llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp?rev=258285&r1=258284&r2=258285&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp Tue Jan 19 22:21:16 2016
@@ -128,7 +128,7 @@ static bool IsSafeToMove(const MachineIn
// Check for memory dependencies and side effects.
for (--I; I != D; --I)
- SawSideEffects |= I->isSafeToMove(&AA, SawStore);
+ SawSideEffects |= !I->isSafeToMove(&AA, SawStore);
return !(SawStore && Def->mayLoad() && !Def->isInvariantLoad(&AA)) &&
!(SawSideEffects && !Def->isSafeToMove(&AA, SawStore));
}
Modified: llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll?rev=258285&r1=258284&r2=258285&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll Tue Jan 19 22:21:16 2016
@@ -128,4 +128,21 @@ return:
ret void
}
+; Don't stackify stores effects across other instructions with side effects.
+
+; CHECK: side_effects:
+; CHECK: store
+; CHECK-NEXT: call
+; CHECK-NEXT: store
+; CHECK-NEXT: call
+declare void @evoke_side_effects()
+define hidden void @stackify_store_across_side_effects(double* nocapture %d) {
+entry:
+ store double 2.0, double* %d
+ call void @evoke_side_effects()
+ store double 2.0, double* %d
+ call void @evoke_side_effects()
+ ret void
+}
+
!0 = !{}
Modified: llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/userstack.ll?rev=258285&r1=258284&r2=258285&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/userstack.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/userstack.ll Tue Jan 19 22:21:16 2016
@@ -47,31 +47,37 @@ define void @alloca3264() {
}
; CHECK-LABEL: allocarray:
-; CHECK: .local i32, i32, i32, i32, i32, i32{{$}}
+; CHECK: .local i32, i32, i32, i32, i32{{$}}
define void @allocarray() {
- ; CHECK: i32.const [[L1:.+]]=, __stack_pointer
+ ; CHECK-NEXT: i32.const [[L1:.+]]=, __stack_pointer
; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]])
- ; CHECK-NEXT: i32.const [[L2:.+]]=, 32
+ ; CHECK-NEXT: i32.const [[L2:.+]]=, 32{{$}}
; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]]
+ ; CHECK-NEXT: i32.const [[L2]]=, __stack_pointer{{$}}
+ ; CHECK-NEXT: i32.store [[SP]]=, 0([[L2]]), [[SP]]
%r = alloca [5 x i32]
- ; CHECK: i32.const $push[[L3:.+]]=, 1
- ; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]]
+
+ ; CHECK-NEXT: i32.const $push[[L4:.+]]=, 4
+ ; CHECK-NEXT: i32.const [[L5:.+]]=, 12
+ ; CHECK-NEXT: i32.add [[L5]]=, [[SP]], [[L5]]
+ ; CHECK-NEXT: i32.add $push[[L6:.+]]=, [[L5]], $pop[[L4]]
+ ; CHECK-NEXT: i32.const $push[[L9:.+]]=, 1{{$}}
+ ; CHECK-NEXT: i32.store $push[[L10:.+]]=, 12([[SP]]), $pop[[L9]]{{$}}
+ ; CHECK-NEXT: i32.store $discard=, 0($pop3), $pop[[L10]]{{$}}
%p = getelementptr [5 x i32], [5 x i32]* %r, i32 0, i32 0
store i32 1, i32* %p
- ; CHECK: i32.const $push[[L4:.+]]=, 4
- ; CHECK: i32.const [[L5:.+]]=, 12
- ; CHECK: i32.add [[L5]]=, [[SP]], [[L5]]
- ; CHECK: i32.add $push[[L6:.+]]=, [[L5]], $pop[[L4]]
- ; CHECK: i32.store {{.*}}=, 0($pop[[L6]]), ${{.+}}
%p2 = getelementptr [5 x i32], [5 x i32]* %r, i32 0, i32 1
store i32 1, i32* %p2
- ; CHECK: i32.const [[L7:.+]]=, 32
+
+ ; CHECK-NEXT: i32.const [[L7:.+]]=, 32
; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L7]]
; CHECK-NEXT: i32.const [[L8:.+]]=, __stack_pointer
- ; CHECK-NEXT: i32.store [[SP]]=, 0([[L7]]), [[SP]]
+ ; CHECK-NEXT: i32.store [[SP]]=, 0([[L8]]), [[SP]]
ret void
}
+; CHECK-LABEL: allocarray_inbounds:
+; CHECK: .local i32, i32, i32, i32{{$}}
define void @allocarray_inbounds() {
; CHECK: i32.const [[L1:.+]]=, __stack_pointer
; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]])
@@ -93,6 +99,7 @@ define void @allocarray_inbounds() {
ret void
}
+; CHECK-LABEL: dynamic_alloca:
define void @dynamic_alloca(i32 %alloc) {
; TODO: Support frame pointers
;%r = alloca i32, i32 %alloc
More information about the llvm-commits
mailing list