Skip to content

Commit 3266a87

Browse files
authored
[NFC] Remove SAL annotations from internal APIs (#5639)
We don't keep these annotations up to date or rely on them, so to simplify our platform layering and ease code formatting this change removes all the SAL annotations from internal APIs. This change also replaces most `_Analysis_Assme_(...)` annotations with `assert(...)`. One `_Analysis_Assume_` in ParseDecl.cpp needed to be updated because it was incorrect. The code was `_Analysis_Assume_(assert(name.size() > sizeof("space"));`. When converted to an `assert` it fired in our test suite because the sizeof a string literal includes the null terminator, but the size of a StringRef does not. A few of the `_Analysis_Assume_` annotations were removed because they didn't make sense (like the ones inside the `DXASSERT` implementation, and a few others were removed to avoid introducing additional header or linkage dependencies. This change does not introduce any functional or behavioral changes.
1 parent d2882d8 commit 3266a87

File tree

170 files changed

+3714
-4522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+3714
-4522
lines changed

include/dxc/DxilContainer/DxcContainerBuilder.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ namespace hlsl {
2525

2626
class DxcContainerBuilder : public IDxcContainerBuilder {
2727
public:
28-
HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pDxilContainerHeader) override; // Loads DxilContainer to the builder
29-
HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) override; // Add the given part with fourCC
30-
HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) override; // Remove the part with fourCC
31-
HRESULT STDMETHODCALLTYPE SerializeContainer(_Out_ IDxcOperationResult **ppResult) override; // Builds a container of the given container builder state
28+
// Loads DxilContainer to the builder
29+
HRESULT STDMETHODCALLTYPE Load(IDxcBlob *pDxilContainerHeader) override;
30+
// Add the given part with fourCC
31+
HRESULT STDMETHODCALLTYPE AddPart(UINT32 fourCC, IDxcBlob *pSource) override;
32+
// Remove the part with fourCC
33+
HRESULT STDMETHODCALLTYPE RemovePart(UINT32 fourCC) override;
34+
// Builds a container of the given container builder state
35+
HRESULT STDMETHODCALLTYPE
36+
SerializeContainer(IDxcOperationResult **ppResult) override;
3237

3338
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
3439
DXC_MICROCOM_TM_CTOR(DxcContainerBuilder)
@@ -65,4 +70,4 @@ class DxcContainerBuilder : public IDxcContainerBuilder {
6570
HRESULT UpdateOffsetTable(AbstractMemoryStream *pStream);
6671
HRESULT UpdateParts(AbstractMemoryStream *pStream);
6772
void AddPart(DxilPart&& part);
68-
};
73+
};

include/dxc/DxilContainer/DxilContainer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ const DxilProgramHeader *
444444
GetDxilProgramHeader(const DxilContainerHeader *pHeader, DxilFourCC fourCC);
445445

446446
/// Initializes container with the specified values.
447-
void InitDxilContainer(_Out_ DxilContainerHeader *pHeader, uint32_t partCount,
447+
void InitDxilContainer(DxilContainerHeader *pHeader, uint32_t partCount,
448448
uint32_t containerSizeInBytes);
449449

450450
/// Checks whether pHeader claims by signature to be a DXIL container
@@ -587,7 +587,8 @@ inline bool IsDxilShaderDebugNameValid(const DxilPartHeader *pPart) {
587587
}
588588

589589
inline bool GetDxilShaderDebugName(const DxilPartHeader *pDebugNamePart,
590-
const char **ppUtf8Name, _Out_opt_ uint16_t *pUtf8NameLen) {
590+
const char **ppUtf8Name,
591+
uint16_t *pUtf8NameLen) {
591592
*ppUtf8Name = nullptr;
592593
if (!IsDxilShaderDebugNameValid(pDebugNamePart)) {
593594
return false;
@@ -627,7 +628,7 @@ inline SerializeDxilFlags operator~(SerializeDxilFlags l) {
627628
void CreateDxcContainerReflection(IDxcContainerReflection **ppResult);
628629

629630
// Converts uint32_t partKind to char array object.
630-
inline char * PartKindToCharArray(uint32_t partKind, _Out_writes_(5) char* pText) {
631+
inline char *PartKindToCharArray(uint32_t partKind, char *pText) {
631632
pText[0] = (char)((partKind & 0x000000FF) >> 0);
632633
pText[1] = (char)((partKind & 0x0000FF00) >> 8);
633634
pText[2] = (char)((partKind & 0x00FF0000) >> 16);

include/dxc/DxilContainer/DxilContainerReader.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ namespace hlsl {
5151
// Minor = DXBC_MAJOR_VERSION
5252
//
5353
// Returns S_OK or E_FAIL
54-
HRESULT Load(_In_ const void* pContainer, _In_ uint32_t containerSizeInBytes);
54+
HRESULT Load(const void *pContainer, uint32_t containerSizeInBytes);
5555

56-
HRESULT GetVersion(_Out_ DxilContainerVersion *pResult);
57-
HRESULT GetPartCount(_Out_ uint32_t *pResult);
58-
HRESULT GetPartContent(uint32_t idx, _Outptr_ const void **ppResult, _Out_ uint32_t *pResultSize = nullptr);
59-
HRESULT GetPartFourCC(uint32_t idx, _Out_ uint32_t *pResult);
60-
HRESULT FindFirstPartKind(uint32_t kind, _Out_ uint32_t *pResult);
56+
HRESULT GetVersion(DxilContainerVersion *pResult);
57+
HRESULT GetPartCount(uint32_t *pResult);
58+
HRESULT GetPartContent(uint32_t idx, const void **ppResult,
59+
uint32_t *pResultSize = nullptr);
60+
HRESULT GetPartFourCC(uint32_t idx, uint32_t *pResult);
61+
HRESULT FindFirstPartKind(uint32_t kind, uint32_t *pResult);
6162

6263
private:
6364
const void* m_pContainer = nullptr;

include/dxc/DxilContainer/DxilPipelineStateValidation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct PSVStringTable {
194194
PSVStringTable() : Table(nullptr), Size(0) {}
195195
PSVStringTable(const char *table, uint32_t size) : Table(table), Size(size) {}
196196
const char *Get(uint32_t offset) const {
197-
_Analysis_assume_(offset < Size && Table && Table[Size-1] == '\0');
197+
assert(offset < Size && Table && Table[Size - 1] == '\0');
198198
return Table + offset;
199199
}
200200
};
@@ -279,7 +279,7 @@ struct PSVSemanticIndexTable {
279279
PSVSemanticIndexTable() : Table(nullptr), Entries(0) {}
280280
PSVSemanticIndexTable(const uint32_t *table, uint32_t entries) : Table(table), Entries(entries) {}
281281
const uint32_t *Get(uint32_t offset) const {
282-
_Analysis_assume_(offset < Entries && Table);
282+
assert(offset < Entries && Table);
283283
return Table + offset;
284284
}
285285
};
@@ -526,7 +526,7 @@ class DxilPipelineStateValidation
526526
_T *GetRecord(void *pRecords, uint32_t recordSize, uint32_t numRecords,
527527
uint32_t index) const {
528528
if (pRecords && index < numRecords && sizeof(_T) <= recordSize) {
529-
__analysis_assume((size_t)index * (size_t)recordSize <= UINT_MAX);
529+
assert((size_t)index * (size_t)recordSize <= UINT_MAX);
530530
return reinterpret_cast<_T *>(reinterpret_cast<uint8_t *>(pRecords) +
531531
(index * recordSize));
532532
}

include/dxc/DxilContainer/DxilRuntimeReflection.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ class StringTableReader {
203203
m_size = size;
204204
}
205205
const char *Get(uint32_t offset) const {
206-
_Analysis_assume_(offset < m_size && m_table &&
207-
m_table[m_size - 1] == '\0');
208206
(void)m_size; // avoid unused private warning if use above is ignored.
209207
return m_table + offset;
210208
}
@@ -224,8 +222,6 @@ class RawBytesReader {
224222
}
225223
uint32_t Size() const { return m_size; }
226224
const void *Get(uint32_t offset) const {
227-
_Analysis_assume_(offset < m_size && m_table);
228-
(void)m_size; // avoid unused private warning if use above is ignored.
229225
return (const void*)(((const char*)m_table) + offset);
230226
}
231227
};

include/dxc/DxilRootSignature/DxilRootSignature.h

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ struct DxilDescriptorRange {
245245
};
246246
struct DxilRootDescriptorTable {
247247
uint32_t NumDescriptorRanges;
248-
_Field_size_full_(NumDescriptorRanges) DxilDescriptorRange *pDescriptorRanges;
248+
DxilDescriptorRange *pDescriptorRanges;
249249
};
250250
struct DxilRootConstants {
251251
uint32_t ShaderRegister;
@@ -280,7 +280,7 @@ struct DxilDescriptorRange1 {
280280
};
281281
struct DxilRootDescriptorTable1 {
282282
uint32_t NumDescriptorRanges;
283-
_Field_size_full_(NumDescriptorRanges) DxilDescriptorRange1 *pDescriptorRanges;
283+
DxilDescriptorRange1 *pDescriptorRanges;
284284
};
285285
struct DxilRootParameter1 {
286286
DxilRootParameterType ParameterType;
@@ -293,9 +293,9 @@ struct DxilRootParameter1 {
293293
};
294294
struct DxilRootSignatureDesc {
295295
uint32_t NumParameters;
296-
_Field_size_full_(NumParameters) DxilRootParameter *pParameters;
296+
DxilRootParameter *pParameters;
297297
uint32_t NumStaticSamplers;
298-
_Field_size_full_(NumStaticSamplers) DxilStaticSamplerDesc *pStaticSamplers;
298+
DxilStaticSamplerDesc *pStaticSamplers;
299299
DxilRootSignatureFlags Flags;
300300
};
301301
struct DxilStaticSamplerDesc {
@@ -315,9 +315,9 @@ struct DxilStaticSamplerDesc {
315315
};
316316
struct DxilRootSignatureDesc1 {
317317
uint32_t NumParameters;
318-
_Field_size_full_(NumParameters) DxilRootParameter1 *pParameters;
318+
DxilRootParameter1 *pParameters;
319319
uint32_t NumStaticSamplers;
320-
_Field_size_full_(NumStaticSamplers) DxilStaticSamplerDesc *pStaticSamplers;
320+
DxilStaticSamplerDesc *pStaticSamplers;
321321
DxilRootSignatureFlags Flags;
322322
};
323323
struct DxilVersionedRootSignatureDesc {
@@ -365,25 +365,23 @@ void ConvertRootSignature(const DxilVersionedRootSignatureDesc* pRootSignatureIn
365365
DxilRootSignatureVersion RootSignatureVersionOut,
366366
const DxilVersionedRootSignatureDesc ** ppRootSignatureOut);
367367

368-
void SerializeRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature,
369-
_Outptr_ IDxcBlob **ppBlob, _Outptr_ IDxcBlobEncoding **ppErrorBlob,
370-
bool bAllowReservedRegisterSpace);
368+
void SerializeRootSignature(
369+
const DxilVersionedRootSignatureDesc *pRootSignature, IDxcBlob **ppBlob,
370+
IDxcBlobEncoding **ppErrorBlob, bool bAllowReservedRegisterSpace);
371371

372-
void DeserializeRootSignature(_In_reads_bytes_(SrcDataSizeInBytes) const void *pSrcData,
373-
_In_ uint32_t SrcDataSizeInBytes,
374-
_Out_ const DxilVersionedRootSignatureDesc **ppRootSignature);
372+
void DeserializeRootSignature(
373+
const void *pSrcData, uint32_t SrcDataSizeInBytes,
374+
const DxilVersionedRootSignatureDesc **ppRootSignature);
375375

376376
// Takes PSV - pipeline state validation data, not shader container.
377-
bool VerifyRootSignatureWithShaderPSV(_In_ const DxilVersionedRootSignatureDesc *pDesc,
378-
_In_ DXIL::ShaderKind ShaderKind,
379-
_In_reads_bytes_(PSVSize) const void *pPSVData,
380-
_In_ uint32_t PSVSize,
381-
_In_ llvm::raw_ostream &DiagStream);
377+
bool VerifyRootSignatureWithShaderPSV(
378+
const DxilVersionedRootSignatureDesc *pDesc, DXIL::ShaderKind ShaderKind,
379+
const void *pPSVData, uint32_t PSVSize, llvm::raw_ostream &DiagStream);
382380

383381
// standalone verification
384-
bool VerifyRootSignature(_In_ const DxilVersionedRootSignatureDesc *pDesc,
385-
_In_ llvm::raw_ostream &DiagStream,
386-
_In_ bool bAllowReservedRegisterSpace);
382+
bool VerifyRootSignature(const DxilVersionedRootSignatureDesc *pDesc,
383+
llvm::raw_ostream &DiagStream,
384+
bool bAllowReservedRegisterSpace);
387385

388386
class DxilVersionedRootSignature {
389387
DxilVersionedRootSignatureDesc *m_pRootSignature;

include/dxc/HLSL/DxilValidation.h

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,77 +29,66 @@ namespace hlsl {
2929
#include "dxc/HLSL/DxilValidation.inc"
3030

3131
const char *GetValidationRuleText(ValidationRule value);
32-
void GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor);
33-
HRESULT ValidateDxilModule(_In_ llvm::Module *pModule,
34-
_In_opt_ llvm::Module *pDebugModule);
32+
void GetValidationVersion(unsigned *pMajor, unsigned *pMinor);
33+
HRESULT ValidateDxilModule(llvm::Module *pModule, llvm::Module *pDebugModule);
3534

3635
// DXIL Container Verification Functions (return false on failure)
3736

38-
bool VerifySignatureMatches(_In_ llvm::Module *pModule,
37+
bool VerifySignatureMatches(llvm::Module *pModule,
3938
hlsl::DXIL::SignatureKind SigKind,
40-
_In_reads_bytes_(SigSize) const void *pSigData,
41-
_In_ uint32_t SigSize);
39+
const void *pSigData, uint32_t SigSize);
4240

4341
// PSV = data for Pipeline State Validation
44-
bool VerifyPSVMatches(_In_ llvm::Module *pModule,
45-
_In_reads_bytes_(PSVSize) const void *pPSVData,
46-
_In_ uint32_t PSVSize);
42+
bool VerifyPSVMatches(llvm::Module *pModule, const void *pPSVData,
43+
uint32_t PSVSize);
4744

4845
// PSV = data for Pipeline State Validation
49-
bool VerifyRDATMatches(_In_ llvm::Module *pModule,
50-
_In_reads_bytes_(RDATSize) const void *pRDATData,
51-
_In_ uint32_t RDATSize);
46+
bool VerifyRDATMatches(llvm::Module *pModule, const void *pRDATData,
47+
uint32_t RDATSize);
5248

53-
bool VerifyFeatureInfoMatches(_In_ llvm::Module *pModule,
54-
_In_reads_bytes_(FeatureInfoSize) const void *pFeatureInfoData,
55-
_In_ uint32_t FeatureInfoSize);
49+
bool VerifyFeatureInfoMatches(llvm::Module *pModule,
50+
const void *pFeatureInfoData,
51+
uint32_t FeatureInfoSize);
5652

5753
// Validate the container parts, assuming supplied module is valid, loaded from the container provided
5854
struct DxilContainerHeader;
59-
HRESULT ValidateDxilContainerParts(_In_ llvm::Module *pModule,
60-
_In_opt_ llvm::Module *pDebugModule,
61-
_In_reads_bytes_(ContainerSize) const DxilContainerHeader *pContainer,
62-
_In_ uint32_t ContainerSize);
55+
HRESULT ValidateDxilContainerParts(llvm::Module *pModule,
56+
llvm::Module *pDebugModule,
57+
const DxilContainerHeader *pContainer,
58+
uint32_t ContainerSize);
6359

6460
// Loads module, validating load, but not module.
65-
HRESULT ValidateLoadModule(_In_reads_bytes_(ILLength) const char *pIL,
66-
_In_ uint32_t ILLength,
67-
_In_ std::unique_ptr<llvm::Module> &pModule,
68-
_In_ llvm::LLVMContext &Ctx,
69-
_In_ llvm::raw_ostream &DiagStream,
70-
_In_ unsigned bLazyLoad);
61+
HRESULT ValidateLoadModule(const char *pIL, uint32_t ILLength,
62+
std::unique_ptr<llvm::Module> &pModule,
63+
llvm::LLVMContext &Ctx,
64+
llvm::raw_ostream &DiagStream, unsigned bLazyLoad);
7165

7266
// Loads module from container, validating load, but not module.
7367
HRESULT ValidateLoadModuleFromContainer(
74-
_In_reads_bytes_(ContainerSize) const void *pContainer,
75-
_In_ uint32_t ContainerSize, _In_ std::unique_ptr<llvm::Module> &pModule,
76-
_In_ std::unique_ptr<llvm::Module> &pDebugModule,
77-
_In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx,
78-
_In_ llvm::raw_ostream &DiagStream);
68+
const void *pContainer, uint32_t ContainerSize,
69+
std::unique_ptr<llvm::Module> &pModule,
70+
std::unique_ptr<llvm::Module> &pDebugModule, llvm::LLVMContext &Ctx,
71+
llvm::LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream);
7972
// Lazy loads module from container, validating load, but not module.
8073
HRESULT ValidateLoadModuleFromContainerLazy(
81-
_In_reads_bytes_(ContainerSize) const void *pContainer,
82-
_In_ uint32_t ContainerSize, _In_ std::unique_ptr<llvm::Module> &pModule,
83-
_In_ std::unique_ptr<llvm::Module> &pDebugModule,
84-
_In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx,
85-
_In_ llvm::raw_ostream &DiagStream);
74+
const void *pContainer, uint32_t ContainerSize,
75+
std::unique_ptr<llvm::Module> &pModule,
76+
std::unique_ptr<llvm::Module> &pDebugModule, llvm::LLVMContext &Ctx,
77+
llvm::LLVMContext &DbgCtx, llvm::raw_ostream &DiagStream);
8678

8779
// Load and validate Dxil module from bitcode.
88-
HRESULT ValidateDxilBitcode(_In_reads_bytes_(ILLength) const char *pIL,
89-
_In_ uint32_t ILLength,
90-
_In_ llvm::raw_ostream &DiagStream);
80+
HRESULT ValidateDxilBitcode(const char *pIL, uint32_t ILLength,
81+
llvm::raw_ostream &DiagStream);
9182

9283
// Full container validation, including ValidateDxilModule
93-
HRESULT ValidateDxilContainer(_In_reads_bytes_(ContainerSize) const void *pContainer,
94-
_In_ uint32_t ContainerSize,
95-
_In_ llvm::raw_ostream &DiagStream);
84+
HRESULT ValidateDxilContainer(const void *pContainer, uint32_t ContainerSize,
85+
llvm::raw_ostream &DiagStream);
9686

9787
// Full container validation, including ValidateDxilModule, with debug module
98-
HRESULT ValidateDxilContainer(_In_reads_bytes_(ContainerSize) const void *pContainer,
99-
_In_ uint32_t ContainerSize,
88+
HRESULT ValidateDxilContainer(const void *pContainer, uint32_t ContainerSize,
10089
const void *pOptDebugBitcode,
10190
uint32_t OptDebugBitcodeSize,
102-
_In_ llvm::raw_ostream &DiagStream);
91+
llvm::raw_ostream &DiagStream);
10392

10493
class PrintDiagnosticContext {
10594
private:

0 commit comments

Comments
 (0)