Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
832b23f
Tiny missed simplification
Nadrieril Mar 1, 2024
3d3b321
Use an enum instead of manually tracking indices for `target_blocks`
Nadrieril Feb 28, 2024
8c3688c
Allocate candidate vectors as we sort them
Nadrieril Mar 2, 2024
edea739
No need to collect test variants ahead of time
Nadrieril Mar 1, 2024
d46ff64
Fix a subtle regression
Nadrieril Mar 2, 2024
c1e6886
Store pattern arity in `DeconstructedPat`
Nadrieril Feb 29, 2024
6ae9fa3
Store field indices in `DeconstructedPat` to avoid virtual wildcards
Nadrieril Feb 29, 2024
d339bda
`DeconstructedPat.data` is always present now
Nadrieril Feb 6, 2024
9962a01
Use `min_exhaustive_patterns` in core & std
Nadrieril Feb 7, 2024
aa71151
Enable PR tracking review assignment
apiraino Mar 12, 2024
22a5267
std: move `Once` implementations to `sys`
joboet Mar 12, 2024
96b8225
Don't Create `ParamCandidate` When Obligation Contains Errors
veera-sivarajan Mar 12, 2024
eab1f30
Fix ICE in diagnostics for parenthesized type arguments
wutchzone Mar 12, 2024
f3b348b
rustdoc: do not preload fonts when browsing locally
rjeli Mar 12, 2024
68fc922
Add `intrinsic_name` to get plain intrinsic name
adpaco-aws Mar 8, 2024
1f544ce
coverage: Remove all unstable values of `-Cinstrument-coverage`
Zalathar Mar 12, 2024
3407fcc
coverage: Add `-Zcoverage-options` for fine control of coverage
Zalathar Mar 8, 2024
1b198ba
Rollup merge of #121820 - Nadrieril:idxpat2, r=compiler-errors
matthiaskrgr Mar 13, 2024
e6ba504
Rollup merge of #121908 - Nadrieril:dynamic-variant-collection, r=mat…
matthiaskrgr Mar 13, 2024
8d78f8e
Rollup merge of #122203 - adpaco-aws:smir-intrinsic-name, r=celinval
matthiaskrgr Mar 13, 2024
8b9ef3b
Rollup merge of #122226 - Zalathar:zcoverage-options, r=nnethercote
matthiaskrgr Mar 13, 2024
e42a702
Rollup merge of #122255 - Nadrieril:min_exh_pats-libs, r=scottmcm
matthiaskrgr Mar 13, 2024
5d13140
Rollup merge of #122360 - veera-sivarajan:bugfix-121941, r=compiler-e…
matthiaskrgr Mar 13, 2024
a18a608
Rollup merge of #122383 - apiraino:enable-pr-tracking, r=jackh726
matthiaskrgr Mar 13, 2024
dff680d
Rollup merge of #122386 - joboet:move_pal_once, r=jhpratt
matthiaskrgr Mar 13, 2024
1ffa5de
Rollup merge of #122400 - wutchzone:122345, r=fmease
matthiaskrgr Mar 13, 2024
62e9e46
Rollup merge of #122410 - rjeli:rustdoc-no-local-font-preload, r=notr…
matthiaskrgr Mar 13, 2024
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
Add intrinsic_name to get plain intrinsic name
  • Loading branch information
adpaco-aws committed Mar 12, 2024
commit 68fc92242f1e6165f917cce8304c8cf35518f63a
10 changes: 10 additions & 0 deletions compiler/rustc_smir/src/rustc_smir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,16 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
}
}

/// Retrieve the plain intrinsic name of an instance.
///
/// This assumes that the instance is an intrinsic.
fn intrinsic_name(&self, def: InstanceDef) -> Symbol {
let tables = self.0.borrow_mut();
let instance = tables.instances[def];
let intrinsic = tables.tcx.intrinsic(instance.def_id()).unwrap();
intrinsic.name.to_string()
}

fn ty_layout(&self, ty: Ty) -> Result<Layout, Error> {
let mut tables = self.0.borrow_mut();
let tcx = tables.tcx;
Expand Down
1 change: 1 addition & 0 deletions compiler/stable_mir/src/compiler_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ pub trait Context {
fn vtable_allocation(&self, global_alloc: &GlobalAlloc) -> Option<AllocId>;
fn krate(&self, def_id: DefId) -> Crate;
fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol;
fn intrinsic_name(&self, def: InstanceDef) -> Symbol;

/// Return information about the target machine.
fn target_info(&self) -> MachineInfo;
Expand Down
11 changes: 11 additions & 0 deletions compiler/stable_mir/src/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ impl Instance {
with(|context| context.instance_name(self.def, true))
}

/// Retrieve the plain intrinsic name of an instance if it's an intrinsic.
///
/// The plain name does not include type arguments (as `trimmed_name` does),
/// which is more convenient to match with intrinsic symbols.
pub fn intrinsic_name(&self) -> Option<Symbol> {
match self.kind {
InstanceKind::Intrinsic => Some(with(|context| context.intrinsic_name(self.def))),
InstanceKind::Item | InstanceKind::Virtual { .. } | InstanceKind::Shim => None,
}
}

/// Resolve an instance starting from a function definition and generic arguments.
pub fn resolve(def: FnDef, args: &GenericArgs) -> Result<Instance, crate::Error> {
with(|context| {
Expand Down
14 changes: 13 additions & 1 deletion tests/ui-fulldeps/stable-mir/check_defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern crate stable_mir;

use std::assert_matches::assert_matches;
use mir::{mono::Instance, TerminatorKind::*};
use stable_mir::mir::mono::InstanceKind;
use rustc_smir::rustc_internal;
use stable_mir::ty::{RigidTy, TyKind, Ty, UintTy};
use stable_mir::*;
Expand All @@ -35,9 +36,10 @@ fn test_stable_mir() -> ControlFlow<()> {
assert_eq!(main_fn.trimmed_name(), "main");

let instances = get_instances(main_fn.body().unwrap());
assert_eq!(instances.len(), 2);
assert_eq!(instances.len(), 3);
test_fn(instances[0], "from_u32", "std::char::from_u32", "core");
test_fn(instances[1], "Vec::<u8>::new", "std::vec::Vec::<u8>::new", "alloc");
test_fn(instances[2], "ctpop::<u8>", "std::intrinsics::ctpop::<u8>", "core");
test_vec_new(instances[1]);
ControlFlow::Continue(())
}
Expand All @@ -48,6 +50,14 @@ fn test_fn(instance: Instance, expected_trimmed: &str, expected_qualified: &str,
assert_eq!(&trimmed, expected_trimmed);
assert_eq!(&qualified, expected_qualified);

if instance.kind == InstanceKind::Intrinsic {
let intrinsic = instance.intrinsic_name().unwrap();
let (trimmed_base, _trimmed_args) = trimmed.split_once("::").unwrap();
assert_eq!(intrinsic, trimmed_base);
return;
}
assert!(instance.intrinsic_name().is_none());

let item = CrateItem::try_from(instance).unwrap();
let trimmed = item.trimmed_name();
let qualified = item.name();
Expand Down Expand Up @@ -119,10 +129,12 @@ fn generate_input(path: &str) -> std::io::Result<()> {
write!(
file,
r#"
#![feature(core_intrinsics)]

fn main() {{
let _c = core::char::from_u32(99);
let _v = Vec::<u8>::new();
let _i = std::intrinsics::ctpop::<u8>(0);
}}
"#
)?;
Expand Down