From: Akira Hatanaka Date: Fri, 5 Sep 2014 22:30:32 +0000 (+0000) Subject: [inline asm] Add a check in InlineAsm::ConstraintInfo::Parse to make sure '{' X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cbbae7f41d3f10316c17731b35c3aafd7db2d6be;p=oota-llvm.git [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217288 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/InlineAsm.cpp b/lib/IR/InlineAsm.cpp index a3e1da3b189..16d874f32fc 100644 --- a/lib/IR/InlineAsm.cpp +++ b/lib/IR/InlineAsm.cpp @@ -91,6 +91,10 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, if (*I == '~') { Type = isClobber; ++I; + + // '{' must immediately follow '~'. + if (I != E && *I != '{') + return true; } else if (*I == '=') { ++I; Type = isOutput; diff --git a/test/Assembler/inline-asm-clobber.ll b/test/Assembler/inline-asm-clobber.ll new file mode 100644 index 00000000000..65c8e444e80 --- /dev/null +++ b/test/Assembler/inline-asm-clobber.ll @@ -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 +}