This is an archive of the discontinued LLVM Phabricator instance.

Cleanup LLVMMC headers
ClosedPublic

Authored by serge-sans-paille on Feb 8 2022, 7:01 AM.

Details

Summary

There's a few relevant forward declarations in there that may require downstream
adding explicit includes:

llvm/MC/MCContext.h no longer includes llvm/BinaryFormat/ELF.h, llvm/MC/MCSubtargetInfo.h, llvm/MC/MCTargetOptions.h
llvm/MC/MCObjectStreamer.h no longer include llvm/MC/MCAssembler.h
llvm/MC/MCAssembler.h no longer includes llvm/MC/MCFixup.h, llvm/MC/MCFragment.h

Counting preprocessed lines required to rebuild llvm-project on my setup:
before: 1052436830
after: 1049293745

Which is significant and backs up the change in addition to the usual benefits of
decreasing coupling between headers and compilation units.

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Feb 8 2022, 7:01 AM
pengfei added a subscriber: skan.Feb 8 2022, 7:06 AM
MaskRay accepted this revision.Feb 8 2022, 8:00 PM

LGTM.

llvm/include/llvm/MC/MCContext.h
48

The clang-format should be done separately.

llvm/include/llvm/MC/MCDwarf.h
33

move this below

llvm/include/llvm/MC/MCLinkerOptimizationHint.h
27

sort

llvm/include/llvm/MC/MCStreamer.h
41

Sort at least MC* declarations

llvm/lib/MC/MCAssembler.cpp
44

forward declarations are usually after using namespace llvm;

This revision is now accepted and ready to land.Feb 8 2022, 8:00 PM
MaskRay added inline comments.Feb 8 2022, 8:01 PM
llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
2405 ↗(On Diff #406811)

sort

Consider committing this change separately

This revision was landed with ongoing or failed builds.Feb 9 2022, 2:09 AM
This revision was automatically updated to reflect the committed changes.

Hi it seems like this change might have been responsible for the lldb incremental bot to have broken

/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/../include/c++/v1/__memory/unique_ptr.h:50:19: error: missing '#include "llvm/MC/MCSubtargetInfo.h"'; 'MCSubtargetInfo' must be defined before it is used

static_assert(sizeof(_Tp) > 0,
              ^

/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/../include/c++/v1/__memory/unique_ptr.h:315:7: note: in instantiation of member function 'std::default_delete<llvm::MCSubtargetInfo>::operator()' requested here

__ptr_.second()(__tmp);
^

/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/../include/c++/v1/__memory/unique_ptr.h:269:19: note: in instantiation of member function 'std::unique_ptr<llvm::MCSubtargetInfo>::reset' requested here

~unique_ptr() { reset(); }
                ^

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/DWARFLinker/DWARFStreamer.h:46:3: note: in instantiation of member function 'std::unique_ptr<llvm::MCSubtargetInfo>::~unique_ptr' requested here

DwarfStreamer(OutputFileType OutFileType, raw_pwrite_stream &OutFile,
^

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCSubtargetInfo.h:76:7: note: definition here is not reachable
class MCSubtargetInfo {

^

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp:9:10: fatal error: could not build module 'LLVM_DWARFLinker'
#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h"

Build is here: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41179/

Please revert the change or fix it as soon as poosible, thanks

Hi it seems like this change might have been responsible for the lldb incremental bot to have broken

/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/../include/c++/v1/__memory/unique_ptr.h:50:19: error: missing '#include "llvm/MC/MCSubtargetInfo.h"'; 'MCSubtargetInfo' must be defined before it is used

static_assert(sizeof(_Tp) > 0,
              ^

/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/../include/c++/v1/__memory/unique_ptr.h:315:7: note: in instantiation of member function 'std::default_delete<llvm::MCSubtargetInfo>::operator()' requested here

__ptr_.second()(__tmp);
^

/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/../include/c++/v1/__memory/unique_ptr.h:269:19: note: in instantiation of member function 'std::unique_ptr<llvm::MCSubtargetInfo>::reset' requested here

~unique_ptr() { reset(); }
                ^

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/DWARFLinker/DWARFStreamer.h:46:3: note: in instantiation of member function 'std::unique_ptr<llvm::MCSubtargetInfo>::~unique_ptr' requested here

DwarfStreamer(OutputFileType OutFileType, raw_pwrite_stream &OutFile,
^

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCSubtargetInfo.h:76:7: note: definition here is not reachable
class MCSubtargetInfo {

^

/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp:9:10: fatal error: could not build module 'LLVM_DWARFLinker'
#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h"

Build is here: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41179/

Please revert the change or fix it as soon as poosible, thanks

Is this a LLVM_ENABLE_MODULES=on build? For regular build check-lldb builds.

I added a possibly missing header to llvm/include/llvm/DWARFLinker/DWARFStreamer.h and am building a module build to confirm.