Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ static void query(const MachineInstr &MI, bool &Read, bool &Write,
// Check for writes to __stack_pointer global.
if ((MI.getOpcode() == WebAssembly::GLOBAL_SET_I32 ||
MI.getOpcode() == WebAssembly::GLOBAL_SET_I64) &&
strcmp(MI.getOperand(0).getSymbolName(), "__stack_pointer") == 0)
MI.getOperand(0).isSymbol() &&
!strcmp(MI.getOperand(0).getSymbolName(), "__stack_pointer"))
StackPointer = true;

// Analyze calls.
Expand Down
16 changes: 16 additions & 0 deletions llvm/test/CodeGen/WebAssembly/global-set.ll
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ define void @set_f64_global(double %v) {
ret void
}

declare i32 @get_i32()
define i32 @stackifyAcrossGlobalSet() {
; https://github.com/llvm/llvm-project/issues/156055
; CHECK-LABEL: stackifyAcrossGlobalSet:
; CHECK-NEXT: .functype
; CHECK-NEXT: .local
; CHECK-NEXT: call get_i32
; CHECK-NEXT: local.tee
; CHECK-NEXT: global.set i32_global
; CHECK-NEXT: local.get
; CHECK-NEXT: end_function
%1 = call i32 @get_i32()
store i32 %1, ptr addrspace(1) @i32_global
ret i32 %1
}

; CHECK: .globaltype i32_global, i32
; CHECK: .globl i32_global
; CHECK-LABEL: i32_global:
Expand Down
Loading