Skip to content

Conversation

bogner
Copy link
Contributor

@bogner bogner commented Sep 4, 2025

This should demonstrate #147352 well enough to look at how it will affect the backends, but it still needs a fair amount of work and cleanup.

  • I'm just using i8 for the padding at this point, rather than dx.Padding/spv.Padding types. This is fairly easy to change and will come shortly
  • Most of the frontend bits need some abstraction and cleanup
  • We need a lot more tests - I have checked that the offload test suite still passes with these changes but haven't verified all of the numerous related bugs
  • I'm not entirely confident on the handling of arrays nested in structs and vice versa, but the basic examples seem to work
  • I still need to figure out how to stage this, so the git history is a bit of a mess at the moment.

CHECK-lines ignore whitespace, so we can remove some here and make this
a bit easier to read.
This mostly just works. A couple of notes:
1. We should use explicit padding
2. A couple of the tests have hacks to deal with vector alignment
3. More complicated GEPs probably don't have coverage
This abandons the `dx.Layout` idea and just uses explicit padding.

Note: this doesn't really work as is. Since the AST still has everything
represented as standard types without the padding, various places will
create GEPs with the wrong offsets and we fail to clean these up. We
need to move some of this logic into Sema and the AST itself.

There are a couple of other things on top of that:
- We can't/shouldn't just use `i8` arrays - we need something explicit.
- The algorithm to add padding in HLSLBufferLayoutBuilder is hacky.
- Reordered fields break stuff, including ones from implicit bindings.
Copy link

github-actions bot commented Sep 4, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions h,c,cpp -- clang/lib/Basic/Targets/DirectX.h clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGHLSLRuntime.h clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp clang/lib/CodeGen/HLSLBufferLayoutBuilder.h clang/lib/CodeGen/Targets/DirectX.cpp clang/lib/CodeGen/Targets/SPIR.cpp clang/test/CodeGenHLSL/basic-target.c llvm/include/llvm/Analysis/DXILResource.h llvm/lib/Analysis/DXILResource.cpp llvm/lib/Frontend/HLSL/CBuffer.cpp llvm/lib/Target/DirectX/DXILCBufferAccess.cpp llvm/lib/Target/DirectX/DirectXTargetMachine.cpp

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 42687a94d..2b7d488af 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4682,7 +4682,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
   } else if (E->getType().getAddressSpace() == LangAS::hlsl_constant) {
     // This is an array inside of a cbuffer.
     Addr = EmitPointerWithAlignment(E->getBase(), &EltBaseInfo, &EltTBAAInfo);
-    auto *Idx = EmitIdxAfterBase(/*Promote*/true);
+    auto *Idx = EmitIdxAfterBase(/*Promote*/ true);
 
     // ...
     CharUnits RowAlignedSize = getContext()
@@ -4694,7 +4694,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
     llvm::Value *ScaledIdx = Builder.CreateMul(Idx, RowAlignedSizeVal);
 
     CharUnits EltAlign =
-      getArrayElementAlign(Addr.getAlignment(), Idx, RowAlignedSize);
+        getArrayElementAlign(Addr.getAlignment(), Idx, RowAlignedSize);
     llvm::Value *EltPtr =
         emitArraySubscriptGEP(*this, Int8Ty, Addr.emitRawPointer(*this),
                               ScaledIdx, false, SignedIndices, E->getExprLoc());

const unsigned IndexInLayout = IndexInLayoutElements + 1;
assert(Layout[IndexInLayout] == UINT_MAX &&
LayoutElements[IndexInLayoutElements] == nullptr);
assert(Layout[I.second] == std::pair(UINT_MAX, nullptr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line causes a build failure on my machine:

[264/1543] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o
FAILED: tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o
/nix/store/bichdz31xjvg04ajh8b7qjw6q704a2lb-sccache-0.10.0/bin/sccache /nix/store/pprbhrczrj2gbvvsb0fr2dpqahqz6m77-clang-wrapper-19.1.7/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/workspace/llvm-project/build/tools/clang/lib/CodeGen -I/workspace/llvm-project/clang/lib/CodeGen -I/workspace/llvm-project/clang/include -I/workspace/llvm-project/build/tools/clang/include -I/workspace/llvm-project/build/include -I/workspace/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O2 -g -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o -MF tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o.d -o tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o -c /workspace/llvm-project/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
/workspace/llvm-project/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp:136:29: error: invalid operands to binary expression ('std::pair<unsigned int, llvm::Type *>' and 'std::pair<unsigned int, std::nullptr_t>' (aka 'pair<unsigned int, std::nullptr_t>'))
  136 |     assert(Layout[I.second] == std::pair(UINT_MAX, nullptr));
      |     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is failing for me locally. It appears that some memcpy intrinsics are being replaced with loads and stores.

FAIL: Clang :: CodeGenHLSL/ArrayAssignable.hlsl (1 of 1)
******************** TEST 'Clang :: CodeGenHLSL/ArrayAssignable.hlsl' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/workspace/llvm-project/build/bin/clang -cc1 -internal-isystem /workspace/llvm-project/build/lib/clang/22/include -nostdsysteminc -triple dxil-pc-shadermodel6.3-library -finclude-default-header -emit-llvm -disable-llvm-passes -o - /workspace/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl | /workspace/llvm-project/build/bin/FileCheck /workspace/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl # RUN: at line 1
+ /workspace/llvm-project/build/bin/clang -cc1 -internal-isystem /workspace/llvm-project/build/lib/clang/22/include -nostdsysteminc -triple dxil-pc-shadermodel6.3-library -finclude-default-header -emit-llvm -disable-llvm-passes -o - /workspace/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
+ /workspace/llvm-project/build/bin/FileCheck /workspace/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
/workspace/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl:144:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: call void @llvm.memcpy.p0.p2.i32(ptr align 4 [[C]], ptr addrspace(2) align 4 @c1, i32 8, i1 false)
               ^
<stdin>:149:108: note: scanning from here
 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %C, ptr align 4 @__const._Z11arr_assign8v.C, i32 8, i1 false)
                                                                                                           ^
...
Input file: <stdin>
Check file: /workspace/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl

-dump-input=help explains the following input dump.

Input was:
<<<<<<
             .
             .
             .
           144:
           145: ; Function Attrs: alwaysinline convergent mustprogress norecurse nounwind
           146: define hidden void @_Z11arr_assign8v() #2 {
           147: entry:
           148:  %C = alloca [2 x float], align 4
           149:  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %C, ptr align 4 @__const._Z11arr_assign8v.C, i32 8, i1 false)
next:144'0                                                                                                                 X error: no match found
next:144'1                                                                                                                   with "C" equal to "%C"
           150:  %0 = getelementptr inbounds [2 x float], ptr %C, i32 0
next:144'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           151:  %load = load float, ptr addrspace(2) @c1, align 4
next:144'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           152:  store float %load, ptr %0, align 4
next:144'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           153:  %1 = getelementptr inbounds [2 x float], ptr %C, i32 1
next:144'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           154:  %load1 = load float, ptr addrspace(2) getelementptr inbounds (i8, ptr addrspace(2) @c1, i32 32), align 4
next:144'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

@Icohedron
Copy link
Contributor

This shader fails to compile due to hitting an assert:

// compile args: -T cs_6_2 -E CSMain
typedef uint32_t4 uint32_t8[2];
void Foo(uint32_t8) {}
cbuffer Constants {
  uint32_t8 s;
}
[numthreads(1, 1, 1)]
void CSMain() {
  Foo(s);
}
clang-dxc: /workspace/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From &) [To = clang::ConstantArrayType, From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: bin/clang-dxc -T cs_6_2 -E CSMain test.hlsl
1.      <eof> parser at end of file
2.      test.hlsl:7:6: LLVM IR generation of declaration 'CSMain'
3.      test.hlsl:7:6: Generating code for declaration 'CSMain'
 #0 0x00005f0f884f1e1b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:834:13
 #1 0x00005f0f884ef7b3 llvm::sys::RunSignalHandlers() /workspace/llvm-project/llvm/lib/Support/Signals.cpp:105:18
 #2 0x00005f0f8845b670 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /workspace/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #3 0x00005f0f8845b670 CrashRecoverySignalHandler(int) /workspace/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51
 #4 0x00007fd04ae419c0 __restore_rt (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x419c0)
 #5 0x00007fd04ae9cf3c __pthread_kill_implementation (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x9cf3c)
 #6 0x00007fd04ae4190e gsignal (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x4190e)
 #7 0x00007fd04ae28942 abort (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x28942)
 #8 0x00007fd04ae2885e _nl_load_domain.cold (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x2885e)
 #9 0x00007fd04ae396f7 (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x396f7)
#10 0x00005f0f88a80990 clang::CodeGen::CodeGenFunction::EmitAggregateCopy(clang::CodeGen::LValue, clang::CodeGen::LValue, clang::QualType, clang::CodeGen::AggValueSlot::Overlap_t, bool) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:2306:7
#11 0x00005f0f88a87eee (anonymous namespace)::AggExprEmitter::EmitCopy(clang::QualType, clang::CodeGen::AggValueSlot const&, clang::CodeGen::AggValueSlot const&) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:0:7
#12 0x00005f0f88a7f6db (anonymous namespace)::AggExprEmitter::EmitFinalDestCopy(clang::QualType, clang::CodeGen::LValue const&, clang::CodeGen::CodeGenFunction::ExprValueKind) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:0:3
#13 0x00005f0f88a88249 (anonymous namespace)::AggExprEmitter::EmitAggLoadOfLValue(clang::Expr const*) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:266:1
#14 0x00005f0f88a8c306 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:115:3
#15 0x00005f0f88a8c306 (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:0:0
#16 0x00005f0f88a7f157 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:115:3
#17 0x00005f0f88a7f157 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) /workspace/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:2227:49
#18 0x00005f0f888b8515 clang::CodeGen::AggValueSlot::getAddress() const /workspace/llvm-project/clang/lib/CodeGen/CGValue.h:645:12
#19 0x00005f0f888b8515 clang::CodeGen::AggValueSlot::asRValue() const /workspace/llvm-project/clang/lib/CodeGen/CGValue.h:670:35
#20 0x00005f0f888b8515 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) /workspace/llvm-project/clang/lib/CodeGen/CGExpr.cpp:276:20
#21 0x00005f0f888b8b05 clang::CodeGen::CodeGenFunction::EmitAnyExprToTemp(clang::Expr const*) /workspace/llvm-project/clang/lib/CodeGen/CGExpr.cpp:289:1
#22 0x00005f0f88798fe0 clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) /workspace/llvm-project/clang/lib/CodeGen/CGCall.cpp:4931:34
#23 0x00005f0f88798111 clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const>>, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) /workspace/llvm-project/clang/lib/CodeGen/CGCall.cpp:4774:5
#24 0x00005f0f888e0fbb clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*, llvm::CallBase**, clang::CodeGen::CGFunctionInfo const**) /workspace/llvm-project/clang/lib/CodeGen/CGExpr.cpp:6593:34
#25 0x00005f0f888df868 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) /workspace/llvm-project/clang/lib/CodeGen/CGExpr.cpp:0:10
#26 0x00005f0f888fc675 clang::CodeGen::RValue::isScalar() const /workspace/llvm-project/clang/lib/CodeGen/CGValue.h:64:41
#27 0x00005f0f888fc675 clang::CodeGen::RValue::getScalarVal() const /workspace/llvm-project/clang/lib/CodeGen/CGValue.h:72:5
#28 0x00005f0f888fc675 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) /workspace/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:631:36
#29 0x00005f0f888e9eac (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /workspace/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:452:52
#30 0x00005f0f888e9eac clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) /workspace/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:5873:8
#31 0x00005f0f888b82ea clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) /workspace/llvm-project/clang/lib/CodeGen/CGExpr.cpp:244:5
#32 0x00005f0f887fcbee llvm::IRBuilderBase::GetInsertBlock() const /workspace/llvm-project/llvm/include/llvm/IR/IRBuilder.h:201:47
#33 0x00005f0f887fcbee clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /workspace/llvm-project/clang/lib/CodeGen/CGStmt.cpp:133:42
#34 0x00005f0f8880964c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /workspace/llvm-project/clang/lib/CodeGen/CGStmt.cpp:588:22
#35 0x00005f0f887e7b9d clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /workspace/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:0:5
#36 0x00005f0f887e7b9d clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /workspace/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1628:5
#37 0x00005f0f8871e90c clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /workspace/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:6358:3
#38 0x00005f0f8871663b llvm::TimeTraceScope::~TimeTraceScope() /workspace/llvm-project/llvm/include/llvm/Support/TimeProfiler.h:200:9
#39 0x00005f0f8871663b clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /workspace/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4462:3
#40 0x00005f0f8871b2ed clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) /workspace/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4173:5
#41 0x00005f0f88714f05 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) /workspace/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:7264:5
#42 0x00005f0f88c547ac (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) /workspace/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:189:20
#43 0x00005f0f88c4b745 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /workspace/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:172:22
#44 0x00005f0f8a757f49 clang::ParseAST(clang::Sema&, bool, bool) /workspace/llvm-project/clang/lib/Parse/ParseAST.cpp:174:17
#45 0x00005f0f89185d1f clang::HLSLFrontendAction::ExecuteAction() /workspace/llvm-project/clang/lib/Frontend/FrontendActions.cpp:0:26
#46 0x00005f0f8914c177 clang::FrontendAction::Execute() /workspace/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1314:10
#47 0x00005f0f890bf0fd llvm::Error::getPtr() const /workspace/llvm-project/llvm/include/llvm/Support/Error.h:278:42
#48 0x00005f0f890bf0fd llvm::Error::operator bool() /workspace/llvm-project/llvm/include/llvm/Support/Error.h:241:16
#49 0x00005f0f890bf0fd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /workspace/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1066:23
#50 0x00005f0f8923fb6a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /workspace/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:302:25
#51 0x00005f0f8704069d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /workspace/llvm-project/clang/tools/driver/cc1_main.cpp:297:15
#52 0x00005f0f8703cb0c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /workspace/llvm-project/clang/tools/driver/driver.cpp:223:12
#53 0x00005f0f88f2f2de clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0::operator()() const /workspace/llvm-project/clang/lib/Driver/Job.cpp:436:30
#54 0x00005f0f88f2f2de void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) /workspace/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#55 0x00005f0f8845b269 llvm::function_ref<void ()>::operator()() const /workspace/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#56 0x00005f0f8845b269 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /workspace/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#57 0x00005f0f88f2e8b9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /workspace/llvm-project/clang/lib/Driver/Job.cpp:436:7
#58 0x00005f0f88eef356 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /workspace/llvm-project/clang/lib/Driver/Compilation.cpp:196:15
#59 0x00005f0f88eef5c8 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /workspace/llvm-project/clang/lib/Driver/Compilation.cpp:246:13
#60 0x00005f0f88f08c99 llvm::SmallVectorBase<unsigned int>::empty() const /workspace/llvm-project/llvm/include/llvm/ADT/SmallVector.h:82:46
#61 0x00005f0f88f08c99 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /workspace/llvm-project/clang/lib/Driver/Driver.cpp:2244:23
#62 0x00005f0f8703c2aa clang_main(int, char**, llvm::ToolContext const&) /workspace/llvm-project/clang/tools/driver/driver.cpp:404:21
#63 0x00005f0f8704c55f main /workspace/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:17:10
#64 0x00007fd04ae2a4d8 __libc_start_call_main (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x2a4d8)
#65 0x00007fd04ae2a59b __libc_start_main@GLIBC_2.2.5 (/nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6+0x2a59b)
#66 0x00005f0f8703a4a5 _start (bin/clang-dxc+0x2d924a5)
clang-dxc: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git (git@github.com:Icohedron/llvm-project.git a8b72d5621310bb1f0d18b5b601312c78af39b1a)
Target: dxilv1.2-unknown-shadermodel6.2-compute
Thread model: posix
InstalledDir: /workspace/llvm-project/build/bin
Build config: +assertions

Removing the typedef and just using uint32_t4 [2] lets the shader compile without hitting the assertion error.
Making the typedef a scalar or a vector also does not cause the assert to be hit.
Therefore the issue appears to be due to the use of a typedef that is defined to be an array of any type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants