diff options
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | 5 | ||||
-rw-r--r-- | llvm/test/CodeGen/WebAssembly/inline-asm.ll | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp index 7746316e5ba..cb7bcf3f69f 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -316,6 +316,9 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { if (MO.isDef()) { assert(MI.getOpcode() == TargetOpcode::INLINEASM); unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); + // If this register operand is tied to another operand, we can't + // change it to an immediate. Untie it first. + MI.untieRegOperand(MI.getOperandNo(&MO)); MO.ChangeToImmediate(LocalId); continue; } @@ -331,6 +334,8 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { // indices as immediates. if (MI.getOpcode() == TargetOpcode::INLINEASM) { unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg); + // Untie it first if this reg operand is tied to another operand. + MI.untieRegOperand(MI.getOperandNo(&MO)); MO.ChangeToImmediate(LocalId); continue; } diff --git a/llvm/test/CodeGen/WebAssembly/inline-asm.ll b/llvm/test/CodeGen/WebAssembly/inline-asm.ll index 0a20423d7c8..5f674f1b4de 100644 --- a/llvm/test/CodeGen/WebAssembly/inline-asm.ll +++ b/llvm/test/CodeGen/WebAssembly/inline-asm.ll @@ -97,6 +97,15 @@ entry: ret i32 %t0 } +; CHECK-LABEL: tied_operands +; CHECK: get_local $push0=, 0 +; CHECK: return $pop0 +define i32 @tied_operands(i32 %var) { +entry: + %ret = call i32 asm "", "=r,0"(i32 %var) + ret i32 %ret +} + attributes #0 = { nounwind } !0 = !{i32 47} |