[PATCH] D151979: [RISCV] Handle "o" inline asm memory constraint
Wang Pengcheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 2 01:05:21 PDT 2023
pcwang-thead created this revision.
pcwang-thead added reviewers: MaskRay, asb, craig.topper, kito-cheng, jrtc27.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
pcwang-thead requested review of this revision.
Herald added subscribers: llvm-commits, eopXD.
Herald added a project: LLVM.
This is the same as D100412 <https://reviews.llvm.org/D100412>.
We just found the same crash when we tried to compile some packges
like mariadb, php, etc.
For constraint "o", it means "A memory operand is allowed, but
only if the address is offsettable.". So I think it can be handled
just like constraint "m" for RISCV target.
And we print verbose information when unsupported constraints occur.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151979
Files:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/inline-asm.ll
Index: llvm/test/CodeGen/RISCV/inline-asm.ll
===================================================================
--- llvm/test/CodeGen/RISCV/inline-asm.ll
+++ llvm/test/CodeGen/RISCV/inline-asm.ll
@@ -101,6 +101,22 @@
ret i32 %2
}
+define void @constraint_o(ptr %a) nounwind {
+; RV32I-LABEL: constraint_o:
+; RV32I: # %bb.0:
+; RV32I-NEXT: #APP
+; RV32I-NEXT: #NO_APP
+; RV32I-NEXT: ret
+;
+; RV64I-LABEL: constraint_o:
+; RV64I: # %bb.0:
+; RV64I-NEXT: #APP
+; RV64I-NEXT: #NO_APP
+; RV64I-NEXT: ret
+ call void asm sideeffect "", "=*o"(ptr elementtype(i32) %a)
+ ret void
+}
+
define void @constraint_I() nounwind {
; RV32I-LABEL: constraint_I:
; RV32I: # %bb.0:
Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -2128,6 +2128,7 @@
// Always produce a register and immediate operand, as expected by
// RISCVAsmPrinter::PrintAsmMemoryOperand.
switch (ConstraintID) {
+ case InlineAsm::Constraint_o:
case InlineAsm::Constraint_m: {
SDValue Op0, Op1;
bool Found = SelectAddrRegImm(Op, Op0, Op1);
@@ -2143,7 +2144,9 @@
CurDAG->getTargetConstant(0, SDLoc(Op), Subtarget->getXLenVT()));
return false;
default:
- break;
+ llvm_unreachable(("Unexpected asm memory constraint " +
+ InlineAsm::getMemConstraintName(ConstraintID).str())
+ .c_str());
}
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151979.527771.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230602/6421960d/attachment.bin>
More information about the llvm-commits
mailing list