Skip to content
Open
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
15 changes: 15 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,21 @@ define void @set_f64_global(double %v) {
ret void
}

declare i32 @get_i32()
define i32 @testFunc() {
; CHECK-LABEL: testFunc:
; 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without %2 = add i32 %1, 1 in the reproducer in #156055, this doesn't seem to trigger the assertion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I just tested locally, and if I comment out the change in WebAssemblyRegStackify.cpp, this test fails. I wonder if there is some difference in how the backend is being run. Although there are no special flags or anything AFAIK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're right, I can reproduce it now. I'm not sure why I wasn't able to last week.. I guess I was confused or something.
By the way how about making the function name a little descriptive than testFunc? Otherwise LGTM.

ret i32 %1
}

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