This is an archive of the discontinued LLVM Phabricator instance.

[clang-tools-extra] [clangd] Split huge generated CompletionModel.cpp into smaller files
AbandonedPublic

Authored by thesamesam on Oct 19 2022, 12:14 PM.

Details

Summary

Previously build system generated single huge CompletionModel.cpp with size about 6.5 MiB.
Compilation + assembling on PPC32 with GCC + GNU assembler resulted in 22010 errors:

{standard input}: Assembler messages:
{standard input}:181155: Error: operand out of range (0x0000000000008164 is not between 0xffffffffffff8000 and 0x0000000000007fff)
{standard input}:181192: Error: operand out of range (0x000000000000816c is not between 0xffffffffffff8000 and 0x0000000000007fff)
{standard input}:181211: Error: operand out of range (0x0000000000008080 is not between 0xffffffffffff8000 and 0x0000000000007fff)
{standard input}:181220: Error: operand out of range (0x00000000000081b8 is not between 0xffffffffffff8000 and 0x0000000000007fff)
{standard input}:181225: Error: operand out of range (0x0000000000008168 is not between 0xffffffffffff8000 and 0x0000000000007fff)
[...]

Separate compilation + assembling of given portion of code avoids exceeding
capabilities of compiler / assembler.

Bug: https://bugs.gentoo.org/829602
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tested-by: erhard_f@mailbox.org <erhard_f@mailbox.org>

Diff Detail

Event Timeline

thesamesam created this revision.Oct 19 2022, 12:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 19 2022, 12:14 PM
thesamesam requested review of this revision.Oct 19 2022, 12:14 PM
mgorny added inline comments.Oct 19 2022, 8:01 PM
clang-tools-extra/clangd/CMakeLists.txt
48

Since the file is included, can't you just pass it via variable (i.e. set with PARENT_SCOPE)?

nridge added a subscriber: nridge.Oct 24 2022, 12:51 AM
thesamesam updated this revision to Diff 472807.Nov 2 2022, 4:45 PM

Use PARENT_SCOPE.

thakis added inline comments.Nov 5 2022, 8:14 AM
clang-tools-extra/clangd/quality/CompletionModel.cmake
25

Can we list them? We try not to use globs in cmakelists.txt files.

Arfrever added inline comments.
clang-tools-extra/clangd/quality/CompletionModel.cmake
25

This gen_decision_forest() function is called from 2 places (clang-tools-extra/clangd/CMakeLists.txt, clang-tools-extra/clangd/unittests/CMakeLists.txt), on different models, so this is impossible to do, at least in this file (clang-tools-extra/clangd/quality/CompletionModel.cmake).

And hardcoding of list of files in those CMakeLists.txt files would be inflexible and more fragile, since gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/quality/model CompletionModel ...) generates 301 .cpp files (1 file for each of 300 trees: CompletionModel0.cpp, CompletionModel1.cpp, ... until CompletionModel299.cpp, and 1 file for final function: CompletionModel.cpp).

I don't think we should add significant build-system complexity here in order to support the completion model on ppc32.
Do people actually use clangd on ppc32 machines? (The linked bug calls this a clang build failure, but this code is not part of clang).

If we need to support building on this toolchain, then we should probably just disable the decision forest model entirely and use the heuristic completion scorer instead.

I don't think we should add significant build-system complexity here in order to support the completion model on ppc32.
Do people actually use clangd on ppc32 machines? (The linked bug calls this a clang build failure, but this code is not part of clang).

If we need to support building on this toolchain, then we should probably just disable the decision forest model entirely and use the heuristic completion scorer instead.

I've had a think about this and I'm not aware of anyone using clangd on ppc32. So I agree this patch isn't worth the complexity. But it'd be nice to just switch to the heuristic scorer if it's somewhat easy rather than leave it broken (or bother having to wire up some "PPC is not supported" message). I've got no idea how to do that though.

thakis requested changes to this revision.Dec 7 2022, 8:10 AM

I think this is obsolete now that D139107 is in, right? Marking as "request changes" to get it off my dashboard. Ideally you'll hit "Abandon" (which I can't do since I'm not owner of the patch).

This revision now requires changes to proceed.Dec 7 2022, 8:10 AM
thesamesam abandoned this revision.Dec 7 2022, 8:11 AM

Done, thanks!