[llvm] bb7016f - [Aarch64] handle "o" inline asm memory constraints

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 15 23:36:36 PDT 2021


Author: Nick Desaulniers
Date: 2021-04-15T23:36:21-07:00
New Revision: bb7016f8f50e1f1b8d388a9a42e3a7bb51254ca2

URL: https://github.com/llvm/llvm-project/commit/bb7016f8f50e1f1b8d388a9a42e3a7bb51254ca2
DIFF: https://github.com/llvm/llvm-project/commit/bb7016f8f50e1f1b8d388a9a42e3a7bb51254ca2.diff

LOG: [Aarch64] handle "o" inline asm memory constraints

This Linux kernel is making use of this inline asm constraint which is
causing an ICE.

PR49956

Link: https://github.com/ClangBuiltLinux/linux/issues/1348

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D100412

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
    llvm/lib/Target/AArch64/AArch64ISelLowering.h
    llvm/test/CodeGen/AArch64/arm64-inline-asm.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
index f70eee6037061..3d8aa291a8961 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
@@ -369,6 +369,7 @@ bool AArch64DAGToDAGISel::SelectInlineAsmMemoryOperand(
   default:
     llvm_unreachable("Unexpected asm memory constraint");
   case InlineAsm::Constraint_m:
+  case InlineAsm::Constraint_o:
   case InlineAsm::Constraint_Q:
     // We need to make sure that this one operand does not end up in XZR, thus
     // require the address to be in a PointerRegClass register.

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
index 63df223261502..c67f3b0a9d4f8 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -1027,6 +1027,8 @@ class AArch64TargetLowering : public TargetLowering {
   unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
     if (ConstraintCode == "Q")
       return InlineAsm::Constraint_Q;
+    if (ConstraintCode == "o")
+      return InlineAsm::Constraint_o;
     // FIXME: clang has code for 'Ump', 'Utf', 'Usa', and 'Ush' but these are
     //        followed by llvm_unreachable so we'll leave them unimplemented in
     //        the backend for now.

diff  --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm.ll
index 5381e65015dff..cb3e095aceb21 100644
--- a/llvm/test/CodeGen/AArch64/arm64-inline-asm.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm.ll
@@ -297,3 +297,13 @@ entry:
   call void asm sideeffect "", "=*r|m,0,~{memory}"(<9 x float>* nonnull %m.addr, <9 x float> %m)
   ret void
 }
+
+define void @test_o_output_constraint() {
+; CHECK-LABEL: test_o_output_constraint:
+; CHECK: sub sp, sp, #16
+; CHECK: add x[[REG:[0-9]+]], sp, #15
+; CHECK: mov [x[[REG]]], 7
+  %b = alloca i8, align 1
+  call void asm "mov $0, 7", "=*o"(i8* %b)
+  ret void
+}


        


More information about the llvm-commits mailing list