mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
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:
@@ -105,6 +105,7 @@ PassManagerBuilder::PassManagerBuilder() {
|
||||
VerifyInput = false;
|
||||
VerifyOutput = false;
|
||||
MergeFunctions = false;
|
||||
PrepareForLTO = false;
|
||||
}
|
||||
|
||||
PassManagerBuilder::~PassManagerBuilder() {
|
||||
@@ -401,6 +402,17 @@ void PassManagerBuilder::populateModulePassManager(
|
||||
// GlobalOpt already deletes dead functions and globals, at -O2 try a
|
||||
// late pass of GlobalDCE. It is capable of deleting dead cycles.
|
||||
if (OptLevel > 1) {
|
||||
if (!PrepareForLTO) {
|
||||
// Remove avail extern fns and globals definitions if we aren't
|
||||
// compiling an object file for later LTO. For LTO we want to preserve
|
||||
// these so they are eligible for inlining at link-time. Note if they
|
||||
// are unreferenced they will be removed by GlobalDCE below, so
|
||||
// this only impacts referenced available externally globals.
|
||||
// Eventually they will be suppressed during codegen, but eliminating
|
||||
// here enables more opportunity for GlobalDCE as it may make
|
||||
// globals referenced by available external functions dead.
|
||||
MPM.add(createEliminateAvailableExternallyPass());
|
||||
}
|
||||
MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
|
||||
MPM.add(createConstantMergePass()); // Merge dup global constants
|
||||
}
|
||||
|
Reference in New Issue
Block a user