From bbf308456183bf541fe337e99521dfa0efa0fafc Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 2 Mar 2015 13:41:53 +0000 Subject: [FIX] Make parallel codegen aware of region statements llvm-svn: 230959 --- polly/lib/CodeGen/IslCodeGeneration.cpp | 36 +++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'polly/lib/CodeGen/IslCodeGeneration.cpp') diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index fde674d78b1..b4d23a13641 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -312,17 +312,9 @@ struct FindValuesUser { SetVector &SCEVs; }; -/// Extract the values and SCEVs needed to generate code for a ScopStmt. -/// -/// This function extracts a ScopStmt from a given isl_set and computes the -/// Values this statement depends on as well as a set of SCEV expressions that -/// need to be synthesized when generating code for this statment. -static int findValuesInStmt(isl_set *Set, void *UserPtr) { - isl_id *Id = isl_set_get_tuple_id(Set); - struct FindValuesUser &User = *static_cast(UserPtr); - const ScopStmt *Stmt = static_cast(isl_id_get_user(Id)); - const BasicBlock *BB = Stmt->getBasicBlock(); - +/// @brief Extract the values and SCEVs needed to generate code for a block. +static int findValuesInBlock(struct FindValuesUser &User, const ScopStmt *Stmt, + const BasicBlock *BB) { // Check all the operands of instructions in the basic block. for (const Instruction &Inst : *BB) { for (Value *SrcVal : Inst.operands()) { @@ -340,6 +332,28 @@ static int findValuesInStmt(isl_set *Set, void *UserPtr) { User.Values.insert(SrcVal); } } + return 0; +} + +/// Extract the values and SCEVs needed to generate code for a ScopStmt. +/// +/// This function extracts a ScopStmt from a given isl_set and computes the +/// Values this statement depends on as well as a set of SCEV expressions that +/// need to be synthesized when generating code for this statment. +static int findValuesInStmt(isl_set *Set, void *UserPtr) { + isl_id *Id = isl_set_get_tuple_id(Set); + struct FindValuesUser &User = *static_cast(UserPtr); + const ScopStmt *Stmt = static_cast(isl_id_get_user(Id)); + + if (Stmt->isBlockStmt()) + findValuesInBlock(User, Stmt, Stmt->getBasicBlock()); + else { + assert(Stmt->isRegionStmt() && + "Stmt was neither block nor region statement"); + for (const BasicBlock *BB : Stmt->getRegion()->blocks()) + findValuesInBlock(User, Stmt, BB); + } + isl_id_free(Id); isl_set_free(Set); return 0; -- cgit v1.2.3