Skip to content

Commit

Permalink
[Attributor][FIX] Only avoid visiting PHI uses multiple times (PR51249)
Browse files Browse the repository at this point in the history
AAPointerInfoFloating needs to visit all uses and some multiple times if
we go through PHI nodes. Attributor::checkForAllUses keeps a visited set
so we don't recurs endlessly. We now allow recursion for non-phi uses so
we track all pointer offsets via PHI nodes properly without endless
recursion.

This replaces the first attempt D107579.

Differential Revision: https://reviews.llvm.org/D107798
  • Loading branch information
jdoerfert committed Aug 11, 2021
1 parent f358727 commit 96da6dd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 45 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/IPO/Attributor.cpp
Expand Up @@ -32,6 +32,7 @@
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/IR/ValueHandle.h"
Expand Down Expand Up @@ -1023,7 +1024,7 @@ bool Attributor::checkForAllUses(function_ref<bool(const Use &, bool &)> Pred,

while (!Worklist.empty()) {
const Use *U = Worklist.pop_back_val();
if (!Visited.insert(U).second)
if (isa<PHINode>(U->getUser()) && !Visited.insert(U).second)
continue;
LLVM_DEBUG(dbgs() << "[Attributor] Check use: " << **U << " in "
<< *U->getUser() << "\n");
Expand Down

0 comments on commit 96da6dd

Please sign in to comment.