Skip to content

Commit 1915523

Browse files
committed
[NewPM][AMDGPU] Make amdgpu-aa work with NewPM
An AMDGPUAA class already existed that was supposed to work with the new PM, but it wasn't tested and was a bit broken. Fix up the existing classes to have the right keys/parameters. Wire up AMDGPUAA inside AMDGPUTargetMachine. Add it to the list of alias analyses for the "default" AAManager since in adjustPassManager() amdgpu-aa is added into the pipeline at the beginning. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D93914
1 parent 4e838ba commit 1915523

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ using namespace llvm;
3232

3333
#define DEBUG_TYPE "amdgpu-aa"
3434

35+
AnalysisKey AMDGPUAA::Key;
36+
3537
// Register this pass...
3638
char AMDGPUAAWrapperPass::ID = 0;
3739
char AMDGPUExternalAAWrapper::ID = 0;

llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {
4242
/// Handle invalidation events from the new pass manager.
4343
///
4444
/// By definition, this result is stateless and so remains valid.
45-
bool invalidate(Function &, const PreservedAnalyses &) { return false; }
45+
bool invalidate(Function &, const PreservedAnalyses &,
46+
FunctionAnalysisManager::Invalidator &Inv) {
47+
return false;
48+
}
4649

4750
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
4851
AAQueryInfo &AAQI);
@@ -54,7 +57,7 @@ class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {
5457
class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
5558
friend AnalysisInfoMixin<AMDGPUAA>;
5659

57-
static char PassID;
60+
static AnalysisKey Key;
5861

5962
public:
6063
using Result = AMDGPUAAResult;

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
489489
});
490490
}
491491

492+
void AMDGPUTargetMachine::registerAliasAnalyses(AAManager &AAM) {
493+
AAM.registerFunctionAnalysis<AMDGPUAA>();
494+
}
495+
492496
void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
493497
bool DebugPassManager) {
494498
PB.registerPipelineParsingCallback(
@@ -543,6 +547,18 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
543547
return false;
544548
});
545549

550+
PB.registerAnalysisRegistrationCallback([](FunctionAnalysisManager &FAM) {
551+
FAM.registerPass([&] { return AMDGPUAA(); });
552+
});
553+
554+
PB.registerParseAACallback([](StringRef AAName, AAManager &AAM) {
555+
if (AAName == "amdgpu-aa") {
556+
AAM.registerFunctionAnalysis<AMDGPUAA>();
557+
return true;
558+
}
559+
return false;
560+
});
561+
546562
PB.registerPipelineStartEPCallback([this, DebugPassManager](
547563
ModulePassManager &PM,
548564
PassBuilder::OptimizationLevel Level) {

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class AMDGPUTargetMachine : public LLVMTargetMachine {
5858

5959
void registerPassBuilderCallbacks(PassBuilder &PB,
6060
bool DebugPassManager) override;
61+
void registerAliasAnalyses(AAManager &) override;
6162

6263
/// Get the integer value of a null pointer in the given address space.
6364
static int64_t getNullPointerValue(unsigned AddrSpace) {

llvm/test/CodeGen/AMDGPU/amdgpu-alias-analysis.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt -mtriple=amdgcn-- -data-layout=A5 -aa-eval -amdgpu-aa -amdgpu-aa-wrapper -disable-basic-aa -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s
22
; RUN: opt -mtriple=r600-- -data-layout=A5 -aa-eval -amdgpu-aa -amdgpu-aa-wrapper -disable-basic-aa -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s
3+
; RUN: opt -mtriple=amdgcn-- -data-layout=A5 -passes=aa-eval -aa-pipeline=amdgpu-aa -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s
4+
; RUN: opt -mtriple=r600-- -data-layout=A5 -passes=aa-eval -aa-pipeline=amdgpu-aa -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s
35

46
; CHECK: NoAlias: i8 addrspace(1)* %p1, i8 addrspace(5)* %p
57

0 commit comments

Comments
 (0)