mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
Revert r199191, "LTO: add API to set strategy for -internalize"
Please update also Other/link-opts.ll, in next time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199197 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -54,11 +54,10 @@ APIList("internalize-public-api-list", cl::value_desc("list"),
|
||||
namespace {
|
||||
class InternalizePass : public ModulePass {
|
||||
std::set<std::string> ExternalNames;
|
||||
bool OnlyHidden;
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
explicit InternalizePass(bool OnlyHidden = false);
|
||||
explicit InternalizePass(ArrayRef<const char *> ExportList, bool OnlyHidden);
|
||||
explicit InternalizePass();
|
||||
explicit InternalizePass(ArrayRef<const char *> ExportList);
|
||||
void LoadFile(const char *Filename);
|
||||
virtual bool runOnModule(Module &M);
|
||||
|
||||
@@ -73,17 +72,16 @@ char InternalizePass::ID = 0;
|
||||
INITIALIZE_PASS(InternalizePass, "internalize",
|
||||
"Internalize Global Symbols", false, false)
|
||||
|
||||
InternalizePass::InternalizePass(bool OnlyHidden)
|
||||
: ModulePass(ID), OnlyHidden(OnlyHidden) {
|
||||
InternalizePass::InternalizePass()
|
||||
: ModulePass(ID) {
|
||||
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
|
||||
if (!APIFile.empty()) // If a filename is specified, use it.
|
||||
LoadFile(APIFile.c_str());
|
||||
ExternalNames.insert(APIList.begin(), APIList.end());
|
||||
}
|
||||
|
||||
InternalizePass::InternalizePass(ArrayRef<const char *> ExportList,
|
||||
bool OnlyHidden)
|
||||
: ModulePass(ID), OnlyHidden(OnlyHidden) {
|
||||
InternalizePass::InternalizePass(ArrayRef<const char *> ExportList)
|
||||
: ModulePass(ID){
|
||||
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
|
||||
for(ArrayRef<const char *>::const_iterator itr = ExportList.begin();
|
||||
itr != ExportList.end(); itr++) {
|
||||
@@ -108,11 +106,7 @@ void InternalizePass::LoadFile(const char *Filename) {
|
||||
}
|
||||
|
||||
static bool shouldInternalize(const GlobalValue &GV,
|
||||
const std::set<std::string> &ExternalNames,
|
||||
bool OnlyHidden) {
|
||||
if (OnlyHidden && !GV.hasHiddenVisibility())
|
||||
return false;
|
||||
|
||||
const std::set<std::string> &ExternalNames) {
|
||||
// Function must be defined here
|
||||
if (GV.isDeclaration())
|
||||
return false;
|
||||
@@ -161,8 +155,9 @@ bool InternalizePass::runOnModule(Module &M) {
|
||||
}
|
||||
|
||||
// Mark all functions not in the api as internal.
|
||||
// FIXME: maybe use private linkage?
|
||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||
if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
|
||||
if (!shouldInternalize(*I, ExternalNames))
|
||||
continue;
|
||||
|
||||
I->setLinkage(GlobalValue::InternalLinkage);
|
||||
@@ -196,9 +191,10 @@ bool InternalizePass::runOnModule(Module &M) {
|
||||
|
||||
// Mark all global variables with initializers that are not in the api as
|
||||
// internal as well.
|
||||
// FIXME: maybe use private linkage?
|
||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I) {
|
||||
if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
|
||||
if (!shouldInternalize(*I, ExternalNames))
|
||||
continue;
|
||||
|
||||
I->setLinkage(GlobalValue::InternalLinkage);
|
||||
@@ -210,7 +206,7 @@ bool InternalizePass::runOnModule(Module &M) {
|
||||
// Mark all aliases that are not in the api as internal as well.
|
||||
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
|
||||
I != E; ++I) {
|
||||
if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
|
||||
if (!shouldInternalize(*I, ExternalNames))
|
||||
continue;
|
||||
|
||||
I->setLinkage(GlobalValue::InternalLinkage);
|
||||
@@ -222,11 +218,10 @@ bool InternalizePass::runOnModule(Module &M) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
ModulePass *llvm::createInternalizePass(bool OnlyHidden) {
|
||||
return new InternalizePass(OnlyHidden);
|
||||
ModulePass *llvm::createInternalizePass() {
|
||||
return new InternalizePass();
|
||||
}
|
||||
|
||||
ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList,
|
||||
bool OnlyHidden) {
|
||||
return new InternalizePass(ExportList, OnlyHidden);
|
||||
ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList) {
|
||||
return new InternalizePass(ExportList);
|
||||
}
|
||||
|
Reference in New Issue
Block a user