Skip to content

Commit

Permalink
Improve MemoryEffect check
Browse files Browse the repository at this point in the history
  • Loading branch information
spavloff committed Jan 15, 2025
1 parent 72d83be commit 9eaaba9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions llvm/include/llvm/Support/ModRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ template <typename LocationEnum> class MemoryEffectsBase {
return getWithoutLoc(Location::InaccessibleMem).doesNotAccessMemory();
}

bool doesAccessInaccessibleMem() const {
return isModOrRefSet(getModRef(Location::InaccessibleMem));
}

/// Whether this function only (at most) accesses argument and inaccessible
/// memory.
bool onlyAccessesInaccessibleOrArgMem() const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/IntrinsicInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID IID) {
bool IntrinsicInst::canAccessFPEnvironment(LLVMContext &C, Intrinsic::ID IID) {
AttributeList Attrs = Intrinsic::getAttributes(C, IID);
MemoryEffects ME = Attrs.getMemoryEffects();
return ME.onlyAccessesInaccessibleMem();
return ME.doesAccessInaccessibleMem();
}

//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 9eaaba9

Please sign in to comment.