1
Fork 0

review comments: clean up

This commit is contained in:
Esteban Küber 2019-08-04 09:44:06 -07:00
parent 23400677d7
commit 387dcff796
4 changed files with 9 additions and 14 deletions

View file

@ -30,7 +30,7 @@ use std::iter;
use std::str; use std::str;
use std::sync::Arc; use std::sync::Arc;
use syntax::symbol::LocalInternedString; use syntax::symbol::LocalInternedString;
use syntax::source_map::Span; use syntax::source_map::{DUMMY_SP, Span};
use crate::abi::Abi; use crate::abi::Abi;
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
@ -861,10 +861,10 @@ impl LayoutOf for CodegenCx<'ll, 'tcx> {
type TyLayout = TyLayout<'tcx>; type TyLayout = TyLayout<'tcx>;
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout { fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.spanned_layout_of(ty, None) self.spanned_layout_of(ty, DUMMY_SP)
} }
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Option<Span>) -> Self::TyLayout { fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)) self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
.unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e { .unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
match span { match span {

View file

@ -182,18 +182,13 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
rvalue: &mir::Rvalue<'tcx>, rvalue: &mir::Rvalue<'tcx>,
location: Location) { location: Location) {
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue); debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
let mut decl_span = None;
if let mir::PlaceBase::Local(local) = &place.base {
if let Some(decl) = self.fx.mir.local_decls.get(*local) {
decl_span = Some(decl.source_info.span);
}
}
if let mir::Place { if let mir::Place {
base: mir::PlaceBase::Local(index), base: mir::PlaceBase::Local(index),
projection: None, projection: None,
} = *place { } = *place {
self.assign(index, location); self.assign(index, location);
let decl_span = self.fx.mir.local_decls[index].source_info.span;
if !self.fx.rvalue_creates_operand(rvalue, decl_span) { if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
self.not_ssa(index); self.not_ssa(index);
} }

View file

@ -6,7 +6,7 @@ use rustc::middle::lang_items::ExchangeMallocFnLangItem;
use rustc_apfloat::{ieee, Float, Status, Round}; use rustc_apfloat::{ieee, Float, Status, Round};
use std::{u128, i128}; use std::{u128, i128};
use syntax::symbol::sym; use syntax::symbol::sym;
use syntax::source_map::Span; use syntax::source_map::{DUMMY_SP, Span};
use crate::base; use crate::base;
use crate::MemFlags; use crate::MemFlags;
@ -137,7 +137,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
} }
_ => { _ => {
assert!(self.rvalue_creates_operand(rvalue, None)); assert!(self.rvalue_creates_operand(rvalue, DUMMY_SP));
let (mut bx, temp) = self.codegen_rvalue_operand(bx, rvalue); let (mut bx, temp) = self.codegen_rvalue_operand(bx, rvalue);
temp.val.store(&mut bx, dest); temp.val.store(&mut bx, dest);
bx bx
@ -171,7 +171,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
rvalue: &mir::Rvalue<'tcx> rvalue: &mir::Rvalue<'tcx>
) -> (Bx, OperandRef<'tcx, Bx::Value>) { ) -> (Bx, OperandRef<'tcx, Bx::Value>) {
assert!( assert!(
self.rvalue_creates_operand(rvalue, None), self.rvalue_creates_operand(rvalue, DUMMY_SP),
"cannot codegen {:?} to operand", "cannot codegen {:?} to operand",
rvalue, rvalue,
); );
@ -696,7 +696,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
} }
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Option<Span>) -> bool { pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
match *rvalue { match *rvalue {
mir::Rvalue::Ref(..) | mir::Rvalue::Ref(..) |
mir::Rvalue::Len(..) | mir::Rvalue::Len(..) |

View file

@ -1013,7 +1013,7 @@ pub trait LayoutOf {
type TyLayout; type TyLayout;
fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout; fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout;
fn spanned_layout_of(&self, ty: Self::Ty, _span: Option<Span>) -> Self::TyLayout { fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyLayout {
self.layout_of(ty) self.layout_of(ty)
} }
} }