[llvm] r217288 - [inline asm] Add a check in InlineAsm::ConstraintInfo::Parse to make sure '{'

Akira Hatanaka ahatanaka at apple.com
Fri Sep 5 15:30:32 PDT 2014


Author: ahatanak
Date: Fri Sep  5 17:30:32 2014
New Revision: 217288

URL: http://llvm.org/viewvc/llvm-project?rev=217288&view=rev
Log:
[inline asm] Add a check in InlineAsm::ConstraintInfo::Parse to make sure '{'
follows '~' in a clobber constraint string.

Previously llc would hit an llvm_unreachable when compiling an inline-asm
instruction with malformed constraint string "~x{21}". This commit enables
LLParser to catch the error earlier and print a more helpful diagnostic.

rdar://problem/14206559

Added:
    llvm/trunk/test/Assembler/inline-asm-clobber.ll
Modified:
    llvm/trunk/lib/IR/InlineAsm.cpp

Modified: llvm/trunk/lib/IR/InlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/InlineAsm.cpp?rev=217288&r1=217287&r2=217288&view=diff
==============================================================================
--- llvm/trunk/lib/IR/InlineAsm.cpp (original)
+++ llvm/trunk/lib/IR/InlineAsm.cpp Fri Sep  5 17:30:32 2014
@@ -91,6 +91,10 @@ bool InlineAsm::ConstraintInfo::Parse(St
   if (*I == '~') {
     Type = isClobber;
     ++I;
+
+    // '{' must immediately follow '~'.
+    if (I != E && *I != '{')
+      return true;
   } else if (*I == '=') {
     ++I;
     Type = isOutput;

Added: llvm/trunk/test/Assembler/inline-asm-clobber.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/inline-asm-clobber.ll?rev=217288&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/inline-asm-clobber.ll (added)
+++ llvm/trunk/test/Assembler/inline-asm-clobber.ll Fri Sep  5 17:30:32 2014
@@ -0,0 +1,10 @@
+; RUN: not llvm-as <%s 2>&1  | FileCheck %s
+
+; "~x{21}" is not a valid clobber constraint.
+
+; CHECK: invalid type for inline asm constraint string
+
+define void @foo() nounwind {
+  call void asm sideeffect "mov x0, #42", "~{x0},~{x19},~x{21}"() nounwind
+  ret void
+}





More information about the llvm-commits mailing list