Skip to content

Commit c22171f

Browse files
authored
Revert "[DXIL][Analysis] Make alignment on StructuredBuffer optional" (llvm#101088)
Seeing build failures, reverting to investigate. Reverts llvm#100697
1 parent a94edb6 commit c22171f

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

llvm/include/llvm/Analysis/DXILResource.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ResourceInfo {
4747

4848
struct StructInfo {
4949
uint32_t Stride;
50-
MaybeAlign Alignment;
50+
Align Alignment;
5151

5252
bool operator==(const StructInfo &RHS) const {
5353
return std::tie(Stride, Alignment) == std::tie(RHS.Stride, RHS.Alignment);
@@ -138,7 +138,7 @@ class ResourceInfo {
138138
CBufferSize = Size;
139139
}
140140
void setSampler(dxil::SamplerType Ty) { SamplerTy = Ty; }
141-
void setStruct(uint32_t Stride, MaybeAlign Alignment) {
141+
void setStruct(uint32_t Stride, Align Alignment) {
142142
assert(isStruct() && "Not a Struct");
143143
Struct.Stride = Stride;
144144
Struct.Alignment = Alignment;
@@ -164,7 +164,7 @@ class ResourceInfo {
164164
dxil::ResourceKind Kind);
165165
static ResourceInfo RawBuffer(Value *Symbol, StringRef Name);
166166
static ResourceInfo StructuredBuffer(Value *Symbol, StringRef Name,
167-
uint32_t Stride, MaybeAlign Alignment);
167+
uint32_t Stride, Align Alignment);
168168
static ResourceInfo Texture2DMS(Value *Symbol, StringRef Name,
169169
dxil::ElementType ElementTy,
170170
uint32_t ElementCount, uint32_t SampleCount);
@@ -180,9 +180,9 @@ class ResourceInfo {
180180
static ResourceInfo RWRawBuffer(Value *Symbol, StringRef Name,
181181
bool GloballyCoherent, bool IsROV);
182182
static ResourceInfo RWStructuredBuffer(Value *Symbol, StringRef Name,
183-
uint32_t Stride, MaybeAlign Alignment,
184-
bool GloballyCoherent, bool IsROV,
185-
bool HasCounter);
183+
uint32_t Stride,
184+
Align Alignment, bool GloballyCoherent,
185+
bool IsROV, bool HasCounter);
186186
static ResourceInfo RWTexture2DMS(Value *Symbol, StringRef Name,
187187
dxil::ElementType ElementTy,
188188
uint32_t ElementCount, uint32_t SampleCount,

llvm/lib/Analysis/DXILResource.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ ResourceInfo ResourceInfo::RawBuffer(Value *Symbol, StringRef Name) {
7979
}
8080

8181
ResourceInfo ResourceInfo::StructuredBuffer(Value *Symbol, StringRef Name,
82-
uint32_t Stride,
83-
MaybeAlign Alignment) {
82+
uint32_t Stride, Align Alignment) {
8483
ResourceInfo RI(ResourceClass::SRV, ResourceKind::StructuredBuffer, Symbol,
8584
Name);
8685
RI.setStruct(Stride, Alignment);
@@ -128,8 +127,7 @@ ResourceInfo ResourceInfo::RWRawBuffer(Value *Symbol, StringRef Name,
128127
}
129128

130129
ResourceInfo ResourceInfo::RWStructuredBuffer(Value *Symbol, StringRef Name,
131-
uint32_t Stride,
132-
MaybeAlign Alignment,
130+
uint32_t Stride, Align Alignment,
133131
bool GloballyCoherent, bool IsROV,
134132
bool HasCounter) {
135133
ResourceInfo RI(ResourceClass::UAV, ResourceKind::StructuredBuffer, Symbol,
@@ -286,8 +284,7 @@ MDTuple *ResourceInfo::getAsMetadata(LLVMContext &Ctx) const {
286284

287285
std::pair<uint32_t, uint32_t> ResourceInfo::getAnnotateProps() const {
288286
uint32_t ResourceKind = llvm::to_underlying(Kind);
289-
uint32_t AlignLog2 =
290-
(isStruct() && Struct.Alignment) ? Log2(*Struct.Alignment) : 0;
287+
uint32_t AlignLog2 = isStruct() ? Log2(Struct.Alignment) : 0;
291288
bool IsUAV = isUAV();
292289
bool IsROV = IsUAV && UAVFlags.IsROV;
293290
bool IsGloballyCoherent = IsUAV && UAVFlags.GloballyCoherent;

llvm/unittests/Analysis/DXILResourceTest.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,6 @@ TEST(DXILResource, AnnotationsAndMetadata) {
151151
EXPECT_MDEQ(
152152
MD, TestMD.get(0, Symbol, "Buffer0", 0, 0, 1, 12, 0, TestMD.get(1, 16)));
153153

154-
// StructuredBuffer<float3> Buffer1 : register(t1);
155-
Symbol = UndefValue::get(StructType::create(
156-
Context, {Floatx3Ty}, "class.StructuredBuffer<vector<float, 3> >"));
157-
Resource = ResourceInfo::StructuredBuffer(Symbol, "Buffer1",
158-
/*Stride=*/12, {});
159-
Resource.bind(1, 0, 1, 1);
160-
Props = Resource.getAnnotateProps();
161-
EXPECT_EQ(Props.first, 0x0000000cU);
162-
EXPECT_EQ(Props.second, 0x0000000cU);
163-
MD = Resource.getAsMetadata(Context);
164-
EXPECT_MDEQ(
165-
MD, TestMD.get(1, Symbol, "Buffer1", 0, 1, 1, 12, 0, TestMD.get(1, 12)));
166-
167154
// Texture2D<float4> ColorMapTexture : register(t2);
168155
Symbol = UndefValue::get(StructType::create(
169156
Context, {Floatx4Ty}, "class.Texture2D<vector<float, 4> >"));

0 commit comments

Comments
 (0)