Issue 159176
Summary [HLSL] Invalid aggregate _expression_ assertion error when using arrays with `select`
Labels new issue
Assignees
Reporter kmpeng
    https://godbolt.org/z/d31cT6q1a
```hlsl
StructuredBuffer<bool> Cond : register(t0);
StructuredBuffer<float2> TrueVal: register(t1);
StructuredBuffer<float2> FalseVal : register(t3);

RWStructuredBuffer<float2> Out : register(u5);


[numthreads(1,1,1)]
void main() {
    float2 trueArray[2] = { TrueVal[0], TrueVal[1] };
    float2 falseArray[2] = { FalseVal[0], FalseVal[1] };
  
    float2 resultArray[2] = select(Cond[0], trueArray, falseArray);
    Out[0] = resultArray[0];
    Out[1] = resultArray[1];
}
```
This code produces this assertion error:
```
clang: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CGExprAgg.cpp:2206: void clang::CodeGen::CodeGenFunction::EmitAggExpr(const clang::Expr*, clang::CodeGen::AggValueSlot): Assertion `E && hasAggregateEvaluationKind(E->getType()) && "Invalid aggregate _expression_ to emit"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang --driver-mode=dxc -Zi -Qembed_debug -Fc /app/output.s -fcolor-diagnostics -fno-crash-diagnostics -T cs_6_5 <source>
1.	<eof> parser at end of file
2.	<source>:9:6: LLVM IR generation of declaration 'main'
3.	<source>:9:6: Generating code for declaration 'main'
 #0 0x000000000417e408 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x417e408)
 #1 0x000000000417b834 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x417b834)
 #2 0x00000000040bfec8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000726302442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007263024969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000726302442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007263024287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000072630242871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x0000726302439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000044fbec4 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44fbec4)
#10 0x0000000004a07f92 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a07f92)
#11 0x0000000004a11620 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a11620)
#12 0x0000000004a16d56 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#13 0x0000000004a17567 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a17567)
#14 0x0000000004656ccc clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4656ccc)
#15 0x000000000466d48b clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x466d48b)
#16 0x0000000004664c61 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4664c61)
#17 0x000000000466ceec clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x466ceec)
#18 0x00000000046d538e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x46d538e)
#19 0x00000000046e7274 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x46e7274)
#20 0x0000000004752f10 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4752f10)
#21 0x000000000474dc04 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x474dc04)
#22 0x000000000474eaa0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x474eaa0)
#23 0x00000000047594e3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#24 0x0000000004abc5e0 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#25 0x0000000004aab914 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4aab914)
#26 0x0000000006838f44 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6838f44)
#27 0x0000000004ab7fd8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ab7fd8)
#28 0x0000000004dd708e clang::HLSLFrontendAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4dd708e)
#29 0x0000000004db21c5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4db21c5)
#30 0x0000000004d2d47e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d2d47e)
#31 0x0000000004ea74fd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ea74fd)
#32 0x0000000000db5cbf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb5cbf)
#33 0x0000000000dac92a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000000004b20f59 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::'lambda'()>(long) Job.cpp:0:0
#35 0x00000000040c0364 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40c0364)
#36 0x0000000004b2156f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#37 0x0000000004ae214d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ae214d)
#38 0x0000000004ae31de clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ae31de)
#39 0x0000000004aeb175 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4aeb175)
#40 0x0000000000db2145 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb2145)
#41 0x0000000000c63f94 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc63f94)
#42 0x0000726302429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#43 0x0000726302429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#44 0x0000000000dac3d5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdac3d5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to