[llvm] r350906 - [WebAssembly] Fix stack pointer store check in RegStackify
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 10 15:12:07 PST 2019
Author: aheejin
Date: Thu Jan 10 15:12:07 2019
New Revision: 350906
URL: http://llvm.org/viewvc/llvm-project?rev=350906&view=rev
Log:
[WebAssembly] Fix stack pointer store check in RegStackify
Summary:
We now use __stack_pointer global and global.get/global.set 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
`global.set` 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.
Reviewers: dschuff, sunfish
Subscribers: jgravelle-google, sbc100, llvm-commits
Differential Revision: https://reviews.llvm.org/D56094
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp?rev=350906&r1=350905&r2=350906&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp Thu Jan 10 15:12:07 2019
@@ -181,19 +181,6 @@ static void Query(const MachineInstr &MI
// 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 @@ static void Query(const MachineInstr &MI
}
}
+ // Check for writes to __stack_pointer global.
+ if (MI.getOpcode() == WebAssembly::GLOBAL_SET_I32 &&
+ strcmp(MI.getOperand(0).getSymbolName(), "__stack_pointer") == 0)
+ StackPointer = true;
+
// Analyze calls.
if (MI.isCall()) {
unsigned CalleeOpNo = WebAssembly::getCalleeOpNo(MI);
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=350906&r1=350905&r2=350906&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll Thu Jan 10 15:12:07 2019
@@ -634,7 +634,7 @@ bb10:
; NOREGS-LABEL: stackpointer_dependency:
; NOREGS: call stackpointer_callee at FUNCTION
; NOREGS: global.set __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)
More information about the llvm-commits
mailing list