Skip to content

Commit 3d346c9

Browse files
author
joaosaffran
committed
fixing assert
1 parent 040d6d5 commit 3d346c9

File tree

5 files changed

+11
-27
lines changed

5 files changed

+11
-27
lines changed

llvm/lib/MC/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_llvm_component_library(LLVMMC
22
ConstantPools.cpp
33
DXContainerPSVInfo.cpp
4+
DXContainerRootSignature.cpp
45
ELFObjectWriter.cpp
56
GOFFObjectWriter.cpp
67
MCAsmBackend.cpp

llvm/lib/Target/DirectX/DXContainerGlobals.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "llvm/IR/Module.h"
2525
#include "llvm/InitializePasses.h"
2626
#include "llvm/MC/DXContainerPSVInfo.h"
27+
#include "llvm/MC/DXContainerRootSignature.h"
2728
#include "llvm/Pass.h"
2829
#include "llvm/Support/MD5.h"
2930
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -159,7 +160,11 @@ void DXContainerGlobals::addRootSignature(Module &M,
159160

160161
SmallString<256> Data;
161162
raw_svector_ostream OS(Data);
162-
MRS->write(OS);
163+
164+
RootSignatureHeader RSH;
165+
RSH.Flags = MRS->Flags;
166+
RSH.Version = MRS->Version;
167+
RSH.write(OS);
163168

164169
Constant *Constant =
165170
ConstantDataArray::getString(M.getContext(), Data, /*AddNull*/ false);

llvm/lib/Target/DirectX/DXILRootSignature.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static bool parseRootFlags(ModuleRootSignature *MRS, MDNode *RootFlagNode) {
3232

3333
// Root Element validation, as specified:
3434
// https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-during-dxil-generation
35-
assert((Value & ~0x80000fff) != 0 && "Invalid flag for RootFlag Element");
35+
assert((Value & ~0x80000fff) == 0 && "Invalid flag for RootFlag Element");
3636

3737
MRS->Flags = Value;
3838
return false;
@@ -99,17 +99,6 @@ bool ModuleRootSignature::parse(int32_t Version, NamedMDNode *Root) {
9999
return HasError;
100100
}
101101

102-
void ModuleRootSignature::write(raw_ostream &OS) {
103-
dxbc::RootSignatureDesc Out{this->Version, this->Flags};
104-
105-
if (sys::IsBigEndianHost) {
106-
Out.swapBytes();
107-
}
108-
109-
OS.write(reinterpret_cast<const char *>(&Out),
110-
sizeof(dxbc::RootSignatureDesc));
111-
}
112-
113102
AnalysisKey RootSignatureAnalysis::Key;
114103

115104
ModuleRootSignature RootSignatureAnalysis::run(Module &M,

llvm/lib/Target/DirectX/DXILRootSignature.h

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct ModuleRootSignature {
3636
ModuleRootSignature() = default;
3737

3838
bool parse(int32_t Version, NamedMDNode *Root);
39-
void write(raw_ostream &OS);
4039
};
4140

4241
class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> {

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll

+3-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
target triple = "dxil-unknown-shadermodel6.0-compute"
55

6-
; CHECK: @dx.rts0 = private constant [8 x i8] c"{{.*}}", section "RTS0", align 4
6+
; CHECK: @dx.rts0 = private constant [12 x i8] c"{{.*}}", section "RTS0", align 4
77

88

99
define void @main() #0 {
@@ -21,18 +21,8 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
2121

2222

2323
; DXC: - Name: RTS0
24-
; DXC-NEXT: Size: 8
24+
; DXC-NEXT: Size: 12
2525
; DXC-NEXT: RootSignature:
26+
; DXC-NEXT: Size: 8
2627
; DXC-NEXT: Version: 1
2728
; DXC-NEXT: AllowInputAssemblerInputLayout: true
28-
; DXC-NEXT: DenyVertexShaderRootAccess: false
29-
; DXC-NEXT: DenyHullShaderRootAccess: false
30-
; DXC-NEXT: DenyDomainShaderRootAccess: false
31-
; DXC-NEXT: DenyGeometryShaderRootAccess: false
32-
; DXC-NEXT: DenyPixelShaderRootAccess: false
33-
; DXC-NEXT: AllowStreamOutput: false
34-
; DXC-NEXT: LocalRootSignature: false
35-
; DXC-NEXT: DenyAmplificationShaderRootAccess: false
36-
; DXC-NEXT: DenyMeshShaderRootAccess: false
37-
; DXC-NEXT: CBVSRVUAVHeapDirectlyIndexed: false
38-
; DXC-NEXT: SamplerHeapDirectlyIndexed: false

0 commit comments

Comments
 (0)