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 +}