diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp index c8e3a03239c2c..285cac1a7e626 100644 --- a/src/aotcompile.cpp +++ b/src/aotcompile.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #if defined(USE_POLLY) #include #include @@ -1216,7 +1217,10 @@ void addPipeline(ModulePassManager &MPM, int opt_level, bool lower_intrinsics, b void optimizeModule(Module &M, TargetMachine *TM, int opt_level, bool lower_intrinsics, bool dump_native) { // llvm::PassBuilder pb(targetMachine->LLVM, llvm::PipelineTuningOptions(), llvm::None, &passInstrumentationCallbacks); - PassBuilder PB; + PassInstrumentationCallbacks PIC; + StandardInstrumentations SI(false); + SI.registerCallbacks(PIC); + PassBuilder PB(TM, PipelineTuningOptions(), None, &PIC); // Create the analysis managers. LoopAnalysisManager LAM; PB.registerLoopAnalyses(LAM); diff --git a/src/llvm-alloc-opt.cpp b/src/llvm-alloc-opt.cpp index c285dac32d81f..396cd14522244 100644 --- a/src/llvm-alloc-opt.cpp +++ b/src/llvm-alloc-opt.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1148,7 +1149,9 @@ bool AllocOpt::runOnFunction(Function &F, function_ref GetDT) Optimizer optimizer(F, *this, std::move(GetDT)); optimizer.initialize(); optimizer.optimizeAll(); - return optimizer.finalize(); + auto changed = optimizer.finalize(); + assert(!verifyFunction(F)); + return changed; } struct AllocOptLegacy : public FunctionPass { diff --git a/src/llvm-cpufeatures.cpp b/src/llvm-cpufeatures.cpp index 15b017785ba61..44c8eed23337c 100644 --- a/src/llvm-cpufeatures.cpp +++ b/src/llvm-cpufeatures.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,7 @@ bool lowerCPUFeatures(Module &M) for (auto I: Materialized) { I->eraseFromParent(); } + assert(!verifyModule(M)); return true; } else { return false; diff --git a/src/llvm-demote-float16.cpp b/src/llvm-demote-float16.cpp index 7d99a5d3fc01c..0542800491218 100644 --- a/src/llvm-demote-float16.cpp +++ b/src/llvm-demote-float16.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include using namespace llvm; @@ -121,6 +122,7 @@ static bool demoteFloat16(Function &F) if (erase.size() > 0) { for (auto V : erase) V->eraseFromParent(); + assert(!verifyFunction(F)); return true; } else diff --git a/src/llvm-final-gc-lowering.cpp b/src/llvm-final-gc-lowering.cpp index a45154f13ce8b..3961883adb5a2 100644 --- a/src/llvm-final-gc-lowering.cpp +++ b/src/llvm-final-gc-lowering.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -211,6 +212,7 @@ bool FinalLowerGC::doInitialization(Module &M) { } if (j != 0) appendToCompilerUsed(M, ArrayRef(functionList, j)); + assert(!verifyModule(M)); return true; } @@ -244,6 +246,7 @@ bool FinalLowerGC::doFinalization(Module &M) used = new GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, ConstantArray::get(ATy, init), "llvm.compiler.used"); used->setSection("llvm.metadata"); + assert(!verifyModule(M)); return true; } @@ -320,6 +323,8 @@ bool FinalLowerGC::runOnFunction(Function &F) } } + assert(!verifyFunction(F)); + return true; } diff --git a/src/llvm-julia-licm.cpp b/src/llvm-julia-licm.cpp index c45aa66b1d805..fa66e959e3855 100644 --- a/src/llvm-julia-licm.cpp +++ b/src/llvm-julia-licm.cpp @@ -8,6 +8,7 @@ #include "llvm/Analysis/LoopIterator.h" #include #include +#include #include #include @@ -174,6 +175,7 @@ struct JuliaLICM : public JuliaPassContext { } } } + assert(!verifyFunction(*L->getBlocks()[0]->getParent())); return changed; } }; diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp index eac66392290f4..7e599d9ced709 100644 --- a/src/llvm-late-gc-lowering.cpp +++ b/src/llvm-late-gc-lowering.cpp @@ -2699,6 +2699,7 @@ bool LateLowerGCFrame::runOnFunction(Function &F, bool *CFGModified) { std::map> CallFrames; // = OptimizeCallFrames(S, Ordering); PlaceRootsAndUpdateCalls(Colors, S, CallFrames); CleanupIR(F, &S, CFGModified); + assert(!verifyFunction(F)); return true; } diff --git a/src/llvm-lower-handlers.cpp b/src/llvm-lower-handlers.cpp index 747066e731892..76af3cafdd728 100644 --- a/src/llvm-lower-handlers.cpp +++ b/src/llvm-lower-handlers.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -215,6 +216,7 @@ static bool lowerExcHandlers(Function &F) { LifetimeEnd->insertAfter(it.first); } } + assert(!verifyFunction(F)); return true; } diff --git a/src/llvm-muladd.cpp b/src/llvm-muladd.cpp index 7f9b2a5b266fd..638afdccb7abf 100644 --- a/src/llvm-muladd.cpp +++ b/src/llvm-muladd.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -80,6 +81,7 @@ static bool combineMulAdd(Function &F) } } } + assert(!verifyFunction(F)); return true; } diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp index 3a377547da7eb..994c6d5ef54df 100644 --- a/src/llvm-multiversioning.cpp +++ b/src/llvm-multiversioning.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "julia.h" @@ -1105,6 +1106,7 @@ static bool runMultiVersioning(Module &M, function_ref Get // and collected all the shared/target-specific relocations. clone.emit_metadata(); + assert(!verifyModule(M)); return true; } diff --git a/src/llvm-propagate-addrspaces.cpp b/src/llvm-propagate-addrspaces.cpp index 8da0e108c94d5..ca62603f0828c 100644 --- a/src/llvm-propagate-addrspaces.cpp +++ b/src/llvm-propagate-addrspaces.cpp @@ -295,6 +295,7 @@ bool propagateJuliaAddrspaces(Function &F) { visitor.ToDelete.clear(); visitor.LiftingMap.clear(); visitor.Visited.clear(); + assert(!verifyFunction(F)); return true; } diff --git a/src/llvm-ptls.cpp b/src/llvm-ptls.cpp index 9f9da7dbe29eb..ba2bded1e62e0 100644 --- a/src/llvm-ptls.cpp +++ b/src/llvm-ptls.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -281,6 +282,7 @@ bool LowerPTLS::runOnModule(Module &_M, bool *CFGModified) } assert(pgcstack_getter->use_empty()); pgcstack_getter->eraseFromParent(); + assert(!verifyModule(_M)); return true; } diff --git a/src/llvm-remove-addrspaces.cpp b/src/llvm-remove-addrspaces.cpp index 610268cfa9833..7b9ce49aaa683 100644 --- a/src/llvm-remove-addrspaces.cpp +++ b/src/llvm-remove-addrspaces.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -453,6 +454,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper) } } + assert(!verifyModule(M)); return true; } diff --git a/src/llvm-remove-ni.cpp b/src/llvm-remove-ni.cpp index c252905dc75f9..823e0e45ae097 100644 --- a/src/llvm-remove-ni.cpp +++ b/src/llvm-remove-ni.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "julia.h" @@ -32,6 +33,7 @@ static bool removeNI(Module &M) } dlstr.erase(nistart, niend - nistart); M.setDataLayout(dlstr); + assert(!verifyModule(M)); return true; } } diff --git a/src/llvm-simdloop.cpp b/src/llvm-simdloop.cpp index 7a15c8b1a0068..79d5c58c6fcda 100644 --- a/src/llvm-simdloop.cpp +++ b/src/llvm-simdloop.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "julia_assert.h" @@ -205,6 +206,7 @@ static bool markLoopInfo(Module &M, Function *marker, function_refdeleteValue(); marker->eraseFromParent(); + assert(!verifyModule(M)); return Changed; }