[PATCH] D158062: [RISCV] Teach RISCVMergeBaseOffset to handle inline asm

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 14:03:31 PDT 2023


jrtc27 added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp:462
+        }
+        NewMI->addOperand(UseMI.getOperand(I));
+        NewMI->addOperand(ImmOp);
----------------
wangpc wrote:
> craig.topper wrote:
> > craig.topper wrote:
> > > Can we use MachineOperand::ChangeToGA and MachineOperand::ChangeToMCSymbol to avoid building a new instruction?
> > Though I guess we would also need ChangeToCPI for constant pool?
> There are four cases of using `RISCVTargetLowering::getAddr`: `GlobalAddress`, `BlockAddress`, `ConstantPool` and `JumpTable`.
> `BlockAddress`, `ConstantPool` and `JumpTable` are used in compiler intenelly, so user can't use it in inline asm(?). And there is no corresponding `changeToXXX` methods for them (If they are really needed, I can add them in another patch).
> 
You can absolutely get a BlockAddress in IR, and that's exposed to C for the GNU indirect goto `&&label` syntax. You have to write some very cursed C (something like `"m"(*(void **)&&label)`) to end up with it in an m constraint, but it's technically possible to write, and so that input will now hit this report_fatal_error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158062/new/

https://reviews.llvm.org/D158062



More information about the llvm-commits mailing list