From fec86c8352d57fd7764d0fa2c4975010c7de793e Mon Sep 17 00:00:00 2001 From: Levente Kurusa Date: Tue, 25 Sep 2018 20:35:19 +0200 Subject: codegen_llvm: check inline assembly constraints with LLVM LLVM provides a way of checking whether the constraints and the actual inline assembly make sense. This commit introduces a check before emitting code for the inline assembly. If LLVM rejects the inline assembly (or its constraints), then the compiler emits an error E0668 ("malformed inline assembly"). Signed-off-by: Levente Kurusa --- src/rustllvm/RustWrapper.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/rustllvm/RustWrapper.cpp') diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 9b9c908ea52..f1ab1d4ddfa 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -426,6 +426,11 @@ extern "C" LLVMValueRef LLVMRustInlineAsm(LLVMTypeRef Ty, char *AsmString, HasSideEffects, IsAlignStack, fromRust(Dialect))); } +extern "C" bool LLVMRustInlineAsmVerify(LLVMTypeRef Ty, + char *Constraints) { + return InlineAsm::Verify(unwrap(Ty), Constraints); +} + extern "C" void LLVMRustAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm) { unwrap(M)->appendModuleInlineAsm(StringRef(Asm)); } -- cgit 1.4.1-3-g733a5