diff options
| author | bors <bors@rust-lang.org> | 2018-09-28 09:17:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-28 09:17:28 +0000 |
| commit | d623ec6ba32b2d056810c7a8dabdc3e5198a2a53 (patch) | |
| tree | 794a6e273ec9f299722e53b3d8359db5b18bcf98 /src/rustllvm/RustWrapper.cpp | |
| parent | bd8d030d014a4aa13b9b02b0ce98e2de2a2c54be (diff) | |
| parent | 0991d2098f9b750331962ad5566200644a00f69e (diff) | |
| download | rust-d623ec6ba32b2d056810c7a8dabdc3e5198a2a53.tar.gz rust-d623ec6ba32b2d056810c7a8dabdc3e5198a2a53.zip | |
Auto merge of #54568 - levex:issue-54130, r=nagisa
codegen_llvm: check inline assembly constraints with LLVM
---%<---
Hey all,
As issue #54130 highlights, constraints are not checked and passing bad constraints to LLVM can crash it since a `Verify()` call is placed inside an assertion (see: `src/llvm/lib/IR/InlineAsm.cpp:39`).
As this is my first PR to the Rust compiler (woot! :tada:), there might be better ways of achieving this result. In particular, I am not too happy about generating an error in codegen; it would be much nicer if we did it earlier. However, @rkruppe [noted on IRC](https://botbot.me/mozilla/rustc/2018-09-25/?msg=104791581&page=1) that this should be fine for an unstable feature and a much better solution than the _status quo_, which is an ICE.
Thanks!
--->%---
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").
Fixes: #54130
Signed-off-by: Levente Kurusa \<lkurusa@acm.org\>
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
| -rw-r--r-- | src/rustllvm/RustWrapper.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
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<FunctionType>(Ty), Constraints); +} + extern "C" void LLVMRustAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm) { unwrap(M)->appendModuleInlineAsm(StringRef(Asm)); } |
