Skip to content

Commit

Permalink
[AliasSetTracker] Do not treat experimental_guard intrinsic as memory…
Browse files Browse the repository at this point in the history
… writing instruction

The `experimental_guard` intrinsic has memory write semantics to model the thread-exiting
logic, but does not do any actual writes to memory. Currently, `AliasSetTracker` treats it as a
normal memory write. As result, a loop-invariant load cannot be hoisted out of loop because
the guard may possibly alias with it.

This patch makes `AliasSetTracker` so that it doesn't treat guards as memory writes.

Differential Revision: https://reviews.llvm.org/D50497
Reviewed By: reames

llvm-svn: 339753
  • Loading branch information
Max Kazantsev committed Aug 15, 2018
1 parent 530b8d1 commit 5a10d12
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 49 deletions.
8 changes: 7 additions & 1 deletion llvm/lib/Analysis/AliasSetTracker.cpp
Expand Up @@ -24,6 +24,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/AtomicOrdering.h"
Expand Down Expand Up @@ -169,7 +170,12 @@ void AliasSet::addUnknownInst(Instruction *I, AliasAnalysis &AA) {
addRef();
UnknownInsts.emplace_back(I);

if (!I->mayWriteToMemory()) {
// Guards are marked as modifying memory for control flow modelling purposes,
// but don't actually modify any specific memory location.
using namespace PatternMatch;
bool MayWriteMemory = I->mayWriteToMemory() &&
!match(I, m_Intrinsic<Intrinsic::experimental_guard>());
if (!MayWriteMemory) {
Alias = SetMayAlias;
Access |= RefAccess;
return;
Expand Down

0 comments on commit 5a10d12

Please sign in to comment.