Skip to content

Remove Unused Includes - #127295

Open
moyo1997 wants to merge 23 commits into
dotnet:mainfrom
moyo1997:includecleanup
Open

moyo1997 wants to merge 23 commits into
dotnet:mainfrom
moyo1997:includecleanup

Conversation

@moyo1997

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings April 22, 2026 18:15
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Apr 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR primarily removes a large number of unused/redundant #include directives across CoreCLR, NativeAOT, tooling, and host components, likely aiming to reduce header coupling and improve build hygiene.

Changes:

  • Removed unused or transitive #include directives across many C/C++ translation units.
  • Simplified include sets in VM, JIT, MD, debug, and NativeAOT runtime sources.
  • Updated a few tool/source files to use more specific headers (e.g., caparser.h).
Show a summary per file
File Description
src/native/corehost/hostmisc/longfile.windows.cpp Remove unused include
src/coreclr/vm/virtualcallstub.cpp Remove unused include
src/coreclr/vm/typehandle.cpp Remove unused include (but see opt-restore comment)
src/coreclr/vm/tieredcompilation.cpp Remove unused include
src/coreclr/vm/threadsuspend.cpp Remove unused include
src/coreclr/vm/threads.cpp Remove unused includes
src/coreclr/vm/stublink.cpp Remove unused include
src/coreclr/vm/stubhelpers.cpp Remove unused includes
src/coreclr/vm/stdinterfaces_wrapper.cpp Remove unused include
src/coreclr/vm/stdinterfaces.cpp Remove unused include
src/coreclr/vm/runtimehandles.cpp Remove unused include (but see opt-restore comment)
src/coreclr/vm/readytoruninfo.cpp Remove unused include
src/coreclr/vm/qcallentrypoints.cpp Remove unused includes
src/coreclr/vm/prestub.cpp Remove unused include
src/coreclr/vm/precode_portable.cpp Remove unused include
src/coreclr/vm/pgo.cpp Remove unused include
src/coreclr/vm/perfmap.cpp Remove unused include
src/coreclr/vm/peassembly.cpp Remove unused includes
src/coreclr/vm/onstackreplacement.cpp Remove unused include
src/coreclr/vm/multicorejit.cpp Remove unused include
src/coreclr/vm/methodtable.cpp Remove unused include
src/coreclr/vm/method.cpp Remove unused include
src/coreclr/vm/jitinterfacegen.cpp Remove unused include
src/coreclr/vm/interoputil.cpp Remove unused include
src/coreclr/vm/interoplibinterface_comwrappers.cpp Remove unused includes
src/coreclr/vm/interopconverter.cpp Remove unused include
src/coreclr/vm/gchelpers.cpp Remove optimization pragma includes
src/coreclr/vm/finalizerthread.cpp Remove unused include
src/coreclr/vm/fieldmarshaler.cpp Remove unused include
src/coreclr/vm/exceptionhandling.cpp Remove unused include
src/coreclr/vm/dllimport.cpp Remove unused include
src/coreclr/vm/corelib.cpp Remove unused includes
src/coreclr/vm/comutilnative.cpp Remove unused includes (but see opt-restore comment)
src/coreclr/vm/commodule.cpp Remove unused include
src/coreclr/vm/cominterfacemarshaler.cpp Remove unused include
src/coreclr/vm/comcallablewrapper.cpp Remove unused includes (but see opt-restore comment)
src/coreclr/vm/clsload.cpp Remove unused include
src/coreclr/vm/classcompat.cpp Remove unused includes
src/coreclr/vm/class.cpp Remove unused include
src/coreclr/vm/ceeload.cpp Remove unused include (but see opt-restore comment)
src/coreclr/vm/callcounting.cpp Remove unused include
src/coreclr/vm/binder.cpp Remove unused include
src/coreclr/vm/autotrace.cpp Remove unused include
src/coreclr/vm/assembly.cpp Remove unused includes (but see opt-restore comment)
src/coreclr/vm/appdomain.cpp Remove unused includes
src/coreclr/vm/amd64/cgenamd64.cpp Remove unused include
src/coreclr/utilcode/sstring.cpp Remove unused include
src/coreclr/utilcode/rangelist.cpp Remove unused include
src/coreclr/utilcode/log.cpp Remove unused include
src/coreclr/utilcode/hostimpl.cpp Remove unused include
src/coreclr/tools/superpmi/superpmi/streamingsuperpmi.cpp Remove unused includes
src/coreclr/tools/superpmi/superpmi-shim-simple/superpmi-shim-simple.cpp Remove unused include
src/coreclr/tools/superpmi/superpmi-shim-simple/jithost.cpp Remove unused include
src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp Remove unused includes
src/coreclr/tools/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp Remove unused include
src/coreclr/tools/superpmi/superpmi-shim-counter/jithost.cpp Remove unused include
src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp Remove unused includes
src/coreclr/tools/superpmi/mcs/verbmerge.cpp Remove unused include
src/coreclr/tools/superpmi/mcs/removedup.cpp Remove unused include
src/coreclr/tools/superpmi/mcs/mcs.cpp Remove unused include
src/coreclr/tools/metainfo/mdobj.cpp Remove unused standard includes
src/coreclr/tools/metainfo/mdinfo.cpp Replace CA helper include with caparser.h
src/coreclr/runtime/MiscNativeHelpers.cpp Remove unused include
src/coreclr/nativeaot/Runtime/yieldprocessornormalized.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp Remove unused include
src/coreclr/nativeaot/Runtime/windows/PalCommon.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/threadstore.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/stressLog.cpp Remove unused include
src/coreclr/nativeaot/Runtime/startup.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/rhassert.cpp Remove unused include
src/coreclr/nativeaot/Runtime/portable.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/interoplibinterface_java.cpp Remove unused include
src/coreclr/nativeaot/Runtime/eventtrace_gcheap.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/eventtrace.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp Remove unused include
src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-aot.cpp Remove unused include
src/coreclr/nativeaot/Runtime/event.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp Remove unused include
src/coreclr/nativeaot/Runtime/UniversalTransitionHelpers.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/TypeManager.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/ThunksMapping.cpp Remove unused include
src/coreclr/nativeaot/Runtime/SyncClean.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/RestrictedCallouts.cpp Remove unused include
src/coreclr/nativeaot/Runtime/MiscHelpers.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/MathHelpers.cpp Remove unused include
src/coreclr/nativeaot/Runtime/HandleTableHelpers.cpp Remove unused include
src/coreclr/nativeaot/Runtime/GcStressControl.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/GCHelpers.cpp Remove unused includes
src/coreclr/nativeaot/Runtime/FinalizerHelpers.cpp Remove unused include
src/coreclr/nativeaot/Runtime/EHHelpers.cpp Remove unused include
src/coreclr/nativeaot/Runtime/DebugHeader.cpp Remove unused include
src/coreclr/nativeaot/Runtime/Crst.cpp Remove unused include
src/coreclr/nativeaot/Runtime/AsmOffsetsVerify.cpp Remove unused include
src/coreclr/nativeaot/Bootstrap/main.cpp Remove unused include
src/coreclr/minipal/Windows/memory.cpp Remove unused standard include
src/coreclr/md/runtime/mdinternaldisp.cpp Remove unused include
src/coreclr/md/enc/stgtiggerstream.cpp Remove unused include
src/coreclr/md/compiler/regmeta_vm.cpp Remove unused include
src/coreclr/md/compiler/regmeta_import.cpp Remove unused include
src/coreclr/md/compiler/regmeta_emit.cpp Remove unused include
src/coreclr/md/compiler/regmeta_compilersupport.cpp Remove unused includes
src/coreclr/md/compiler/regmeta.cpp Remove unused include
src/coreclr/md/compiler/custattr_import.cpp Remove unused includes
src/coreclr/jit/simdcodegenxarch.cpp Remove unused include
src/coreclr/jit/promotiondecomposition.cpp Remove unused include
src/coreclr/jit/promotion.cpp Remove unused include
src/coreclr/jit/loopcloning.cpp Remove unused include
src/coreclr/jit/importer.cpp Remove unused include
src/coreclr/jit/ee_il_dll.cpp Remove unused include
src/coreclr/jit/dllmain.cpp Remove unused include
src/coreclr/jit/block.cpp Remove unused include
src/coreclr/interop/interoplib.cpp Remove unused include
src/coreclr/ildasm/windasm.cpp Remove unused include
src/coreclr/ildasm/ildasmpch.cpp Remove include (now empty TU)
src/coreclr/ildasm/dres.cpp Remove unused include
src/coreclr/gcinfo/arraylist.cpp Remove unused include
src/coreclr/gc/vxsort/do_vxsort_avx512.cpp Remove redundant includes
src/coreclr/gc/vxsort/do_vxsort_avx2.cpp Remove redundant includes
src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp Remove unused include
src/coreclr/dlls/mscoree/exports.cpp Remove unused include
src/coreclr/debug/runtimeinfo/runtimeinfo.cpp Remove unused include
src/coreclr/debug/ee/funceval.cpp Remove unused include
src/coreclr/debug/ee/debuggermodule.cpp Remove unused include
src/coreclr/debug/ee/dactable.cpp Remove unused include
src/coreclr/debug/ee/amd64/walker.cpp Remove unused include
src/coreclr/debug/di/dbgtransportmanager.cpp Remove unused include
src/coreclr/debug/debug-pal/win/processdescriptor.cpp Remove unused includes
src/coreclr/debug/daccess/dacfn.cpp Remove unused include
src/coreclr/debug/createdump/main.cpp Remove unused include
src/coreclr/binder/assembly.cpp Remove unused include

Copilot's findings

Comments suppressed due to low confidence (1)

src/coreclr/vm/ceeload.cpp:4469

  • <optsmallperfcritical.h> is included with the comment 'Optimization intended for Module::EnsureActive only', but the corresponding <optdefault.h> restore was removed. This causes subsequent code in the file to be built under the perf-critical optimization settings; re-add the restore include after Module::EnsureActive to keep the optimization scope limited as intended.
  • Files reviewed: 132/132 changed files
  • Comments generated: 5

Comment thread src/coreclr/vm/assembly.cpp
Comment thread src/coreclr/vm/comcallablewrapper.cpp
Comment thread src/coreclr/vm/runtimehandles.cpp
Comment thread src/coreclr/vm/typehandle.cpp
Comment thread src/coreclr/vm/comutilnative.cpp
Copilot AI review requested due to automatic review settings April 22, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (4)

src/coreclr/gc/vxsort/do_vxsort_avx2.cpp:10

  • The vxsort_targets_enable_avx2.h / vxsort_targets_disable.h includes were removed. These headers push/pop compiler target attributes (e.g., target("avx2")) so this function is compiled with the required ISA. Without them, the build can fail (unsupported intrinsics) or the function may not be properly isolated to AVX2-capable CPUs. Please restore the enable/disable includes around this implementation.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include "common.h"


#include "vxsort.h"
#include "machine_traits.avx2.h"
#include "packer.h"

src/coreclr/vm/perfmap.cpp:10

  • common.h was removed, but this file includes perfmap.h, which depends on CoreCLR VM types/macros (e.g., MethodDesc, PCODE, contracts, CrstStatic) that are normally provided via common.h. As-is, this is very likely to fail to compile. Please re-add #include "common.h" (typically first) so the required VM definitions are available.
    src/coreclr/vm/autotrace.cpp:26
  • common.h was removed, but this file uses CoreCLR VM infrastructure (CLRConfig, W(...), u16_strlen, FormatInteger, HANDLE, etc.) that is typically made available via common.h/the VM PCH. As written, this is likely to fail to compile. Please restore #include "common.h" near the top of the file.
    src/coreclr/gc/vxsort/do_vxsort_avx512.cpp:10
  • The vxsort_targets_enable_avx512.h / vxsort_targets_disable.h includes were removed. These headers push/pop compiler target attributes so this function is compiled with AVX-512 enabled. Without them, the build can fail or the function may not be correctly isolated to AVX-512-capable CPUs. Please restore the enable/disable includes around this implementation.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include "common.h"


#include "vxsort.h"
#include "machine_traits.avx512.h"

void do_vxsort_avx512 (uint8_t** low, uint8_t** high, uint8_t* range_low, uint8_t* range_high)
  • Files reviewed: 131/131 changed files
  • Comments generated: 6

Comment thread src/coreclr/vm/typehandle.cpp
Comment thread src/coreclr/vm/comcallablewrapper.cpp
Comment thread src/coreclr/vm/ceeload.cpp
Comment thread src/coreclr/vm/assembly.cpp
Comment thread src/coreclr/vm/gchelpers.cpp
Comment thread src/coreclr/vm/precode_portable.cpp
Copilot AI review requested due to automatic review settings April 22, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (3)

src/coreclr/ildasm/ildasmpch.cpp:6

  • ildasmpch.cpp is the compilation unit used to build the ildasm precompiled header, but it no longer includes ildasmpch.h. Without including the PCH header, PCH generation (and builds that rely on it) may fail. Please restore #include "ildasmpch.h" in this file.
//
// This is just to build the PCH for ildasm

src/coreclr/vm/perfmap.cpp:13

  • perfmap.h depends on CoreCLR VM types/macros (e.g., CrstStatic, _ASSERTE, ARRAY_SIZE) that are normally provided via common.h. With the common.h include removed here, this translation unit may fail to compile (or become dependent on forced includes/PCH behavior) when including clrconfignocache.h / perfmap.h. Re-add #include "common.h" (or include the specific required headers) before these includes to keep the file self-contained across build configurations.
    src/coreclr/vm/autotrace.cpp:26
  • This file uses many CoreCLR/Win32 types and helpers (CLRConfig, HANDLE, WCHAR, CreateEventW, FormatInteger, etc.). With common.h removed, it now has no general runtime header included, which can lead to missing declarations unless the build forcibly includes common.h for this TU. Please restore the common.h include (or add the minimal required headers) to avoid build-config-dependent compilation.
  • Files reviewed: 128/130 changed files
  • Comments generated: 2

Comment thread src/coreclr/vm/precode_portable.cpp
Comment thread src/coreclr/utilcode/sstring.cpp
@jkotas

jkotas commented Apr 22, 2026

Copy link
Copy Markdown
Member

Could you please update the PR title and description with what you are trying to achieve?

@moyo1997 moyo1997 changed the title attempt 1 Remove Unused Includes Apr 22, 2026
Copilot AI review requested due to automatic review settings April 22, 2026 22:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

src/coreclr/ildasm/ildasmpch.cpp:6

  • This file’s comment says it exists "to build the PCH for ildasm", but after removing the #include "ildasmpch.h" it no longer does that. Either restore the include (if a PCH is still intended) or remove/update this file and any build references so the comment and build intent stay accurate.
//
// This is just to build the PCH for ildasm

  • Files reviewed: 124/126 changed files
  • Comments generated: 1

Comment thread src/coreclr/vm/gchelpers.cpp
Copilot AI review requested due to automatic review settings April 22, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (2)

src/coreclr/vm/comutilnative.cpp:1734

  • <optsmallperfcritical.h> is still included for the COMInterlocked FCIMPLs, but the <optdefault.h> include that restores default optimization settings was removed. This causes the optimization pragmas (and FPO_ON) to leak into the rest of the file. Please re-add <optdefault.h> after the last COMInterlocked FCIMPL in this block.
    src/coreclr/vm/gchelpers.cpp:1600
  • This hunk removes the <optsmallperfcritical.h> / <optdefault.h> pair that previously scoped MSVC optimization pragmas for ErectWriteBarrier. Those headers are not “unused” includes; they change codegen (optimize-for-speed and frame-pointer omission in non-debug MSVC builds). If the intent is to keep ErectWriteBarrier perf-critical, please restore the scoped optimization includes around it; otherwise, consider updating/removing the nearby comment(s) or adding a justification since this can be a measurable perf regression in a very hot path.
  • Files reviewed: 122/124 changed files
  • Comments generated: 0 new

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (2)

src/coreclr/vm/autotrace.cpp:25

  • common.h was removed, but this file uses VM contracts/macros (e.g., CLRConfig, HANDLE, LPWSTR, STANDARD_VM_CONTRACT) that are typically provided via the CoreCLR precompiled header. As written, this will fail to compile (especially on MSVC with PCH enabled). Add back the appropriate PCH/header include (likely common.h) or include the specific headers that define these types/macros before they are used.
    src/coreclr/vm/perfmap.cpp:12
  • common.h was removed before including perfmap.h. perfmap.h references CoreCLR VM types (e.g., MethodDesc, PCODE, CrstStatic, contracts macros) that are not declared in this file’s current include set, so this will not compile when FEATURE_PERFMAP is enabled. Add back #include "common.h" (or otherwise ensure the required forward declarations/includes exist before perfmap.h).
  • Files reviewed: 119/121 changed files
  • Comments generated: 0 new

@huoyaoyuan

Copy link
Copy Markdown
Member

I don't think this can be done in a batch way. The native build of the codebase is very complicated, with various different platforms and include tricks. There are false positives like removing the pch file or functionality toggling headers. This shouldn't be done by who is not very familiar to the codebase.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (6)

src/coreclr/vm/runtimehandles.cpp:223

  • #include <optsmallperfcritical.h> is used just above for RuntimeTypeHandle::GetNextIntroducedMethod, but the corresponding #include <optdefault.h> was removed. This will keep the perf-critical optimization pragmas enabled for subsequent methods in this file; please restore optdefault.h after the intended region.
    src/coreclr/vm/comcallablewrapper.cpp:1178
  • This file enables #include <optsmallperfcritical.h> for the CCW QI helpers, but the matching #include <optdefault.h> after QIStandardInterface was removed. That leaves the optimization pragmas active for the remainder of the file; please restore optdefault.h after the intended perf-critical section.
    src/coreclr/vm/perfmap.cpp:12
  • common.h was removed, but this translation unit uses VM infrastructure types/macros (e.g., Volatile, CrstStatic, CLRConfig, contract macros) that are typically provided via common.h/the VM PCH. This is likely to cause compile failures; restore #include "common.h" as the first include in the file.
    src/coreclr/vm/gchelpers.cpp:1600
  • ErectWriteBarrier is a hot path and previously had an optsmallperfcritical.h/optdefault.h optimization bracket. Removing those includes changes compiler optimization settings for this function (and may regress write barrier performance). If the intent is only to remove unused includes, keep the optimization bracket (or replace it with an equivalent pragma).
    src/coreclr/vm/autotrace.cpp:26
  • common.h was removed, but this file uses many VM types/macros (e.g., HANDLE, WCHAR, CLRConfig, contract macros) that are normally provided via common.h/the VM PCH. This will likely break the build (and may also violate the PCH include requirement). Add #include "common.h" back as the first include for this translation unit.
    src/coreclr/ildasm/ildasmpch.cpp:6
  • This file exists to build the ildasm precompiled header, but it no longer includes ildasmpch.h. With MSVC /Yc this will typically fail (or produce an empty/incorrect PCH). Restore the #include "ildasmpch.h" in this TU (or adjust the build to generate the PCH elsewhere).
//
// This is just to build the PCH for ildasm

  • Files reviewed: 117/119 changed files
  • Comments generated: 2

Comment thread src/coreclr/vm/clsload.cpp
Comment thread src/coreclr/tools/superpmi/superpmi/streamingsuperpmi.cpp
Copilot AI review requested due to automatic review settings May 13, 2026 21:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 102/105 changed files
  • Comments generated: 0 new

Copilot AI review requested due to automatic review settings May 14, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (3)

src/coreclr/vm/comcallablewrapper.cpp:1

  • Typo in comment: 'IObjctSafe' should be 'IObjectSafe'. While this line is not part of the diff, it is adjacent to changes; consider correcting if touching this header block.
    src/coreclr/nativeaot/Runtime/portable.cpp:1
  • PalLimitedContext.h was removed but CommonMacros.inl and downstream headers in this file may rely on types declared by it (it was previously included before CommonMacros.inl, matching the include order used in sibling files such as ThunksMapping.cpp and event.cpp). Please verify this file still compiles on all targets, since the ordering and presence of PalLimitedContext.h appears load-bearing in other runtime files.
    src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp:1
  • Removing <eventpipe/ep-metadata-generator.h> and <eventpipe/ep-buffer-manager.h> may break builds if any function in this file references ep_metadata_generator_* or ep_buffer_manager_* APIs (these are commonly used by EventPipeInternal::WriteEventData / buffer management paths). Please confirm these are no longer referenced anywhere in the file before removing.
  • Files reviewed: 102/102 changed files
  • Comments generated: 2

@@ -17,8 +17,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#pragma hdrstop
#endif

#include "../../vm/eedbginterfaceimpl.h"
#include "../../vm/common.h"
#include "../../vm/gcenv.h"
#include "../../vm/ecall.h"
@am11

am11 commented May 14, 2026

Copy link
Copy Markdown
Member

As @huoyaoyuan mentioned, this is a non-trivial and unnecessary exercise as a standalone, as a "first PR" in runtime repo. There are number of header includes for platform matrix which is not part of the default CI. Not worth it..

moyo1997 added a commit to moyo1997/runtime that referenced this pull request May 15, 2026
Apply the 102 file changes from dotnet/runtime PR dotnet#127295 which removes
unused #include directives from C++ source files across coreclr and
native host components.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/coreclr/vm/qcallentrypoints.cpp Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 102 out of 102 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/tools/superpmi/superpmi/streamingsuperpmi.cpp
@jkotas

jkotas commented Jun 9, 2026

Copy link
Copy Markdown
Member

FYI: @moyo1997 works on Microsoft C++ team. This PR was produced by a code cleanup tool that they are working on.

@jkotas

jkotas commented Jun 9, 2026

Copy link
Copy Markdown
Member

@moyo1997 Could you please resolve the conflict


#ifdef FEATURE_TIERED_COMPILATION

#include "callcounting.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change looks questionable

Comment on lines 22 to 23


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@moyo1997, please follow up on the code review.

@JulieLeeMSFT JulieLeeMSFT added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jul 6, 2026
@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "a86a00a0de4272cabf5e2485114bbac76367dd7a",
  "last_dispatched_base_ref": "main",
  "last_dispatched_base_sha": "1a591cdf54249e2c2a28b1161a12be09c93d6090",
  "last_reviewed_commit": "a86a00a0de4272cabf5e2485114bbac76367dd7a",
  "last_reviewed_base_ref": "main",
  "last_reviewed_base_sha": "1a591cdf54249e2c2a28b1161a12be09c93d6090",
  "last_recorded_worker_run_id": "29679158312",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "a86a00a0de4272cabf5e2485114bbac76367dd7a",
      "review_id": 4730526726
    }
  ]
}

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Holistic Review

Motivation: This community PR removes unused/redundant #include directives across CoreCLR, NativeAOT, the JIT, the metadata layer, SuperPMI tooling, and the host. Reducing header coupling lowers incremental build times and clarifies each translation unit's real dependencies. This is pure cleanup: 102 files, 178 deletions, 0 additions.

Approach: Individual #include lines are deleted where the header's declarations are not directly referenced (and are still available transitively, e.g. via common.h, or genuinely unneeded). The changes are mechanical and localized to include blocks; no functional code is touched.

Summary: The current base-to-head diff is low-risk and mechanically sound. Notably, several earlier revisions of this PR contained genuinely dangerous removals — dropping <optdefault.h> restores that scope #pragma optimize regions (assembly.cpp, comcallablewrapper.cpp, runtimehandles.cpp, typehandle.cpp, comutilnative.cpp, ceeload.cpp), removing common.h from precode_portable.cpp, and removing needed headers from sstring.cpp, ildasmpch.cpp, dbgtransportmanager.cpp, autotrace.cpp, and gchelpers.cpp. All of those have been reverted and are no longer present in the current diff, which addresses the substantive correctness and performance concerns raised by the built-in Copilot reviewer and by @jkotas. I spot-checked that removed-but-still-needed headers remain reachable transitively (e.g., callcounting.h is pulled in via common.h at vm/common.h:298; the qcall table headers such as floatdouble.h/floatsingle.h are still included where the FCFuncs are actually defined in corelib.cpp).

Verdict: LGTM. The remaining concern is verification breadth rather than any specific defect: because header removals can compile fine in one configuration yet break another, the real gate is green CI across the full matrix (Windows/Unix, x64/arm64, checked/release, DAC, NativeAOT, and the mobile/interp configurations that some of these files are gated to via FEATURE_*/TARGET_*). Please confirm a broad CI run is green before merging. Only minor style nits remain (see Detailed Findings); none are blocking.

Detailed Findings

  • Minor (style): A few removals leave two consecutive blank lines where the include used to be, e.g. src/coreclr/vm/peassembly.cpp (around the removed sha1.h line) and src/coreclr/jit/block.cpp (the leftover blank line after removing jitstd/algorithm.h). Collapsing these to a single blank line keeps the include blocks tidy. @jkotas already flagged the block.cpp case; the same treatment applies to the other spots.
  • Non-blocking (verification): The value of an include-cleanup PR is entirely established by the build. Since this worker does not build or run tests, the correctness of each removal rests on full-matrix CI. Configuration-conditional files are the ones most likely to surprise — e.g. NativeAOT event.h/regdisplay.h removals, md/compiler/* posterror.h removals, and Windows-only host code — so a green run that exercises those legs is the meaningful sign-off.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 159.8 AIC · ⌖ 10.7 AIC · ⊞ 10K

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

@moyo1997 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ),
and conveys certain license rights to the .NET Foundation ( “.NET Foundation” ) for Your contributions to
.NET Foundation open source projects. This Agreement is effective as of the latest signature date below.

1. Definitions.

“Code” means the computer software code, whether in human-readable or machine-executable form,
that is delivered by You to .NET Foundation under this Agreement.

“Project” means any of the projects owned or managed by .NET Foundation and offered under a license
approved by the Open Source Initiative (www.opensource.org).

“Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
Project, including but not limited to communication on electronic mailing lists, source code control
systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
discussing and improving that Project, but excluding communication that is conspicuously marked or
otherwise designated in writing by You as “Not a Submission.”

“Submission” means the Code and any other copyrightable material Submitted by You, including any
associated comments and documentation.

2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
Project. This Agreement covers any and all Submissions that You, now or in the future (except as
described in Section 4 below), Submit to any Project.

3. Originality of Work. You represent that each of Your Submissions is entirely Your
original work. Should You wish to Submit materials that are not Your original work,
You may Submit them separately to the Project if You (a) retain all copyright and
license information that was in the materials as you received them, (b) in the
description accompanying your Submission, include the phrase "Submission
containing materials of a third party:" followed by the names of the third party and any
licenses or other restrictions of which You are aware, and (c) follow any other
instructions in the Project's written guidelines concerning Submissions.

4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
Submission is made in the course of Your work for an employer or Your employer has intellectual
property rights in Your Submission by contract or applicable law, You must secure permission from Your
employer to make the Submission before signing this Agreement. In that case, the term “You” in this
Agreement will refer to You and the employer collectively. If You change employers in the future and
desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
and secure permission from the new employer before Submitting those Submissions.

5. Licenses.

a. Copyright License. You grant .NET Foundation, and those who receive the Submission directly
or indirectly from .NET Foundation, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable
license in the Submission to reproduce, prepare derivative works of, publicly display, publicly perform,
and distribute the Submission and such derivative works, and to sublicense any or all of the foregoing
rights to third parties.

b. Patent License. You grant .NET Foundation, and those who receive the Submission directly or
indirectly from .NET Foundation, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license
under Your patent claims that are necessarily infringed by the Submission or the combination of the
Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
import or otherwise dispose of the Submission alone or with the Project.

c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
granted by implication, exhaustion, estoppel or otherwise.

6. Representations and Warranties. You represent that You are legally entitled to grant the above
licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
have disclosed under Section 3 ). You represent that You have secured permission from Your employer to
make the Submission in cases where Your Submission is made in the course of Your work for Your
employer or Your employer has intellectual property rights in Your Submission by contract or applicable
law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
EXPRESSLY STATED IN SECTIONS 3, 4, AND 6 , THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

7. Notice to .NET Foundation. You agree to notify .NET Foundation in writing of any facts or
circumstances of which You later become aware that would make Your representations in this
Agreement inaccurate in any respect.

8. Information about Submissions. You agree that contributions to Projects and information about
contributions may be maintained indefinitely and disclosed publicly, including Your name and other
information that You submit with Your Submission.

9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
defenses of lack of personal jurisdiction and forum non-conveniens.

10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
supersedes any and all prior agreements, understandings or communications, written or oral, between
the parties relating to the subject matter hereof. This Agreement may be assigned by .NET Foundation.

.NET Foundation dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-coreclr community-contribution Indicates that the PR has been added by a community member needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants