Skip to content

Commit 137daba

Browse files
committed
Fix regressions.
1 parent f012cd9 commit 137daba

7 files changed

+35
-27
lines changed

source/slang/hlsl.meta.slang

+12-12
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct ByteAddressBuffer
150150
{
151151
case hlsl: __intrinsic_asm ".Load2";
152152
default:
153-
return __byteAddressBufferLoad<uint2>(this, location, __alignOf_intrinsic<uint2>());
153+
return __byteAddressBufferLoad<uint2>(this, location, __naturalStrideOf<uint2>());
154154
}
155155
}
156156

@@ -192,7 +192,7 @@ struct ByteAddressBuffer
192192
{
193193
case hlsl: __intrinsic_asm ".Load3";
194194
default:
195-
return __byteAddressBufferLoad<uint3>(this, location, __alignOf_intrinsic<uint3>());
195+
return __byteAddressBufferLoad<uint3>(this, location, __naturalStrideOf<uint3>());
196196
}
197197
}
198198

@@ -234,7 +234,7 @@ struct ByteAddressBuffer
234234
{
235235
case hlsl: __intrinsic_asm ".Load4";
236236
default:
237-
return __byteAddressBufferLoad<uint4>(this, location, __alignOf_intrinsic<uint4>());
237+
return __byteAddressBufferLoad<uint4>(this, location, __naturalStrideOf<uint4>());
238238
}
239239
}
240240

@@ -259,7 +259,7 @@ struct ByteAddressBuffer
259259
[ForceInline]
260260
T LoadAligned<T>(int location)
261261
{
262-
return __byteAddressBufferLoad<T>(this, location, __alignOf_intrinsic<T>());
262+
return __byteAddressBufferLoad<T>(this, location, __naturalStrideOf<T>());
263263
}
264264
};
265265

@@ -3758,7 +3758,7 @@ struct $(item.name)
37583758
{
37593759
case hlsl: __intrinsic_asm ".Load2";
37603760
default:
3761-
return __byteAddressBufferLoad<uint2>(this, location, __alignOf_intrinsic<uint2>());
3761+
return __byteAddressBufferLoad<uint2>(this, location, __naturalStrideOf<uint2>());
37623762
}
37633763
}
37643764

@@ -3800,7 +3800,7 @@ struct $(item.name)
38003800
{
38013801
case hlsl: __intrinsic_asm ".Load3";
38023802
default:
3803-
return __byteAddressBufferLoad<uint3>(this, location, __alignOf_intrinsic<uint3>());
3803+
return __byteAddressBufferLoad<uint3>(this, location, __naturalStrideOf<uint3>());
38043804
}
38053805
}
38063806

@@ -3842,7 +3842,7 @@ struct $(item.name)
38423842
{
38433843
case hlsl: __intrinsic_asm ".Load4";
38443844
default:
3845-
return __byteAddressBufferLoad<uint4>(this, location, __alignOf_intrinsic<uint4>());
3845+
return __byteAddressBufferLoad<uint4>(this, location, __naturalStrideOf<uint4>());
38463846
}
38473847
}
38483848

@@ -3870,7 +3870,7 @@ struct $(item.name)
38703870
[require(cpp_cuda_glsl_hlsl_spirv, byteaddressbuffer_rw)]
38713871
T LoadAligned<T>(int location)
38723872
{
3873-
return __byteAddressBufferLoad<T>(this, location, __alignOf_intrinsic<T>());
3873+
return __byteAddressBufferLoad<T>(this, location, __naturalStrideOf<T>());
38743874
}
38753875

38763876
${{{{
@@ -4763,7 +4763,7 @@ ${{{{
47634763
{
47644764
case hlsl: __intrinsic_asm ".Store2";
47654765
default:
4766-
__byteAddressBufferStore(this, address, __alignOf_intrinsic<uint2>(), value);
4766+
__byteAddressBufferStore(this, address, __naturalStrideOf<uint2>(), value);
47674767
}
47684768
}
47694769

@@ -4800,7 +4800,7 @@ ${{{{
48004800
{
48014801
case hlsl: __intrinsic_asm ".Store3";
48024802
default:
4803-
__byteAddressBufferStore(this, address, __alignOf_intrinsic<uint3>(), value);
4803+
__byteAddressBufferStore(this, address, __naturalStrideOf<uint3>(), value);
48044804
}
48054805
}
48064806

@@ -4837,7 +4837,7 @@ ${{{{
48374837
{
48384838
case hlsl: __intrinsic_asm ".Store4";
48394839
default:
4840-
__byteAddressBufferStore(this, address, __alignOf_intrinsic<uint4>(), value);
4840+
__byteAddressBufferStore(this, address, __naturalStrideOf<uint4>(), value);
48414841
}
48424842
}
48434843

@@ -4856,7 +4856,7 @@ ${{{{
48564856
[ForceInline]
48574857
void StoreAligned<T>(int offset, T value)
48584858
{
4859-
__byteAddressBufferStore(this, offset, __alignOf_intrinsic<T>(), value);
4859+
__byteAddressBufferStore(this, offset, __naturalStrideOf<T>(), value);
48604860
}
48614861
};
48624862

source/slang/slang-emit.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ void calcRequiredLoweringPassSet(RequiredLoweringPassSet& result, CodeGenContext
259259
}
260260
break;
261261
case kIROp_PseudoPtrType:
262+
case kIROp_BoundInterfaceType:
263+
case kIROp_BindExistentialsType:
264+
result.generics = true;
262265
result.existentialTypeLayout = true;
263266
break;
264267
case kIROp_GetRegisterIndex:
@@ -267,6 +270,7 @@ void calcRequiredLoweringPassSet(RequiredLoweringPassSet& result, CodeGenContext
267270
break;
268271
case kIROp_BackwardDifferentiate:
269272
case kIROp_ForwardDifferentiate:
273+
case kIROp_MakeDifferentialPairUserCode:
270274
result.autodiff = true;
271275
break;
272276
case kIROp_VerticesType:
@@ -581,6 +585,9 @@ Result linkAndOptimizeIR(
581585

582586
finalizeSpecialization(irModule);
583587

588+
requiredLoweringPassSet = {};
589+
calcRequiredLoweringPassSet(requiredLoweringPassSet, codeGenContext, irModule->getModuleInst());
590+
584591
switch (target)
585592
{
586593
case CodeGenTarget::PyTorchCppBinding:
@@ -642,9 +649,6 @@ Result linkAndOptimizeIR(
642649
SLANG_RETURN_ON_FAIL(checkGetStringHashInsts(irModule, sink));
643650
}
644651

645-
requiredLoweringPassSet = {};
646-
calcRequiredLoweringPassSet(requiredLoweringPassSet, codeGenContext, irModule->getModuleInst());
647-
648652
// For targets that supports dynamic dispatch, we need to lower the
649653
// generics / interface types to ordinary functions and types using
650654
// function pointers.

source/slang/slang-ir-inline.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,12 @@ struct MandatoryEarlyInliningPass : InliningPassBase
698698
};
699699

700700

701-
void performMandatoryEarlyInlining(IRModule* module)
701+
bool performMandatoryEarlyInlining(IRModule* module)
702702
{
703703
SLANG_PROFILE;
704704

705705
MandatoryEarlyInliningPass pass(module);
706-
pass.considerAllCallSites();
706+
return pass.considerAllCallSites();
707707
}
708708

709709
namespace { // anonymous

source/slang/slang-ir-inline.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Slang
1515
Result performTypeInlining(IRModule* module, DiagnosticSink* sink);
1616

1717
/// Inline any call sites to functions marked `[unsafeForceInlineEarly]`
18-
void performMandatoryEarlyInlining(IRModule* module);
18+
bool performMandatoryEarlyInlining(IRModule* module);
1919

2020
/// Inline any call sites to functions marked `[ForceInline]`
2121
void performForceInlining(IRModule* module);

source/slang/slang-ir-lower-generics.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,7 @@ namespace Slang
277277
sharedContext.targetProgram = program;
278278
sharedContext.sink = sink;
279279

280-
cleanUpRTTIHandleTypes(&sharedContext);
281-
cleanUpInterfaceTypes(&sharedContext);
280+
specializeRTTIObjects(&sharedContext, sink);
282281

283282
lowerTuples(module, sink);
284283
if (sink->getErrorCount() != 0)

source/slang/slang-ir-peephole.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ struct PeepholeContext : InstPassBase
261261

262262
// Save the alignment information and exit early if it is invalid
263263
IRSizeAndAlignment sizeAlignment;
264-
auto alignOfInst = as<IRAlignOf>(inst);
265-
auto baseType = alignOfInst->getBaseOp()->getDataType();
264+
IRType* baseType = nullptr;
265+
if (auto t = as<IRType>(inst->getOperand(0)))
266+
baseType = t;
267+
else
268+
baseType = inst->getOperand(0)->getDataType();
269+
266270
if (SLANG_FAILED(getNaturalSizeAndAlignment(targetProgram->getOptionSet(), baseType, &sizeAlignment)))
267271
break;
268272
if (sizeAlignment.size == 0)

source/slang/slang-lower-to-ir.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -10883,11 +10883,12 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1088310883

1088410884
// Optionally, run another optimization pass to clean up things.
1088510885
//
10886-
if (!sharedContextStorage.m_linkage->m_optionSet.getBoolOption(CompilerOptionName::MinimumSlangOptimization))
10886+
for (;;)
1088710887
{
10888-
for (;;)
10888+
bool changed = false;
10889+
changed |= performMandatoryEarlyInlining(module);
10890+
if (!sharedContextStorage.m_linkage->m_optionSet.getBoolOption(CompilerOptionName::MinimumSlangOptimization))
1088910891
{
10890-
bool changed = false;
1089110892
changed |= constructSSA(module);
1089210893
simplifyCFG(module, CFGSimplificationOptions::getDefault());
1089310894
changed |= applySparseConditionalConstantPropagation(module, compileRequest->getSink());
@@ -10897,9 +10898,9 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1089710898
if (auto func = as<IRGlobalValueWithCode>(inst))
1089810899
eliminateDeadCode(func);
1089910900
}
10900-
if (!changed)
10901-
break;
1090210901
}
10902+
if (!changed)
10903+
break;
1090310904
}
1090410905

1090510906

0 commit comments

Comments
 (0)