Skip to content

[MemDep] Use EarliestEscapeInfo #69727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerSumType.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PredIteratorCache.h"
Expand All @@ -27,7 +28,6 @@

namespace llvm {

class AAResults;
class AssumptionCache;
class BatchAAResults;
class DominatorTree;
Expand Down Expand Up @@ -356,6 +356,7 @@ class MemoryDependenceResults {
const TargetLibraryInfo &TLI;
DominatorTree &DT;
PredIteratorCache PredCache;
EarliestEscapeInfo EII;

unsigned DefaultBlockScanLimit;

Expand All @@ -367,7 +368,7 @@ class MemoryDependenceResults {
MemoryDependenceResults(AAResults &AA, AssumptionCache &AC,
const TargetLibraryInfo &TLI, DominatorTree &DT,
unsigned DefaultBlockScanLimit)
: AA(AA), AC(AC), TLI(TLI), DT(DT),
: AA(AA), AC(AC), TLI(TLI), DT(DT), EII(DT),
DefaultBlockScanLimit(DefaultBlockScanLimit) {}

/// Handle invalidation in the new PM.
Expand Down
12 changes: 5 additions & 7 deletions llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit) {
BatchAAResults BatchAA(AA);
BatchAAResults BatchAA(AA, &EII);
return getPointerDependencyFrom(MemLoc, isLoad, ScanIt, BB, QueryInst, Limit,
BatchAA);
}
Expand Down Expand Up @@ -645,11 +645,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
continue;

// See if this instruction (e.g. a call or vaarg) mod/ref's the pointer.
ModRefInfo MR = BatchAA.getModRefInfo(Inst, MemLoc);
// If necessary, perform additional analysis.
if (isModAndRefSet(MR))
MR = BatchAA.callCapturesBefore(Inst, MemLoc, &DT);
switch (MR) {
switch (BatchAA.getModRefInfo(Inst, MemLoc)) {
case ModRefInfo::NoModRef:
// If the call has no effect on the queried pointer, just ignore it.
continue;
Expand Down Expand Up @@ -1227,7 +1223,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
bool GotWorklistLimit = false;
LLVM_DEBUG(AssertSorted(*Cache));

BatchAAResults BatchAA(AA);
BatchAAResults BatchAA(AA, &EII);
while (!Worklist.empty()) {
BasicBlock *BB = Worklist.pop_back_val();

Expand Down Expand Up @@ -1539,6 +1535,8 @@ void MemoryDependenceResults::invalidateCachedPredecessors() {
}

void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
EII.removeInstruction(RemInst);

// Walk through the Non-local dependencies, removing this one as the value
// for any cached queries.
NonLocalDepMapType::iterator NLDI = NonLocalDepsMap.find(RemInst);
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/BPF/CORE/no-narrow-load.ll
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ lor.end: ; preds = %lor.end.critedge, %
ret void, !dbg !53
}

; CHECK: r[[LOAD1:[0-9]+]] = *(u32 *)(r{{[0-9]+}} + 4)
; CHECK: r[[LOAD1]] &= 65536
; CHECK: r[[LOAD2:[0-9]+]] = *(u32 *)(r{{[0-9]+}} + 4)
; CHECK: r[[LOAD2]] &= 32768
; CHECK: r[[LOAD:[0-9]+]] = *(u32 *)(r{{[0-9]+}} + 4)
; CHECK: r[[COPY:[0-9]+]] = r[[LOAD]]
; CHECK: r[[COPY]] &= 65536
; CHECK: r[[LOAD]] &= 32768

; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/Transforms/GVN/captured-before.ll
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ define i32 @test_store_before_capture(ptr %p) {
; CHECK-NEXT: store i32 123, ptr [[A]], align 4
; CHECK-NEXT: [[P2:%.*]] = load ptr, ptr [[P]], align 8
; CHECK-NEXT: store i32 42, ptr [[P2]], align 4
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
; CHECK-NEXT: call void @capture(ptr [[A]])
; CHECK-NEXT: ret i32 [[V]]
; CHECK-NEXT: ret i32 123
;
%a = alloca i32
store i32 123, ptr %a
Expand Down