[llvm] r340637 - [AArch64] Reject inline asm with FP registers when FP is disabled.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 12:12:13 PDT 2018


Author: efriedma
Date: Fri Aug 24 12:12:13 2018
New Revision: 340637

URL: http://llvm.org/viewvc/llvm-project?rev=340637&view=rev
Log:
[AArch64] Reject inline asm with FP registers when FP is disabled.

Otherwise, we would crash trying to deal with an illegal input.

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


Added:
    llvm/trunk/test/CodeGen/AArch64/inlineasm-illegal-type.ll
Modified:
    llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp

Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=340637&r1=340636&r2=340637&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Fri Aug 24 12:12:13 2018
@@ -5443,6 +5443,8 @@ AArch64TargetLowering::getRegForInlineAs
         return std::make_pair(0U, &AArch64::GPR64commonRegClass);
       return std::make_pair(0U, &AArch64::GPR32commonRegClass);
     case 'w':
+      if (!Subtarget->hasFPARMv8())
+        break;
       if (VT.getSizeInBits() == 16)
         return std::make_pair(0U, &AArch64::FPR16RegClass);
       if (VT.getSizeInBits() == 32)
@@ -5455,6 +5457,8 @@ AArch64TargetLowering::getRegForInlineAs
     // The instructions that this constraint is designed for can
     // only take 128-bit registers so just use that regclass.
     case 'x':
+      if (!Subtarget->hasFPARMv8())
+        break;
       if (VT.getSizeInBits() == 128)
         return std::make_pair(0U, &AArch64::FPR128_loRegClass);
       break;
@@ -5490,6 +5494,11 @@ AArch64TargetLowering::getRegForInlineAs
     }
   }
 
+  if (Res.second && !Subtarget->hasFPARMv8() &&
+      !AArch64::GPR32allRegClass.hasSubClassEq(Res.second) &&
+      !AArch64::GPR64allRegClass.hasSubClassEq(Res.second))
+    return std::make_pair(0U, nullptr);
+
   return Res;
 }
 

Added: llvm/trunk/test/CodeGen/AArch64/inlineasm-illegal-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/inlineasm-illegal-type.ll?rev=340637&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/inlineasm-illegal-type.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/inlineasm-illegal-type.ll Fri Aug 24 12:12:13 2018
@@ -0,0 +1,17 @@
+;RUN:  not llc -mtriple=aarch64-linux-gnu -mattr=-fp-armv8 < %s 2>&1 | FileCheck %s
+
+; CHECK: error: couldn't allocate output register for constraint '{d0}'
+; CHECK: error: couldn't allocate output register for constraint 'w'
+
+define hidden double @test1(double %xx) local_unnamed_addr #0 {
+entry:
+  %0 = tail call double asm "frintp ${0:d}, ${0:d}", "={d0}"()
+  ret double %0
+}
+
+define hidden double @test2(double %xx) local_unnamed_addr #0 {
+entry:
+  %0 = tail call double asm "frintp ${0:d}, ${0:d}", "=w"()
+  ret double %0
+}
+




More information about the llvm-commits mailing list