Skip to content

Commit 18caac7

Browse files
committed
[AMDGPU] add ExpandFeaturePredicates pass to PB
This pass was added to pass builder by 8ea525f but got reverted by accident by 9e810ad. This causes any HIP program compiled with --offload-arch=amdgcnspirv to fail to run. This patch put ExpandFeaturePredicates pass back to PB. Also add it to LTO pipeline. Add a lit test to prevent future regressions. Fixes: SWDEV-533964
1 parent 9f3b05c commit 18caac7

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

clang/test/CodeGenHipStdPar/select-accelerator-code-pass-ordering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// HIPSTDPAR-PRE: Running pass: EntryExitInstrumenterPass
88
// HIPSTDPAR-PRE-NEXT: Running pass: EntryExitInstrumenterPass
99
// HIPSTDPAR-PRE-NOT: Running pass: HipStdParAcceleratorCodeSelectionPass
10+
// HIPSTDPAR-PRE-NEXT: Running pass: AMDGPUExpandFeaturePredicatesPass
1011
// HIPSTDPAR-PRE-NEXT: Running pass: AlwaysInlinerPass
1112

1213
// Ensure Pass HipStdParAcceleratorCodeSelectionPass is invoked in PostLink.

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,16 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
812812
#define GET_PASS_REGISTRY "AMDGPUPassRegistry.def"
813813
#include "llvm/Passes/TargetPassRegistry.inc"
814814

815+
PB.registerPipelineStartEPCallback(
816+
[this](ModulePassManager &PM, OptimizationLevel Level) {
817+
PM.addPass(AMDGPUExpandFeaturePredicatesPass(*this));
818+
});
819+
820+
PB.registerFullLinkTimeOptimizationEarlyEPCallback(
821+
[this](ModulePassManager &PM, OptimizationLevel Level) {
822+
PM.addPass(AMDGPUExpandFeaturePredicatesPass(*this));
823+
});
824+
815825
PB.registerScalarOptimizerLateEPCallback(
816826
[](FunctionPassManager &FPM, OptimizationLevel Level) {
817827
if (Level == OptimizationLevel::O0)

llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto<O1>" -print-pipeline-passes %s -o - | FileCheck %s
33
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto<O2>" -print-pipeline-passes %s -o - | FileCheck %s
44
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto<O3>" -print-pipeline-passes %s -o - | FileCheck %s
5+
; RUN: opt -mtriple=amdgcn--amdhsa -S -O0 -print-pipeline-passes %s -o - | FileCheck --check-prefix=O0 %s
6+
; RUN: opt -mtriple=amdgcn--amdhsa -S -O1 -print-pipeline-passes %s -o - | FileCheck %s
7+
; RUN: opt -mtriple=amdgcn--amdhsa -S -O2 -print-pipeline-passes %s -o - | FileCheck %s
8+
; RUN: opt -mtriple=amdgcn--amdhsa -S -O3 -print-pipeline-passes %s -o - | FileCheck %s
59

610
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto-pre-link<O0>" -print-pipeline-passes -amdgpu-internalize-symbols %s -o - | FileCheck --check-prefix=PRE %s
711
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto-pre-link<O1>" -print-pipeline-passes -amdgpu-internalize-symbols %s -o - | FileCheck --check-prefix=PRE %s
812
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto-pre-link<O2>" -print-pipeline-passes -amdgpu-internalize-symbols %s -o - | FileCheck --check-prefix=PRE %s
913
; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto-pre-link<O3>" -print-pipeline-passes -amdgpu-internalize-symbols %s -o - | FileCheck --check-prefix=PRE %s
1014

11-
15+
; CHECK: amdgpu-expand-feature-predicates
1216
; CHECK: amdgpu-attributor
17+
; O0: amdgpu-expand-feature-predicates
1318
; O0-NOT: amdgpu-attributor
1419

20+
; PRE: amdgpu-expand-feature-predicates
1521
; PRE-NOT: internalize
1622
; PRE-NOT: amdgpu-attributor
1723
; PRE-NOT: printfToRuntime

0 commit comments

Comments
 (0)