diff options
| author | Ralf Jung <post@ralfj.de> | 2018-08-23 19:04:33 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-08-27 18:12:49 +0200 |
| commit | c141ccf158d8c660ef20a51104b701b4eb37822b (patch) | |
| tree | 1e27be9f8ec89be350ca2423a7c3e8a5762e1400 /src/librustc_codegen_llvm | |
| parent | b638d8c75f4e38c75c5caa52b10b18a350431687 (diff) | |
| download | rust-c141ccf158d8c660ef20a51104b701b4eb37822b.tar.gz rust-c141ccf158d8c660ef20a51104b701b4eb37822b.zip | |
Miri Memory Work
* Unify the two maps in memory to store the allocation and its kind together. * Share the handling of statics between CTFE and miri: The miri engine always uses "lazy" `AllocType::Static` when encountering a static. Acessing that static invokes CTFE (no matter the machine). The machine only has any influence when writing to a static, which CTFE outright rejects (but miri makes a copy-on-write). * Add an `AllocId` to by-ref consts so miri can use them as operands without making copies. * Move responsibilities around for the `eval_fn_call` machine hook: The hook just has to find the MIR (or entirely take care of everything); pushing the new stack frame is taken care of by the miri engine. * Expose the intrinsics and lang items implemented by CTFE so miri does not have to reimplement them.
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/mir/constant.rs | 4 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/operand.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/place.rs | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index 2657543b2d1..b6c9658dd6f 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -57,7 +57,7 @@ pub fn scalar_to_llvm( let base_addr = match alloc_type { Some(AllocType::Memory(alloc)) => { let init = const_alloc_to_llvm(cx, alloc); - if alloc.runtime_mutability == Mutability::Mutable { + if alloc.mutability == Mutability::Mutable { consts::addr_of_mut(cx, init, alloc.align, None) } else { consts::addr_of(cx, init, alloc.align, None) @@ -134,7 +134,7 @@ pub fn codegen_static_initializer( let static_ = cx.tcx.const_eval(param_env.and(cid))?; let alloc = match static_.val { - ConstValue::ByRef(alloc, n) if n.bytes() == 0 => alloc, + ConstValue::ByRef(_, alloc, n) if n.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", static_), }; Ok((const_alloc_to_llvm(cx, alloc), alloc)) diff --git a/src/librustc_codegen_llvm/mir/operand.rs b/src/librustc_codegen_llvm/mir/operand.rs index 9537379813d..419e7298588 100644 --- a/src/librustc_codegen_llvm/mir/operand.rs +++ b/src/librustc_codegen_llvm/mir/operand.rs @@ -126,7 +126,7 @@ impl OperandRef<'ll, 'tcx> { }; OperandValue::Pair(a_llval, b_llval) }, - ConstValue::ByRef(alloc, offset) => { + ConstValue::ByRef(_, alloc, offset) => { return Ok(PlaceRef::from_const_alloc(bx, layout, alloc, offset).load(bx)); }, }; diff --git a/src/librustc_codegen_llvm/mir/place.rs b/src/librustc_codegen_llvm/mir/place.rs index ce3292eaa42..833dca8c75f 100644 --- a/src/librustc_codegen_llvm/mir/place.rs +++ b/src/librustc_codegen_llvm/mir/place.rs @@ -458,7 +458,7 @@ impl FunctionCx<'a, 'll, 'tcx> { let layout = cx.layout_of(self.monomorphize(&ty)); match bx.tcx().const_eval(param_env.and(cid)) { Ok(val) => match val.val { - mir::interpret::ConstValue::ByRef(alloc, offset) => { + mir::interpret::ConstValue::ByRef(_, alloc, offset) => { PlaceRef::from_const_alloc(bx, layout, alloc, offset) } _ => bug!("promoteds should have an allocation: {:?}", val), |
