brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 3e76dbd Raw
52 lines · cpp
1//===---- CodePreparation.cpp - Code preparation for Scop Detection -------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// The Polly code preparation pass is executed before SCoP detection. Its10// currently only splits the entry block of the SCoP to make room for alloc11// instructions as they are generated during code generation.12//13// XXX: In the future, we should remove the need for this pass entirely and14// instead add this spitting to the code generation pass.15//16//===----------------------------------------------------------------------===//17 18#include "polly/CodePreparation.h"19#include "polly/Support/ScopHelper.h"20#include "llvm/Analysis/DominanceFrontier.h"21#include "llvm/Analysis/LoopInfo.h"22#include "llvm/Analysis/RegionInfo.h"23#include "llvm/Analysis/ScalarEvolution.h"24 25using namespace llvm;26using namespace polly;27 28static bool runCodePreprationImpl(Function &F, DominatorTree *DT, LoopInfo *LI,29                                  RegionInfo *RI) {30  // Find first non-alloca instruction. Every basic block has a non-alloca31  // instruction, as every well formed basic block has a terminator.32  auto &EntryBlock = F.getEntryBlock();33  BasicBlock::iterator I = EntryBlock.begin();34  while (isa<AllocaInst>(I))35    ++I;36 37  // Abort if not necessary to split38  if (I->isTerminator() && isa<BranchInst>(I) &&39      cast<BranchInst>(I)->isUnconditional())40    return false;41 42  // splitBlock updates DT, LI and RI.43  splitEntryBlockForAlloca(&EntryBlock, DT, LI, RI);44 45  return true;46}47 48bool polly::runCodePreparation(Function &F, DominatorTree *DT, LoopInfo *LI,49                               RegionInfo *RI) {50  return runCodePreprationImpl(F, DT, LI, RI);51}52