[WebAssembly] Guard use of getSymbolName with isSymbol (#156105)
WebAssemblyRegStackfy checks for writes to the stack pointer to avoid stackifying across them, but it wasn't prepared for other global_set instructions (such as writes in addrspace 1). Fixes #156055 Thanks to @QuantumSegfault for reporting and identifying the offending code.
This commit is contained in:
parent
1cee0e7b62
commit
a3c41ddcaf
2 changed files with 18 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue