Skip to content

Remove Unused Includes#127295

Draft
moyo1997 wants to merge 14 commits intodotnet:mainfrom
moyo1997:includecleanup
Draft

Remove Unused Includes#127295
moyo1997 wants to merge 14 commits intodotnet: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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 on lines 1932 to 1936
RETURN;
}

#include <optdefault.h>
CHECK Assembly::CheckLoadLevel(FileLoadLevel requiredLevel, BOOL deadlockOK)
{
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

<optsmallperfcritical.h> is used for Assembly::EnsureLoadLevel (see the comment immediately above), but the matching <optdefault.h> restore was removed here. That makes the perf-critical optimization settings apply to the rest of this translation unit; re-add the restore include after EnsureLoadLevel so the optimization scope matches the comment intent.

Copilot uses AI. Check for mistakes.
Comment on lines 1171 to 1175

RETURN NULL;
}
#include <optdefault.h>

//--------------------------------------------------------------------------
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This file still switches into the perf-critical optimization mode via <optsmallperfcritical.h> earlier, but the matching <optdefault.h> restore was removed here. Without restoring defaults, the remainder of the file will compile under the perf-critical settings; re-add the restore include after QIStandardInterface to keep the optimization scope limited (see the common pattern in src/coreclr/vm/methodtable.cpp around GetDispatchMap).

Copilot uses AI. Check for mistakes.
Comment on lines 214 to 220

*ppMethod = pMethod;
}
FCIMPLEND
#include <optdefault.h>

FCIMPL1(AssemblyBaseObject*, RuntimeTypeHandle::GetAssemblyIfExists, ReflectClassBaseObject *pTypeUNSAFE)
{
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

<optsmallperfcritical.h> is used for RuntimeTypeHandle::GetNextIntroducedMethod, but the corresponding <optdefault.h> restore was removed after the FCIMPL block. This will keep the rest of the file under the perf-critical optimization settings; re-add the restore include after FCIMPLEND to avoid unintended codegen/code-size changes.

Copilot uses AI. Check for mistakes.
Comment on lines 684 to 688

return CastCache::TryGetFromCache(*this, type);
}
#include <optdefault.h>

#endif // #ifndef DACCESS_COMPILE
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

<optsmallperfcritical.h> is still used for TypeHandle::CanCastToCached, but the matching <optdefault.h> restore was removed after the method. Without restoring defaults, the rest of the translation unit will compile under the perf-critical optimization settings; re-add the restore include after CanCastToCached to keep the scope minimal.

Copilot uses AI. Check for mistakes.
Comment on lines 1729 to 1733
FCIMPLEND

#include <optdefault.h>

static BOOL HasOverriddenMethod(MethodTable* mt, MethodTable* classMT, WORD methodSlot)
{
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

<optsmallperfcritical.h> is enabled for the COMInterlocked::* FCIMPL block, but the corresponding <optdefault.h> restore was removed before the following non-interlocked helpers. This keeps the remainder of the file under the perf-critical optimization settings; re-add the restore include after the last COMInterlocked FCIMPL to limit the scope.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 22, 2026 20:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 on lines 684 to 689

return CastCache::TryGetFromCache(*this, type);
}
#include <optdefault.h>

#endif // #ifndef DACCESS_COMPILE

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

optsmallperfcritical.h is included for TypeHandle::CanCastToCached, but the corresponding #include <optdefault.h> that resets #pragma optimize was removed. This can leave the rest of the translation unit compiled under the perf-critical optimization settings. Add #include <optdefault.h> immediately after the perf-critical section (right after CanCastToCached) to restore default optimization settings.

Copilot uses AI. Check for mistakes.
Comment on lines 1171 to 1176

RETURN NULL;
}
#include <optdefault.h>

//--------------------------------------------------------------------------
// Init Outer unknown, cache a GIT cookie
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

#include <optsmallperfcritical.h> is used earlier to improve CCW QI performance, but the matching #include <optdefault.h> that reverts optimization settings was removed here. Please restore #include <optdefault.h> after the QI perf-critical region to ensure the remainder of the file is compiled with the intended default optimization settings.

Copilot uses AI. Check for mistakes.
Comment on lines 4463 to 4468
}
#endif // DACCESS_COMPILE

#include <optdefault.h>

CHECK Module::CheckActivated()
{
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

Module::EnsureActive is marked as perf-critical via #include <optsmallperfcritical.h>, but the corresponding #include <optdefault.h> to revert optimization settings was removed in this area. Re-add #include <optdefault.h> after EnsureActive so subsequent code in this TU uses default optimization settings.

Copilot uses AI. Check for mistakes.
Comment on lines 1932 to 1937
RETURN;
}

#include <optdefault.h>
CHECK Assembly::CheckLoadLevel(FileLoadLevel requiredLevel, BOOL deadlockOK)
{
CONTRACTL
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

Assembly::EnsureLoadLevel is placed under #include <optsmallperfcritical.h>, but #include <optdefault.h> was removed here. Please restore #include <optdefault.h> after the perf-critical region so the rest of the file is compiled with default optimization settings.

Copilot uses AI. Check for mistakes.
Comment on lines 1593 to 1597
// This function sets the card table with the granularity of 1 byte, to avoid ghost updates
// that could occur if multiple threads were trying to set different bits in the same card.

#include <optsmallperfcritical.h>
void ErectWriteBarrier(OBJECTREF *dst, OBJECTREF ref)
{
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The perf-tuning pragmas around ErectWriteBarrier were removed (optsmallperfcritical.h / optdefault.h). This write barrier is extremely hot, and dropping the perf-critical optimization region is likely a measurable regression. Please keep the perf-critical optimization scope (or an equivalent mechanism) around ErectWriteBarrier and ensure default optimization is restored afterward.

Copilot uses AI. Check for mistakes.
Comment on lines 4 to 9

#ifdef FEATURE_PORTABLE_ENTRYPOINTS

#include "common.h"
#include "precode_portable.hpp"

#ifdef HOST_64BIT
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

common.h was removed, but precode_portable.hpp relies on VM-wide types/macros (e.g., PCODE, MethodDesc, Volatile, contract macros) and does not include them itself. This change is likely to break compilation of this translation unit. Please restore #include "common.h" (usually as the first include) before including precode_portable.hpp.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 22, 2026 21:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 on lines 5 to 8
#ifdef FEATURE_PORTABLE_ENTRYPOINTS

#include "common.h"
#include "precode_portable.hpp"

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

precode_portable.hpp relies on CoreCLR VM types/macros (e.g., PCODE, MethodDesc, contracts, _ASSERTE) that are typically provided by including common.h first. With common.h removed from this .cpp, the file becomes dependent on forced includes/PCH behavior and may fail to compile in configurations where common.h isn't pre-included. Please restore the common.h include (or add the specific dependencies needed before including precode_portable.hpp).

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 13
#include "stdafx.h"
#include "sstring.h"
#include "ex.h"
#include "holder.h"
#include <minipal/strings.h>

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This file calls minipal_toupper_invariant / minipal_tolower_invariant under !SELF_NO_HOST, but the #include <minipal/strings.h> that declares those APIs was removed. Please restore the include (or include another header that declares these functions) to avoid missing-prototype build errors.

Copilot uses AI. Check for mistakes.
@jkotas
Copy link
Copy Markdown
Member

jkotas commented Apr 22, 2026

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
@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.

Copilot AI review requested due to automatic review settings April 22, 2026 22:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 on lines 1593 to 1598
// This function sets the card table with the granularity of 1 byte, to avoid ghost updates
// that could occur if multiple threads were trying to set different bits in the same card.

#include <optsmallperfcritical.h>
void ErectWriteBarrier(OBJECTREF *dst, OBJECTREF ref)
{
STATIC_CONTRACT_MODE_COOPERATIVE;
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The removed optsmallperfcritical.h / optdefault.h includes are not "unused"—they scope compiler optimization pragmas around ErectWriteBarrier. Dropping them changes how this hot write-barrier helper is optimized and can regress performance (and may also change which optimizations apply to code that follows). Consider restoring the optimization-scope headers (or replacing them with an equivalent, explicit pragma scope) if the intent is to keep this function in the perf-critical optimization mode.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 22, 2026 23:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 review requested due to automatic review settings April 23, 2026 03:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 review requested due to automatic review settings April 23, 2026 16:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 on lines 20 to 23
#include "excep.h"
#include "threads.h"
#include "comsynchronizable.h"
#include "threads.h"
#include "dllimport.h"
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

There are duplicate includes (threads.h and also vars.hpp later). Since this change is touching the include list, consider removing duplicates to keep the include set minimal and make include-order dependencies clearer.

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 13
#include "commandline.h"
#include "errorhandling.h"
#include "methodcontext.h"
#include "methodcontextreader.h"
#include "spmiutil.h"
#include "fileio.h"
#include "commandline.h"
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

commandline.h is included twice (at the top include list and again a few lines later). Since this PR is already adjusting includes, remove the duplicate include to keep the header list minimal and avoid confusion about include-order dependencies.

Copilot uses AI. Check for mistakes.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants