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:
Levente Kurusa
2018-09-25 20:35:19 +02:00
parent e5c6575801
commit fec86c8352
6 changed files with 53 additions and 6 deletions

View File

@@ -86,7 +86,10 @@ impl FunctionCx<'a, 'll, 'tcx> {
self.codegen_operand(&bx, input).immediate()
}).collect();
asm::codegen_inline_asm(&bx, asm, outputs, input_vals);
let res = asm::codegen_inline_asm(&bx, asm, outputs, input_vals);
if !res {
span_err!(bx.sess(), statement.source_info.span, E0668, "malformed inline assembly");
}
bx
}
mir::StatementKind::FakeRead(..) |