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 <lkurusa@acm.org>
This commit is contained in:
parent
e5c6575801
commit
fec86c8352
6 changed files with 53 additions and 6 deletions
|
@ -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<FunctionType>(Ty), Constraints);
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
|
||||
unwrap(M)->appendModuleInlineAsm(StringRef(Asm));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue