-------------------------------------------------------------------------------- I1 cache: 65536 B, 64 B, 4-way associative D1 cache: 32768 B, 64 B, 8-way associative LL cache: 67108864 B, 64 B, 64-way associative Command: /usr/home/liquid/.rustup/toolchains/w-profiling/bin/rustc --crate-name c2_chacha --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg feature="cipher" --cfg feature="default" --cfg feature="rustcrypto_api" --cfg feature="std" -C metadata=e0e4d142b8e499fd -C extra-filename=-e0e4d142b8e499fd --out-dir /usr/home/liquid/tmp/.tmpHrqv2H/target/release/deps -L dependency=/usr/home/liquid/tmp/.tmpHrqv2H/target/release/deps --extern cipher=/usr/home/liquid/tmp/.tmpHrqv2H/target/release/deps/libcipher-70c01f7a00babbba.rmeta --extern ppv_lite86=/usr/home/liquid/tmp/.tmpHrqv2H/target/release/deps/libppv_lite86-000e67fe83937146.rmeta -Adeprecated -Aunknown-lints -Zincremental-verify-ich Data file: results/cgout-w-profiling-c2-chacha-0.3.3-Opt-Full Events recorded: Ir Events shown: Ir Event sort order: Ir Thresholds: 0.1 Include dirs: User annotated: Auto-annotation: on -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 4,146,652,057 (100.0%) PROGRAM TOTALS -------------------------------------------------------------------------------- Ir file:function -------------------------------------------------------------------------------- 226,422,897 ( 5.46%) ???:computeKnownBits(llvm::Value const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) 152,898,368 ( 3.69%) ???:llvm::isNonEscapingLocalObject(llvm::Value const*, llvm::SmallDenseMap, llvm::detail::DenseMapPair >*) 93,406,122 ( 2.25%) ./malloc/malloc.c:_int_free 82,329,801 ( 1.99%) ./malloc/malloc.c:_int_malloc 81,196,265 ( 1.96%) ???:llvm::InstCombinerImpl::run() 79,614,814 ( 1.92%) ???:getShuffleDemandedElts(llvm::ShuffleVectorInst const*, llvm::APInt const&, llvm::APInt&, llvm::APInt&) 79,516,037 ( 1.92%) ???:llvm::BasicAAResult::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&, llvm::AAQueryInfo&) 75,361,071 ( 1.82%) ???:llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const 65,158,407 ( 1.57%) ???:llvm::SelectionDAG::computeKnownBits(llvm::SDValue, llvm::APInt const&, unsigned int) const 58,896,250 ( 1.42%) ???:computeKnownBits(llvm::Value const*, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) [clone .llvm.15619146473165121143] 58,670,751 ( 1.41%) ./malloc/malloc.c:malloc 54,669,007 ( 1.32%) ???:combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, llvm::LoopInfo*) 49,070,150 ( 1.18%) ???:computeKnownBitsFromAssume(llvm::Value const*, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) 48,041,898 ( 1.16%) ???:computeKnownBitsFromOperator(llvm::Operator const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) 46,642,566 ( 1.12%) ???:llvm::BasicAAResult::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&, llvm::AAQueryInfo&) 45,876,942 ( 1.11%) ???:llvm::ConstantDataSequential::getElementAsConstant(unsigned int) const 34,461,470 ( 0.83%) ???:llvm::DataLayout::getAlignment(llvm::Type*, bool) const 31,642,415 ( 0.76%) ???:llvm::TargetLibraryInfoImpl::getLibFunc(llvm::Function const&, llvm::LibFunc&) const 29,939,331 ( 0.72%) ./malloc/malloc.c:free 29,039,516 ( 0.70%) ???:llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const 28,832,150 ( 0.70%) ???:runCVP(llvm::Module&) [clone .llvm.11785992503873176614] 28,666,956 ( 0.69%) ???:bool llvm::DenseMapBase*, llvm::DenseMapInfo<(anonymous namespace)::SimpleValue>, llvm::detail::DenseMapPair<(anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*> >, (anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*, llvm::DenseMapInfo<(anonymous namespace)::SimpleValue>, llvm::detail::DenseMapPair<(anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*> >::LookupBucketFor<(anonymous namespace)::SimpleValue>((anonymous namespace)::SimpleValue const&, llvm::detail::DenseMapPair<(anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*> const*&) const 27,904,341 ( 0.67%) ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:__memcmp_avx2_movbe 26,956,125 ( 0.65%) ???:llvm::AnalysisManager::getResultImpl(llvm::AnalysisKey*, llvm::Function&) 26,570,983 ( 0.64%) ???:llvm::InlineFunction(llvm::CallBase&, llvm::InlineFunctionInfo&, llvm::AAResults*, bool, llvm::Function*) 26,522,088 ( 0.64%) ???:llvm::AnalysisManager::invalidate(llvm::Function&, llvm::PreservedAnalyses const&) 26,330,527 ( 0.63%) ???:llvm::Type::isSizedDerivedType(llvm::SmallPtrSetImpl*) const 25,097,208 ( 0.61%) ???:llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) 23,951,164 ( 0.58%) ???:(anonymous namespace)::eliminateDeadStores(llvm::Function&, llvm::AAResults&, llvm::MemorySSA&, llvm::DominatorTree&, llvm::PostDominatorTree&, llvm::TargetLibraryInfo const&, llvm::LoopInfo const&) [clone .llvm.5769264623867638418] 21,712,626 ( 0.52%) ???:llvm::SimplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&, llvm::OptimizationRemarkEmitter*) 20,827,825 ( 0.50%) ???:llvm::ValueHandleBase::AddToUseList() 19,737,083 ( 0.48%) ???:llvm::SROA::runOnAlloca(llvm::AllocaInst&) 19,583,592 ( 0.47%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms 18,938,065 ( 0.46%) ???:(anonymous namespace)::PruningFunctionCloner::CloneBlock(llvm::BasicBlock const*, llvm::ilist_iterator, false, true>, std::vector >&) 18,285,074 ( 0.44%) ???:llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Value*, llvm::APInt, llvm::KnownBits&, unsigned int, llvm::Instruction*) 17,761,510 ( 0.43%) ???:llvm::InstCombinerImpl::SimplifyDemandedVectorElts(llvm::Value*, llvm::APInt, llvm::APInt&, unsigned int, bool) 16,391,080 ( 0.40%) ???:llvm::FPPassManager::runOnFunction(llvm::Function&) 15,698,772 ( 0.38%) ???:llvm::AttributeSetNode::get(llvm::LLVMContext&, llvm::AttrBuilder const&) 14,827,044 ( 0.36%) ???:llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) 14,277,034 ( 0.34%) ???:llvm::Type::getPrimitiveSizeInBits() const 13,609,901 ( 0.33%) ???:llvm::InstCombinerImpl::visitBitCast(llvm::BitCastInst&) 13,352,646 ( 0.32%) ???:(anonymous namespace)::EarlyCSE::run() [clone .llvm.7062997131228810369] 13,329,757 ( 0.32%) ???:llvm::Intrinsic::getDeclaration(llvm::Module*, unsigned int, llvm::ArrayRef) 12,928,029 ( 0.31%) ???:llvm::GVN::processBlock(llvm::BasicBlock*) 12,921,339 ( 0.31%) ???:llvm::MDTuple::getImpl(llvm::LLVMContext&, llvm::ArrayRef, llvm::Metadata::StorageType, bool) 12,561,809 ( 0.30%) ???:llvm::SROA::rewritePartition(llvm::AllocaInst&, llvm::sroa::AllocaSlices&, llvm::sroa::Partition&) 12,211,517 ( 0.29%) ???:llvm::X86TargetLowering::computeKnownBitsForTargetNode(llvm::SDValue, llvm::KnownBits&, llvm::APInt const&, llvm::SelectionDAG const&, unsigned int) const 12,008,026 ( 0.29%) ???:llvm::SROA::runImpl(llvm::Function&, llvm::DominatorTree&, llvm::AssumptionCache&) 11,910,063 ( 0.29%) ???:llvm::InstCombinerImpl::visitLoadInst(llvm::LoadInst&) 11,878,089 ( 0.29%) ???:llvm::PointerMayBeCaptured(llvm::Value const*, llvm::CaptureTracker*, unsigned int) 11,665,900 ( 0.28%) ./malloc/malloc.c:malloc_consolidate 11,658,349 ( 0.28%) ???:updateCGAndAnalysisManagerForPass(llvm::LazyCallGraph&, llvm::LazyCallGraph::SCC&, llvm::LazyCallGraph::Node&, llvm::AnalysisManager&, llvm::CGSCCUpdateResult&, llvm::AnalysisManager&, bool) [clone .llvm.5426518467876156712] 11,642,012 ( 0.28%) ???:llvm::InstCombinerImpl::visitAdd(llvm::BinaryOperator&) 11,399,651 ( 0.27%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::CalculateFromScratch(llvm::DominatorTreeBase&, llvm::DomTreeBuilder::SemiNCAInfo >::BatchUpdateInfo*) 11,215,698 ( 0.27%) ???:llvm::TargetLowering::SimplifyDemandedVectorElts(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const 10,911,201 ( 0.26%) ???:(anonymous namespace)::LazyValueInfoImpl::solve() [clone .llvm.4316243980339171764] 10,823,927 ( 0.26%) ???:llvm::AAResults::getModRefInfo(llvm::Instruction const*, llvm::Optional const&, llvm::AAQueryInfo&) 10,649,834 ( 0.26%) ???:llvm::ReplaceableMetadataImpl::replaceAllUsesWith(llvm::Metadata*) 10,309,110 ( 0.25%) ./elf/dl-lookup.c:_dl_lookup_symbol_x 10,270,663 ( 0.25%) ???:llvm::InstCombinerImpl::visitStoreInst(llvm::StoreInst&) 10,137,964 ( 0.24%) ???:llvm::DemandedBits::isInstructionDead(llvm::Instruction*) 9,764,462 ( 0.24%) ???:llvm::Instruction::eraseFromParent() 9,713,011 ( 0.23%) /tmp/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/../../../../gcc-5.5.0/libstdc++-v3/libsupc++/new_op.cc:operator new(unsigned long) 9,313,596 ( 0.22%) ???:llvm::EVT::getVectorNumElements() const 9,159,293 ( 0.22%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_erms 8,973,323 ( 0.22%) ???:(anonymous namespace)::CVPLatticeFunc::ComputeInstructionState(llvm::Instruction&, llvm::DenseMap, llvm::PointerIntPairInfo > >, (anonymous namespace)::CVPLatticeVal, llvm::DenseMapInfo, llvm::PointerIntPairInfo > > >, llvm::detail::DenseMapPair, llvm::PointerIntPairInfo > >, (anonymous namespace)::CVPLatticeVal> >&, llvm::SparseSolver, llvm::PointerIntPairInfo > >, (anonymous namespace)::CVPLatticeVal, llvm::LatticeKeyInfo, llvm::PointerIntPairInfo > > > >&) 8,906,472 ( 0.21%) ???:(anonymous namespace)::RAGreedy::tryAssign(llvm::LiveInterval&, llvm::AllocationOrder&, llvm::SmallVectorImpl&, llvm::SmallSet > const&) 8,854,596 ( 0.21%) ???:llvm::SROA::splitAlloca(llvm::AllocaInst&, llvm::sroa::AllocaSlices&) 8,789,631 ( 0.21%) ???:llvm::removeUnreachableBlocks(llvm::Function&, llvm::DomTreeUpdater*, llvm::MemorySSAUpdater*) 8,631,252 ( 0.21%) ./malloc/malloc.c:unlink_chunk.constprop.0 8,320,289 ( 0.20%) ???:llvm::MDNode::dropReplaceableUses() 8,167,652 ( 0.20%) ???:llvm::MemorySSA::buildMemorySSA(llvm::BatchAAResults&) 8,026,469 ( 0.19%) ???:llvm::AAResults::Model::getModRefBehavior(llvm::CallBase const*) 7,826,808 ( 0.19%) ???:llvm::GVN::performPRE(llvm::Function&) 7,781,548 ( 0.19%) ???:llvm::Constant::getAggregateElement(unsigned int) const 7,659,530 ( 0.18%) ???:llvm::Value::stripAndAccumulateConstantOffsets(llvm::DataLayout const&, llvm::APInt&, bool, llvm::function_ref) const 7,587,024 ( 0.18%) ???:llvm::X86TargetLowering::X86TargetLowering(llvm::X86TargetMachine const&, llvm::X86Subtarget const&) 7,530,492 ( 0.18%) ???:llvm::MemoryLocation::getOrNone(llvm::Instruction const*) 7,305,343 ( 0.18%) ???:llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) 7,274,501 ( 0.18%) ???:getTargetConstantBitsFromNode(llvm::SDValue, unsigned int, llvm::APInt&, llvm::SmallVectorImpl&, bool, bool) 6,993,271 ( 0.17%) ???:llvm::computeConstantRange(llvm::Value const*, bool, llvm::AssumptionCache*, llvm::Instruction const*, unsigned int) 6,955,534 ( 0.17%) ???:llvm::SCCPInstVisitor::solve() 6,660,366 ( 0.16%) ???:llvm::coro::declaresIntrinsics(llvm::Module const&, std::initializer_list) 6,634,276 ( 0.16%) ???:llvm::LiveIntervalUnion::Query::collectInterferingVRegs(unsigned int) 6,628,677 ( 0.16%) ???:llvm::SimplifyGEPInst(llvm::Type*, llvm::ArrayRef, llvm::SimplifyQuery const&) 6,520,412 ( 0.16%) ???:llvm::AAResults::Model::pointsToConstantMemory(llvm::MemoryLocation const&, llvm::AAQueryInfo&, bool) 6,457,119 ( 0.16%) ???:llvm::BitstreamCursor::readRecord(unsigned int, llvm::SmallVectorImpl&, llvm::StringRef*) 6,379,207 ( 0.15%) ???:llvm::getObjectSize(llvm::Value const*, unsigned long&, llvm::DataLayout const&, llvm::TargetLibraryInfo const*, llvm::ObjectSizeOpts) 6,350,284 ( 0.15%) ???:llvm::TargetLoweringBase::computeRegisterProperties(llvm::TargetRegisterInfo const*) 6,263,818 ( 0.15%) ???:(anonymous namespace)::AggressiveDeadCodeElimination::performDeadCodeElimination() 6,206,672 ( 0.15%) ???:getAdjustedPtr(llvm::IRBuilder&, llvm::DataLayout const&, llvm::Value*, llvm::APInt, llvm::Type*, llvm::Twine const&) 6,181,324 ( 0.15%) ./string/../sysdeps/x86_64/multiarch/strcmp-avx2.S:__strncmp_avx2 5,944,525 ( 0.14%) ???:llvm::Instruction::setMetadata(unsigned int, llvm::MDNode*) 5,930,114 ( 0.14%) ???:llvm::AttributeList::addAttribute(llvm::LLVMContext&, unsigned int, llvm::Attribute::AttrKind) const 5,879,918 ( 0.14%) ???:llvm::MDNode::concatenate(llvm::MDNode*, llvm::MDNode*) 5,832,409 ( 0.14%) ???:llvm::detail::PassModel>, llvm::PreservedAnalyses, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) 5,782,989 ( 0.14%) ???:llvm::PassRegistry::enumerateWith(llvm::PassRegistrationListener*) 5,720,961 ( 0.14%) ???:llvm::ReassociatePass::BuildRankMap(llvm::Function&, llvm::ReversePostOrderTraversal >&) 5,594,372 ( 0.13%) ???:SimplifyAddInst(llvm::Value*, llvm::Value*, bool, bool, llvm::SimplifyQuery const&, unsigned int) [clone .llvm.1619516508949622737] 5,566,544 ( 0.13%) ???:llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const 5,508,201 ( 0.13%) ???:llvm::Instruction::~Instruction() 5,480,835 ( 0.13%) ???:(anonymous namespace)::LazyValueInfoImpl::getEdgeValue(llvm::Value*, llvm::BasicBlock*, llvm::BasicBlock*, llvm::Instruction*) [clone .llvm.4316243980339171764] 5,426,418 ( 0.13%) ???:isKnownNonZero(llvm::Value const*, llvm::APInt const&, unsigned int, (anonymous namespace)::Query const&) [clone .llvm.15619146473165121143] 5,386,698 ( 0.13%) ???:llvm::simplifyCFG(llvm::BasicBlock*, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&, llvm::ArrayRef) 5,316,031 ( 0.13%) ???:llvm::InstCombinerImpl::visitPHINode(llvm::PHINode&) 5,180,762 ( 0.12%) ???:runImpl(llvm::Function&, llvm::LazyValueInfo*, llvm::DominatorTree*, llvm::SimplifyQuery const&) [clone .llvm.16011871802505272439] 5,169,201 ( 0.12%) ???:llvm::InstCombinerImpl::visitAllocaInst(llvm::AllocaInst&) 5,164,892 ( 0.12%) ???:llvm::GVN::ValueTable::phiTranslate(llvm::BasicBlock const*, llvm::BasicBlock const*, unsigned int, llvm::GVN&) 5,150,979 ( 0.12%) ???:llvm::InstCombinerImpl::visitXor(llvm::BinaryOperator&) 5,102,343 ( 0.12%) ???:(anonymous namespace)::Mapper::mapValue(llvm::Value const*) [clone .llvm.12166235158543170009] 5,007,072 ( 0.12%) ???:??? 4,922,575 ( 0.12%) ???:checkFunctionMemoryAccess(llvm::Function&, bool, llvm::AAResults&, llvm::SmallSetVector const&) [clone .llvm.9774227059444965931] 4,874,022 ( 0.12%) ???:llvm::InstCombinerImpl::visitShuffleVectorInst(llvm::ShuffleVectorInst&) 4,847,578 ( 0.12%) ???:llvm::MDNode::setOperand(unsigned int, llvm::Metadata*) 4,845,521 ( 0.12%) ./elf/dl-lookup.c:do_lookup_x 4,778,378 ( 0.12%) ./string/../sysdeps/x86_64/multiarch/memchr-avx2.S:__memchr_avx2 4,702,170 ( 0.11%) ???:llvm::ConstantInt::get(llvm::IntegerType*, unsigned long, bool) 4,696,318 ( 0.11%) ???:(anonymous namespace)::PromoteMem2Reg::run() 4,680,668 ( 0.11%) ???:llvm::Twine::printOneChild(llvm::raw_ostream&, llvm::Twine::Child, llvm::Twine::NodeKind) const 4,660,718 ( 0.11%) ???:(anonymous namespace)::LazyValueInfoImpl::getValueInBlock(llvm::Value*, llvm::BasicBlock*, llvm::Instruction*) [clone .llvm.4316243980339171764] 4,653,519 ( 0.11%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_unaligned_erms 4,551,459 ( 0.11%) ???:llvm::SimplifyShuffleVectorInst(llvm::Value*, llvm::Value*, llvm::ArrayRef, llvm::Type*, llvm::SimplifyQuery const&) 4,536,905 ( 0.11%) ???:llvm::MemoryLocation::get(llvm::LoadInst const*) 4,524,818 ( 0.11%) ???:llvm::TargetTransformInfo::Model::getUserCost(llvm::User const*, llvm::ArrayRef, llvm::TargetTransformInfo::TargetCostKind) 4,520,124 ( 0.11%) ???:llvm::KnownBits::computeForAddCarry(llvm::KnownBits const&, llvm::KnownBits const&, llvm::KnownBits const&) 4,517,495 ( 0.11%) ???:(anonymous namespace)::MachineCopyPropagation::runOnMachineFunction(llvm::MachineFunction&) 4,479,530 ( 0.11%) ???:llvm::X86TargetMachine::getSubtargetImpl(llvm::Function const&) const 4,436,312 ( 0.11%) ???:llvm::Value::stripPointerCasts() const 4,414,385 ( 0.11%) ???:llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*) 4,379,851 ( 0.11%) ???:llvm::InstCombinerImpl::visitAllocSite(llvm::Instruction&) 4,333,172 ( 0.10%) ???:llvm::DecodePSHUFBMask(llvm::ArrayRef, llvm::APInt const&, llvm::SmallVectorImpl&) 4,329,068 ( 0.10%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:, (), core::hash::BuildHasherDefault>>::from_hash::>::{closure#0}> 4,312,800 ( 0.10%) ???:llvm::SmallPtrSetImplBase::insert_imp_big(void const*) 4,284,092 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_resolve/src/imports.rs:::try_define 4,239,360 ( 0.10%) ???:llvm::RegisterClassInfo::computePSetLimit(unsigned int) const 4,223,506 ( 0.10%) ???:ScopedAliasMetadataDeepCloner::clone() 4,185,400 ( 0.10%) ???:llvm::X86TTIImpl::getCastInstrCost(unsigned int, llvm::Type*, llvm::Type*, llvm::TargetTransformInfo::CastContextHint, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs -------------------------------------------------------------------------------- Ir -- line 111 ---------------------------------------- . const EMPTY: u8 = 0b1111_1111; . . /// Control byte value for a deleted bucket. . const DELETED: u8 = 0b1000_0000; . . /// Checks whether a control byte represents a full bucket (top bit is clear). . #[inline] . fn is_full(ctrl: u8) -> bool { 986,156 ( 0.02%) ctrl & 0x80 == 0 . } . . /// Checks whether a control byte represents a special value (top bit is set). . #[inline] . fn is_special(ctrl: u8) -> bool { . ctrl & 0x80 != 0 . } . . /// Checks whether a special control value is EMPTY (just check 1 bit). . #[inline] . fn special_is_empty(ctrl: u8) -> bool { . debug_assert!(is_special(ctrl)); 68,566 ( 0.00%) ctrl & 0x01 != 0 . } . . /// Primary hash function, used to select the initial bucket to probe from. . #[inline] . #[allow(clippy::cast_possible_truncation)] . fn h1(hash: u64) -> usize { . // On 32-bit platforms we simply ignore the higher hash bits. . hash as usize -- line 140 ---------------------------------------- -- line 143 ---------------------------------------- . /// Secondary hash function, saved in the low 7 bits of the control byte. . #[inline] . #[allow(clippy::cast_possible_truncation)] . fn h2(hash: u64) -> u8 { . // Grab the top 7 bits of the hash. While the hash is normally a full 64-bit . // value, some hash functions (such as FxHash) produce a usize result . // instead, which means that the top 32 bits are 0 on 32-bit platforms. . let hash_len = usize::min(mem::size_of::(), mem::size_of::()); 11,858,521 ( 0.29%) let top7 = hash >> (hash_len * 8 - 7); . (top7 & 0x7f) as u8 // truncation . } . . /// Probe sequence based on triangular numbers, which is guaranteed (since our . /// table size is a power of two) to visit every group of elements exactly once. . /// . /// A triangular probe has us jump by 1 more group every time. So first we . /// jump by 1 group (meaning we just continue our linear scan), then 2 groups -- line 159 ---------------------------------------- -- line 170 ---------------------------------------- . #[inline] . fn move_next(&mut self, bucket_mask: usize) { . // We should have found an empty bucket by now and ended the probe. . debug_assert!( . self.stride <= bucket_mask, . "Went past end of probe sequence" . ); . 158,278 ( 0.00%) self.stride += Group::WIDTH; 158,278 ( 0.00%) self.pos += self.stride; 129,529 ( 0.00%) self.pos &= bucket_mask; . } . } . . /// Returns the number of buckets needed to hold the given number of items, . /// taking the maximum load factor into account. . /// . /// Returns `None` if an overflow occurs. . // Workaround for emscripten bug emscripten-core/emscripten-fastcomp#258 . #[cfg_attr(target_os = "emscripten", inline(never))] . #[cfg_attr(not(target_os = "emscripten"), inline)] . fn capacity_to_buckets(cap: usize) -> Option { . debug_assert_ne!(cap, 0); . . // For small tables we require at least 1 empty bucket so that lookups are . // guaranteed to terminate if an element doesn't exist in the table. 44,214 ( 0.00%) if cap < 8 { . // We don't bother with a table size of 2 buckets since that can only . // hold a single element. Instead we skip directly to a 4 bucket table . // which can hold 3 elements. 90,470 ( 0.00%) return Some(if cap < 4 { 4 } else { 8 }); . } . . // Otherwise require 1/8 buckets to be empty (87.5% load) . // . // Be careful when modifying this, calculate_layout relies on the . // overflow check here. 24,078 ( 0.00%) let adjusted_cap = cap.checked_mul(8)? / 7; . . // Any overflows will have been caught by the checked_mul. Also, any . // rounding errors from the division above will be cleaned up by . // next_power_of_two (which can't overflow because of the previous division). . Some(adjusted_cap.next_power_of_two()) . } . . /// Returns the maximum effective capacity for the given bucket mask, taking . /// the maximum load factor into account. . #[inline] . fn bucket_mask_to_capacity(bucket_mask: usize) -> usize { 117,319 ( 0.00%) if bucket_mask < 8 { . // For tables with 1/2/4/8 buckets, we always reserve one empty slot. . // Keep in mind that the bucket mask is one less than the bucket count. . bucket_mask . } else { . // For larger tables we reserve 12.5% of the slots as empty. 29,416 ( 0.00%) ((bucket_mask + 1) / 8) * 7 . } . } . . /// Helper which allows the max calculation for ctrl_align to be statically computed for each T . /// while keeping the rest of `calculate_layout_for` independent of `T` . #[derive(Copy, Clone)] . struct TableLayout { . size: usize, -- line 233 ---------------------------------------- -- line 246 ---------------------------------------- . . #[inline] . fn calculate_layout_for(self, buckets: usize) -> Option<(Layout, usize)> { . debug_assert!(buckets.is_power_of_two()); . . let TableLayout { size, ctrl_align } = self; . // Manual layout calculation since Layout methods are not yet stable. . let ctrl_offset = 86,132 ( 0.00%) size.checked_mul(buckets)?.checked_add(ctrl_align - 1)? & !(ctrl_align - 1); 118,490 ( 0.00%) let len = ctrl_offset.checked_add(buckets + Group::WIDTH)?; . . Some(( . unsafe { Layout::from_size_align_unchecked(len, ctrl_align) }, . ctrl_offset, . )) . } . } . -- line 263 ---------------------------------------- -- line 337 ---------------------------------------- . } . } . #[cfg_attr(feature = "inline-more", inline)] . pub unsafe fn drop(&self) { . self.as_ptr().drop_in_place(); . } . #[inline] . pub unsafe fn read(&self) -> T { 598 ( 0.00%) self.as_ptr().read() . } . #[inline] . pub unsafe fn write(&self, val: T) { . self.as_ptr().write(val); . } . #[inline] . pub unsafe fn as_ref<'a>(&self) -> &'a T { . &*self.as_ptr() -- line 353 ---------------------------------------- -- line 422 ---------------------------------------- . /// Creates a new empty hash table without allocating any memory, using the . /// given allocator. . /// . /// In effect this returns a table with exactly 1 bucket. However we can . /// leave the data pointer dangling since that bucket is never written to . /// due to our load factor forcing us to always have at least 1 free bucket. . #[inline] . pub fn new_in(alloc: A) -> Self { 462 ( 0.00%) Self { . table: RawTableInner::new_in(alloc), . marker: PhantomData, . } . } . . /// Allocates a new hash table with the given number of buckets. . /// . /// The control bytes are left uninitialized. -- line 438 ---------------------------------------- -- line 440 ---------------------------------------- . unsafe fn new_uninitialized( . alloc: A, . buckets: usize, . fallibility: Fallibility, . ) -> Result { . debug_assert!(buckets.is_power_of_two()); . . Ok(Self { 105 ( 0.00%) table: RawTableInner::new_uninitialized( . alloc, . TableLayout::new::(), . buckets, . fallibility, . )?, . marker: PhantomData, . }) . } -- line 456 ---------------------------------------- -- line 458 ---------------------------------------- . /// Attempts to allocate a new hash table with at least enough capacity . /// for inserting the given number of elements without reallocating. . fn fallible_with_capacity( . alloc: A, . capacity: usize, . fallibility: Fallibility, . ) -> Result { . Ok(Self { 6,381 ( 0.00%) table: RawTableInner::fallible_with_capacity( . alloc, . TableLayout::new::(), . capacity, . fallibility, . )?, . marker: PhantomData, . }) . } -- line 474 ---------------------------------------- -- line 527 ---------------------------------------- . debug_assert_ne!(self.table.bucket_mask, 0); . debug_assert!(index < self.buckets()); . Bucket::from_base_index(self.data_end(), index) . } . . /// Erases an element from the table without dropping it. . #[cfg_attr(feature = "inline-more", inline)] . #[deprecated(since = "0.8.1", note = "use erase or remove instead")] 7,295 ( 0.00%) pub unsafe fn erase_no_drop(&mut self, item: &Bucket) { 7,295 ( 0.00%) let index = self.bucket_index(item); . self.table.erase(index); 14,590 ( 0.00%) } . . /// Erases an element from the table, dropping it in place. . #[cfg_attr(feature = "inline-more", inline)] . #[allow(clippy::needless_pass_by_value)] . #[allow(deprecated)] . pub unsafe fn erase(&mut self, item: Bucket) { . // Erase the element from the table first since drop might panic. 3,950 ( 0.00%) self.erase_no_drop(&item); . item.drop(); . } . . /// Finds and erases an element from the table, dropping it in place. . /// Returns true if an element was found. . #[cfg(feature = "raw")] . #[cfg_attr(feature = "inline-more", inline)] . pub fn erase_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> bool { -- line 554 ---------------------------------------- -- line 563 ---------------------------------------- . } . } . . /// Removes an element from the table, returning it. . #[cfg_attr(feature = "inline-more", inline)] . #[allow(clippy::needless_pass_by_value)] . #[allow(deprecated)] . pub unsafe fn remove(&mut self, item: Bucket) -> T { 10,640 ( 0.00%) self.erase_no_drop(&item); 35 ( 0.00%) item.read() . } . . /// Finds and removes an element from the table, returning it. . #[cfg_attr(feature = "inline-more", inline)] 290,100 ( 0.01%) pub fn remove_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option { . // Avoid `Option::map` because it bloats LLVM IR. 1,106 ( 0.00%) match self.find(hash, eq) { 2,297 ( 0.00%) Some(bucket) => Some(unsafe { self.remove(bucket) }), 37,147 ( 0.00%) None => None, . } 411,665 ( 0.01%) } . . /// Marks all table buckets as empty without dropping their contents. . #[cfg_attr(feature = "inline-more", inline)] . pub fn clear_no_drop(&mut self) { . self.table.clear_no_drop(); . } . . /// Removes all elements from the table without freeing the backing memory. . #[cfg_attr(feature = "inline-more", inline)] . pub fn clear(&mut self) { . // Ensure that the table is reset even if one of the drops panic . let mut self_ = guard(self, |self_| self_.clear_no_drop()); . unsafe { 1 ( 0.00%) self_.drop_elements(); . } . } . 7 ( 0.00%) unsafe fn drop_elements(&mut self) { 5,398 ( 0.00%) if mem::needs_drop::() && !self.is_empty() { . for item in self.iter() { . item.drop(); . } . } 8 ( 0.00%) } . . /// Shrinks the table to fit `max(self.len(), min_size)` elements. . #[cfg_attr(feature = "inline-more", inline)] . pub fn shrink_to(&mut self, min_size: usize, hasher: impl Fn(&T) -> u64) { . // Calculate the minimal number of elements that we need to reserve . // space for. . let min_size = usize::max(self.table.items, min_size); . if min_size == 0 { -- line 615 ---------------------------------------- -- line 642 ---------------------------------------- . } . } . } . . /// Ensures that at least `additional` items can be inserted into the table . /// without reallocation. . #[cfg_attr(feature = "inline-more", inline)] . pub fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64) { 165,568 ( 0.00%) if additional > self.table.growth_left { . // Avoid `Result::unwrap_or_else` because it bloats LLVM IR. 74,752 ( 0.00%) if self . .reserve_rehash(additional, hasher, Fallibility::Infallible) . .is_err() . { . unsafe { hint::unreachable_unchecked() } . } . } . } . -- line 660 ---------------------------------------- -- line 671 ---------------------------------------- . } else { . Ok(()) . } . } . . /// Out-of-line slow path for `reserve` and `try_reserve`. . #[cold] . #[inline(never)] 172,134 ( 0.00%) fn reserve_rehash( . &mut self, . additional: usize, . hasher: impl Fn(&T) -> u64, . fallibility: Fallibility, . ) -> Result<(), TryReserveError> { . unsafe { . self.table.reserve_rehash_inner( . additional, -- line 687 ---------------------------------------- -- line 690 ---------------------------------------- . TableLayout::new::(), . if mem::needs_drop::() { . Some(mem::transmute(ptr::drop_in_place:: as unsafe fn(*mut T))) . } else { . None . }, . ) . } 117,592 ( 0.00%) } . . /// Allocates a new table of a different size and moves the contents of the . /// current table into it. . fn resize( . &mut self, . capacity: usize, . hasher: impl Fn(&T) -> u64, . fallibility: Fallibility, -- line 706 ---------------------------------------- -- line 714 ---------------------------------------- . ) . } . } . . /// Inserts a new element into the table, and returns its raw bucket. . /// . /// This does not check if the given element already exists in the table. . #[cfg_attr(feature = "inline-more", inline)] 1,728,064 ( 0.04%) pub fn insert(&mut self, hash: u64, value: T, hasher: impl Fn(&T) -> u64) -> Bucket { . unsafe { . let mut index = self.table.find_insert_slot(hash); . . // We can avoid growing the table once we have reached our load . // factor if we are replacing a tombstone. This works since the . // number of EMPTY slots does not change in this case. 2,011 ( 0.00%) let old_ctrl = *self.table.ctrl(index); 983,157 ( 0.02%) if unlikely(self.table.growth_left == 0 && special_is_empty(old_ctrl)) { . self.reserve(1, hasher); . index = self.table.find_insert_slot(hash); . } . . self.table.record_item_insert_at(index, old_ctrl, hash); . . let bucket = self.bucket(index); 4 ( 0.00%) bucket.write(value); . bucket . } 1,255,875 ( 0.03%) } . . /// Attempts to insert a new element without growing the table and return its raw bucket. . /// . /// Returns an `Err` containing the given element if inserting it would require growing the . /// table. . /// . /// This does not check if the given element already exists in the table. . #[cfg(feature = "raw")] -- line 749 ---------------------------------------- -- line 760 ---------------------------------------- . } . } . } . . /// Inserts a new element into the table, and returns a mutable reference to it. . /// . /// This does not check if the given element already exists in the table. . #[cfg_attr(feature = "inline-more", inline)] 292,896 ( 0.01%) pub fn insert_entry(&mut self, hash: u64, value: T, hasher: impl Fn(&T) -> u64) -> &mut T { 38 ( 0.00%) unsafe { self.insert(hash, value, hasher).as_mut() } 219,672 ( 0.01%) } . . /// Inserts a new element into the table, without growing the table. . /// . /// There must be enough space in the table to insert the new element. . /// . /// This does not check if the given element already exists in the table. . #[cfg_attr(feature = "inline-more", inline)] . #[cfg(any(feature = "raw", feature = "rustc-internal-api"))] 323 ( 0.00%) pub unsafe fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket { 202,143 ( 0.00%) let (index, old_ctrl) = self.table.prepare_insert_slot(hash); 4,573 ( 0.00%) let bucket = self.table.bucket(index); . . // If we are replacing a DELETED entry then we don't need to update . // the load counter. 410,478 ( 0.01%) self.table.growth_left -= special_is_empty(old_ctrl) as usize; . . bucket.write(value); 326,430 ( 0.01%) self.table.items += 1; . bucket 613 ( 0.00%) } . . /// Temporary removes a bucket, applying the given function to the removed . /// element and optionally put back the returned value in the same bucket. . /// . /// Returns `true` if the bucket still contains an element . /// . /// This does not check if the given bucket is actually occupied. . #[cfg_attr(feature = "inline-more", inline)] -- line 798 ---------------------------------------- -- line 813 ---------------------------------------- . true . } else { . false . } . } . . /// Searches for an element in the table. . #[inline] 27,246 ( 0.00%) pub fn find(&self, hash: u64, mut eq: impl FnMut(&T) -> bool) -> Option> { 8,790 ( 0.00%) let result = self.table.find_inner(hash, &mut |index| unsafe { 9,269 ( 0.00%) eq(self.bucket(index).as_ref()) 3,016 ( 0.00%) }); . . // Avoid `Option::map` because it bloats LLVM IR. . match result { 1,181 ( 0.00%) Some(index) => Some(unsafe { self.bucket(index) }), . None => None, . } 31,008 ( 0.00%) } . . /// Gets a reference to an element in the table. . #[inline] . pub fn get(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&T> { . // Avoid `Option::map` because it bloats LLVM IR. 11,458 ( 0.00%) match self.find(hash, eq) { . Some(bucket) => Some(unsafe { bucket.as_ref() }), . None => None, . } . } . . /// Gets a mutable reference to an element in the table. . #[inline] 525 ( 0.00%) pub fn get_mut(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&mut T> { . // Avoid `Option::map` because it bloats LLVM IR. 14,085 ( 0.00%) match self.find(hash, eq) { . Some(bucket) => Some(unsafe { bucket.as_mut() }), . None => None, . } 600 ( 0.00%) } . . /// Attempts to get mutable references to `N` entries in the table at once. . /// . /// Returns an array of length `N` with the results of each query. . /// . /// At most one mutable reference will be returned to any entry. `None` will be returned if any . /// of the hashes are duplicates. `None` will be returned if the hash is not found. . /// -- line 859 ---------------------------------------- -- line 920 ---------------------------------------- . #[inline] . pub fn len(&self) -> usize { . self.table.items . } . . /// Returns `true` if the table contains no elements. . #[inline] . pub fn is_empty(&self) -> bool { 292,000 ( 0.01%) self.len() == 0 . } . . /// Returns the number of buckets in the table. . #[inline] . pub fn buckets(&self) -> usize { . self.table.bucket_mask + 1 . } . -- line 936 ---------------------------------------- -- line 938 ---------------------------------------- . /// the caller to ensure that the `RawTable` outlives the `RawIter`. . /// Because we cannot make the `next` method unsafe on the `RawIter` . /// struct, we have to make the `iter` method unsafe. . #[inline] . pub unsafe fn iter(&self) -> RawIter { . let data = Bucket::from_base_index(self.data_end(), 0); . RawIter { . iter: RawIterRange::new(self.table.ctrl.as_ptr(), data, self.table.buckets()), 34,045 ( 0.00%) items: self.table.items, . } . } . . /// Returns an iterator over occupied buckets that could match a given hash. . /// . /// `RawTable` only stores 7 bits of the hash value, so this iterator may . /// return items that have a hash value different than the one provided. You . /// should always validate the returned values before using them. -- line 954 ---------------------------------------- -- line 995 ---------------------------------------- . /// Iteration starts at the provided iterator's current location. . /// . /// It is up to the caller to ensure that the iterator is valid for this . /// `RawTable` and covers all items that remain in the table. . pub unsafe fn into_iter_from(self, iter: RawIter) -> RawIntoIter { . debug_assert_eq!(iter.len(), self.len()); . . let alloc = self.table.alloc.clone(); 2,396 ( 0.00%) let allocation = self.into_allocation(); 1,797 ( 0.00%) RawIntoIter { 2,995 ( 0.00%) iter, . allocation, . marker: PhantomData, . alloc, . } . } . . /// Converts the table into a raw allocation. The contents of the table . /// should be dropped using a `RawIter` before freeing the allocation. . #[cfg_attr(feature = "inline-more", inline)] . pub(crate) fn into_allocation(self) -> Option<(NonNull, Layout)> { 911 ( 0.00%) let alloc = if self.table.is_empty_singleton() { . None . } else { . // Avoid `Option::unwrap_or_else` because it bloats LLVM IR. . let (layout, ctrl_offset) = match calculate_layout::(self.table.buckets()) { . Some(lco) => lco, . None => unsafe { hint::unreachable_unchecked() }, . }; . Some(( 212 ( 0.00%) unsafe { NonNull::new_unchecked(self.table.ctrl.as_ptr().sub(ctrl_offset)) }, . layout, . )) . }; . mem::forget(self); . alloc . } . } . -- line 1033 ---------------------------------------- -- line 1042 ---------------------------------------- . T: Sync, . A: Sync, . { . } . . impl RawTableInner { . #[inline] . const fn new_in(alloc: A) -> Self { 252,711 ( 0.01%) Self { . // Be careful to cast the entire slice to a raw pointer. . ctrl: unsafe { NonNull::new_unchecked(Group::static_empty() as *const _ as *mut u8) }, . bucket_mask: 0, . items: 0, . growth_left: 0, . alloc, . } . } . } . . impl RawTableInner { . #[cfg_attr(feature = "inline-more", inline)] 144,832 ( 0.00%) unsafe fn new_uninitialized( . alloc: A, . table_layout: TableLayout, . buckets: usize, . fallibility: Fallibility, . ) -> Result { . debug_assert!(buckets.is_power_of_two()); . . // Avoid `Option::ok_or_else` because it bloats LLVM IR. -- line 1071 ---------------------------------------- -- line 1078 ---------------------------------------- . // exceed `isize::MAX`. We can skip this check on 64-bit systems since . // such allocations will never succeed anyways. . // . // This mirrors what Vec does in the standard library. . if mem::size_of::() < 8 && layout.size() > isize::MAX as usize { . return Err(fallibility.capacity_overflow()); . } . 34,832 ( 0.00%) let ptr: NonNull = match do_alloc(&alloc, layout) { . Ok(block) => block.cast(), . Err(_) => return Err(fallibility.alloc_err(layout)), . }; . . let ctrl = NonNull::new_unchecked(ptr.as_ptr().add(ctrl_offset)); 81,156 ( 0.00%) Ok(Self { . ctrl, 35,654 ( 0.00%) bucket_mask: buckets - 1, . items: 0, . growth_left: bucket_mask_to_capacity(buckets - 1), . alloc, . }) 105,572 ( 0.00%) } . . #[inline] 16,031 ( 0.00%) fn fallible_with_capacity( . alloc: A, . table_layout: TableLayout, . capacity: usize, . fallibility: Fallibility, . ) -> Result { 4,100 ( 0.00%) if capacity == 0 { 3,133 ( 0.00%) Ok(Self::new_in(alloc)) . } else { . unsafe { . let buckets = . capacity_to_buckets(capacity).ok_or_else(|| fallibility.capacity_overflow())?; . 66,106 ( 0.00%) let result = Self::new_uninitialized(alloc, table_layout, buckets, fallibility)?; . result.ctrl(0).write_bytes(EMPTY, result.num_ctrl_bytes()); . 8,393 ( 0.00%) Ok(result) . } . } 16,031 ( 0.00%) } . . /// Searches for an empty or deleted bucket which is suitable for inserting . /// a new element and sets the hash for that slot. . /// . /// There must be at least 1 empty bucket in the table. . #[inline] 68,269 ( 0.00%) unsafe fn prepare_insert_slot(&self, hash: u64) -> (usize, u8) { . let index = self.find_insert_slot(hash); 68,269 ( 0.00%) let old_ctrl = *self.ctrl(index); . self.set_ctrl_h2(index, hash); . (index, old_ctrl) 136,538 ( 0.00%) } . . /// Searches for an empty or deleted bucket which is suitable for inserting . /// a new element. . /// . /// There must be at least 1 empty bucket in the table. . #[inline] . fn find_insert_slot(&self, hash: u64) -> usize { . let mut probe_seq = self.probe_seq(hash); . loop { . unsafe { . let group = Group::load(self.ctrl(probe_seq.pos)); 653,577 ( 0.02%) if let Some(bit) = group.match_empty_or_deleted().lowest_set_bit() { 1,883,473 ( 0.05%) let result = (probe_seq.pos + bit) & self.bucket_mask; . . // In tables smaller than the group width, trailing control . // bytes outside the range of the table are filled with . // EMPTY entries. These will unfortunately trigger a . // match, but once masked may point to a full bucket that . // is already occupied. We detect this situation here and . // perform a second scan starting at the beginning of the . // table. This second scan is guaranteed to find an empty . // slot (due to the load factor) before hitting the trailing . // control bytes (containing EMPTY). 873,401 ( 0.02%) if unlikely(is_full(*self.ctrl(result))) { . debug_assert!(self.bucket_mask < Group::WIDTH); . debug_assert_ne!(probe_seq.pos, 0); . return Group::load_aligned(self.ctrl(0)) . .match_empty_or_deleted() . .lowest_set_bit_nonzero(); . } . . return result; -- line 1165 ---------------------------------------- -- line 1171 ---------------------------------------- . . /// Searches for an element in the table. This uses dynamic dispatch to reduce the amount of . /// code generated, but it is eliminated by LLVM optimizations. . #[inline] . fn find_inner(&self, hash: u64, eq: &mut dyn FnMut(usize) -> bool) -> Option { . let h2_hash = h2(hash); . let mut probe_seq = self.probe_seq(hash); . 33,228 ( 0.00%) loop { . let group = unsafe { Group::load(self.ctrl(probe_seq.pos)) }; . 1,413,707 ( 0.03%) for bit in group.match_byte(h2_hash) { 2,509,092 ( 0.06%) let index = (probe_seq.pos + bit) & self.bucket_mask; . 1,748,967 ( 0.04%) if likely(eq(index)) { . return Some(index); . } . } . 529,979 ( 0.01%) if likely(group.match_empty().any_bit_set()) { . return None; . } . . probe_seq.move_next(self.bucket_mask); . } . } . . #[allow(clippy::mut_mut)] . #[inline] . unsafe fn prepare_rehash_in_place(&mut self) { . // Bulk convert all full control bytes to DELETED, and all DELETED . // control bytes to EMPTY. This effectively frees up all buckets . // containing a DELETED entry. 3 ( 0.00%) for i in (0..self.buckets()).step_by(Group::WIDTH) { . let group = Group::load_aligned(self.ctrl(i)); . let group = group.convert_special_to_empty_and_full_to_deleted(); . group.store_aligned(self.ctrl(i)); . } . . // Fix up the trailing control bytes. See the comments in set_ctrl . // for the handling of tables smaller than the group width. 3 ( 0.00%) if self.buckets() < Group::WIDTH { . self.ctrl(0) . .copy_to(self.ctrl(Group::WIDTH), self.buckets()); . } else { . self.ctrl(0) . .copy_to(self.ctrl(self.buckets()), Group::WIDTH); . } . } . -- line 1220 ---------------------------------------- -- line 1225 ---------------------------------------- . Bucket::from_base_index(self.data_end(), index) . } . . #[inline] . unsafe fn bucket_ptr(&self, index: usize, size_of: usize) -> *mut u8 { . debug_assert_ne!(self.bucket_mask, 0); . debug_assert!(index < self.buckets()); . let base: *mut u8 = self.data_end().as_ptr(); 2,394,928 ( 0.06%) base.sub((index + 1) * size_of) . } . . #[inline] . unsafe fn data_end(&self) -> NonNull { . NonNull::new_unchecked(self.ctrl.as_ptr().cast()) . } . . /// Returns an iterator-like object for a probe sequence on the table. . /// . /// This iterator never terminates, but is guaranteed to visit each bucket . /// group exactly once. The loop using `probe_seq` must terminate upon . /// reaching a group containing an empty bucket. . #[inline] . fn probe_seq(&self, hash: u64) -> ProbeSeq { . ProbeSeq { 9,213,556 ( 0.22%) pos: h1(hash) & self.bucket_mask, . stride: 0, . } . } . . /// Returns the index of a bucket for which a value must be inserted if there is enough rooom . /// in the table, otherwise returns error . #[cfg(feature = "raw")] . #[inline] -- line 1257 ---------------------------------------- -- line 1263 ---------------------------------------- . } else { . self.record_item_insert_at(index, old_ctrl, hash); . Ok(index) . } . } . . #[inline] . unsafe fn record_item_insert_at(&mut self, index: usize, old_ctrl: u8, hash: u64) { 1,228,567 ( 0.03%) self.growth_left -= special_is_empty(old_ctrl) as usize; . self.set_ctrl_h2(index, hash); 982,840 ( 0.02%) self.items += 1; . } . . #[inline] . fn is_in_same_group(&self, i: usize, new_i: usize, hash: u64) -> bool { . let probe_seq_pos = self.probe_seq(hash).pos; . let probe_index = . |pos: usize| (pos.wrapping_sub(probe_seq_pos) & self.bucket_mask) / Group::WIDTH; 36 ( 0.00%) probe_index(i) == probe_index(new_i) . } . . /// Sets a control byte to the hash, and possibly also the replicated control byte at . /// the end of the array. . #[inline] . unsafe fn set_ctrl_h2(&self, index: usize, hash: u64) { . self.set_ctrl(index, h2(hash)); . } -- line 1289 ---------------------------------------- -- line 1312 ---------------------------------------- . // replicate the buckets at the end of the trailing group. For example . // with 2 buckets and a group size of 4, the control bytes will look . // like this: . // . // Real | Replicated . // --------------------------------------------- . // | [A] | [B] | [EMPTY] | [EMPTY] | [A] | [B] | . // --------------------------------------------- 1,841,918 ( 0.04%) let index2 = ((index.wrapping_sub(Group::WIDTH)) & self.bucket_mask) + Group::WIDTH; . 613,642 ( 0.01%) *self.ctrl(index) = ctrl; 613,883 ( 0.01%) *self.ctrl(index2) = ctrl; . } . . /// Returns a pointer to a control byte. . #[inline] . unsafe fn ctrl(&self, index: usize) -> *mut u8 { . debug_assert!(index < self.num_ctrl_bytes()); . self.ctrl.as_ptr().add(index) . } . . #[inline] . fn buckets(&self) -> usize { 105,020 ( 0.00%) self.bucket_mask + 1 . } . . #[inline] . fn num_ctrl_bytes(&self) -> usize { 79,867 ( 0.00%) self.bucket_mask + 1 + Group::WIDTH . } . . #[inline] . fn is_empty_singleton(&self) -> bool { 571,089 ( 0.01%) self.bucket_mask == 0 . } . . #[allow(clippy::mut_mut)] . #[inline] . unsafe fn prepare_resize( . &self, . table_layout: TableLayout, . capacity: usize, . fallibility: Fallibility, . ) -> Result, TryReserveError> { . debug_assert!(self.items <= capacity); . . // Allocate and initialize the new table. 1,272 ( 0.00%) let mut new_table = RawTableInner::fallible_with_capacity( . self.alloc.clone(), . table_layout, . capacity, . fallibility, . )?; 47,214 ( 0.00%) new_table.growth_left -= self.items; . new_table.items = self.items; . . // The hash function may panic, in which case we simply free the new . // table without dropping any elements that may have been copied into . // it. . // . // This guard is also used to free the old table on success, see . // the comment at the bottom of this function. . Ok(guard(new_table, move |self_| { 21,132 ( 0.00%) if !self_.is_empty_singleton() { . self_.free_buckets(table_layout); . } . })) . } . . /// Reserves or rehashes to make room for `additional` more elements. . /// . /// This uses dynamic dispatch to reduce the amount of -- line 1383 ---------------------------------------- -- line 1388 ---------------------------------------- . &mut self, . additional: usize, . hasher: &dyn Fn(&mut Self, usize) -> u64, . fallibility: Fallibility, . layout: TableLayout, . drop: Option, . ) -> Result<(), TryReserveError> { . // Avoid `Option::ok_or_else` because it bloats LLVM IR. 42,268 ( 0.00%) let new_items = match self.items.checked_add(additional) { . Some(new_items) => new_items, . None => return Err(fallibility.capacity_overflow()), . }; 42,266 ( 0.00%) let full_capacity = bucket_mask_to_capacity(self.bucket_mask); 90,857 ( 0.00%) if new_items <= full_capacity / 2 { . // Rehash in-place without re-allocating if we have plenty of spare . // capacity that is locked up due to DELETED entries. . self.rehash_in_place(hasher, layout.size, drop); 2 ( 0.00%) Ok(()) . } else { . // Otherwise, conservatively resize to at least the next size up . // to avoid churning deletes into frequent rehashes. . self.resize_inner( 21,132 ( 0.00%) usize::max(new_items, full_capacity + 1), . hasher, . fallibility, . layout, . ) . } . } . . /// Allocates a new table of a different size and moves the contents of the -- line 1418 ---------------------------------------- -- line 1424 ---------------------------------------- . #[inline(always)] . unsafe fn resize_inner( . &mut self, . capacity: usize, . hasher: &dyn Fn(&mut Self, usize) -> u64, . fallibility: Fallibility, . layout: TableLayout, . ) -> Result<(), TryReserveError> { 3,161 ( 0.00%) let mut new_table = self.prepare_resize(layout, capacity, fallibility)?; . . // Copy all elements to the new table. . for i in 0..self.buckets() { 358,465 ( 0.01%) if !is_full(*self.ctrl(i)) { . continue; . } . . // This may panic. . let hash = hasher(self, i); . . // We can use a simpler version of insert() here since: . // - there are no DELETED entries. -- line 1444 ---------------------------------------- -- line 1454 ---------------------------------------- . } . . // We successfully copied all elements without panicking. Now replace . // self with the new table. The old table will have its memory freed but . // the items will not be dropped (since they have been moved into the . // new table). . mem::swap(self, &mut new_table); . 21,132 ( 0.00%) Ok(()) . } . . /// Rehashes the contents of the table in place (i.e. without changing the . /// allocation). . /// . /// If `hasher` panics then some the table's contents may be lost. . /// . /// This uses dynamic dispatch to reduce the amount of -- line 1470 ---------------------------------------- -- line 1496 ---------------------------------------- . } . self_.growth_left = bucket_mask_to_capacity(self_.bucket_mask) - self_.items; . }); . . // At this point, DELETED elements are elements that we haven't . // rehashed yet. Find them and re-insert them at their ideal . // position. . 'outer: for i in 0..guard.buckets() { 64 ( 0.00%) if *guard.ctrl(i) != DELETED { . continue; . } . . let i_p = guard.bucket_ptr(i, size_of); . . 'inner: loop { . // Hash the current item . let hash = hasher(*guard, i); -- line 1512 ---------------------------------------- -- line 1515 ---------------------------------------- . let new_i = guard.find_insert_slot(hash); . let new_i_p = guard.bucket_ptr(new_i, size_of); . . // Probing works by scanning through all of the control . // bytes in groups, which may not be aligned to the group . // size. If both the new and old position fall within the . // same unaligned group, then there is no benefit in moving . // it and we can just continue to the next item. 12 ( 0.00%) if likely(guard.is_in_same_group(i, new_i, hash)) { . guard.set_ctrl_h2(i, hash); . continue 'outer; . } . . // We are moving the current item to a new position. Write . // our H2 to the control byte of the new position. . let prev_ctrl = guard.replace_ctrl_h2(new_i, hash); . if prev_ctrl == EMPTY { -- line 1531 ---------------------------------------- -- line 1541 ---------------------------------------- . // swapped into the old slot. . debug_assert_eq!(prev_ctrl, DELETED); . ptr::swap_nonoverlapping(i_p, new_i_p, size_of); . continue 'inner; . } . } . } . 3 ( 0.00%) guard.growth_left = bucket_mask_to_capacity(guard.bucket_mask) - guard.items; . . mem::forget(guard); . } . . #[inline] . unsafe fn free_buckets(&mut self, table_layout: TableLayout) { . // Avoid `Option::unwrap_or_else` because it bloats LLVM IR. . let (layout, ctrl_offset) = match table_layout.calculate_layout_for(self.buckets()) { . Some(lco) => lco, . None => hint::unreachable_unchecked(), . }; . self.alloc.deallocate( 14,798 ( 0.00%) NonNull::new_unchecked(self.ctrl.as_ptr().sub(ctrl_offset)), . layout, . ); . } . . /// Marks all table buckets as empty without dropping their contents. . #[inline] . fn clear_no_drop(&mut self) { 2,378 ( 0.00%) if !self.is_empty_singleton() { . unsafe { . self.ctrl(0).write_bytes(EMPTY, self.num_ctrl_bytes()); . } . } 3,107 ( 0.00%) self.items = 0; 2,378 ( 0.00%) self.growth_left = bucket_mask_to_capacity(self.bucket_mask); . } . . #[inline] . unsafe fn erase(&mut self, index: usize) { . debug_assert!(is_full(*self.ctrl(index))); 60,606 ( 0.00%) let index_before = index.wrapping_sub(Group::WIDTH) & self.bucket_mask; . let empty_before = Group::load(self.ctrl(index_before)).match_empty(); . let empty_after = Group::load(self.ctrl(index)).match_empty(); . . // If we are inside a continuous block of Group::WIDTH full or deleted . // cells then a probe window may have seen a full block when trying to . // insert. We therefore need to keep that block non-empty so that . // lookups will continue searching to the next probe window. . // . // Note that in this context `leading_zeros` refers to the bytes at the . // end of a group, while `trailing_zeros` refers to the bytes at the . // beginning of a group. 242,424 ( 0.01%) let ctrl = if empty_before.leading_zeros() + empty_after.trailing_zeros() >= Group::WIDTH { . DELETED . } else { 302,045 ( 0.01%) self.growth_left += 1; . EMPTY . }; . self.set_ctrl(index, ctrl); 242,424 ( 0.01%) self.items -= 1; . } . } . . impl Clone for RawTable { 1,248 ( 0.00%) fn clone(&self) -> Self { 179 ( 0.00%) if self.table.is_empty_singleton() { . Self::new_in(self.table.alloc.clone()) . } else { . unsafe { . let mut new_table = ManuallyDrop::new( . // Avoid `Result::ok_or_else` because it bloats LLVM IR. . match Self::new_uninitialized( . self.table.alloc.clone(), . self.table.buckets(), -- line 1615 ---------------------------------------- -- line 1624 ---------------------------------------- . // We need to free the memory allocated for the new table. . new_table.free_buckets(); . }); . . // Return the newly created table. . ManuallyDrop::into_inner(new_table) . } . } 1,404 ( 0.00%) } . . fn clone_from(&mut self, source: &Self) { . if source.table.is_empty_singleton() { . *self = Self::new_in(self.table.alloc.clone()); . } else { . unsafe { . // First, drop all our elements without clearing the control bytes. . self.drop_elements(); -- line 1640 ---------------------------------------- -- line 1687 ---------------------------------------- . .table . .ctrl(0) . .copy_to_nonoverlapping(self.table.ctrl(0), self.table.num_ctrl_bytes()); . source . .data_start() . .copy_to_nonoverlapping(self.data_start(), self.table.buckets()); . . self.table.items = source.table.items; 42 ( 0.00%) self.table.growth_left = source.table.growth_left; . } . } . . impl RawTable { . /// Common code for clone and clone_from. Assumes `self.buckets() == source.buckets()`. . #[cfg_attr(feature = "inline-more", inline)] . unsafe fn clone_from_impl(&mut self, source: &Self, mut on_panic: impl FnMut(&mut Self)) { . // Copy the control bytes unchanged. We do this in a single pass -- line 1703 ---------------------------------------- -- line 1790 ---------------------------------------- . fn default() -> Self { . Self::new_in(Default::default()) . } . } . . #[cfg(feature = "nightly")] . unsafe impl<#[may_dangle] T, A: Allocator + Clone> Drop for RawTable { . #[cfg_attr(feature = "inline-more", inline)] 270,458 ( 0.01%) fn drop(&mut self) { 256,173 ( 0.01%) if !self.table.is_empty_singleton() { . unsafe { . self.drop_elements(); . self.free_buckets(); . } . } 289,566 ( 0.01%) } . } . #[cfg(not(feature = "nightly"))] . impl Drop for RawTable { . #[cfg_attr(feature = "inline-more", inline)] . fn drop(&mut self) { . if !self.table.is_empty_singleton() { . unsafe { . self.drop_elements(); -- line 1813 ---------------------------------------- -- line 1817 ---------------------------------------- . } . } . . impl IntoIterator for RawTable { . type Item = T; . type IntoIter = RawIntoIter; . . #[cfg_attr(feature = "inline-more", inline)] 2,396 ( 0.00%) fn into_iter(self) -> RawIntoIter { . unsafe { . let iter = self.iter(); . self.into_iter_from(iter) . } 2,995 ( 0.00%) } . } . . /// Iterator over a sub-range of a table. Unlike `RawIter` this iterator does . /// not track an item count. . pub(crate) struct RawIterRange { . // Mask of full buckets in the current group. Bits are cleared from this . // mask as each element is processed. . current_group: BitMask, -- line 1838 ---------------------------------------- -- line 1934 ---------------------------------------- . . impl Iterator for RawIterRange { . type Item = Bucket; . . #[cfg_attr(feature = "inline-more", inline)] . fn next(&mut self) -> Option> { . unsafe { . loop { 82,423 ( 0.00%) if let Some(index) = self.current_group.lowest_set_bit() { 11,358 ( 0.00%) self.current_group = self.current_group.remove_lowest_bit(); 17,894 ( 0.00%) return Some(self.data.next_n(index)); . } . 69,343 ( 0.00%) if self.next_ctrl >= self.end { . return None; . } . . // We might read past self.end up to the next group boundary, . // but this is fine because it only occurs on tables smaller . // than the group size where the trailing control bytes are all . // EMPTY. On larger tables self.end is guaranteed to be aligned . // to the group size (since tables are power-of-two sized). 2,406 ( 0.00%) self.current_group = Group::load_aligned(self.next_ctrl).match_full(); 1,648 ( 0.00%) self.data = self.data.next_n(Group::WIDTH); 5,223 ( 0.00%) self.next_ctrl = self.next_ctrl.add(Group::WIDTH); . } . } . } . . #[inline] . fn size_hint(&self) -> (usize, Option) { . // We don't have an item count, so just guess based on the range size. . ( -- line 1966 ---------------------------------------- -- line 2102 ---------------------------------------- . } . } else { . // We must have already iterated past the removed item. . } . } . } . . unsafe fn drop_elements(&mut self) { 633 ( 0.00%) if mem::needs_drop::() && self.len() != 0 { . for item in self { . item.drop(); . } . } . } . } . . impl Clone for RawIter { -- line 2118 ---------------------------------------- -- line 2124 ---------------------------------------- . } . } . } . . impl Iterator for RawIter { . type Item = Bucket; . . #[cfg_attr(feature = "inline-more", inline)] 13,137 ( 0.00%) fn next(&mut self) -> Option> { 28,356 ( 0.00%) if let Some(b) = self.iter.next() { 101,833 ( 0.00%) self.items -= 1; . Some(b) . } else { . // We don't check against items == 0 here to allow the . // compiler to optimize away the item count entirely if the . // iterator length is never queried. . debug_assert_eq!(self.items, 0); . None . } 26,274 ( 0.00%) } . . #[inline] . fn size_hint(&self) -> (usize, Option) { . (self.items, Some(self.items)) . } . } . . impl ExactSizeIterator for RawIter {} -- line 2151 ---------------------------------------- -- line 2177 ---------------------------------------- . T: Sync, . A: Sync, . { . } . . #[cfg(feature = "nightly")] . unsafe impl<#[may_dangle] T, A: Allocator + Clone> Drop for RawIntoIter { . #[cfg_attr(feature = "inline-more", inline)] 1,126 ( 0.00%) fn drop(&mut self) { . unsafe { . // Drop all remaining elements . self.iter.drop_elements(); . . // Free the table 4,250 ( 0.00%) if let Some((ptr, layout)) = self.allocation { . self.alloc.deallocate(ptr, layout); . } . } 214 ( 0.00%) } . } . #[cfg(not(feature = "nightly"))] . impl Drop for RawIntoIter { . #[cfg_attr(feature = "inline-more", inline)] . fn drop(&mut self) { . unsafe { . // Drop all remaining elements . self.iter.drop_elements(); -- line 2203 ---------------------------------------- -- line 2209 ---------------------------------------- . } . } . } . . impl Iterator for RawIntoIter { . type Item = T; . . #[cfg_attr(feature = "inline-more", inline)] 729 ( 0.00%) fn next(&mut self) -> Option { 141 ( 0.00%) unsafe { Some(self.iter.next()?.read()) } 1,993 ( 0.00%) } . . #[inline] . fn size_hint(&self) -> (usize, Option) { 3 ( 0.00%) self.iter.size_hint() . } . } . . impl ExactSizeIterator for RawIntoIter {} . impl FusedIterator for RawIntoIter {} . . /// Iterator which consumes elements without freeing the table storage. . pub struct RawDrain<'a, T, A: Allocator + Clone = Global> { -- line 2231 ---------------------------------------- -- line 2259 ---------------------------------------- . where . T: Sync, . A: Sync, . { . } . . impl Drop for RawDrain<'_, T, A> { . #[cfg_attr(feature = "inline-more", inline)] 360 ( 0.00%) fn drop(&mut self) { . unsafe { . // Drop all remaining elements. Note that this may panic. . self.iter.drop_elements(); . . // Reset the contents of the table now that all elements have been . // dropped. . self.table.clear_no_drop(); . . // Move the now empty table back to its original location. 45 ( 0.00%) self.orig_table . .as_ptr() . .copy_from_nonoverlapping(&*self.table, 1); . } 360 ( 0.00%) } . } . . impl Iterator for RawDrain<'_, T, A> { . type Item = T; . . #[cfg_attr(feature = "inline-more", inline)] . fn next(&mut self) -> Option { . unsafe { -- line 2289 ---------------------------------------- 5,041,949 ( 0.12%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_resolve/src/imports.rs -------------------------------------------------------------------------------- Ir -- line 109 ---------------------------------------- . /// The resolution of `module_path`. . pub imported_module: Cell>>, . pub vis: Cell, . pub used: Cell, . } . . impl<'a> Import<'a> { . pub fn is_glob(&self) -> bool { 74,975 ( 0.00%) matches!(self.kind, ImportKind::Glob { .. }) . } . . pub fn is_nested(&self) -> bool { . match self.kind { . ImportKind::Single { nested, .. } => nested, . _ => false, . } . } . . crate fn crate_lint(&self) -> CrateLint { 165 ( 0.00%) CrateLint::UsePath { root_id: self.root_id, root_span: self.root_span } 291 ( 0.00%) } . } . 149,445 ( 0.00%) #[derive(Clone, Default, Debug)] . /// Records information about the resolution of a name in a namespace of a module. . pub struct NameResolution<'a> { . /// Single imports that may define the name in the namespace. . /// Imports are arena-allocated, so it's ok to use pointers as keys. . single_imports: FxHashSet>>, . /// The least shadowable known binding for this name, or None if there are no known bindings. . pub binding: Option<&'a NameBinding<'a>>, . shadowed_glob: Option<&'a NameBinding<'a>>, . } . . impl<'a> NameResolution<'a> { . // Returns the binding for the name if it is known or None if it not known. . pub(crate) fn binding(&self) -> Option<&'a NameBinding<'a>> { 99,158 ( 0.00%) self.binding.and_then(|binding| { 99,338 ( 0.00%) if !binding.is_glob_import() || self.single_imports.is_empty() { . Some(binding) . } else { . None . } . }) . } . . crate fn add_single_import(&mut self, import: &'a Import<'a>) { -- line 155 ---------------------------------------- -- line 177 ---------------------------------------- . &mut self, . module: ModuleOrUniformRoot<'a>, . ident: Ident, . ns: Namespace, . parent_scope: &ParentScope<'a>, . record_used: bool, . path_span: Span, . ) -> Result<&'a NameBinding<'a>, Determinacy> { 11,576 ( 0.00%) self.resolve_ident_in_module_unadjusted_ext( . module, . ident, . ns, . parent_scope, . false, . record_used, . path_span, . ) . .map_err(|(determinacy, _)| determinacy) . } . . /// Attempts to resolve `ident` in namespaces `ns` of `module`. . /// Invariant: if `record_used` is `Some`, expansion and import resolution must be complete. 72,177 ( 0.00%) crate fn resolve_ident_in_module_unadjusted_ext( . &mut self, . module: ModuleOrUniformRoot<'a>, . ident: Ident, . ns: Namespace, . parent_scope: &ParentScope<'a>, . restricted_shadowing: bool, . record_used: bool, . path_span: Span, -- line 207 ---------------------------------------- -- line 259 ---------------------------------------- . path_span, . ); . return binding.map_err(|determinacy| (determinacy, Weak::No)); . } . }; . . let key = self.new_key(ident, ns); . let resolution = 27,496 ( 0.00%) self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports. . 12,425 ( 0.00%) if let Some(binding) = resolution.binding { 1,055 ( 0.00%) if !restricted_shadowing && binding.expansion != LocalExpnId::ROOT { 780 ( 0.00%) if let NameBindingKind::Res(_, true) = binding.kind { . self.macro_expanded_macro_export_errors.insert((path_span, binding.span)); . } . } . } . 13,748 ( 0.00%) let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { 1,854 ( 0.00%) if let Some(unusable_binding) = this.unusable_binding { . if ptr::eq(binding, unusable_binding) { . return Err((Determined, Weak::No)); . } . } 990 ( 0.00%) let usable = this.is_accessible_from(binding.vis, parent_scope.module); 1,144 ( 0.00%) if usable { Ok(binding) } else { Err((Determined, Weak::No)) } . }; . 6,874 ( 0.00%) if record_used { 3,290 ( 0.00%) return resolution . .binding . .and_then(|binding| { . // If the primary binding is unusable, search further and return the shadowed glob . // binding if it exists. What we really want here is having two separate scopes in . // a module - one for non-globs and one for globs, but until that's done use this . // hack to avoid inconsistent resolution ICEs during import validation. 3,894 ( 0.00%) if let Some(unusable_binding) = self.unusable_binding { . if ptr::eq(binding, unusable_binding) { . return resolution.shadowed_glob; . } . } . Some(binding) . }) . .ok_or((Determined, Weak::No)) . .and_then(|binding| { 1,628 ( 0.00%) if self.last_import_segment && check_usable(self, binding).is_err() { . Err((Determined, Weak::No)) . } else { 4,620 ( 0.00%) self.record_use(ident, binding, restricted_shadowing); . 2,310 ( 0.00%) if let Some(shadowed_glob) = resolution.shadowed_glob { . // Forbid expanded shadowing to avoid time travel. . if restricted_shadowing . && binding.expansion != LocalExpnId::ROOT . && binding.res() != shadowed_glob.res() . { . self.ambiguity_errors.push(AmbiguityError { . kind: AmbiguityKind::GlobVsExpanded, . ident, -- line 317 ---------------------------------------- -- line 318 ---------------------------------------- . b1: binding, . b2: shadowed_glob, . misc1: AmbiguityErrorMisc::None, . misc2: AmbiguityErrorMisc::None, . }); . } . } . 3,850 ( 0.00%) if !self.is_accessible_from(binding.vis, parent_scope.module) { . self.privacy_errors.push(PrivacyError { . ident, . binding, . dedup_span: path_span, . }); . } . . Ok(binding) . } . }); . } . . // Items and single imports are not shadowable, if we have one, then it's determined. 5,376 ( 0.00%) if let Some(binding) = resolution.binding { 60 ( 0.00%) if !binding.is_glob_import() { . return check_usable(self, binding); . } . } . . // --- From now on we either have a glob resolution or no resolution. --- . . // Check if one of single imports can still define the name, . // if it can then our result is not determined and can be invalidated. 15,050 ( 0.00%) for single_import in &resolution.single_imports { . if !self.is_accessible_from(single_import.vis.get(), parent_scope.module) { . continue; . } . let module = match single_import.imported_module.get() { . Some(x) => x, . None => return Err((Undetermined, Weak::No)), . }; . let ident = match single_import.kind { -- line 358 ---------------------------------------- -- line 385 ---------------------------------------- . // Additionally, any macro in any module can plant names in the root module if it creates . // `macro_export` macros, so the root module effectively has unresolved invocations if any . // module has unresolved invocations. . // However, it causes resolution/expansion to stuck too often (#53144), so, to make . // progress, we have to ignore those potential unresolved invocations from other modules . // and prohibit access to macro-expanded `macro_export` macros instead (unless restricted . // shadowing is enabled, see `macro_expanded_macro_export_errors`). . let unexpanded_macros = !module.unexpanded_invocations.borrow().is_empty(); 7,525 ( 0.00%) if let Some(binding) = resolution.binding { . if !unexpanded_macros || ns == MacroNS || restricted_shadowing { . return check_usable(self, binding); . } else { . return Err((Undetermined, Weak::No)); . } . } . . // --- From now on we have no resolution. --- -- line 401 ---------------------------------------- -- line 403 ---------------------------------------- . // Now we are in situation when new item/import can appear only from a glob or a macro . // expansion. With restricted shadowing names from globs and macro expansions cannot . // shadow names from outer scopes, so we can freely fallback from module search to search . // in outer scopes. For `early_resolve_ident_in_lexical_scope` to continue search in outer . // scopes we return `Undetermined` with `Weak::Yes`. . . // Check if one of unexpanded macros can still define the name, . // if it can then our "no resolution" result is not determined and can be invalidated. 1,505 ( 0.00%) if unexpanded_macros { . return Err((Undetermined, Weak::Yes)); . } . . // Check if one of glob imports can still define the name, . // if it can then our "no resolution" result is not determined and can be invalidated. 5,388 ( 0.00%) for glob_import in module.globs.borrow().iter() { 244 ( 0.00%) if !self.is_accessible_from(glob_import.vis.get(), parent_scope.module) { . continue; . } 318 ( 0.00%) let module = match glob_import.imported_module.get() { . Some(ModuleOrUniformRoot::Module(module)) => module, . Some(_) => continue, . None => return Err((Undetermined, Weak::Yes)), . }; . let tmp_parent_scope; . let (mut adjusted_parent_scope, mut ident) = . (parent_scope, ident.normalize_to_macros_2_0()); . match ident.span.glob_adjust(module.expansion, glob_import.span) { -- line 429 ---------------------------------------- -- line 452 ---------------------------------------- . continue; . } . Ok(_) | Err(Undetermined) => return Err((Undetermined, Weak::Yes)), . } . } . . // No resolution and no one else can define the name - determinate error. . Err((Determined, Weak::No)) 61,866 ( 0.00%) } . . // Given a binding and an import that resolves to it, . // return the corresponding binding defined by the import. 447,760 ( 0.01%) crate fn import( . &self, . binding: &'a NameBinding<'a>, . import: &'a Import<'a>, . ) -> &'a NameBinding<'a> { 447,760 ( 0.01%) let vis = if binding.vis.is_at_least(import.vis.get(), self) . || pub_use_of_private_extern_crate_hack(import, binding) . { . import.vis.get() . } else { . binding.vis . }; . 134,328 ( 0.00%) if let ImportKind::Glob { ref max_vis, .. } = import.kind { 178,704 ( 0.00%) if vis == import.vis.get() || vis.is_at_least(max_vis.get(), self) { . max_vis.set(vis) . } . } . 44,776 ( 0.00%) self.arenas.alloc_name_binding(NameBinding { . kind: NameBindingKind::Import { binding, import, used: Cell::new(false) }, . ambiguity: None, 44,776 ( 0.00%) span: import.span, . vis, 44,776 ( 0.00%) expansion: import.parent_scope.expansion, . }) 358,208 ( 0.01%) } . . // Define the name or return the existing binding if there is a collision. 649,344 ( 0.02%) crate fn try_define( . &mut self, . module: Module<'a>, . key: BindingKey, . binding: &'a NameBinding<'a>, . ) -> Result<(), &'a NameBinding<'a>> { . let res = binding.res(); 974,016 ( 0.02%) self.check_reserved_macro_name(key.ident, res); . self.set_binding_parent_module(binding, module); 324,672 ( 0.01%) self.update_resolution(module, key, |this, resolution| { . if let Some(old_binding) = resolution.binding { 24,820 ( 0.00%) if res == Res::Err { . // Do not override real bindings with `Res::Err`s from error recovery. . return Ok(()); . } 9,928 ( 0.00%) match (old_binding.is_glob_import(), binding.is_glob_import()) { . (true, true) => { 14,892 ( 0.00%) if res != old_binding.res() { . resolution.binding = Some(this.ambiguity( . AmbiguityKind::GlobVsGlob, . old_binding, . binding, . )); 39,712 ( 0.00%) } else if !old_binding.vis.is_at_least(binding.vis, &*this) { . // We are glob-importing the same item but with greater visibility. . resolution.binding = Some(binding); . } . } . (old_glob @ true, false) | (old_glob @ false, true) => { . let (glob_binding, nonglob_binding) = . if old_glob { (old_binding, binding) } else { (binding, old_binding) }; . if glob_binding.res() != nonglob_binding.res() -- line 524 ---------------------------------------- -- line 535 ---------------------------------------- . } . resolution.shadowed_glob = Some(glob_binding); . } . (false, false) => { . return Err(old_binding); . } . } . } else { 147,444 ( 0.00%) resolution.binding = Some(binding); . } . . Ok(()) . }) 487,008 ( 0.01%) } . . fn ambiguity( . &self, . kind: AmbiguityKind, . primary_binding: &'a NameBinding<'a>, . secondary_binding: &'a NameBinding<'a>, . ) -> &'a NameBinding<'a> { . self.arenas.alloc_name_binding(NameBinding { -- line 556 ---------------------------------------- -- line 563 ---------------------------------------- . // If the resolution becomes a success, define it in the module's glob importers. . fn update_resolution(&mut self, module: Module<'a>, key: BindingKey, f: F) -> T . where . F: FnOnce(&mut Resolver<'a>, &mut NameResolution<'a>) -> T, . { . // Ensure that `resolution` isn't borrowed when defining in the module's glob importers, . // during which the resolution might end up getting re-defined via a glob cycle. . let (binding, t) = { 866,448 ( 0.02%) let resolution = &mut *self.resolution(module, key).borrow_mut(); . let old_binding = resolution.binding(); . . let t = f(self, resolution); . . match resolution.binding() { . _ if old_binding.is_some() => return t, . None => return t, . Some(binding) => match old_binding { -- line 579 ---------------------------------------- -- line 580 ---------------------------------------- . Some(old_binding) if ptr::eq(old_binding, binding) => return t, . _ => (binding, t), . }, . } . }; . . // Define `binding` in `module`s glob importers. . for import in module.glob_importers.borrow_mut().iter() { 19,912 ( 0.00%) let mut ident = key.ident; 44,802 ( 0.00%) let scope = match ident.span.reverse_glob_adjust(module.expansion, import.span) { . Some(Some(def)) => self.expn_def_scope(def), 9,956 ( 0.00%) Some(None) => import.parent_scope.module, . None => continue, . }; 9,956 ( 0.00%) if self.is_accessible_from(binding.vis, scope) { 19,856 ( 0.00%) let imported_binding = self.import(binding, import); . let key = BindingKey { ident, ..key }; 74,460 ( 0.00%) let _ = self.try_define(import.parent_scope.module, key, imported_binding); . } . } . . t . } . . // Define a "dummy" resolution containing a Res::Err as a placeholder for a . // failed resolution -- line 605 ---------------------------------------- -- line 643 ---------------------------------------- . // This is a fixed-point algorithm. We resolve imports until our efforts . // are stymied by an unresolved import; then we bail out of the current . // module and continue. We terminate successfully once no more imports . // remain or unsuccessfully when no forward progress in resolving imports . // is made. . . /// Resolves all imports for the crate. This method performs the fixed- . /// point iteration. 16 ( 0.00%) pub fn resolve_imports(&mut self) { 10 ( 0.00%) let mut prev_num_indeterminates = self.r.indeterminate_imports.len() + 1; 29 ( 0.00%) while self.r.indeterminate_imports.len() < prev_num_indeterminates { . prev_num_indeterminates = self.r.indeterminate_imports.len(); 154 ( 0.00%) for import in mem::take(&mut self.r.indeterminate_imports) { . match self.resolve_import(&import) { 60 ( 0.00%) true => self.r.determined_imports.push(import), 26 ( 0.00%) false => self.r.indeterminate_imports.push(import), . } . } . } 16 ( 0.00%) } . 7 ( 0.00%) pub fn finalize_imports(&mut self) { 2 ( 0.00%) for module in self.r.arenas.local_modules().iter() { 15 ( 0.00%) self.finalize_resolutions_in(module); . } . . let mut seen_spans = FxHashSet::default(); . let mut errors = vec![]; . let mut prev_root_id: NodeId = NodeId::from_u32(0); 1 ( 0.00%) let determined_imports = mem::take(&mut self.r.determined_imports); 1 ( 0.00%) let indeterminate_imports = mem::take(&mut self.r.indeterminate_imports); . 12 ( 0.00%) for (is_indeterminate, import) in determined_imports . .into_iter() . .map(|i| (false, i)) . .chain(indeterminate_imports.into_iter().map(|i| (true, i))) . { 306 ( 0.00%) if let Some(err) = self.finalize_import(import) { . if let ImportKind::Single { source, ref source_bindings, .. } = import.kind { . if source.name == kw::SelfLower { . // Silence `unresolved import` error if E0429 is already emitted . if let Err(Determined) = source_bindings.value_ns.get() { . continue; . } . } . } -- line 688 ---------------------------------------- -- line 703 ---------------------------------------- . let path = import_path_to_string( . &import.module_path.iter().map(|seg| seg.ident).collect::>(), . &import.kind, . err.span, . ); . errors.push((path, err)); . prev_root_id = import.root_id; . } 102 ( 0.00%) } else if is_indeterminate { . // Consider erroneous imports used to avoid duplicate diagnostics. . self.r.used_imports.insert(import.id); . let path = import_path_to_string( . &import.module_path.iter().map(|seg| seg.ident).collect::>(), . &import.kind, . import.span, . ); . let err = UnresolvedImportError { -- line 719 ---------------------------------------- -- line 721 ---------------------------------------- . label: None, . note: Vec::new(), . suggestion: None, . }; . errors.push((path, err)); . } . } . 1 ( 0.00%) if !errors.is_empty() { . self.throw_unresolved_import_error(errors, None); . } 8 ( 0.00%) } . . fn throw_unresolved_import_error( . &self, . errors: Vec<(String, UnresolvedImportError)>, . span: Option, . ) { . /// Upper limit on the number of `span_label` messages. . const MAX_LABEL_COUNT: usize = 10; -- line 740 ---------------------------------------- -- line 776 ---------------------------------------- . /// If successful, the resolved bindings are written into the module. . fn resolve_import(&mut self, import: &'b Import<'b>) -> bool { . debug!( . "(resolving import for module) resolving import `{}::...` in `{}`", . Segment::names_to_string(&import.module_path), . module_to_string(import.parent_scope.module).unwrap_or_else(|| "???".to_string()), . ); . 257 ( 0.00%) let module = if let Some(module) = import.imported_module.get() { 52 ( 0.00%) module . } else { . // For better failure detection, pretend that the import will . // not define any names while resolving its module path. . let orig_vis = import.vis.replace(ty::Visibility::Invisible); . let path_res = self.r.resolve_path( . &import.module_path, . None, 51 ( 0.00%) &import.parent_scope, . false, . import.span, . import.crate_lint(), . ); . import.vis.set(orig_vis); . 357 ( 0.00%) match path_res { 255 ( 0.00%) PathResult::Module(module) => module, . PathResult::Indeterminate => return false, . PathResult::NonModule(..) | PathResult::Failed { .. } => return true, . } . }; . . import.imported_module.set(Some(module)); 861 ( 0.00%) let (source, target, source_bindings, target_bindings, type_ns_only) = match import.kind { . ImportKind::Single { . source, . target, 68 ( 0.00%) ref source_bindings, 68 ( 0.00%) ref target_bindings, 68 ( 0.00%) type_ns_only, . .. . } => (source, target, source_bindings, target_bindings, type_ns_only), . ImportKind::Glob { .. } => { . self.resolve_glob_import(import); . return true; . } . _ => unreachable!(), . }; . 68 ( 0.00%) let mut indeterminate = false; 2,924 ( 0.00%) self.r.per_ns(|this, ns| { 612 ( 0.00%) if !type_ns_only || ns == TypeNS { 840 ( 0.00%) if let Err(Undetermined) = source_bindings[ns].get() { . // For better failure detection, pretend that the import will . // not define any names while resolving its module path. 180 ( 0.00%) let orig_vis = import.vis.replace(ty::Visibility::Invisible); . let binding = this.resolve_ident_in_module( 540 ( 0.00%) module, 540 ( 0.00%) source, . ns, 180 ( 0.00%) &import.parent_scope, . false, 180 ( 0.00%) import.span, . ); . import.vis.set(orig_vis); . source_bindings[ns].set(binding); . } else { . return; . }; . 180 ( 0.00%) let parent = import.parent_scope.module; 452 ( 0.00%) match source_bindings[ns].get() { 162 ( 0.00%) Err(Undetermined) => indeterminate = true, . // Don't update the resolution, because it was never added. 164 ( 0.00%) Err(Determined) if target.name == kw::Underscore => {} . Err(Determined) => { 164 ( 0.00%) let key = this.new_key(target, ns); . this.update_resolution(parent, key, |_, resolution| { 164 ( 0.00%) resolution.single_imports.remove(&PtrKey(import)); . }); . } . Ok(binding) if !binding.is_importable() => { . let msg = format!("`{}` is not directly importable", target); . struct_span_err!(this.session, import.span, E0253, "{}", &msg) . .span_label(import.span, "cannot be imported directly") . .emit(); . // Do not import this illegal binding. Import a dummy binding and pretend . // everything is fine . this.import_dummy_binding(import); . } . Ok(binding) => { 176 ( 0.00%) let imported_binding = this.import(binding, import); 44 ( 0.00%) target_bindings[ns].set(Some(imported_binding)); 132 ( 0.00%) this.define(parent, target, ns, imported_binding); . } . } . } 1,632 ( 0.00%) }); . 178 ( 0.00%) !indeterminate . } . . /// Performs final import resolution, consistency checks and error reporting. . /// . /// Optionally returns an unresolved import error. This error is buffered and used to . /// consolidate multiple unresolved import errors into a single diagnostic. 510 ( 0.00%) fn finalize_import(&mut self, import: &'b Import<'b>) -> Option { . let orig_vis = import.vis.replace(ty::Visibility::Invisible); 204 ( 0.00%) let orig_unusable_binding = match &import.kind { . ImportKind::Single { target_bindings, .. } => { 84 ( 0.00%) Some(mem::replace(&mut self.r.unusable_binding, target_bindings[TypeNS].get())) . } . _ => None, . }; 102 ( 0.00%) let prev_ambiguity_errors_len = self.r.ambiguity_errors.len(); . let path_res = self.r.resolve_path( . &import.module_path, . None, 51 ( 0.00%) &import.parent_scope, . true, 51 ( 0.00%) import.span, . import.crate_lint(), . ); 51 ( 0.00%) let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len; 51 ( 0.00%) if let Some(orig_unusable_binding) = orig_unusable_binding { 42 ( 0.00%) self.r.unusable_binding = orig_unusable_binding; . } . import.vis.set(orig_vis); 255 ( 0.00%) if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res { . // Consider erroneous imports used to avoid duplicate diagnostics. . self.r.used_imports.insert(import.id); . } . let module = match path_res { 153 ( 0.00%) PathResult::Module(module) => { . // Consistency checks, analogous to `finalize_macro_resolutions`. 153 ( 0.00%) if let Some(initial_module) = import.imported_module.get() { 153 ( 0.00%) if !ModuleOrUniformRoot::same_def(module, initial_module) && no_ambiguity { . span_bug!(import.span, "inconsistent resolution for an import"); . } . } else if self.r.privacy_errors.is_empty() { . let msg = "cannot determine resolution for the import"; . let msg_note = "import resolution is stuck, try simplifying other imports"; . self.r.session.struct_span_err(import.span, msg).note(msg_note).emit(); . } . 153 ( 0.00%) module . } . PathResult::Failed { is_error_from_last_segment: false, span, label, suggestion } => { . if no_ambiguity { . assert!(import.imported_module.get().is_none()); . self.r . .report_error(span, ResolutionError::FailedToResolve { label, suggestion }); . } . return None; -- line 928 ---------------------------------------- -- line 961 ---------------------------------------- . assert!(import.imported_module.get().is_none()); . } . // The error was already reported earlier. . return None; . } . PathResult::Indeterminate => unreachable!(), . }; . 549 ( 0.00%) let (ident, target, source_bindings, target_bindings, type_ns_only) = match import.kind { . ImportKind::Single { . source, . target, 42 ( 0.00%) ref source_bindings, 42 ( 0.00%) ref target_bindings, 42 ( 0.00%) type_ns_only, . .. . } => (source, target, source_bindings, target_bindings, type_ns_only), 18 ( 0.00%) ImportKind::Glob { is_prelude, ref max_vis } => { 27 ( 0.00%) if import.module_path.len() <= 1 { . // HACK(eddyb) `lint_if_path_starts_with_module` needs at least . // 2 segments, so the `resolve_path` above won't trigger it. . let mut full_path = import.module_path.clone(); . full_path.push(Segment::from_ident(Ident::empty())); . self.r.lint_if_path_starts_with_module( . import.crate_lint(), . &full_path, . import.span, . None, . ); . } . 36 ( 0.00%) if let ModuleOrUniformRoot::Module(module) = module { 9 ( 0.00%) if ptr::eq(module, import.parent_scope.module) { . // Importing a module into itself is not allowed. . return Some(UnresolvedImportError { . span: import.span, . label: Some(String::from("cannot glob-import a module into itself")), . note: Vec::new(), . suggestion: None, . }); . } . } 41 ( 0.00%) if !is_prelude && 8 ( 0.00%) max_vis.get() != ty::Visibility::Invisible && // Allow empty globs. 8 ( 0.00%) !max_vis.get().is_at_least(import.vis.get(), &*self) . { . let msg = "glob import doesn't reexport anything because no candidate is public enough"; . self.r.lint_buffer.buffer_lint(UNUSED_IMPORTS, import.id, import.span, msg); . } . return None; . } . _ => unreachable!(), . }; . 84 ( 0.00%) let mut all_ns_err = true; 1,932 ( 0.00%) self.r.per_ns(|this, ns| { 378 ( 0.00%) if !type_ns_only || ns == TypeNS { 126 ( 0.00%) let orig_vis = import.vis.replace(ty::Visibility::Invisible); . let orig_unusable_binding = 252 ( 0.00%) mem::replace(&mut this.unusable_binding, target_bindings[ns].get()); . let orig_last_import_segment = mem::replace(&mut this.last_import_segment, true); . let binding = this.resolve_ident_in_module( 378 ( 0.00%) module, 504 ( 0.00%) ident, . ns, 126 ( 0.00%) &import.parent_scope, . true, . import.span, . ); 252 ( 0.00%) this.last_import_segment = orig_last_import_segment; 252 ( 0.00%) this.unusable_binding = orig_unusable_binding; . import.vis.set(orig_vis); . . match binding { . Ok(binding) => { . // Consistency checks, analogous to `finalize_macro_resolutions`. 132 ( 0.00%) let initial_res = source_bindings[ns].get().map(|initial_binding| { 44 ( 0.00%) all_ns_err = false; 132 ( 0.00%) if let Some(target_binding) = target_bindings[ns].get() { 44 ( 0.00%) if target.name == kw::Underscore . && initial_binding.is_extern_crate() . && !initial_binding.is_import() . { . this.record_use( . ident, . target_binding, . import.module_path.is_empty(), . ); . } . } . initial_binding.res() . }); . let res = binding.res(); 616 ( 0.00%) if let Ok(initial_res) = initial_res { 132 ( 0.00%) if res != initial_res && this.ambiguity_errors.is_empty() { . span_bug!(import.span, "inconsistent resolution for an import"); . } . } else if res != Res::Err . && this.ambiguity_errors.is_empty() . && this.privacy_errors.is_empty() . { . let msg = "cannot determine resolution for the import"; . let msg_note = -- line 1063 ---------------------------------------- -- line 1070 ---------------------------------------- . // single import (see test `issue-55884-2.rs`). In theory single imports should . // always block globs, even if they are not yet resolved, so that this kind of . // self-inconsistent resolution never happens. . // Re-enable the assert when the issue is fixed. . // assert!(result[ns].get().is_err()); . } . } . } 1,008 ( 0.00%) }); . 84 ( 0.00%) if all_ns_err { . let mut all_ns_failed = true; . self.r.per_ns(|this, ns| { . if !type_ns_only || ns == TypeNS { . let binding = this.resolve_ident_in_module( . module, . ident, . ns, . &import.parent_scope, -- line 1088 ---------------------------------------- -- line 1175 ---------------------------------------- . }) . } else { . // `resolve_ident_in_module` reported a privacy error. . self.r.import_dummy_binding(import); . None . }; . } . 42 ( 0.00%) let mut reexport_error = None; 42 ( 0.00%) let mut any_successful_reexport = false; 84 ( 0.00%) let mut crate_private_reexport = false; 504 ( 0.00%) self.r.per_ns(|this, ns| { 294 ( 0.00%) if let Ok(binding) = source_bindings[ns].get() { 132 ( 0.00%) let vis = import.vis.get(); 264 ( 0.00%) if !binding.vis.is_at_least(vis, &*this) { . reexport_error = Some((ns, binding)); . if let ty::Visibility::Restricted(binding_def_id) = binding.vis { . if binding_def_id.is_top_level_module() { . crate_private_reexport = true; . } . } . } else { 88 ( 0.00%) any_successful_reexport = true; . } . } . }); . . // All namespaces must be re-exported with extra visibility for an error to occur. 84 ( 0.00%) if !any_successful_reexport { . let (ns, binding) = reexport_error.unwrap(); . if pub_use_of_private_extern_crate_hack(import, binding) { . let msg = format!( . "extern crate `{}` is private, and cannot be \ . re-exported (error E0365), consider declaring with \ . `pub`", . ident . ); -- line 1211 ---------------------------------------- -- line 1241 ---------------------------------------- . format!("consider marking `{}` as `pub` in the imported module", ident); . struct_span_err!(self.r.session, import.span, E0364, "{}", error_msg) . .span_note(import.span, ¬e_msg) . .emit(); . } . } . } . 126 ( 0.00%) if import.module_path.len() <= 1 { . // HACK(eddyb) `lint_if_path_starts_with_module` needs at least . // 2 segments, so the `resolve_path` above won't trigger it. . let mut full_path = import.module_path.clone(); 36 ( 0.00%) full_path.push(Segment::from_ident(ident)); 84 ( 0.00%) self.r.per_ns(|this, ns| { 72 ( 0.00%) if let Ok(binding) = source_bindings[ns].get() { 36 ( 0.00%) this.lint_if_path_starts_with_module( . import.crate_lint(), . &full_path, 12 ( 0.00%) import.span, . Some(binding), . ); . } . }); . } . . // Record what this import resolves to for later uses in documentation, . // this may resolve to either a value or a type, but for documentation . // purposes it's good enough to just favor one over the other. 1,176 ( 0.00%) self.r.per_ns(|this, ns| { 496 ( 0.00%) if let Ok(binding) = source_bindings[ns].get() { 704 ( 0.00%) this.import_res_map.entry(import.id).or_default()[ns] = Some(binding.res()); . } 1,008 ( 0.00%) }); . 378 ( 0.00%) self.check_for_redundant_imports(ident, import, source_bindings, target_bindings, target); . . debug!("(resolving single import) successfully resolved import"); . None 408 ( 0.00%) } . . fn check_for_redundant_imports( . &mut self, . ident: Ident, . import: &'b Import<'b>, . source_bindings: &PerNS, Determinacy>>>, . target_bindings: &PerNS>>>, . target: Ident, . ) { . // Skip if the import was produced by a macro. 42 ( 0.00%) if import.parent_scope.expansion != LocalExpnId::ROOT { . return; . } . . // Skip if we are inside a named module (in contrast to an anonymous . // module defined by a block). 126 ( 0.00%) if let ModuleKind::Def(..) = import.parent_scope.module.kind { . return; . } . . let mut is_redundant = PerNS { value_ns: None, type_ns: None, macro_ns: None }; . . let mut redundant_span = PerNS { value_ns: None, type_ns: None, macro_ns: None }; . . self.r.per_ns(|this, ns| { -- line 1304 ---------------------------------------- -- line 1350 ---------------------------------------- . let module = match import.imported_module.get().unwrap() { . ModuleOrUniformRoot::Module(module) => module, . _ => { . self.r.session.span_err(import.span, "cannot glob-import all possible crates"); . return; . } . }; . 27 ( 0.00%) if module.is_trait() { . self.r.session.span_err(import.span, "items in traits are not importable"); . return; 9 ( 0.00%) } else if ptr::eq(module, import.parent_scope.module) { . return; 36 ( 0.00%) } else if let ImportKind::Glob { is_prelude: true, .. } = import.kind { 2 ( 0.00%) self.r.prelude = Some(module); . return; . } . . // Add to module's glob_importers . module.glob_importers.borrow_mut().push(import); . . // Ensure that `resolutions` isn't borrowed during `try_define`, . // since it might get updated via a glob cycle. 24 ( 0.00%) let bindings = self . .r . .resolutions(module) . .borrow() . .iter() . .filter_map(|(key, resolution)| { 159,296 ( 0.00%) resolution.borrow().binding().map(|binding| (*key, binding)) . }) . .collect::>(); 79,648 ( 0.00%) for (mut key, binding) in bindings { 358,416 ( 0.01%) let scope = match key.ident.span.reverse_glob_adjust(module.expansion, import.span) { . Some(Some(def)) => self.r.expn_def_scope(def), 79,648 ( 0.00%) Some(None) => import.parent_scope.module, . None => continue, . }; 318,592 ( 0.01%) if self.r.is_accessible_from(binding.vis, scope) { 79,424 ( 0.00%) let imported_binding = self.r.import(binding, import); 436,832 ( 0.01%) let _ = self.r.try_define(import.parent_scope.module, key, imported_binding); . } . } . . // Record the destination of this import . self.r.record_partial_res(import.id, PartialRes::new(module.res().unwrap())); . } . . // Miscellaneous post-processing, including recording re-exports, . // reporting conflicts, and reporting unresolved imports. . fn finalize_resolutions_in(&mut self, module: Module<'b>) { . // Since import resolution is finished, globs will not define any more names. 60 ( 0.00%) *module.globs.borrow_mut() = Vec::new(); . . let mut reexports = Vec::new(); . 75 ( 0.00%) module.for_each_child(self.r, |_, ident, _, binding| { . // Filter away ambiguous imports and anything that has def-site hygiene. . // FIXME: Implement actual cross-crate hygiene. . let is_good_import = 79,590 ( 0.00%) binding.is_import() && !binding.is_ambiguity() && !ident.span.from_expansion(); 40,119 ( 0.00%) if is_good_import || binding.is_macro_def() { . let res = binding.res().expect_non_local(); . if res != def::Res::Err { 159,028 ( 0.00%) reexports.push(ModChild { ident, res, vis: binding.vis, span: binding.span }); . } . } . }); . 15 ( 0.00%) if !reexports.is_empty() { 17 ( 0.00%) if let Some(def_id) = module.opt_def_id() { . // Call to `expect_local` should be fine because current . // code is only called for local modules. . self.r.reexport_map.insert(def_id.expect_local(), reexports); . } . } . } . } . -- line 1428 ---------------------------------------- 1,210,597 ( 0.03%) -------------------------------------------------------------------------------- The following files chosen for auto-annotation could not be found: -------------------------------------------------------------------------------- ./elf/dl-lookup.c ./malloc/malloc.c ./string/../sysdeps/x86_64/multiarch/memchr-avx2.S ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S ./string/../sysdeps/x86_64/multiarch/strcmp-avx2.S /tmp/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/../../../../gcc-5.5.0/libstdc++-v3/libsupc++/new_op.cc -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 60,039,588 ( 1.45%) events annotated