Add new EliminateAvailableExternally module pass, which is performed in

O2 compiles just before GlobalDCE, unless we are preparing for LTO.

This pass eliminates available externally globals (turning them into
declarations), regardless of whether they are dead/unreferenced, since
we are guaranteed to have a copy available elsewhere at link time.
This enables additional opportunities for GlobalDCE.

If we are preparing for LTO (e.g. a -flto -c compile), the pass is not
included as we want to preserve available externally functions for possible
link time inlining. The FE indicates whether we are doing an -flto compile
via the new PrepareForLTO flag on the PassManagerBuilder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Teresa Johnson
2015-06-10 17:49:28 +00:00
parent 881c8e0c9a
commit b78ea510c1
6 changed files with 117 additions and 0 deletions

View File

@@ -70,6 +70,12 @@ ModulePass *createGlobalOptimizerPass();
///
ModulePass *createGlobalDCEPass();
//===----------------------------------------------------------------------===//
/// This transform is designed to eliminate available external globals
/// (functions or global variables)
///
ModulePass *createEliminateAvailableExternallyPass();
//===----------------------------------------------------------------------===//
/// createGVExtractionPass - If deleteFn is true, this pass deletes
/// the specified global values. Otherwise, it deletes as much of the module as

View File

@@ -121,6 +121,7 @@ public:
bool VerifyInput;
bool VerifyOutput;
bool MergeFunctions;
bool PrepareForLTO;
private:
/// ExtensionList - This is list of all of the extensions that are registered.