[PATCH] D56094: [WebAssembly] Fix stack pointer store check in RegStackify
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 26 14:47:31 PST 2018
aheejin created this revision.
aheejin added reviewers: sbc100, sunfish.
Herald added subscribers: llvm-commits, jgravelle-google, dschuff.
We now use __stack_pointer global and get_global/set_global instruction.
This fixes the checking routine for stack_pointer writes accordingly.
This also fixes the existing __stack_pointer test in reg-stackify.ll:
That test used to pass not because of __stack_pointer clashes but
because the function `stackpointer_callee` was not marked as `readnone`,
so it was assumed to possibly write to memory arbitraily, and
`set_global` instruction was marked as `mayStore` in the .td definition,
so they were identified as intervening writes. After we added `readnone`
to its attribute, this test fails without this patch.
Repository:
rL LLVM
https://reviews.llvm.org/D56094
Files:
lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
test/CodeGen/WebAssembly/reg-stackify.ll
Index: test/CodeGen/WebAssembly/reg-stackify.ll
===================================================================
--- test/CodeGen/WebAssembly/reg-stackify.ll
+++ test/CodeGen/WebAssembly/reg-stackify.ll
@@ -634,7 +634,7 @@
; NOREGS-LABEL: stackpointer_dependency:
; NOREGS: call stackpointer_callee at FUNCTION
; NOREGS: set_global __stack_pointer
-declare i32 @stackpointer_callee(i8* readnone, i8* readnone)
+declare i32 @stackpointer_callee(i8* readnone, i8* readnone) nounwind readnone
declare i8* @llvm.frameaddress(i32)
define i32 @stackpointer_dependency(i8* readnone) {
%2 = tail call i8* @llvm.frameaddress(i32 0)
Index: lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
+++ lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
@@ -181,19 +181,6 @@
// Check for stores.
if (MI.mayStore()) {
Write = true;
-
- // Check for stores to __stack_pointer.
- for (auto MMO : MI.memoperands()) {
- const MachinePointerInfo &MPI = MMO->getPointerInfo();
- if (MPI.V.is<const PseudoSourceValue *>()) {
- auto PSV = MPI.V.get<const PseudoSourceValue *>();
- if (const ExternalSymbolPseudoSourceValue *EPSV =
- dyn_cast<ExternalSymbolPseudoSourceValue>(PSV))
- if (StringRef(EPSV->getSymbol()) == "__stack_pointer") {
- StackPointer = true;
- }
- }
- }
} else if (MI.hasOrderedMemoryRef()) {
switch (MI.getOpcode()) {
case WebAssembly::DIV_S_I32:
@@ -258,6 +245,11 @@
}
}
+ // Check for stores to __stack_pointer global.
+ if (MI.getOpcode() == WebAssembly::SET_GLOBAL_I32 &&
+ strcmp(MI.getOperand(0).getSymbolName(), "__stack_pointer") == 0)
+ StackPointer = true;
+
// Analyze calls.
if (MI.isCall()) {
unsigned CalleeOpNo = WebAssembly::getCalleeOpNo(MI);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56094.179529.patch
Type: text/x-patch
Size: 1930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181226/b7d240d2/attachment.bin>
More information about the llvm-commits
mailing list