mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-18 01:39:03 +02:00
Several changes to optimizer related code.
- New functions codeGenOptLevel() and verifyModule() to remove code duplication - Hidden option no-verify renamed to disable-verify and moved to optimizer (like opt tool) - Removed global.params.noVerify
This commit is contained in:
@@ -375,10 +375,6 @@ static cl::opt<MultiSetter, true, cl::parser<bool> > release("release",
|
||||
cl::location(ReleaseSetter),
|
||||
cl::ValueDisallowed);
|
||||
|
||||
cl::opt<bool, true> noVerify("noverify",
|
||||
llvm::cl::desc("Do not run the validation pass before writing bitcode"),
|
||||
cl::location(global.params.noVerify));
|
||||
|
||||
cl::opt<bool, true> singleObj("singleobj",
|
||||
cl::desc("Create only a single output object file"),
|
||||
cl::location(global.params.singleObj));
|
||||
|
||||
@@ -325,8 +325,6 @@ int main(int argc, char** argv)
|
||||
|
||||
#if LDC_LLVM_VER >= 301
|
||||
llvm::TargetOptions targetOptions;
|
||||
// FIXME: Options here are { None, Less, Default, Aggressive } as defined http://llvm.org/docs/doxygen/html/namespacellvm_1_1CodeGenOpt.html
|
||||
llvm::CodeGenOpt::Level codeGenOptLevel = llvm::CodeGenOpt::None; // I am setting this to None for the moment as I dont know how this changes generation
|
||||
#endif
|
||||
|
||||
Array* libs;
|
||||
@@ -554,7 +552,7 @@ int main(int argc, char** argv)
|
||||
targetOptions,
|
||||
mRelocModel,
|
||||
mCodeModel,
|
||||
codeGenOptLevel
|
||||
codeGenOptLevel()
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -33,22 +33,7 @@ void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostrea
|
||||
void writeModule(llvm::Module* m, std::string filename)
|
||||
{
|
||||
// run optimizer
|
||||
bool reverify = ldc_optimize_module(m);
|
||||
|
||||
// verify the llvm
|
||||
if (!global.params.noVerify && reverify) {
|
||||
std::string verifyErr;
|
||||
Logger::println("Verifying module... again...");
|
||||
LOG_SCOPE;
|
||||
if (llvm::verifyModule(*m,llvm::ReturnStatusAction,&verifyErr))
|
||||
{
|
||||
error("%s", verifyErr.c_str());
|
||||
fatal();
|
||||
}
|
||||
else {
|
||||
Logger::println("Verification passed!");
|
||||
}
|
||||
}
|
||||
ldc_optimize_module(m);
|
||||
|
||||
// eventually do our own path stuff, dmd's is a bit strange.
|
||||
typedef llvm::sys::Path LLPath;
|
||||
@@ -141,16 +126,8 @@ void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostrea
|
||||
else
|
||||
Passes.add(new TargetData(&m));
|
||||
|
||||
// Last argument is enum CodeGenOpt::Level OptLevel
|
||||
// debug info doesn't work properly with OptLevel != None!
|
||||
CodeGenOpt::Level LastArg = CodeGenOpt::Default;
|
||||
if (global.params.symdebug || !optimize())
|
||||
LastArg = CodeGenOpt::None;
|
||||
else if (optLevel() >= 3)
|
||||
LastArg = CodeGenOpt::Aggressive;
|
||||
|
||||
llvm::formatted_raw_ostream fout(out);
|
||||
if (Target.addPassesToEmitFile(Passes, fout, fileType, LastArg))
|
||||
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
|
||||
assert(0 && "no support for asm output");
|
||||
|
||||
Passes.doInitialization();
|
||||
|
||||
Reference in New Issue
Block a user