diff --git a/src/llvm-cpufeatures.cpp b/src/llvm-cpufeatures.cpp index 15b017785ba61..4f98f09309ba9 100644 --- a/src/llvm-cpufeatures.cpp +++ b/src/llvm-cpufeatures.cpp @@ -16,11 +16,13 @@ #include "llvm-version.h" #include "passes.h" +#include #include #include #include #include #include +#include #include #include @@ -31,6 +33,9 @@ using namespace llvm; +STATISTIC(LoweredWithFMA, "Number of have_fma's that were lowered to true"); +STATISTIC(LoweredWithoutFMA, "Number of have_fma's that were lowered to false"); + extern JuliaOJIT *jl_ExecutionEngine; // whether this platform unconditionally (i.e. without needing multiversioning) supports FMA @@ -75,11 +80,13 @@ bool have_fma(Function &intr, Function &caller) { } void lowerHaveFMA(Function &intr, Function &caller, CallInst *I) { - if (have_fma(intr, caller)) + if (have_fma(intr, caller)) { + ++LoweredWithFMA; I->replaceAllUsesWith(ConstantInt::get(I->getType(), 1)); - else + } else { + ++LoweredWithoutFMA; I->replaceAllUsesWith(ConstantInt::get(I->getType(), 0)); - + } return; } @@ -104,6 +111,7 @@ bool lowerCPUFeatures(Module &M) for (auto I: Materialized) { I->eraseFromParent(); } + assert(!verifyModule(M)); return true; } else { return false; diff --git a/src/llvm-julia-licm.cpp b/src/llvm-julia-licm.cpp index 46e72291aeb42..497594b9923a0 100644 --- a/src/llvm-julia-licm.cpp +++ b/src/llvm-julia-licm.cpp @@ -3,11 +3,13 @@ #include "llvm-version.h" #include "passes.h" +#include #include #include #include "llvm/Analysis/LoopIterator.h" #include #include +#include #include #include @@ -20,6 +22,12 @@ using namespace llvm; +STATISTIC(HoistedPreserveBegin, "Number of gc_preserve_begin instructions hoisted out of a loop"); +STATISTIC(SunkPreserveEnd, "Number of gc_preserve_end instructions sunk out of a loop"); +STATISTIC(ErasedPreserveEnd, "Number of gc_preserve_end instructions removed from nonterminating loops"); +STATISTIC(HoistedWriteBarrier, "Number of write barriers hoisted out of a loop"); +STATISTIC(HoistedAllocation, "Number of allocations hoisted out of a loop"); + /* * Julia LICM pass. * This takes care of some julia intrinsics that is safe to move around/out of loops but @@ -113,6 +121,7 @@ struct JuliaLICM : public JuliaPassContext { } if (!canhoist) continue; + ++HoistedPreserveBegin; call->moveBefore(preheader->getTerminator()); changed = true; } @@ -123,9 +132,11 @@ struct JuliaLICM : public JuliaPassContext { changed = true; auto exit_pts = get_exit_pts(); if (exit_pts.empty()) { + ++ErasedPreserveEnd; call->eraseFromParent(); continue; } + ++SunkPreserveEnd; call->moveBefore(exit_pts[0]); for (unsigned i = 1; i < exit_pts.size(); i++) { // Clone exit @@ -141,6 +152,7 @@ struct JuliaLICM : public JuliaPassContext { } } if (valid) { + ++HoistedWriteBarrier; call->moveBefore(preheader->getTerminator()); changed = true; } @@ -166,12 +178,14 @@ struct JuliaLICM : public JuliaPassContext { continue; } if (valid) { + ++HoistedAllocation; call->moveBefore(preheader->getTerminator()); changed = true; } } } } + assert(!verifyFunction(*L->getHeader()->getParent())); return changed; } };