Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip layout query when computing integer type size during mangling #86776

Merged
merged 1 commit into from
Jul 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Skip layout query when computing integer type size during mangling
  • Loading branch information
tmiasko committed Jul 1, 2021
commit c99f1b9b7e67f96b51d873bd3ce2c09df0b34ef2
10 changes: 5 additions & 5 deletions compiler/rustc_symbol_mangling/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
use rustc_middle::ty::layout::IntegerExt;
use rustc_middle::ty::print::{Print, Printer};
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
use rustc_middle::ty::{self, FloatTy, Instance, IntTy, Ty, TyCtxt, TypeFoldable, UintTy};
use rustc_target::abi::Integer;
use rustc_target::spec::abi::Abi;

use std::fmt::Write;
Expand Down Expand Up @@ -553,11 +555,9 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
ty::Uint(_) | ty::Bool | ty::Char => {
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty)
}
ty::Int(_) => {
let param_env = ty::ParamEnv::reveal_all();
ct.try_eval_bits(self.tcx, param_env, ct.ty).and_then(|b| {
let sz = self.tcx.layout_of(param_env.and(ct.ty)).ok()?.size;
let val = sz.sign_extend(b) as i128;
ty::Int(ity) => {
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty).and_then(|b| {
let val = Integer::from_int_ty(&self.tcx, *ity).size().sign_extend(b) as i128;
if val < 0 {
neg = true;
}
Expand Down