Skip to content

Commit 87a63a6

Browse files
author
Cooper Partin
committed
Add cs4 test and updated logic to handle legacy pass manager
1 parent a3c0af0 commit 87a63a6

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ static void updateFlags(ComputedShaderFlags &Flags, const Instruction &I) {
4040
}
4141

4242
static void updateResourceFlags(ComputedShaderFlags &Flags, Module &M,
43-
ModuleAnalysisManager &AM) {
44-
const DXILResourceMap &DRM = AM.getResult<DXILResourceAnalysis>(M);
43+
ModuleAnalysisManager *AM) {
44+
if (!AM)
45+
return;
46+
47+
const DXILResourceMap &DRM = AM->getResult<DXILResourceAnalysis>(M);
4548
if (DRM.empty())
4649
return;
4750

48-
const dxil::ModuleMetadataInfo &MMDI = AM.getResult<DXILMetadataAnalysis>(M);
51+
const dxil::ModuleMetadataInfo &MMDI = AM->getResult<DXILMetadataAnalysis>(M);
4952
VersionTuple SM = MMDI.ShaderModelVersion;
5053
Triple::EnvironmentType SP = MMDI.ShaderProfile;
5154

@@ -71,7 +74,7 @@ static void updateResourceFlags(ComputedShaderFlags &Flags, Module &M,
7174
}
7275

7376
ComputedShaderFlags
74-
ComputedShaderFlags::computeFlags(Module &M, ModuleAnalysisManager &AM) {
77+
ComputedShaderFlags::computeFlags(Module &M, ModuleAnalysisManager *AM) {
7578
ComputedShaderFlags Flags;
7679
updateResourceFlags(Flags, M, AM);
7780

@@ -104,7 +107,7 @@ AnalysisKey ShaderFlagsAnalysis::Key;
104107

105108
ComputedShaderFlags ShaderFlagsAnalysis::run(Module &M,
106109
ModuleAnalysisManager &AM) {
107-
return ComputedShaderFlags::computeFlags(M, AM);
110+
return ComputedShaderFlags::computeFlags(M, &AM);
108111
}
109112

110113
PreservedAnalyses ShaderFlagsAnalysisPrinter::run(Module &M,

llvm/lib/Target/DirectX/DXILShaderFlags.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct ComputedShaderFlags {
6060
return FeatureFlags;
6161
}
6262

63-
static ComputedShaderFlags computeFlags(Module &M, ModuleAnalysisManager &AM);
63+
static ComputedShaderFlags computeFlags(Module &M, ModuleAnalysisManager *AM);
6464
void print(raw_ostream &OS = dbgs()) const;
6565
LLVM_DUMP_METHOD void dump() const { print(); }
6666
};
@@ -102,8 +102,7 @@ class ShaderFlagsAnalysisWrapper : public ModulePass {
102102
const ComputedShaderFlags &getShaderFlags() { return Flags; }
103103

104104
bool runOnModule(Module &M) override {
105-
auto AM = ModuleAnalysisManager();
106-
Flags = ComputedShaderFlags::computeFlags(M, AM);
105+
Flags = ComputedShaderFlags::computeFlags(M, nullptr);
107106
return false;
108107
}
109108

llvm/test/CodeGen/DirectX/ShaderFlags/buffers.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
22

3-
target triple = "dxil-pc-shadermodel6.7-library"
3+
target triple = "dxil-pc-shadermodel6.3-compute"
44

55
@G = external constant <4 x float>, align 4
66

@@ -11,9 +11,8 @@ define void @test_bufferflags() {
1111
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_i32_1_0t(
1212
i32 2, i32 7, i32 1, i32 0, i1 false)
1313

14-
; CHECK: ; Shader Flags Value: 0x00020010
14+
; CHECK: ; Shader Flags Value: 0x00000010
1515
; CHECK: ; Note: shader requires additional functionality:
16-
; CHECK-NEXT: ; Raw and Structured buffers
1716
; CHECK-NEXT: ; Note: extra DXIL module flags:
1817
; CHECK-NEXT: ; D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
1918
; CHECK-NEXT: {{^;$}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
2+
3+
target triple = "dxil-pc-shadermodel4.0-compute"
4+
5+
@G = external constant <4 x float>, align 4
6+
7+
define void @test_bufferflags() {
8+
9+
; RWBuffer<int> Buf : register(u7, space2)
10+
%uav0 = call target("dx.TypedBuffer", i32, 1, 0, 1)
11+
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_i32_1_0t(
12+
i32 2, i32 7, i32 1, i32 0, i1 false)
13+
14+
; CHECK: ; Shader Flags Value: 0x00020010
15+
; CHECK: ; Note: shader requires additional functionality:
16+
; CHECK-NEXT: ; Raw and Structured buffers
17+
; CHECK-NEXT: ; Note: extra DXIL module flags:
18+
; CHECK-NEXT: ; D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
19+
; CHECK-NEXT: {{^;$}}
20+
21+
ret void
22+
}
23+
24+
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }

0 commit comments

Comments
 (0)