diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index e117b6cd3f45..49037aed56b2 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -585,11 +585,16 @@ void GVN::ValueTable::verifyRemoved(const Value *V) const { //===----------------------------------------------------------------------===// PreservedAnalyses GVN::run(Function &F, AnalysisManager &AM) { - bool Changed = runImpl(F, AM.getResult(F), - AM.getResult(F), - AM.getResult(F), - AM.getResult(F), - &AM.getResult(F)); + // FIXME: The order of evaluation of these 'getResult' calls is very + // significant! Re-ordering these variables will cause GVN when run alone to + // be less effective! We should fix memdep and basic-aa to not exhibit this + // behavior, but until then don't change the order here. + auto &AC = AM.getResult(F); + auto &DT = AM.getResult(F); + auto &TLI = AM.getResult(F); + auto &AA = AM.getResult(F); + auto &MemDep = AM.getResult(F); + bool Changed = runImpl(F, AC, DT, TLI, AA, &MemDep); return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all(); }