This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Fix Memory Access of failing tests.
ClosedPublic

Authored by nandini12396 on Aug 25 2017, 8:26 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

nandini12396 created this revision.Aug 25 2017, 8:26 AM

@Meinersbur : there is something absurd.. I added the following just before buildSchedule:

diff --git a/lib/Analysis/ScopBuilder.cpp b/lib/Analysis/ScopBuilder.cpp
index 8bad622..a0d5d59 100644
--- a/lib/Analysis/ScopBuilder.cpp
+++ b/lib/Analysis/ScopBuilder.cpp
@@ -1051,6 +1051,13 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {
     return;
   }
 
+  for (ScopStmt &Stmt : scop->Stmts) {
+    dbgs() << Stmt;
+    dbgs() << Stmt.getBasicBlock();
+    for (ScopStmt *Stmt1 : scop->getStmtListFor(Stmt.getBasicBlock()))
+      dbgs() << *Stmt1;
+  }
+
   scop->buildSchedule(LI);

but Stmt1 seems to not exist.

Meinersbur edited edge metadata.Aug 28 2017, 1:35 PM

Together with D36402, I don't see any tests failing.

The only time I see Stmt1 to no "exist" is when Stmt.getBasicBlock() returns nullptr. This happens when Stmt is a region statement, which expected.

Maybe I didn't understand your question. Can you elaborate? Which test is failing and what statement to you expect to be Stmt1?

Passes test/ScopInfo/stmt_split_scalar_dependence.ll.

The culprit is

void Scop::removeFromStmtMap(ScopStmt &Stmt) {
  if (Stmt.isRegionStmt())
    for (BasicBlock *BB : Stmt.getRegion()->blocks()) {
      StmtMap.erase(BB);
      for (Instruction &Inst : *BB)
        InstStmtMap.erase(&Inst);
  } else {
    StmtMap.erase(Stmt.getBasicBlock()); // <-- here
    for (Instruction *Inst : Stmt.getInstructions())
      InstStmtMap.erase(Inst);
  }
}

It removes all statements associated with the BB, not just the one passed. After the operation, StmtMap contains no more statement for that BB, even if previously it had more than one.

oh yes. Thank you very much for catching this! :-)

nandini12396 retitled this revision from [Polly] [WIP] Fix Memory Access of failing tests. to [Polly] Fix Memory Access of failing tests..
nandini12396 edited the summary of this revision. (Show Details)

LGTM.

Unfortunately the patch does apply to current trunk. Could rebase it? Thank you.

Meinersbur accepted this revision.Aug 31 2017, 6:29 AM
This revision is now accepted and ready to land.Aug 31 2017, 6:29 AM

I get a compilation error:
error C2181: illegal else without matching if.

Before uploading/updating a patch, please always run "make/ninja check-polly".

I apologise. It somehow got modified.

Thanks. committed as r312324.

This revision was automatically updated to reflect the committed changes.