[WebAssembly] Fix operand rewriting in inline asm lowering.
authorDan Gohman <dan433584@gmail.com>
Tue, 4 Sep 2018 17:46:12 +0000 (17:46 +0000)
committerDan Gohman <dan433584@gmail.com>
Tue, 4 Sep 2018 17:46:12 +0000 (17:46 +0000)
Use MachineOperand::ChangeToImmediate rather than reassigning
MachineOperands to new values created from MachineOperand::CreateImm,
so that their parent pointers are preserved.

This fixes "Instruction has operand with wrong parent set" errors
reported by the MachineVerifier.

llvm-svn: 341389

llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
llvm/test/CodeGen/WebAssembly/inline-asm.ll

index c2fcb43..7746316 100644 (file)
@@ -316,8 +316,7 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
         if (MO.isDef()) {
           assert(MI.getOpcode() == TargetOpcode::INLINEASM);
           unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg);
-          MRI.removeRegOperandFromUseList(&MO);
-          MO = MachineOperand::CreateImm(LocalId);
+          MO.ChangeToImmediate(LocalId);
           continue;
         }
 
@@ -332,8 +331,7 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
         // indices as immediates.
         if (MI.getOpcode() == TargetOpcode::INLINEASM) {
           unsigned LocalId = getLocalId(Reg2Local, CurLocal, OldReg);
-          MRI.removeRegOperandFromUseList(&MO);
-          MO = MachineOperand::CreateImm(LocalId);
+          MO.ChangeToImmediate(LocalId);
           continue;
         }
 
index 0864d6c..0a20423 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -no-integrated-as | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -no-integrated-as -verify-machineinstrs | FileCheck %s
 
 ; Test basic inline assembly. Pass -no-integrated-as since these aren't
 ; actually valid assembly syntax.