Commit 3c1d4ff8 authored by Michael Kruse's avatar Michael Kruse
Browse files

Reduce diff delta

parent 23ca2a83
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -62,10 +62,6 @@ class ScopBuilder {
  // The Scop
  std::unique_ptr<Scop> scop;

#if 0
  llvm::json::Array *LoopNest = nullptr;
#endif

  /// Collection to hold taken assumptions.
  ///
  /// There are two reasons why we want to record assumptions first before we
@@ -783,10 +779,6 @@ class ScopBuilder {
    // The (possibly incomplete) schedule for this loop.
    isl::schedule Schedule;

#if 0
    llvm::json::Array *Nest = nullptr;
#endif

    // The number of basic blocks in the current loop, for which a schedule has
    // already been constructed.
    unsigned NumBlocksProcessed;
@@ -846,10 +838,6 @@ public:
  /// @return Give up the ownership of the scop object or static control part
  ///         for the region
  std::unique_ptr<Scop> getScop() { return std::move(scop); }

#if 0
  auto getLoopNest() { return LoopNest; }
#endif
};
} // end namespace polly

+0 −13
Original line number Diff line number Diff line
@@ -44,19 +44,6 @@ struct DumpModulePass : llvm::PassInfoMixin<DumpModulePass> {
  llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
};

struct DumpModuleOfFunctionPass
    : llvm::PassInfoMixin<DumpModuleOfFunctionPass> {
  std::string Filename;
  bool IsSuffix;
  llvm::DenseSet<llvm::Module *> AlreadyDumped;

  DumpModuleOfFunctionPass(std::string Filename, bool IsSuffix)
      : Filename(std::move(Filename)), IsSuffix(IsSuffix) {}

  llvm::PreservedAnalyses run(llvm::Function &F,
                              llvm::FunctionAnalysisManager &AM);
};

} // namespace polly

namespace llvm {
+24 −112
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
@@ -55,10 +54,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include <cassert>

using namespace llvm;
@@ -1150,22 +1146,6 @@ static isl::schedule combineInSequence(isl::schedule Prev, isl::schedule Succ) {
  return Prev.sequence(Succ);
}

#if 0
static json::Array *combineInSequence(json::Array *Prev, json::Array *Succ) {
  if (!Prev)
    return Succ;
  if (!Succ)
    return Prev;

  auto Result = new json::Array();
  for (auto X : *Prev)
    Result->emplace_back(X);
  for (auto X : *Succ)
    Result->emplace_back(X);
  return Result;
}
#endif

// Create an isl_multi_union_aff that defines an identity mapping from the
// elements of USet to their N-th dimension.
//
@@ -1206,14 +1186,6 @@ void ScopBuilder::buildSchedule() {
  buildSchedule(scop->getRegion().getNode(), LoopStack);
  assert(LoopStack.size() == 1 && LoopStack.back().L == L);
  scop->setScheduleTree(LoopStack[0].Schedule);
#if 0
  assert(!this->LoopNest);
  this->LoopNest = LoopStack[0].Nest;
  if (!this->LoopNest) {
    // Ensure member if there is not loop at all (-polly-process-unprofitable)
    this->LoopNest = new json::Array();
  }
#endif
}

/// To generate a schedule for the elements in a Region we traverse the Region
@@ -1301,9 +1273,6 @@ void ScopBuilder::buildSchedule(RegionNode *RN, LoopStackTy &LoopStack) {
    isl::union_set UDomain{Stmt->getDomain()};
    auto StmtSchedule = isl::schedule::from_domain(UDomain);
    LoopData->Schedule = combineInSequence(LoopData->Schedule, StmtSchedule);
#if 0
    LoopData->Nest = combineInSequence(LoopData->Nest, nullptr);
#endif
  }

  // Check if we just processed the last node in this loop. If we did, finalize
@@ -1319,9 +1288,6 @@ void ScopBuilder::buildSchedule(RegionNode *RN, LoopStackTy &LoopStack) {
  while (LoopData->L &&
         LoopData->NumBlocksProcessed == getNumBlocksInLoop(LoopData->L)) {
    isl::schedule Schedule = LoopData->Schedule;
#if 0
    auto Subloopnest = LoopData->Nest;
#endif
    auto NumBlocksProcessed = LoopData->NumBlocksProcessed;

    assert(std::next(LoopData) != LoopStack.rend());
@@ -1330,10 +1296,6 @@ void ScopBuilder::buildSchedule(RegionNode *RN, LoopStackTy &LoopStack) {
    --Dimension;

    if (!Schedule.is_null()) {
#if 0
      bool IsPerfectNest = Schedule.get_root().get_child(0).n_children() ==
                           1; // Root is a domain node
#endif
      isl::union_set Domain = Schedule.get_domain();
      isl::multi_union_pw_aff MUPA = mapToDimension(Domain, Dimension);
      Schedule = Schedule.insert_partial_schedule(MUPA);
@@ -1355,56 +1317,6 @@ void ScopBuilder::buildSchedule(RegionNode *RN, LoopStackTy &LoopStack) {
            Schedule.get_root().child(0).insert_mark(IslLoopId).get_schedule();

      LoopData->Schedule = combineInSequence(LoopData->Schedule, Schedule);
#if 0
      auto LoopId = L->getLoopID();
      auto BeginLoc = (LoopId && LoopId->getNumOperands() > 1)
                          ? LoopId->getOperand(1).get()
                          : nullptr;

      auto Start = dyn_cast_or_null<DILocation>(BeginLoc);

      json::Object Loop;
      if (Start) {
        Loop["filename"] = Start->getFilename();
        Loop["directory"] = Start->getDirectory();
        Loop["path"] = (Twine(Start->getDirectory()) +
                        llvm::sys::path::get_separator() + Start->getFilename())
                           .str();
        if (Start->getSource())
          Loop["source"] = Start->getSource().getValue().str();
        Loop["line"] = Start->getLine();
        Loop["column"] = Start->getColumn();
      }

      Loop["function"] = RN->getEntry()->getParent()->getName().str();
      {
        SmallVector<char, 255> Buf;
        raw_svector_ostream OS(Buf);
        RN->getEntry()->printAsOperand(OS, /*PrintType=*/false);
        Loop["entry"] = Buf;
      }
      {
        BasicBlock *BBExit = RN->getEntry();
        if (RN->isSubRegion()) {
          auto *LocalRegion = RN->getNodeAs<Region>();
          BBExit = LocalRegion->getExit();
        }

        SmallVector<char, 255> Buf;
        raw_svector_ostream OS(Buf);
        BBExit->printAsOperand(OS, /*PrintType=*/false);
        Loop["exit"] = Buf;
      }


      if (Subloopnest) {
        Loop["subloops"] = json::Value(std::move(*Subloopnest));
        Loop["perfectnest"] = IsPerfectNest;
      } else
        Loop["subloops"] = json::Array();
      auto Nest = new json::Array({std::move(Loop)});
      LoopData->Nest = combineInSequence(LoopData->Nest, Nest);
#endif
    }

    LoopData->NumBlocksProcessed += NumBlocksProcessed;
@@ -2392,7 +2304,7 @@ void ScopBuilder::buildAccessFunctions(ScopStmt *Stmt, BasicBlock &BB,
  }
}

polly::MemoryAccess *ScopBuilder::addMemoryAccess(
MemoryAccess *ScopBuilder::addMemoryAccess(
    ScopStmt *Stmt, Instruction *Inst, MemoryAccess::AccessType AccType,
    Value *BaseAddress, Type *ElementType, bool Affine, Value *AccessValue,
    ArrayRef<const SCEV *> Subscripts, ArrayRef<const SCEV *> Sizes,
@@ -2789,33 +2701,33 @@ void ScopBuilder::collectSurroundingLoops(ScopStmt &Stmt) {
}

/// Return the reduction type for a given binary operator.
static polly::MemoryAccess::ReductionType
getReductionType(const BinaryOperator *BinOp, const Instruction *Load) {
static MemoryAccess::ReductionType getReductionType(const BinaryOperator *BinOp,
                                                    const Instruction *Load) {
  if (!BinOp)
    return polly::MemoryAccess::RT_NONE;
    return MemoryAccess::RT_NONE;
  switch (BinOp->getOpcode()) {
  case polly::Instruction::FAdd:
  case Instruction::FAdd:
    if (!BinOp->isFast())
      return polly::MemoryAccess::RT_NONE;
      return MemoryAccess::RT_NONE;
    LLVM_FALLTHROUGH;
  case polly::Instruction::Add:
    return polly::MemoryAccess::RT_ADD;
  case polly::Instruction::Or:
    return polly::MemoryAccess::RT_BOR;
  case polly::Instruction::Xor:
    return polly::MemoryAccess::RT_BXOR;
  case polly::Instruction::And:
    return polly::MemoryAccess::RT_BAND;
  case polly::Instruction::FMul:
  case Instruction::Add:
    return MemoryAccess::RT_ADD;
  case Instruction::Or:
    return MemoryAccess::RT_BOR;
  case Instruction::Xor:
    return MemoryAccess::RT_BXOR;
  case Instruction::And:
    return MemoryAccess::RT_BAND;
  case Instruction::FMul:
    if (!BinOp->isFast())
      return polly::MemoryAccess::RT_NONE;
      return MemoryAccess::RT_NONE;
    LLVM_FALLTHROUGH;
  case polly::Instruction::Mul:
  case Instruction::Mul:
    if (DisableMultiplicativeReductions)
      return polly::MemoryAccess::RT_NONE;
    return polly::MemoryAccess::RT_MUL;
      return MemoryAccess::RT_NONE;
    return MemoryAccess::RT_MUL;
  default:
    return polly::MemoryAccess::RT_NONE;
    return MemoryAccess::RT_NONE;
  }
}

@@ -3280,7 +3192,7 @@ void ScopBuilder::collectCandidateReductionLoads(
/// scop array.
static const ScopArrayInfo *findCanonicalArray(Scop &S,
                                               MemoryAccessList &Accesses) {
  for (polly::MemoryAccess *Access : Accesses) {
  for (MemoryAccess *Access : Accesses) {
    const ScopArrayInfo *CanonicalArray = S.getScopArrayInfoOrNull(
        Access->getAccessInstruction(), MemoryKind::Array);
    if (CanonicalArray)
@@ -3292,7 +3204,7 @@ static const ScopArrayInfo *findCanonicalArray(Scop &S,
/// Check if @p Array severs as base array in an invariant load.
static bool isUsedForIndirectHoistedLoad(Scop &S, const ScopArrayInfo *Array) {
  for (InvariantEquivClassTy &EqClass2 : S.getInvariantAccesses())
    for (polly::MemoryAccess *Access2 : EqClass2.InvariantAccesses)
    for (MemoryAccess *Access2 : EqClass2.InvariantAccesses)
      if (Access2->getScopArrayInfo() == Array)
        return true;
  return false;
@@ -3303,7 +3215,7 @@ static bool isUsedForIndirectHoistedLoad(Scop &S, const ScopArrayInfo *Array) {
static void replaceBasePtrArrays(Scop &S, const ScopArrayInfo *Old,
                                 const ScopArrayInfo *New) {
  for (ScopStmt &Stmt : S)
    for (polly::MemoryAccess *Access : Stmt) {
    for (MemoryAccess *Access : Stmt) {
      if (Access->getLatestScopArrayInfo() != Old)
        continue;

@@ -3477,7 +3389,7 @@ bool ScopBuilder::calculateMinMaxAccess(AliasGroupTy AliasGroup,
  return !LimitReached;
}

static isl::set getAccessDomain(polly::MemoryAccess *MA) {
static isl::set getAccessDomain(MemoryAccess *MA) {
  isl::set Domain = MA->getStatement()->getDomain();
  Domain = Domain.project_out(isl::dim::set, 0, Domain.tuple_dim().release());
  return Domain.reset_tuple_id();
+1 −0
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ enum class dim {
};
} // namespace isl
#include <isl/id.h>
#include <isl/space.h>
#include <isl/val.h>
+0 −17
Original line number Diff line number Diff line
@@ -96,23 +96,6 @@ llvm::PreservedAnalyses DumpModulePass::run(llvm::Module &M,
  return PreservedAnalyses::all();
}

llvm::PreservedAnalyses
DumpModuleOfFunctionPass::run(llvm::Function &F,
                              llvm::FunctionAnalysisManager &AM) {
  Module *M = F.getParent();
  if (!M)
    return PreservedAnalyses::all();

  auto It = AlreadyDumped.insert(M);
  if (!It.second) {
    // Module has been dumped before.
    return PreservedAnalyses::all();
  }

  runDumpModule(*M, Filename, IsSuffix);
  return PreservedAnalyses::all();
}

INITIALIZE_PASS_BEGIN(DumpModuleWrapperPass, "polly-dump-module",
                      "Polly - Dump Module", false, false)
INITIALIZE_PASS_END(DumpModuleWrapperPass, "polly-dump-module",
Loading