Iterate over StringMaps using structured bindings. NFCI.
This commit is contained in:
parent
02c75e8465
commit
fcf4e360ba
|
@ -815,10 +815,8 @@ bool GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
|
||||||
IdentifierIndexWriterTrait Trait;
|
IdentifierIndexWriterTrait Trait;
|
||||||
|
|
||||||
// Populate the hash table.
|
// Populate the hash table.
|
||||||
for (InterestingIdentifierMap::iterator I = InterestingIdentifiers.begin(),
|
for (auto &[Identifier, IDs] : InterestingIdentifiers) {
|
||||||
IEnd = InterestingIdentifiers.end();
|
Generator.insert(Identifier, IDs, Trait);
|
||||||
I != IEnd; ++I) {
|
|
||||||
Generator.insert(I->first(), I->second, Trait);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the on-disk hash table in a buffer.
|
// Create the on-disk hash table in a buffer.
|
||||||
|
|
|
@ -405,8 +405,8 @@ public:
|
||||||
/// Sort call targets in descending order of call frequency.
|
/// Sort call targets in descending order of call frequency.
|
||||||
static const SortedCallTargetSet SortCallTargets(const CallTargetMap &Targets) {
|
static const SortedCallTargetSet SortCallTargets(const CallTargetMap &Targets) {
|
||||||
SortedCallTargetSet SortedTargets;
|
SortedCallTargetSet SortedTargets;
|
||||||
for (const auto &I : Targets) {
|
for (const auto &[Target, Frequency] : Targets) {
|
||||||
SortedTargets.emplace(I.first(), I.second);
|
SortedTargets.emplace(Target, Frequency);
|
||||||
}
|
}
|
||||||
return SortedTargets;
|
return SortedTargets;
|
||||||
}
|
}
|
||||||
|
@ -415,8 +415,8 @@ public:
|
||||||
static const CallTargetMap adjustCallTargets(const CallTargetMap &Targets,
|
static const CallTargetMap adjustCallTargets(const CallTargetMap &Targets,
|
||||||
float DistributionFactor) {
|
float DistributionFactor) {
|
||||||
CallTargetMap AdjustedTargets;
|
CallTargetMap AdjustedTargets;
|
||||||
for (const auto &I : Targets) {
|
for (const auto &[Target, Frequency] : Targets) {
|
||||||
AdjustedTargets[I.first()] = I.second * DistributionFactor;
|
AdjustedTargets[Target] = Frequency * DistributionFactor;
|
||||||
}
|
}
|
||||||
return AdjustedTargets;
|
return AdjustedTargets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,9 +159,9 @@ private:
|
||||||
addProfiledFunction(Samples.getFuncName());
|
addProfiledFunction(Samples.getFuncName());
|
||||||
|
|
||||||
for (const auto &Sample : Samples.getBodySamples()) {
|
for (const auto &Sample : Samples.getBodySamples()) {
|
||||||
for (const auto &Target : Sample.second.getCallTargets()) {
|
for (const auto &[Target, Frequency] : Sample.second.getCallTargets()) {
|
||||||
addProfiledFunction(Target.first());
|
addProfiledFunction(Target);
|
||||||
addProfiledCall(Samples.getFuncName(), Target.first(), Target.second);
|
addProfiledCall(Samples.getFuncName(), Target, Frequency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,8 +592,8 @@ std::string codegen::getFeaturesStr() {
|
||||||
if (getMCPU() == "native") {
|
if (getMCPU() == "native") {
|
||||||
StringMap<bool> HostFeatures;
|
StringMap<bool> HostFeatures;
|
||||||
if (sys::getHostCPUFeatures(HostFeatures))
|
if (sys::getHostCPUFeatures(HostFeatures))
|
||||||
for (auto &F : HostFeatures)
|
for (const auto &[Feature, IsEnabled] : HostFeatures)
|
||||||
Features.AddFeature(F.first(), F.second);
|
Features.AddFeature(Feature, IsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const &MAttr : getMAttrs())
|
for (auto const &MAttr : getMAttrs())
|
||||||
|
@ -612,8 +612,8 @@ std::vector<std::string> codegen::getFeatureList() {
|
||||||
if (getMCPU() == "native") {
|
if (getMCPU() == "native") {
|
||||||
StringMap<bool> HostFeatures;
|
StringMap<bool> HostFeatures;
|
||||||
if (sys::getHostCPUFeatures(HostFeatures))
|
if (sys::getHostCPUFeatures(HostFeatures))
|
||||||
for (auto &F : HostFeatures)
|
for (const auto &[Feature, IsEnabled] : HostFeatures)
|
||||||
Features.AddFeature(F.first(), F.second);
|
Features.AddFeature(Feature, IsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const &MAttr : getMAttrs())
|
for (auto const &MAttr : getMAttrs())
|
||||||
|
|
|
@ -1059,8 +1059,8 @@ int SlotTracker::processIndex() {
|
||||||
// assigned consecutively. Since the StringMap iteration order isn't
|
// assigned consecutively. Since the StringMap iteration order isn't
|
||||||
// guaranteed, use a std::map to order by module ID before assigning slots.
|
// guaranteed, use a std::map to order by module ID before assigning slots.
|
||||||
std::map<uint64_t, StringRef> ModuleIdToPathMap;
|
std::map<uint64_t, StringRef> ModuleIdToPathMap;
|
||||||
for (auto &ModPath : TheIndex->modulePaths())
|
for (auto &[ModPath, ModId] : TheIndex->modulePaths())
|
||||||
ModuleIdToPathMap[ModPath.second.first] = ModPath.first();
|
ModuleIdToPathMap[ModId.first] = ModPath;
|
||||||
for (auto &ModPair : ModuleIdToPathMap)
|
for (auto &ModPair : ModuleIdToPathMap)
|
||||||
CreateModulePathSlot(ModPair.second);
|
CreateModulePathSlot(ModPair.second);
|
||||||
|
|
||||||
|
@ -2875,13 +2875,12 @@ void AssemblyWriter::printModuleSummaryIndex() {
|
||||||
std::string RegularLTOModuleName =
|
std::string RegularLTOModuleName =
|
||||||
ModuleSummaryIndex::getRegularLTOModuleName();
|
ModuleSummaryIndex::getRegularLTOModuleName();
|
||||||
moduleVec.resize(TheIndex->modulePaths().size());
|
moduleVec.resize(TheIndex->modulePaths().size());
|
||||||
for (auto &ModPath : TheIndex->modulePaths())
|
for (auto &[ModPath, ModId] : TheIndex->modulePaths())
|
||||||
moduleVec[Machine.getModulePathSlot(ModPath.first())] = std::make_pair(
|
moduleVec[Machine.getModulePathSlot(ModPath)] = std::make_pair(
|
||||||
// A module id of -1 is a special entry for a regular LTO module created
|
// A module id of -1 is a special entry for a regular LTO module created
|
||||||
// during the thin link.
|
// during the thin link.
|
||||||
ModPath.second.first == -1u ? RegularLTOModuleName
|
ModId.first == -1u ? RegularLTOModuleName : std::string(ModPath),
|
||||||
: (std::string)std::string(ModPath.first()),
|
ModId.second);
|
||||||
ModPath.second.second);
|
|
||||||
|
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (auto &ModPair : moduleVec) {
|
for (auto &ModPair : moduleVec) {
|
||||||
|
|
|
@ -258,8 +258,8 @@ char *LLVMGetHostCPUFeatures(void) {
|
||||||
StringMap<bool> HostFeatures;
|
StringMap<bool> HostFeatures;
|
||||||
|
|
||||||
if (sys::getHostCPUFeatures(HostFeatures))
|
if (sys::getHostCPUFeatures(HostFeatures))
|
||||||
for (auto &F : HostFeatures)
|
for (const auto &[Feature, IsEnabled] : HostFeatures)
|
||||||
Features.AddFeature(F.first(), F.second);
|
Features.AddFeature(Feature, IsEnabled);
|
||||||
|
|
||||||
return strdup(Features.getString().c_str());
|
return strdup(Features.getString().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,8 @@ LogicalResult PatternApplicatorExtension::findAllMatches(
|
||||||
// also used by the following operations.
|
// also used by the following operations.
|
||||||
auto *dialect =
|
auto *dialect =
|
||||||
root->getContext()->getLoadedDialect<transform::TransformDialect>();
|
root->getContext()->getLoadedDialect<transform::TransformDialect>();
|
||||||
for (const auto &pair : dialect->getPDLConstraintHooks())
|
for (const auto &[name, constraintFn] : dialect->getPDLConstraintHooks())
|
||||||
patternModule.registerConstraintFunction(pair.first(), pair.second);
|
patternModule.registerConstraintFunction(name, constraintFn);
|
||||||
|
|
||||||
// Register a noop rewriter because PDL requires patterns to end with some
|
// Register a noop rewriter because PDL requires patterns to end with some
|
||||||
// rewrite call.
|
// rewrite call.
|
||||||
|
|
|
@ -145,8 +145,8 @@ bool ExecutionEngine::setupTargetTriple(Module *llvmModule) {
|
||||||
llvm::StringMap<bool> hostFeatures;
|
llvm::StringMap<bool> hostFeatures;
|
||||||
|
|
||||||
if (llvm::sys::getHostCPUFeatures(hostFeatures))
|
if (llvm::sys::getHostCPUFeatures(hostFeatures))
|
||||||
for (auto &f : hostFeatures)
|
for (const auto &[feature, isEnabled] : hostFeatures)
|
||||||
features.AddFeature(f.first(), f.second);
|
features.AddFeature(feature, isEnabled);
|
||||||
|
|
||||||
std::unique_ptr<llvm::TargetMachine> machine(target->createTargetMachine(
|
std::unique_ptr<llvm::TargetMachine> machine(target->createTargetMachine(
|
||||||
targetTriple, cpu, features.getString(), {}, {}));
|
targetTriple, cpu, features.getString(), {}, {}));
|
||||||
|
|
Loading…
Reference in New Issue