8000 Minimize uses of `LocalInternedString` by nnethercote · Pull Request #64141 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Minimize uses of LocalInternedString #64141

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

Merged
merged 12 commits into from
Sep 5, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove LocalInternedString uses from `librustc_codegen_llvm/consts.…
…rs`.
  • Loading branch information
nnethercote committed Sep 4, 2019
commit b50db34e4dd1321b4f075eaa6bc88fc8f95e17fc
15 changes: 8 additions & 7 deletions src/librustc_codegen_llvm/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ use rustc::mir::interpret::{ConstValue, Allocation, read_target_uint,
Pointer, ErrorHandled, GlobalId};
use rustc::mir::mono::MonoItem;
use rustc::hir::Node;
use syntax_pos::Span;
use rustc_target::abi::HasDataLayout;
use syntax::symbol::sym;
use syntax_pos::symbol::LocalInternedString;
use rustc::ty::{self, Ty, Instance};
use rustc_codegen_ssa::traits::*;
use syntax::symbol::{Symbol, sym};
use syntax_pos::Span;

use rustc::ty::layout::{self, Size, Align, LayoutOf};

Expand Down Expand Up @@ -104,10 +103,11 @@ fn check_and_apply_linkage(
cx: &CodegenCx<'ll, 'tcx>,
attrs: &CodegenFnAttrs,
ty: Ty<'tcx>,
sym: LocalInternedString,
sym: Symbol,
span: Span
) -> &'ll Value {
let llty = cx.layout_of(ty).llvm_type(cx);
let sym = sym.as_str();
if let Some(linkage) = attrs.linkage {
debug!("get_static: sym={} linkage={:?}", sym, linkage);

Expand Down Expand Up @@ -203,7 +203,7 @@ impl CodegenCx<'ll, 'tcx> {
def_id);

let ty = instance.ty(self.tcx);
let sym = self.tcx.symbol_name(instance).name.as_str();
let sym = self.tcx.symbol_name(instance).name.as_symbol();

debug!("get_static: sym={} instance={:?}", sym, instance);

Expand All @@ -214,11 +214,12 @@ impl CodegenCx<'ll, 'tcx> {
Node::Item(&hir::Item {
ref attrs, span, node: hir::ItemKind::Static(..), ..
}) => {
if self.get_declared_value(&sym[..]).is_some() {
let sym_str = sym.as_str();
if self.get_declared_value(&sym_str).is_some() {
span_bug!(span, "Conflicting symbol names for static?");
}

let g = self.define_global(&sym[..], llty).unwrap();
let g = self.define_global(&sym_str, llty).unwrap();

if !self.tcx.is_reachable_non_generic(def_id) {
unsafe {
Expand Down
0