#include "llvm/MC/SubtargetFeature.h"
#include "llvm/PassManager.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
PM.add(P);
// If we are verifying all of the intermediate steps, add the verifier...
- if (VerifyEach) PM.add(createVerifierPass());
+ if (VerifyEach) {
+ PM.add(createVerifierPass());
+ PM.add(createDebugInfoVerifierPass());
+ }
}
/// AddOptimizationPasses - This routine adds optimization passes
/// OptLevel - Optimization Level
static void AddOptimizationPasses(PassManagerBase &MPM,FunctionPassManager &FPM,
unsigned OptLevel, unsigned SizeLevel) {
- FPM.add(createVerifierPass()); // Verify that input is correct
+ FPM.add(createVerifierPass()); // Verify that input is correct
+ MPM.add(createDebugInfoVerifierPass()); // Verify that debug info is correct
PassManagerBuilder Builder;
Builder.OptLevel = OptLevel;
if (StripDebug)
addPass(PM, createStripSymbolsPass(true));
+ // Verify debug info only after it's (possibly) stripped.
+ PM.add(createDebugInfoVerifierPass());
+
if (DisableOptimizations) return;
// -std-compile-opts adds the same module passes as -O3.
if (StripDebug)
addPass(PM, createStripSymbolsPass(true));
+ // Verify debug info only after it's (possibly) stripped.
+ PM.add(createDebugInfoVerifierPass());
+
if (DisableOptimizations) return;
PassManagerBuilder Builder;
Error);
// Some modules don't specify a triple, and this is okay.
if (!TheTarget) {
- return 0;
+ return nullptr;
}
// Package up features to be passed to target/subtarget
GetCodeGenOptLevel());
}
+#ifdef LINK_POLLY_INTO_TOOLS
+namespace polly {
+void initializePollyPasses(llvm::PassRegistry &Registry);
+}
+#endif
+
//===----------------------------------------------------------------------===//
// main for opt
//
InitializeAllTargets();
InitializeAllTargetMCs();
+ InitializeAllAsmPrinters();
// Initialize passes
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeInstrumentation(Registry);
initializeTarget(Registry);
// For codegen passes, only passes that do IR to IR transformation are
- // supported. For now, just add CodeGenPrepare.
+ // supported.
initializeCodeGenPreparePass(Registry);
+ initializeAtomicExpandLoadLinkedPass(Registry);
+
+#ifdef LINK_POLLY_INTO_TOOLS
+ polly::initializePollyPasses(Registry);
+#endif
cl::ParseCommandLineOptions(argc, argv,
"llvm .bc -> .bc modular optimizer and analysis printer\n");
std::unique_ptr<Module> M;
M.reset(ParseIRFile(InputFilename, Err, Context));
- if (M.get() == 0) {
+ if (!M.get()) {
Err.print(argv[0], errs());
return 1;
}
Passes.add(new DataLayoutPass(M.get()));
Triple ModuleTriple(M->getTargetTriple());
- TargetMachine *Machine = 0;
+ TargetMachine *Machine = nullptr;
if (ModuleTriple.getArch())
Machine = GetTargetMachine(Triple(ModuleTriple));
std::unique_ptr<TargetMachine> TM(Machine);
}
const PassInfo *PassInf = PassList[i];
- Pass *P = 0;
+ Pass *P = nullptr;
if (PassInf->getTargetMachineCtor())
P = PassInf->getTargetMachineCtor()(TM.get());
else if (PassInf->getNormalCtor())
}
// Check that the module is well formed on completion of optimization
- if (!NoVerify && !VerifyEach)
+ if (!NoVerify && !VerifyEach) {
Passes.add(createVerifierPass());
+ Passes.add(createDebugInfoVerifierPass());
+ }
// Write bitcode or assembly to the output as the last step...
if (!NoOutput && !AnalyzeOnly) {