Skip to content

Commit

Permalink
AMDGPU/R600: Fix amdgpu alias analysis pass.
Browse files Browse the repository at this point in the history
R600 uses higher AS number to access kernel parameters

Fixes: r298846
Differential Revision: https://reviews.llvm.org/D31520

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299245 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
jvesely committed Mar 31, 2017
1 parent a694469 commit 1abd9ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void AMDGPUAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
}

// Must match the table in getAliasResult.
AMDGPUAAResult::ASAliasRulesTy::ASAliasRulesTy(AMDGPUAS AS_) : AS(AS_) {
AMDGPUAAResult::ASAliasRulesTy::ASAliasRulesTy(AMDGPUAS AS_, Triple::ArchType Arch_)
: Arch(Arch_), AS(AS_) {
// These arrarys are indexed by address space value
// enum elements 0 ... to 5
static const AliasResult ASAliasRulesPrivIsZero[6][6] = {
Expand Down Expand Up @@ -80,8 +81,12 @@ AMDGPUAAResult::ASAliasRulesTy::ASAliasRulesTy(AMDGPUAS AS_) : AS(AS_) {

AliasResult AMDGPUAAResult::ASAliasRulesTy::getAliasResult(unsigned AS1,
unsigned AS2) const {
if (AS1 > AS.MAX_COMMON_ADDRESS || AS2 > AS.MAX_COMMON_ADDRESS)
report_fatal_error("Pointer address space out of range");
if (AS1 > AS.MAX_COMMON_ADDRESS || AS2 > AS.MAX_COMMON_ADDRESS) {
if (Arch == Triple::amdgcn)
report_fatal_error("Pointer address space out of range");
return AS1 == AS2 ? MayAlias : NoAlias;
}

return (*ASAliasRules)[AS1][AS2];
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Target/AMDGPU/AMDGPUAliasAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {

public:
explicit AMDGPUAAResult(const DataLayout &DL, Triple T) : AAResultBase(),
DL(DL), AS(AMDGPU::getAMDGPUAS(T)), ASAliasRules(AS) {}
DL(DL), AS(AMDGPU::getAMDGPUAS(T)), ASAliasRules(AS, T.getArch()) {}
AMDGPUAAResult(AMDGPUAAResult &&Arg)
: AAResultBase(std::move(Arg)), DL(Arg.DL), AS(Arg.AS),
ASAliasRules(Arg.ASAliasRules){}
Expand All @@ -49,9 +49,10 @@ class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {

class ASAliasRulesTy {
public:
ASAliasRulesTy(AMDGPUAS AS_);
ASAliasRulesTy(AMDGPUAS AS_, Triple::ArchType Arch_);
AliasResult getAliasResult(unsigned AS1, unsigned AS2) const;
private:
Triple::ArchType Arch;
AMDGPUAS AS;
const AliasResult (*ASAliasRules)[6][6];
} ASAliasRules;
Expand Down
1 change: 1 addition & 0 deletions test/CodeGen/AMDGPU/amdgpu-alias-analysis.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -mtriple=amdgcn-- -O3 -aa-eval -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s
; RUN: opt -mtriple=r600-- -O3 -aa-eval -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s

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

Expand Down
7 changes: 7 additions & 0 deletions test/CodeGen/AMDGPU/r600.amdgpu-alias-analysis.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; RUN: opt -mtriple=r600-- -O3 -aa-eval -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s

; CHECK: NoAlias: i8 addrspace(7)* %p1, i8* %p

define amdgpu_kernel void @test(i8* %p, i8 addrspace(7)* %p1) {
ret void
}

0 comments on commit 1abd9ec

Please sign in to comment.