From f42197885813cee43234d63271ec99026b546b79 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 2 Apr 2019 09:25:31 +0000 Subject: [PATCH] [Internalize] Replace uses of std::set with DenseSet This makes it faster and saves 104 bytes for my build. llvm-svn: 357458 --- llvm/include/llvm/Transforms/IPO/Internalize.h | 6 +++--- llvm/lib/Transforms/IPO/Internalize.cpp | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/Transforms/IPO/Internalize.h b/llvm/include/llvm/Transforms/IPO/Internalize.h index a7efd3e172a8..6c1e19ef9fe4 100644 --- a/llvm/include/llvm/Transforms/IPO/Internalize.h +++ b/llvm/include/llvm/Transforms/IPO/Internalize.h @@ -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 -#include namespace llvm { class Module; @@ -44,11 +44,11 @@ class InternalizePass : public PassInfoMixin { /// 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 &ExternalComdats); + const DenseSet &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 &ExternalComdats); + DenseSet &ExternalComdats); public: InternalizePass(); diff --git a/llvm/lib/Transforms/IPO/Internalize.cpp b/llvm/lib/Transforms/IPO/Internalize.cpp index 8423a8a4d71b..2e269604e379 100644 --- a/llvm/lib/Transforms/IPO/Internalize.cpp +++ b/llvm/lib/Transforms/IPO/Internalize.cpp @@ -32,7 +32,6 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Utils/GlobalStatus.h" -#include 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 &ExternalComdats) { + GlobalValue &GV, const DenseSet &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 &ExternalComdats) { + GlobalValue &GV, DenseSet &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 ExternalComdats; + DenseSet ExternalComdats; if (!M.getComdatSymbolTable().empty()) { for (Function &F : M) checkComdatVisibility(F, ExternalComdats);