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:
kai
2012-08-16 23:26:52 +02:00
parent 34d595de26
commit e6a07ffdfe
8 changed files with 59 additions and 48 deletions

View File

@@ -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));

View File

@@ -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

View File

@@ -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();