Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0879058
Agent prompt
llvm-beanz May 1, 2026
134bd52
Fix crashes when inout/out params are reference types
May 1, 2026
fd3c944
Fix SPIRV codegen crash on array-to-pointer decay
May 1, 2026
00f4fde
Fix SPIRV out-param writeback for intrinsics and texture operations
May 1, 2026
f2d57e4
Fix buffer load status writeback ordering and update test expectations
May 1, 2026
662b2d3
Fix SPIRV array subscript, resource out-params, and type probe crashes
May 2, 2026
9284ae3
Update SPIRV test CHECK patterns for out-param reference type changes
May 2, 2026
591200c
Add new tests from new_tests/ samples and update DXIL test expectations
May 2, 2026
9571269
Fix remaining CodeGenDXIL test failures for out/inout reference seman…
May 2, 2026
cbbd51d
Fix remaining SPIRV codegen and update test expectations
May 2, 2026
55b95d2
Add agent_thoughts.md documenting the out-param rewrite triage
May 2, 2026
843e139
Updating prompt
llvm-beanz May 2, 2026
504aa9e
[HLSL] Remove duplicate vector truncation diag in PerformImplicitConv…
May 2, 2026
d7699fd
[HLSL] Recognize ParameterModifier inout in ActOnOutParamExpr
May 2, 2026
273b639
[HLSL] Skip reference+restrict rewrite for aggregate out parameters
May 2, 2026
e3e2291
[HLSL] Fix copy-out lowering for HLSLOutArgExpr aggregates and restor…
May 2, 2026
cd7a734
[HLSL] Update AtomicsInvalidDests rewrite to match new IR numbering
May 2, 2026
2990cc5
[Test] Make WEXAdapter group logging visible on POSIX
May 2, 2026
cc7921d
Update agent_thoughts.md with session 2 triage and fixes
May 2, 2026
48c7f53
Updating prompt for try 3
llvm-beanz May 2, 2026
5bf9b60
Revert "[HLSL] Remove duplicate vector truncation diag in PerformImpl…
May 2, 2026
fb241c6
[HLSL] Update cpp-errors verifier expectations for vector truncation …
May 2, 2026
9074b77
Revert "[HLSL] Skip reference+restrict rewrite for aggregate out para…
May 2, 2026
befd066
[HLSL] Remove AST-level copy elision for HLSLOutArgExpr
May 2, 2026
31cf844
[HLSL] Update ValidationTest expectations for inout struct mangling
May 2, 2026
d103a91
[HLSL] Update swizzleBitfieldNotAllowed verifier expectations for vec…
May 2, 2026
3ece287
[Test] Print WEXAdapter Comment/Error messages on POSIX
May 2, 2026
aa69a33
[HLSL] Update FileCheck expectations after removing AST-level copy el…
May 2, 2026
0bbb593
Update agent_thoughts.md with session 3 reverts and test updates
May 2, 2026
77410c6
Another prompt revision
llvm-beanz May 2, 2026
8883837
[Test] Use single-dash check-prefix syntax in HLSLFileCheck tests
May 2, 2026
4668270
[HLSL] Refine ActOnOutParamExpr scalar/vector mismatch diagnostics
May 2, 2026
a590d56
[HLSL] Use memory rep for HLSLOutArgExpr temporary alloca
May 2, 2026
eb7115a
[HLSL] Update copyin-copyout / global-constant / inout-mismatch CHECKs
May 2, 2026
7823727
[HLSL] Update class AST/CHECK expectations for inout array decay and …
May 2, 2026
e9f1b38
[HLSL] Strip references in HasHLSLMatOrientation
May 2, 2026
d042a74
[Test] Relax lifetime test expectations for inout/in struct calls
May 2, 2026
2c10f79
[Test] Update spec.hlsl expectations after vec1<->scalar relaxation
May 2, 2026
1d4f7fa
Update agent_thoughts.md with session 4 fixes and remaining work
May 2, 2026
c17b758
Updating the prompt
llvm-beanz May 2, 2026
955c546
[HLSL] Preserve matrix orientation attribute on out parameter types
May 2, 2026
d559a28
[Test] Update sampler/texture annotation order for HLSL out-param rew…
May 2, 2026
e0c620e
[HLSL] Strip NoOp casts when computing matrix subscript orientation
May 2, 2026
057c3dc
[HLSL] Walk through HLSLOutArgExpr in DXR payload-access analysis
May 2, 2026
5647990
[HLSL] Use getAs<RecordType> in IsHLSLRayQueryType
May 2, 2026
de08f1a
Update agent_thoughts.md with session 5 fixes for last lit failures
May 2, 2026
4a4078b
Update failures
llvm-beanz May 2, 2026
b2e1da6
[HLSL] Strip references in mesh shader output array checks
May 2, 2026
a7dcbee
[HLSL] Preserve rvalue category in HLSL no-op C-style casts
May 2, 2026
0f6853b
Updating the error output
llvm-beanz May 2, 2026
a6211be
[HLSL] Lower matrix subscript on groupshared lvalues
May 2, 2026
075ac05
Update agent_thoughts.md with session 6 fix for groupshared matrix su…
May 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions agent_prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Initial Guidelines

Please make sure that your changes are appropriately tested with unit tests
covering each phase of translation in the compiler, and that your changes
conform to the [LVLM Coding Standards](docs/CodingStandards.rst).

Verify your changes by building and testing using the
cmake/caches/PredefinedParams.cmake cache file with CMake's -C option and
building the check-all target.

Break your changes into small code changes with each change committed
spearately. Record your thought process into a file named "agent_thoughts.md" at
the root of the repository and commit it in its own commit when you're done.

# Request

I'm now seeing just a few test failures locally. Please fix the remaining test
failures on the branch.

See test_output.txt for details of my local failures.
901 changes: 901 additions & 0 deletions agent_thoughts.md

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions include/dxc/Test/WEXAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,20 @@ HRESULT TryGetValue(const wchar_t *param, Common::String &retStr);
namespace Logging {
namespace Log {
inline void StartGroup(const wchar_t *name) {
wprintf(L"BEGIN TEST(S): <%ls>\n", name);
fprintf(stderr, "BEGIN TEST(S): <%ls>\n", name);
fflush(stderr);
}
inline void EndGroup(const wchar_t *name) {
wprintf(L"END TEST(S): <%ls>\n", name);
fprintf(stderr, "END TEST(S): <%ls>\n", name);
fflush(stderr);
}
inline void Comment(const wchar_t *msg) {
fputws(msg, stdout);
fputwc(L'\n', stdout);
fprintf(stdout, "%ls\n", msg);
fflush(stdout);
}
inline void Error(const wchar_t *msg) {
fputws(msg, stderr);
fputwc(L'\n', stderr);
fprintf(stderr, "%ls\n", msg);
fflush(stderr);
ADD_FAILURE();
}
} // namespace Log
Expand Down
32 changes: 32 additions & 0 deletions lib/HLSL/HLMatrixLowerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,38 @@ void HLMatrixLowerPass::lowerHLMatSubscript(
while (GEPOperator *GEP = dyn_cast<GEPOperator>(RootPtr))
RootPtr = GEP->getPointerOperand();

// Handle the case where the matrix pointer is an addrspacecast of an
// lvalue rooted at a global variable or alloca (e.g., a matrix field of a
// groupshared struct). CodeGen emits this addrspacecast whenever the
// matrix subscript intrinsic — which uses generic-address-space matrix
// pointers in its signature — is invoked on an lvalue in a non-zero
// address space. By the time this pass runs, the addrspacecast source may
// already be the lowered storage type (array of scalars), or still be a
// matrix-typed pointer that we need to bitcast to its lowered equivalent.
// In either case, tryGetLoweredPtrOperand bails on this pattern because
// the root is a global variable rather than an Argument or Alloca, so the
// HL subscript call would otherwise leak past matrix lowering.
if (LoweredPtr == nullptr) {
if (auto *ASC = dyn_cast<AddrSpaceCastInst>(MatPtr)) {
Value *SrcPtr = ASC->getOperand(0);
Value *SrcRoot = SrcPtr;
while (auto *GEP = dyn_cast<GEPOperator>(SrcRoot))
SrcRoot = GEP->getPointerOperand();
if (isa<GlobalVariable>(SrcRoot) || isa<AllocaInst>(SrcRoot)) {
Type *SrcElemTy = SrcPtr->getType()->getPointerElementType();
if (HLMatrixType::isa(SrcElemTy)) {
LoweredPtr = CallBuilder.CreateBitCast(
SrcPtr, HLMatrixType::getLoweredType(SrcPtr->getType()));
} else if (SrcElemTy->isArrayTy() || SrcElemTy->isVectorTy()) {
// Already lowered storage; use it directly.
LoweredPtr = SrcPtr;
}
if (LoweredPtr != nullptr)
RootPtr = SrcRoot;
}
}
}

if (LoweredPtr == nullptr) {
if (!isa<Argument>(RootPtr))
return;
Expand Down
49 changes: 49 additions & 0 deletions lib/HLSL/HLOperationLower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4488,6 +4488,50 @@ Value *TranslateBufLoad(ResLoadHelper &helper, HLResource::Kind RK,
return FirstLd;
}

// For pointer-returning buffer loads with an HLSLOutArgExpr status argument,
// the writeback sequence (load from temp alloca + store to actual dest) is
// emitted immediately after the HL call. After SROA expands the result pointer
// into GEP+load accesses and may optimize away the intermediate store,
// UpdateStatus writes to the temp alloca AFTER the existing load of that alloca.
// Fix this by moving the existing load instruction to after all UpdateStatus
// stores so that mem2reg correctly propagates the checkAccessFullyMapped result.
static void FixStatusLoadOrdering(Value *statusAlloca) {
AllocaInst *AI = dyn_cast<AllocaInst>(statusAlloca);
if (!AI)
return;
// Find the pre-existing load from the alloca (from the HLSLOutArgExpr writeback).
LoadInst *statusLoad = nullptr;
for (User *U : AI->users()) {
if (LoadInst *LI = dyn_cast<LoadInst>(U)) {
statusLoad = LI;
break;
}
}
if (!statusLoad)
return;
// Find the last store to the alloca inserted by UpdateStatus.
BasicBlock *BB = statusLoad->getParent();
StoreInst *lastStore = nullptr;
for (Instruction &I : *BB) {
if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
if (SI->getPointerOperand() == AI)
lastStore = SI;
}
}
if (!lastStore)
return;
// Move the load to just after the last UpdateStatus store so that
// mem2reg propagates the correct checkAccessFullyMapped result.
// Check IR ordering: iterate the block to see if statusLoad comes before lastStore.
bool loadBeforeStore = false;
for (Instruction &I : *BB) {
if (&I == statusLoad) { loadBeforeStore = true; break; }
if (&I == lastStore) break;
}
if (loadBeforeStore)
statusLoad->moveBefore(lastStore->getNextNode());
}

Value *TranslateResourceLoad(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
HLOperationLowerHelper &helper,
HLObjectOperationLowerHelper *pObjHelper,
Expand All @@ -4509,6 +4553,11 @@ Value *TranslateResourceLoad(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
"Textures should not be treated as structured buffers.");
TranslateStructBufSubscript(cast<CallInst>(ldHelper.retVal), handle,
ldHelper.status, hlslOP, RK, DL);
// After TranslateStructBufSubscript inserts UpdateStatus stores, move the
// pre-existing status load to after those stores so mem2reg propagates the
// checkAccessFullyMapped result rather than an uninitialized value.
if (ldHelper.status)
FixStatusLoadOrdering(ldHelper.status);
} else {
Ld = TranslateBufLoad(ldHelper, RK, Builder, hlslOP, DL);
dxilutil::MigrateDebugValue(CI, Ld);
Expand Down
7 changes: 7 additions & 0 deletions new_tests/array-tmp.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void fn(float x[2]) { }

float main(float val: A) : B {
float Arr[2] = {0, 0};
fn(Arr);
return Arr[0];
}
14 changes: 14 additions & 0 deletions new_tests/copy-vec.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
struct Agg {
float3 f3;
};

void get(out Agg agg);

static Agg s_agg;

export
float3 main() {
get(s_agg);
return s_agg.f3;
}

9 changes: 9 additions & 0 deletions new_tests/gnarly-float-array.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
typedef int ai32[1];
typedef float af32[1];
void inc(inout float x) { x *= -1; }
int main() : OUT
{
ai32 x = { 42 };
inc(((af32)x)[0]);
return x[0];
}
16 changes: 16 additions & 0 deletions new_tests/implicit_truncation.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
struct Color {
uint16_t r;
uint16_t g;
uint16_t b;
};

RWStructuredBuffer<uint> buf : r0;

[numthreads(4, 8, 16)]
void main() {
Color s;
s.r = 4;
s.g = 5;
s.b = 6;
uint64_t value = (uint)s;
}
3 changes: 3 additions & 0 deletions new_tests/inout_lvalue.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export void fn(inout float3 a, float3 b) {
a += b;
}
4 changes: 4 additions & 0 deletions new_tests/longlong.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// dxc /Tvs_6_0 -spirv longlong.hlsl
uint main() : A {
return vk::ReadClock(vk::SubgroupScope);
}
9 changes: 9 additions & 0 deletions new_tests/simple-inout.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
void fn(inout float x, inout int y) {
y = 2;
x = 1;
}

float main(float val: A) : B {
fn(val, val);
return val;
}
Loading
Loading