[BOLT] Fix X86MCPlusBuilder::replaceRegWithImm
authorAmir Ayupov <aaupov@fb.com>
Thu, 24 Feb 2022 06:30:03 +0000 (22:30 -0800)
committerAmir Ayupov <aaupov@fb.com>
Tue, 1 Mar 2022 03:24:46 +0000 (19:24 -0800)
commit08dcbed92ff99945384311d64225c5cb3d78e79f
treec0dab01960901fd1dbc74ac6dd6f7e78a4a8e476
parenta552fb2a86dba5e33bd94fbcddfd5597eb49e619
[BOLT] Fix X86MCPlusBuilder::replaceRegWithImm

Reassigning the operand didn't update the operand type which resulted in an
assertion (`Assertion `isReg() && "This is not a register operand!"' failed.`)
Reset the instruction instead.

Test Plan:
```
ninja check-bolt
...
PASS: BOLT-Unit :: Core/./CoreTests/X86/MCPlusBuilderTester.ReplaceRegWithImm/0 (90 of 136)
```

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D120263
bolt/lib/Target/X86/X86MCPlusBuilder.cpp
bolt/test/X86/tail-duplication-prop-bug.s
bolt/unittests/Core/MCPlusBuilder.cpp