diff options
author | Heejin Ahn <aheejin@gmail.com> | 2018-09-12 21:34:39 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2018-09-12 21:34:39 +0000 |
commit | 300f42fbce713633f77aee0c16e84f1ce840102b (patch) | |
tree | 1faf12a01bdb3319321c5442bb20234603c3f282 /llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | |
parent | d341988c86ce45a138ff78732dbbb80b78df2ad4 (diff) | |
download | llvm-300f42fbce713633f77aee0c16e84f1ce840102b.zip llvm-300f42fbce713633f77aee0c16e84f1ce840102b.tar.gz llvm-300f42fbce713633f77aee0c16e84f1ce840102b.tar.bz2 |
[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
llvm-svn: 342084
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp index 7746316..cb7bcf3 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; } |