Skip to content

[NFC] Thread DataLayout through helper function signatures for aggregate construction - #183213

Draft
shiltian wants to merge 1 commit into
users/shiltian/aggregate-callers-datalayoutfrom
users/shiltian/aggregate-helpers-datalayout
Draft

[NFC] Thread DataLayout through helper function signatures for aggregate construction#183213
shiltian wants to merge 1 commit into
users/shiltian/aggregate-callers-datalayoutfrom
users/shiltian/aggregate-helpers-datalayout

Conversation

@shiltian

Copy link
Copy Markdown
Contributor

Add const DataLayout *DL parameter to helper functions and classes that
construct aggregate constants but previously had no access to DataLayout. This
is the final preparatory step before the ConstantPointerNull semantic change,
ensuring aggregate collapse-to-ConstantAggregateZero checks have DataLayout
awareness in all remaining call sites.

…egate construction

Add `const DataLayout *DL` parameter to helper functions and classes that
construct aggregate constants but previously had no access to `DataLayout`. This
is the final preparatory step before the `ConstantPointerNull` semantic change,
ensuring aggregate collapse-to-`ConstantAggregateZero` checks have `DataLayout`
awareness in all remaining call sites.
@github-actions

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 3119 tests passed
  • 7 tests skipped

All executed tests passed, but another part of the build failed. Click on a failure below to see the details.

lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.o
FAILED: lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.o
sccache /opt/llvm/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/Target/SPIRV -I/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/include -I/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/include -gmlt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -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 -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fvisibility=hidden -UNDEBUG -fno-exceptions -funwind-tables -fno-rtti -MD -MT lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.o -MF lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.o.d -o lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.o -c /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:147:44: error: out-of-line definition of 'legalizeConstant' does not match any declaration in '(anonymous namespace)::SPIRVLegalizeZeroSizeArraysImpl'
147 | Constant *SPIRVLegalizeZeroSizeArraysImpl::legalizeConstant(Constant *C) {
|                                            ^~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:59:7: note: SPIRVLegalizeZeroSizeArraysImpl defined here
59 | class SPIRVLegalizeZeroSizeArraysImpl
|       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:165:57: error: too few arguments to function call, expected 2, have 1
165 |       Elems.push_back(legalizeConstant(cast<Constant>(U)));
|                       ~~~~~~~~~~~~~~~~                  ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:78:13: note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:172:58: error: too few arguments to function call, expected 2, have 1
172 |       Fields.push_back(legalizeConstant(cast<Constant>(U)));
|                        ~~~~~~~~~~~~~~~~                  ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:78:13: note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:184:65: error: too few arguments to function call, expected 2, have 1
184 |       Constant *LegalizedOp = legalizeConstant(cast<Constant>(U));
|                               ~~~~~~~~~~~~~~~~                  ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:78:13: note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:300:74: error: too few arguments to function call, expected 2, have 1
300 |     Constant *LegalizedInitializer = legalizeConstant(GV.getInitializer());
|                                      ~~~~~~~~~~~~~~~~                    ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.cpp:78:13: note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 3058 tests passed
  • 29 tests skipped

All executed tests passed, but another part of the build failed. Click on a failure below to see the details.

[code=1] lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.obj
FAILED: [code=1] lib/Target/SPIRV/CMakeFiles/LLVMSPIRVCodeGen.dir/SPIRVLegalizeZeroSizeArrays.cpp.obj
sccache C:\clang\clang-msvc\bin\clang-cl.exe  /nologo -TP -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Target\SPIRV -IC:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV -Iinclude -IC:\_work\llvm-project\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Oi /Brepro /bigobj /permissive- -Werror=unguarded-availability-new /W4  -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported /Gw /O2 /Ob2  -MD -UNDEBUG /EHs-c- /GR- -std:c++17 /showIncludes /Folib\Target\SPIRV\CMakeFiles\LLVMSPIRVCodeGen.dir\SPIRVLegalizeZeroSizeArrays.cpp.obj /Fdlib\Target\SPIRV\CMakeFiles\LLVMSPIRVCodeGen.dir\LLVMSPIRVCodeGen.pdb -c -- C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(147,44): error: out-of-line definition of 'legalizeConstant' does not match any declaration in '(anonymous namespace)::SPIRVLegalizeZeroSizeArraysImpl'
147 | Constant *SPIRVLegalizeZeroSizeArraysImpl::legalizeConstant(Constant *C) {
|                                            ^~~~~~~~~~~~~~~~
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(59,7): note: SPIRVLegalizeZeroSizeArraysImpl defined here
59 | class SPIRVLegalizeZeroSizeArraysImpl
|       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(165,57): error: too few arguments to function call, expected 2, have 1
165 |       Elems.push_back(legalizeConstant(cast<Constant>(U)));
|                       ~~~~~~~~~~~~~~~~                  ^
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(78,13): note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(172,58): error: too few arguments to function call, expected 2, have 1
172 |       Fields.push_back(legalizeConstant(cast<Constant>(U)));
|                        ~~~~~~~~~~~~~~~~                  ^
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(78,13): note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(184,65): error: too few arguments to function call, expected 2, have 1
184 |       Constant *LegalizedOp = legalizeConstant(cast<Constant>(U));
|                               ~~~~~~~~~~~~~~~~                  ^
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(78,13): note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(300,74): error: too few arguments to function call, expected 2, have 1
300 |     Constant *LegalizedInitializer = legalizeConstant(GV.getInitializer());
|                                      ~~~~~~~~~~~~~~~~                    ^
C:\_work\llvm-project\llvm-project\llvm\lib\Target\SPIRV\SPIRVLegalizeZeroSizeArrays.cpp(78,13): note: 'legalizeConstant' declared here
78 |   Constant *legalizeConstant(Constant *C, const DataLayout *DL);
|             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@shiltian

Copy link
Copy Markdown
Contributor Author

Don't review this PR in its own. Check #183215 for more context.

@github-actions
github-actions Bot deleted the branch users/shiltian/aggregate-callers-datalayout April 28, 2026 09:08
@github-actions
github-actions Bot deleted the users/shiltian/aggregate-helpers-datalayout branch April 28, 2026 09:08
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.

1 participant