[llvm-commits] Patch for simplifying regions

ether zhhb etherzhhb at gmail.com
Wed Mar 23 21:55:11 PDT 2011


hi,

hi,

I seem Polly have a pass with the same name, how is this patch going on?

>> diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp b/lib/Transforms/Scalar/RegionSimplify.cpp
>> new file mode 100644
>> index 0000000..9c78269
>> --- /dev/null
>> +++ b/lib/Transforms/Scalar/RegionSimplify.cpp
>> @@ -0,0 +1,191 @@
>> +//===- RegionSimplify.cpp -------------------------------------------------===//
>> +//
>> +//                     The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===----------------------------------------------------------------------===//
>> +//
>> +// This file converts refined regions detected by the RegionInfo analysis
>> +// into simple regions.
>> +//
>> +//===----------------------------------------------------------------------===//
>> +
>> +#include "llvm/Instructions.h"
>> +#include "llvm/ADT/Statistic.h"
>> +#include "llvm/Analysis/Dominators.h"
>> +#include "llvm/Analysis/RegionPass.h"
>> +#include "llvm/Analysis/RegionInfo.h"
>> +#include "llvm/Transforms/Utils/BasicBlockUtils.h"
>> +
>> +#define DEBUG_TYPE "region-simplify"
>> +
>> +using namespace llvm;
>> +
>> +STATISTIC(NumEntries, "The # of created entry edges");
>> +STATISTIC(NumExits, "The # of created exit edges");
>> +
>> +namespace {
>> +class RegionSimplify: public RegionPass {
>> +  bool modified;
>> +  Region *CR;
>> +  void createSingleEntryEdge(Region *R);
>> +  void createSingleExitEdge(Region *R);
I seems there are also functions with the same name defined in
ScopHelper.cpp of polly, are they the same functions?

Instead of implement these functions in a specific pass, i suggest
that we move these two functions into
lib\Transforms\Utils\BasicBlockUtils.cpp or even
lib\Transforms\Utils\RegionUtils.cpp, just like the "SplitBlock"
function in llvm. So people can call these function anywhere their
want to modify any region. And the RegionSimplify should simply call
these functions to do their jobs instead denfining the same functions
again.

>> +public:
>> +  static char ID;
>> +  explicit RegionSimplify() :
>> +    RegionPass(ID) {
>> +    initializeRegionSimplifyPass(*PassRegistry::getPassRegistry());
>> +  }
>> +
>> +  virtual void print(raw_ostream&O, const Module *M) const;
>> +
>> +  virtual bool runOnRegion(Region *R, RGPassManager&RGM);
>> +  virtual void getAnalysisUsage(AnalysisUsage&AU) const;
>> +};
>> +}

best regards
ether




More information about the llvm-commits mailing list