[llvm] 37f4955 - [mips] Fix `getRegForInlineAsmConstraint` to do not crash on empty Constraint

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 13:51:01 PST 2019


Author: Simon Atanasyan
Date: 2019-11-06T00:50:39+03:00
New Revision: 37f4955c9baba9f981100b3137cb9486c0d75ce8

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

LOG: [mips] Fix `getRegForInlineAsmConstraint` to do not crash on empty Constraint

Added: 
    llvm/test/CodeGen/Mips/constraint-empty.ll

Modified: 
    llvm/lib/Target/Mips/MipsISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index 906c9a9555f1..eb460ca37979 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -4008,11 +4008,13 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
     }
   }
 
-  std::pair<unsigned, const TargetRegisterClass *> R;
-  R = parseRegForInlineAsmConstraint(Constraint, VT);
+  if (!Constraint.empty()) {
+    std::pair<unsigned, const TargetRegisterClass *> R;
+    R = parseRegForInlineAsmConstraint(Constraint, VT);
 
-  if (R.second)
-    return R;
+    if (R.second)
+      return R;
+  }
 
   return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
 }

diff  --git a/llvm/test/CodeGen/Mips/constraint-empty.ll b/llvm/test/CodeGen/Mips/constraint-empty.ll
new file mode 100644
index 000000000000..65b5d436457b
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/constraint-empty.ll
@@ -0,0 +1,14 @@
+; Check that `getRegForInlineAsmConstraint` does not crash on empty Constraint.
+; RUN: llc -march=mips64 < %s | FileCheck %s
+
+define void @foo() {
+entry:
+  %s = alloca i32, align 4
+  %x = alloca i32, align 4
+  call void asm "", "=*imr,=*m,0,*m,~{$1}"(i32* %x, i32* %s, i32* %x, i32* %s)
+
+; CHECK: #APP
+; CHECK: #NO_APP
+
+  ret void
+}


        


More information about the llvm-commits mailing list