mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +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:
@ -40,7 +40,7 @@ typedef bool lto_bool_t;
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LTO_API_VERSION 6
|
#define LTO_API_VERSION 5
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */
|
LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */
|
||||||
@ -73,11 +73,6 @@ typedef enum {
|
|||||||
LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2
|
LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2
|
||||||
} lto_codegen_model;
|
} lto_codegen_model;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
LTO_INTERNALIZE_FULL = 0,
|
|
||||||
LTO_INTERNALIZE_NONE = 1,
|
|
||||||
LTO_INTERNALIZE_HIDDEN = 2
|
|
||||||
} lto_internalize_strategy;
|
|
||||||
|
|
||||||
/** opaque reference to a loaded object module */
|
/** opaque reference to a loaded object module */
|
||||||
typedef struct LTOModule* lto_module_t;
|
typedef struct LTOModule* lto_module_t;
|
||||||
@ -268,14 +263,6 @@ extern void
|
|||||||
lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
|
lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
|
||||||
int nargs);
|
int nargs);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the strategy to use during internalize. Default strategy is
|
|
||||||
* LTO_INTERNALIZE_FULL.
|
|
||||||
*/
|
|
||||||
extern void
|
|
||||||
lto_codegen_set_internalize_strategy(lto_code_gen_t cg,
|
|
||||||
lto_internalize_strategy);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells LTO optimization passes that this symbol must be preserved
|
* Tells LTO optimization passes that this symbol must be preserved
|
||||||
* because it is referenced by native code or a command line option.
|
* because it is referenced by native code or a command line option.
|
||||||
|
@ -70,7 +70,6 @@ struct LTOCodeGenerator {
|
|||||||
void setTargetOptions(llvm::TargetOptions options);
|
void setTargetOptions(llvm::TargetOptions options);
|
||||||
void setDebugInfo(lto_debug_model);
|
void setDebugInfo(lto_debug_model);
|
||||||
void setCodePICModel(lto_codegen_model);
|
void setCodePICModel(lto_codegen_model);
|
||||||
void setInternalizeStrategy(lto_internalize_strategy);
|
|
||||||
|
|
||||||
void setCpu(const char *mCpu) { MCpu = mCpu; }
|
void setCpu(const char *mCpu) { MCpu = mCpu; }
|
||||||
|
|
||||||
@ -115,14 +114,6 @@ struct LTOCodeGenerator {
|
|||||||
bool disableGVNLoadPRE,
|
bool disableGVNLoadPRE,
|
||||||
std::string &errMsg);
|
std::string &errMsg);
|
||||||
|
|
||||||
bool shouldInternalize() const {
|
|
||||||
return InternalizeStrategy != LTO_INTERNALIZE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool shouldOnlyInternalizeHidden() const {
|
|
||||||
return InternalizeStrategy == LTO_INTERNALIZE_HIDDEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeLTOPasses();
|
void initializeLTOPasses();
|
||||||
|
|
||||||
@ -147,7 +138,6 @@ private:
|
|||||||
bool EmitDwarfDebugInfo;
|
bool EmitDwarfDebugInfo;
|
||||||
bool ScopeRestrictionsDone;
|
bool ScopeRestrictionsDone;
|
||||||
lto_codegen_model CodeModel;
|
lto_codegen_model CodeModel;
|
||||||
lto_internalize_strategy InternalizeStrategy;
|
|
||||||
StringSet MustPreserveSymbols;
|
StringSet MustPreserveSymbols;
|
||||||
StringSet AsmUndefinedRefs;
|
StringSet AsmUndefinedRefs;
|
||||||
llvm::MemoryBuffer *NativeObjectFile;
|
llvm::MemoryBuffer *NativeObjectFile;
|
||||||
|
@ -108,17 +108,14 @@ Pass *createPruneEHPass();
|
|||||||
////
|
////
|
||||||
/// The symbols in \p ExportList are never internalized.
|
/// The symbols in \p ExportList are never internalized.
|
||||||
///
|
///
|
||||||
/// When OnlyHidden=true, only symbols with hidden visibility are internalized.
|
|
||||||
///
|
|
||||||
/// The symbol in DSOList are internalized if it is safe to drop them from
|
/// The symbol in DSOList are internalized if it is safe to drop them from
|
||||||
/// the symbol table.
|
/// the symbol table.
|
||||||
///
|
///
|
||||||
/// Note that commandline options that are used with the above function are not
|
/// Note that commandline options that are used with the above function are not
|
||||||
/// used now!
|
/// used now!
|
||||||
ModulePass *createInternalizePass(ArrayRef<const char *> ExportList,
|
ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
|
||||||
bool OnlyHidden = false);
|
|
||||||
/// createInternalizePass - Same as above, but with an empty exportList.
|
/// createInternalizePass - Same as above, but with an empty exportList.
|
||||||
ModulePass *createInternalizePass(bool OnlyHidden = false);
|
ModulePass *createInternalizePass();
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// createDeadArgEliminationPass - This pass removes arguments from functions
|
/// createDeadArgEliminationPass - This pass removes arguments from functions
|
||||||
|
@ -62,8 +62,7 @@ const char* LTOCodeGenerator::getVersionString() {
|
|||||||
LTOCodeGenerator::LTOCodeGenerator()
|
LTOCodeGenerator::LTOCodeGenerator()
|
||||||
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
|
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
|
||||||
TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
|
TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
|
||||||
CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL) {
|
||||||
InternalizeStrategy(LTO_INTERNALIZE_FULL), NativeObjectFile(NULL) {
|
|
||||||
initializeLTOPasses();
|
initializeLTOPasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,18 +164,6 @@ void LTOCodeGenerator::setCodePICModel(lto_codegen_model model) {
|
|||||||
llvm_unreachable("Unknown PIC model!");
|
llvm_unreachable("Unknown PIC model!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
LTOCodeGenerator::setInternalizeStrategy(lto_internalize_strategy Strategy) {
|
|
||||||
switch (Strategy) {
|
|
||||||
case LTO_INTERNALIZE_FULL:
|
|
||||||
case LTO_INTERNALIZE_NONE:
|
|
||||||
case LTO_INTERNALIZE_HIDDEN:
|
|
||||||
InternalizeStrategy = Strategy;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
llvm_unreachable("Unknown internalize strategy!");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LTOCodeGenerator::writeMergedModules(const char *path,
|
bool LTOCodeGenerator::writeMergedModules(const char *path,
|
||||||
std::string &errMsg) {
|
std::string &errMsg) {
|
||||||
if (!determineTarget(errMsg))
|
if (!determineTarget(errMsg))
|
||||||
@ -390,7 +377,7 @@ static void accumulateAndSortLibcalls(std::vector<StringRef> &Libcalls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LTOCodeGenerator::applyScopeRestrictions() {
|
void LTOCodeGenerator::applyScopeRestrictions() {
|
||||||
if (ScopeRestrictionsDone || !shouldInternalize())
|
if (ScopeRestrictionsDone)
|
||||||
return;
|
return;
|
||||||
Module *mergedModule = Linker.getModule();
|
Module *mergedModule = Linker.getModule();
|
||||||
|
|
||||||
@ -442,8 +429,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
|
|||||||
LLVMCompilerUsed->setSection("llvm.metadata");
|
LLVMCompilerUsed->setSection("llvm.metadata");
|
||||||
}
|
}
|
||||||
|
|
||||||
passes.add(
|
passes.add(createInternalizePass(MustPreserveList));
|
||||||
createInternalizePass(MustPreserveList, shouldOnlyInternalizeHidden()));
|
|
||||||
|
|
||||||
// apply scope restrictions
|
// apply scope restrictions
|
||||||
passes.run(*mergedModule);
|
passes.run(*mergedModule);
|
||||||
|
@ -54,11 +54,10 @@ APIList("internalize-public-api-list", cl::value_desc("list"),
|
|||||||
namespace {
|
namespace {
|
||||||
class InternalizePass : public ModulePass {
|
class InternalizePass : public ModulePass {
|
||||||
std::set<std::string> ExternalNames;
|
std::set<std::string> ExternalNames;
|
||||||
bool OnlyHidden;
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
explicit InternalizePass(bool OnlyHidden = false);
|
explicit InternalizePass();
|
||||||
explicit InternalizePass(ArrayRef<const char *> ExportList, bool OnlyHidden);
|
explicit InternalizePass(ArrayRef<const char *> ExportList);
|
||||||
void LoadFile(const char *Filename);
|
void LoadFile(const char *Filename);
|
||||||
virtual bool runOnModule(Module &M);
|
virtual bool runOnModule(Module &M);
|
||||||
|
|
||||||
@ -73,17 +72,16 @@ char InternalizePass::ID = 0;
|
|||||||
INITIALIZE_PASS(InternalizePass, "internalize",
|
INITIALIZE_PASS(InternalizePass, "internalize",
|
||||||
"Internalize Global Symbols", false, false)
|
"Internalize Global Symbols", false, false)
|
||||||
|
|
||||||
InternalizePass::InternalizePass(bool OnlyHidden)
|
InternalizePass::InternalizePass()
|
||||||
: ModulePass(ID), OnlyHidden(OnlyHidden) {
|
: ModulePass(ID) {
|
||||||
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
|
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
|
||||||
if (!APIFile.empty()) // If a filename is specified, use it.
|
if (!APIFile.empty()) // If a filename is specified, use it.
|
||||||
LoadFile(APIFile.c_str());
|
LoadFile(APIFile.c_str());
|
||||||
ExternalNames.insert(APIList.begin(), APIList.end());
|
ExternalNames.insert(APIList.begin(), APIList.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalizePass::InternalizePass(ArrayRef<const char *> ExportList,
|
InternalizePass::InternalizePass(ArrayRef<const char *> ExportList)
|
||||||
bool OnlyHidden)
|
: ModulePass(ID){
|
||||||
: ModulePass(ID), OnlyHidden(OnlyHidden) {
|
|
||||||
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
|
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
|
||||||
for(ArrayRef<const char *>::const_iterator itr = ExportList.begin();
|
for(ArrayRef<const char *>::const_iterator itr = ExportList.begin();
|
||||||
itr != ExportList.end(); itr++) {
|
itr != ExportList.end(); itr++) {
|
||||||
@ -108,11 +106,7 @@ void InternalizePass::LoadFile(const char *Filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool shouldInternalize(const GlobalValue &GV,
|
static bool shouldInternalize(const GlobalValue &GV,
|
||||||
const std::set<std::string> &ExternalNames,
|
const std::set<std::string> &ExternalNames) {
|
||||||
bool OnlyHidden) {
|
|
||||||
if (OnlyHidden && !GV.hasHiddenVisibility())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Function must be defined here
|
// Function must be defined here
|
||||||
if (GV.isDeclaration())
|
if (GV.isDeclaration())
|
||||||
return false;
|
return false;
|
||||||
@ -161,8 +155,9 @@ bool InternalizePass::runOnModule(Module &M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark all functions not in the api as internal.
|
// 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) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
|
if (!shouldInternalize(*I, ExternalNames))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
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
|
// Mark all global variables with initializers that are not in the api as
|
||||||
// internal as well.
|
// internal as well.
|
||||||
|
// FIXME: maybe use private linkage?
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
|
if (!shouldInternalize(*I, ExternalNames))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
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.
|
// 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();
|
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (!shouldInternalize(*I, ExternalNames, OnlyHidden))
|
if (!shouldInternalize(*I, ExternalNames))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
I->setLinkage(GlobalValue::InternalLinkage);
|
||||||
@ -222,11 +218,10 @@ bool InternalizePass::runOnModule(Module &M) {
|
|||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModulePass *llvm::createInternalizePass(bool OnlyHidden) {
|
ModulePass *llvm::createInternalizePass() {
|
||||||
return new InternalizePass(OnlyHidden);
|
return new InternalizePass();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList,
|
ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList) {
|
||||||
bool OnlyHidden) {
|
return new InternalizePass(ExportList);
|
||||||
return new InternalizePass(ExportList, OnlyHidden);
|
|
||||||
}
|
}
|
||||||
|
@ -252,13 +252,6 @@ void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
|
|||||||
// In here only for backwards compatibility. We use MC now.
|
// In here only for backwards compatibility. We use MC now.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// lto_codegen_set_internalize_strategy - Sets the strategy to use during
|
|
||||||
/// internalize.
|
|
||||||
void lto_codegen_set_internalize_strategy(lto_code_gen_t cg,
|
|
||||||
lto_internalize_strategy strategy) {
|
|
||||||
cg->setInternalizeStrategy(strategy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// lto_codegen_add_must_preserve_symbol - Adds to a list of all global symbols
|
/// lto_codegen_add_must_preserve_symbol - Adds to a list of all global symbols
|
||||||
/// that must exist in the final generated code. If a function is not listed
|
/// that must exist in the final generated code. If a function is not listed
|
||||||
/// there, it might be inlined into every usage and optimized away.
|
/// there, it might be inlined into every usage and optimized away.
|
||||||
|
Reference in New Issue
Block a user