[Internalize] Replace uses of std::set with DenseSet

This makes it faster and saves 104 bytes for my build.

llvm-svn: 357458
This commit is contained in:
Fangrui Song 2019-04-02 09:25:31 +00:00
parent 32029135e0
commit f421978858
2 changed files with 6 additions and 7 deletions

View File

@ -21,11 +21,11 @@
#ifndef LLVM_TRANSFORMS_IPO_INTERNALIZE_H
#define LLVM_TRANSFORMS_IPO_INTERNALIZE_H
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/PassManager.h"
#include <functional>
#include <set>
namespace llvm {
class Module;
@ -44,11 +44,11 @@ class InternalizePass : public PassInfoMixin<InternalizePass> {
/// Internalize GV if it is possible to do so, i.e. it is not externally
/// visible and is not a member of an externally visible comdat.
bool maybeInternalize(GlobalValue &GV,
const std::set<const Comdat *> &ExternalComdats);
const DenseSet<const Comdat *> &ExternalComdats);
/// If GV is part of a comdat and is externally visible, keep track of its
/// comdat so that we don't internalize any of its members.
void checkComdatVisibility(GlobalValue &GV,
std::set<const Comdat *> &ExternalComdats);
DenseSet<const Comdat *> &ExternalComdats);
public:
InternalizePass();

View File

@ -32,7 +32,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/GlobalStatus.h"
#include <set>
using namespace llvm;
#define DEBUG_TYPE "internalize"
@ -111,7 +110,7 @@ bool InternalizePass::shouldPreserveGV(const GlobalValue &GV) {
}
bool InternalizePass::maybeInternalize(
GlobalValue &GV, const std::set<const Comdat *> &ExternalComdats) {
GlobalValue &GV, const DenseSet<const Comdat *> &ExternalComdats) {
if (Comdat *C = GV.getComdat()) {
if (ExternalComdats.count(C))
return false;
@ -138,7 +137,7 @@ bool InternalizePass::maybeInternalize(
// If GV is part of a comdat and is externally visible, keep track of its
// comdat so that we don't internalize any of its members.
void InternalizePass::checkComdatVisibility(
GlobalValue &GV, std::set<const Comdat *> &ExternalComdats) {
GlobalValue &GV, DenseSet<const Comdat *> &ExternalComdats) {
Comdat *C = GV.getComdat();
if (!C)
return;
@ -155,7 +154,7 @@ bool InternalizePass::internalizeModule(Module &M, CallGraph *CG) {
collectUsedGlobalVariables(M, Used, false);
// Collect comdat visiblity information for the module.
std::set<const Comdat *> ExternalComdats;
DenseSet<const Comdat *> ExternalComdats;
if (!M.getComdatSymbolTable().empty()) {
for (Function &F : M)
checkComdatVisibility(F, ExternalComdats);