mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
libLTO, llvm-lto, gold: Introduce flag for controlling optimization level.
This change also introduces a link-time optimization level of 1. This optimization level runs only the globaldce pass as well as cleanup passes for passes that run at -O0, specifically simplifycfg which cleans up lowerbitsets. http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150316/266951.html git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232769 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -26,9 +26,13 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static cl::opt<bool>
|
||||
DisableOpt("disable-opt", cl::init(false),
|
||||
cl::desc("Do not run any optimization passes"));
|
||||
static cl::opt<char>
|
||||
OptLevel("O",
|
||||
cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
|
||||
"(default = '-O2')"),
|
||||
cl::Prefix,
|
||||
cl::ZeroOrMore,
|
||||
cl::init('2'));
|
||||
|
||||
static cl::opt<bool>
|
||||
DisableInline("disable-inlining", cl::init(false),
|
||||
@@ -146,6 +150,11 @@ int main(int argc, char **argv) {
|
||||
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
||||
cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n");
|
||||
|
||||
if (OptLevel < '0' || OptLevel > '3') {
|
||||
errs() << argv[0] << ": optimization level must be between 0 and 3\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize the configured targets.
|
||||
InitializeAllTargets();
|
||||
InitializeAllTargetMCs();
|
||||
@@ -231,6 +240,8 @@ int main(int argc, char **argv) {
|
||||
// Set cpu and attrs strings for the default target/subtarget.
|
||||
CodeGen.setCpu(MCPU.c_str());
|
||||
|
||||
CodeGen.setOptLevel(OptLevel - '0');
|
||||
|
||||
std::string attrs;
|
||||
for (unsigned i = 0; i < MAttrs.size(); ++i) {
|
||||
if (i > 0)
|
||||
@@ -245,7 +256,7 @@ int main(int argc, char **argv) {
|
||||
size_t len = 0;
|
||||
std::string ErrorInfo;
|
||||
const void *Code =
|
||||
CodeGen.compile(&len, DisableOpt, DisableInline, DisableGVNLoadPRE,
|
||||
CodeGen.compile(&len, DisableInline, DisableGVNLoadPRE,
|
||||
DisableLTOVectorization, ErrorInfo);
|
||||
if (!Code) {
|
||||
errs() << argv[0]
|
||||
@@ -265,7 +276,7 @@ int main(int argc, char **argv) {
|
||||
} else {
|
||||
std::string ErrorInfo;
|
||||
const char *OutputName = nullptr;
|
||||
if (!CodeGen.compile_to_file(&OutputName, DisableOpt, DisableInline,
|
||||
if (!CodeGen.compile_to_file(&OutputName, DisableInline,
|
||||
DisableGVNLoadPRE, DisableLTOVectorization,
|
||||
ErrorInfo)) {
|
||||
errs() << argv[0]
|
||||
|
Reference in New Issue
Block a user