summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2018-01-23 23:56:25 +0000
committerMichael Kruse <llvm@meinersbur.de>2018-01-23 23:56:25 +0000
commit1ed2bc526691237ea7a6e2796b25c5eb46cde05e (patch)
tree75da7dd075807c019704ac2cad080db70c1bcac8 /polly/lib/Support
parent03bb127569a515e2023ff406952c4d6fd8c8aaa1 (diff)
downloadbcm5719-llvm-1ed2bc526691237ea7a6e2796b25c5eb46cde05e.tar.gz
bcm5719-llvm-1ed2bc526691237ea7a6e2796b25c5eb46cde05e.zip
[VirtualInst] Derive correct use kind of PHI operands. NFC.
VirtualUse::create is only called for MemoryKind::Value, but its consistency nonetheless checked in verifyUses(). PHI uses are always inter-stmt dependencies, which was not considered by the constructor method. The virtual and non-virtual execution paths were the same, such that verifyUses did not encounter any inconsistencies. llvm-svn: 323283
Diffstat (limited to 'polly/lib/Support')
-rw-r--r--polly/lib/Support/VirtualInstruction.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/polly/lib/Support/VirtualInstruction.cpp b/polly/lib/Support/VirtualInstruction.cpp
index 0e471886489..29bb46b3046 100644
--- a/polly/lib/Support/VirtualInstruction.cpp
+++ b/polly/lib/Support/VirtualInstruction.cpp
@@ -21,13 +21,33 @@ using namespace llvm;
VirtualUse VirtualUse ::create(Scop *S, const Use &U, LoopInfo *LI,
bool Virtual) {
auto *UserBB = getUseBlock(U);
+ Loop *UserScope = LI->getLoopFor(UserBB);
Instruction *UI = dyn_cast<Instruction>(U.getUser());
- ScopStmt *UserStmt = nullptr;
- if (PHINode *PHI = dyn_cast<PHINode>(UI))
- UserStmt = S->getLastStmtFor(PHI->getIncomingBlock(U));
- else
- UserStmt = S->getStmtFor(UI);
- auto *UserScope = LI->getLoopFor(UserBB);
+ ScopStmt *UserStmt = S->getStmtFor(UI);
+
+ // Uses by PHI nodes are always reading values written by other statements,
+ // except it is within a region statement.
+ if (PHINode *PHI = dyn_cast<PHINode>(UI)) {
+ // Handle PHI in exit block.
+ if (S->getRegion().getExit() == PHI->getParent())
+ return VirtualUse(UserStmt, U.get(), Inter, nullptr, nullptr);
+
+ if (UserStmt->getEntryBlock() != PHI->getParent())
+ return VirtualUse(UserStmt, U.get(), Intra, nullptr, nullptr);
+
+ // The MemoryAccess is expected to be set if @p Virtual is true.
+ MemoryAccess *IncomingMA = nullptr;
+ if (Virtual) {
+ if (const ScopArrayInfo *SAI =
+ S->getScopArrayInfoOrNull(PHI, MemoryKind::PHI)) {
+ IncomingMA = S->getPHIRead(SAI);
+ assert(IncomingMA->getStatement() == UserStmt);
+ }
+ }
+
+ return VirtualUse(UserStmt, U.get(), Inter, nullptr, IncomingMA);
+ }
+
return create(S, UserStmt, UserScope, U.get(), Virtual);
}
OpenPOWER on IntegriCloud