aboutsummaryrefslogtreecommitdiff
path: root/tools/lto/LTOCodeGenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lto/LTOCodeGenerator.cpp')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index f0640c2206..0e61c2fb2a 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -46,10 +46,13 @@
#include "llvm/ADT/StringExtras.h"
using namespace llvm;
-static cl::opt<bool> DisableInline("disable-inlining",
+static cl::opt<bool> EnableInternalizing("enable-internalizing", cl::init(false),
+ cl::desc("Internalize functions during LTO"));
+
+static cl::opt<bool> DisableInline("disable-inlining", cl::init(false),
cl::desc("Do not run the inliner pass"));
-static cl::opt<bool> DisableGVNLoadPRE("disable-gvn-loadpre",
+static cl::opt<bool> DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false),
cl::desc("Do not run the GVN load PRE pass"));
const char* LTOCodeGenerator::getVersionString() {
@@ -275,6 +278,14 @@ static void findUsedValues(GlobalVariable *LLVMUsed,
}
void LTOCodeGenerator::applyScopeRestrictions() {
+ // Internalize only if specifically asked for. Otherwise, global symbols which
+ // exist in the final image, but which are used outside of that image
+ // (e.g. bundling) may be removed. This also happens when a function is used
+ // only in inline asm. LLVM doesn't recognize that as a "use", so it could be
+ // stripped.
+ if (!EnableInternalizing)
+ return;
+
if (_scopeRestrictionsDone) return;
Module *mergedModule = _linker.getModule();