[llvm] r364482 - [SCCP] Fix non-deterministic uselists of return values (DenseMap -> MapVector)
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 14:50:33 PDT 2019
Is there some test that already exposes the problematic behavior?
On Thu, Jun 27, 2019 at 12:44 AM Gerolf Hoflehner via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: ghoflehner
> Date: Wed Jun 26 14:44:37 2019
> New Revision: 364482
>
> URL: http://llvm.org/viewvc/llvm-project?rev=364482&view=rev
> Log:
> [SCCP] Fix non-deterministic uselists of return values (DenseMap -> MapVector)
>
> Modified:
> llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=364482&r1=364481&r2=364482&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Jun 26 14:44:37 2019
> @@ -20,6 +20,7 @@
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/DenseMap.h"
> #include "llvm/ADT/DenseSet.h"
> +#include "llvm/ADT/MapVector.h"
> #include "llvm/ADT/PointerIntPair.h"
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/ADT/SmallPtrSet.h"
> @@ -209,11 +210,11 @@ class SCCPSolver : public InstVisitor<SC
> /// TrackedRetVals - If we are tracking arguments into and the return
> /// value out of a function, it will have an entry in this map, indicating
> /// what the known return value for the function is.
> - DenseMap<Function *, LatticeVal> TrackedRetVals;
> + MapVector<Function *, LatticeVal> TrackedRetVals;
>
> /// TrackedMultipleRetVals - Same as TrackedRetVals, but used for functions
> /// that return multiple values.
> - DenseMap<std::pair<Function *, unsigned>, LatticeVal> TrackedMultipleRetVals;
> + MapVector<std::pair<Function *, unsigned>, LatticeVal> TrackedMultipleRetVals;
>
> /// MRVFunctionsTracked - Each function in TrackedMultipleRetVals is
> /// represented here for efficient lookup.
> @@ -371,7 +372,7 @@ public:
> }
>
> /// getTrackedRetVals - Get the inferred return value map.
> - const DenseMap<Function*, LatticeVal> &getTrackedRetVals() {
> + const MapVector<Function*, LatticeVal> &getTrackedRetVals() {
> return TrackedRetVals;
> }
>
> @@ -837,7 +838,7 @@ void SCCPSolver::visitReturnInst(ReturnI
>
> // If we are tracking the return value of this function, merge it in.
> if (!TrackedRetVals.empty() && !ResultOp->getType()->isStructTy()) {
> - DenseMap<Function*, LatticeVal>::iterator TFRVI =
> + MapVector<Function*, LatticeVal>::iterator TFRVI =
> TrackedRetVals.find(F);
> if (TFRVI != TrackedRetVals.end()) {
> mergeInValue(TFRVI->second, F, getValueState(ResultOp));
> @@ -1351,7 +1352,7 @@ CallOverdefined:
> mergeInValue(getStructValueState(I, i), I,
> TrackedMultipleRetVals[std::make_pair(F, i)]);
> } else {
> - DenseMap<Function*, LatticeVal>::iterator TFRVI = TrackedRetVals.find(F);
> + MapVector<Function*, LatticeVal>::iterator TFRVI = TrackedRetVals.find(F);
> if (TFRVI == TrackedRetVals.end())
> goto CallOverdefined; // Not tracking this callee.
>
> @@ -2158,7 +2159,7 @@ bool llvm::runIPSCCP(
> // whether other functions are optimizable.
> SmallVector<ReturnInst*, 8> ReturnsToZap;
>
> - const DenseMap<Function*, LatticeVal> &RV = Solver.getTrackedRetVals();
> + const MapVector<Function*, LatticeVal> &RV = Solver.getTrackedRetVals();
> for (const auto &I : RV) {
> Function *F = I.first;
> if (I.second.isOverdefined() || F->getReturnType()->isVoidTy())
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list