[llvm] r342084 - [WebAssembly] Make tied inline asm operands work again
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 12 14:34:40 PDT 2018
Author: aheejin
Date: Wed Sep 12 14:34:39 2018
New Revision: 342084
URL: http://llvm.org/viewvc/llvm-project?rev=342084&view=rev
Log:
[WebAssembly] Make tied inline asm operands work again
Summary:
rL341389 broke code with tied register operands in inline assembly. For
example, `asm("" : "=r"(var) : "0"(var));`
The code above specifies the input operand to be in the same register
with the output operand, tying the two register. This patch makes this
kind of code work again.
Reviewers: dschuff
Subscribers: sbc100, jgravelle-google, eraman, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D51991
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
llvm/trunk/test/CodeGen/WebAssembly/inline-asm.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp?rev=342084&r1=342083&r2=342084&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp Wed Sep 12 14:34:39 2018
@@ -316,6 +316,9 @@ bool WebAssemblyExplicitLocals::runOnMac
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::runOnMac
// 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;
}
Modified: llvm/trunk/test/CodeGen/WebAssembly/inline-asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/inline-asm.ll?rev=342084&r1=342083&r2=342084&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/inline-asm.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/inline-asm.ll Wed Sep 12 14:34:39 2018
@@ -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}
More information about the llvm-commits
mailing list