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:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user