diff options
| author | Levente Kurusa <lkurusa@acm.org> | 2018-09-25 20:35:19 +0200 |
|---|---|---|
| committer | Levente Kurusa <lkurusa@acm.org> | 2018-09-25 20:38:35 +0200 |
| commit | fec86c8352d57fd7764d0fa2c4975010c7de793e (patch) | |
| tree | 76d7eb0fbda781b8ee5a5c6aca645a99d4946d7f /src/librustc_codegen_llvm/asm.rs | |
| parent | e5c6575801028f5e089ef2e7720aa1af9d452334 (diff) | |
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>
Diffstat (limited to 'src/librustc_codegen_llvm/asm.rs')
| -rw-r--r-- | src/librustc_codegen_llvm/asm.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index 5d27f8eab3e..f1bb41bceba 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -30,7 +30,7 @@ pub fn codegen_inline_asm( ia: &hir::InlineAsm, outputs: Vec<PlaceRef<'ll, 'tcx>>, mut inputs: Vec<&'ll Value> -) { +) -> bool { let mut ext_constraints = vec![]; let mut output_types = vec![]; @@ -97,6 +97,10 @@ pub fn codegen_inline_asm( ia.alignstack, dialect ); + if r.is_none() { + return false; + } + let r = r.unwrap(); // Again, based on how many outputs we have let outputs = ia.outputs.iter().zip(&outputs).filter(|&(ref o, _)| !o.is_indirect); @@ -117,6 +121,8 @@ pub fn codegen_inline_asm( llvm::LLVMSetMetadata(r, kind, llvm::LLVMMDNodeInContext(bx.cx.llcx, &val, 1)); } + + return true; } pub fn codegen_global_asm<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, |
