CTFE: simplify Value type by not checking for alignment
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::value::Value;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
||||
use crate::consts::const_alloc_to_llvm;
|
||||
use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size, Align};
|
||||
use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size};
|
||||
use rustc::mir::interpret::{Scalar, GlobalAlloc, Allocation};
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
|
||||
@@ -329,10 +329,10 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
fn from_const_alloc(
|
||||
&self,
|
||||
layout: TyLayout<'tcx>,
|
||||
align: Align,
|
||||
alloc: &Allocation,
|
||||
offset: Size,
|
||||
) -> PlaceRef<'tcx, &'ll Value> {
|
||||
let align = alloc.align; // follow what CTFE did, not what the layout says
|
||||
let init = const_alloc_to_llvm(self, alloc);
|
||||
let base_addr = self.static_addr_of(init, align, None);
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ pub fn codegen_static_initializer(
|
||||
|
||||
let alloc = match static_.val {
|
||||
ConstValue::ByRef {
|
||||
offset, align, alloc,
|
||||
} if offset.bytes() == 0 && align == alloc.align => {
|
||||
alloc, offset,
|
||||
} if offset.bytes() == 0 => {
|
||||
alloc
|
||||
},
|
||||
_ => bug!("static const eval returned {:#?}", static_),
|
||||
|
||||
Reference in New Issue
Block a user