Skip to content

Remove unused code from CoreCLR utilcode#123525

Merged
AaronRobinsonMSFT merged 2 commits intomainfrom
copilot/remove-unused-code-utilcode
Jan 23, 2026
Merged

Remove unused code from CoreCLR utilcode#123525
AaronRobinsonMSFT merged 2 commits intomainfrom
copilot/remove-unused-code-utilcode

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Description

Removes dead code from CoreCLR utilcode that has no callers in the codebase.

Changes

  • ClrVirtualAllocAligned - Removed function for aligned memory allocation (declaration in utilcode.h, implementation in util.cpp including UNIXTODO comment)
  • ConfigString - Removed configuration string wrapper class (never instantiated)
  • ConfigMethodSet - Removed configuration method set class with init() and two contains() overloads (never used)

ConfigDWORD is preserved - it's actively used throughout the runtime.

Verification

Grep confirms removed items exist only in their declaration/implementation sites. Build passes in Debug and Release configurations.

Original prompt

Remove the following unused code from the CoreCLR utilcode:

1. ClrVirtualAllocAligned

  • Declaration: src/coreclr/inc/utilcode.h line 521
    LPVOID ClrVirtualAllocAligned(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect, SIZE_T alignment);
  • Definition: src/coreclr/utilcode/util.cpp lines 347-372
    • This function has no callers anywhere in the codebase
    • Also remove the associated UNIXTODO comment within the function body (line 366: // UNIXTODO: Add a specialized function to PAL so that we don't have to waste memory)

2. ConfigString class

  • Declaration: src/coreclr/inc/utilcode.h lines 2775-2805
    /**************************************************************************/
    class ConfigString
    {
    public:
        inline LPWSTR val(const CLRConfig::ConfigStringInfo & info)
        ...
    private:
        void init(const CLRConfig::ConfigStringInfo & info);
    private:
        LPWSTR m_value;
        BYTE m_inited;
    };
  • Implementation: src/coreclr/utilcode/util.cpp lines 1200-1215
    /**************************************************************************/
    void ConfigString::init(const CLRConfig::ConfigStringInfo & info)
    ...
  • This class is never instantiated anywhere in the codebase

3. ConfigMethodSet class

  • Declaration: src/coreclr/inc/utilcode.h lines 2807-2837
    /**************************************************************************/
    class ConfigMethodSet
    {
    public:
        bool isEmpty()
        ...
        bool contains(LPCUTF8 methodName, LPCUTF8 className, int argCount = -1);
        bool contains(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SIG_INFO* pSigInfo);
        inline void ensureInit(const CLRConfig::ConfigStringInfo & info)
        ...
    private:
        void init(const CLRConfig::ConfigStringInfo & info);
    private:
        MethodNamesListBase m_list;
        BYTE m_inited;
    };
  • Implementation: src/coreclr/utilcode/util.cpp lines 1145-1198
    /**************************************************************************/
    void ConfigMethodSet::init(const CLRConfig::ConfigStringInfo & info)
    ...
    bool ConfigMethodSet::contains(LPCUTF8 methodName, LPCUTF8 className, int argCount)
    ...
    bool ConfigMethodSet::contains(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SIG_INFO* pSigInfo)
    ...
  • This class is never used anywhere in the codebase

Important Note

DO NOT delete ConfigDWORD - this class IS actively used in many places throughout the runtime (rejit.inl, debug.cpp, gccover.cpp, ceemain.cpp, threadsuspend.cpp, shimprocess.cpp, pedecoder.cpp, codeman.cpp, etc.)

Files to modify:

  1. src/coreclr/inc/utilcode.h - Remove declaration of ClrVirtualAllocAligned, and remove the ConfigString and ConfigMethodSet class declarations
  2. src/coreclr/utilcode/util.cpp - Remove the ClrVirtualAllocAligned function definition (including the UNIXTODO comment), and remove the ConfigString::init and all ConfigMethodSet method implementations

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…et from CoreCLR utilcode

Co-authored-by: adityamandaleeka <219224+adityamandaleeka@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove unused ClrVirtualAllocAligned and ConfigString class Remove unused code from CoreCLR utilcode Jan 23, 2026
@adityamandaleeka adityamandaleeka marked this pull request as ready for review January 23, 2026 06:29
Copilot AI review requested due to automatic review settings January 23, 2026 06:29
Copy link
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

Removes dead/unused CoreCLR utilcode helpers that have no callers, reducing maintenance surface area.

Changes:

  • Removed ClrVirtualAllocAligned declaration/definition (and its associated comment block).
  • Removed unused ConfigString and ConfigMethodSet wrappers from utilcode.h and their implementations from util.cpp.
  • Preserved ConfigDWORD (still used elsewhere).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/utilcode/util.cpp Deletes unused implementations (ClrVirtualAllocAligned, ConfigMethodSet, ConfigString).
src/coreclr/inc/utilcode.h Deletes unused declarations for ClrVirtualAllocAligned, ConfigString, and ConfigMethodSet.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

:shipit:

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 6e843b6 into main Jan 23, 2026
113 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the copilot/remove-unused-code-utilcode branch January 23, 2026 15:47
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants