Repository: dotnet/runtime
File: src/coreclr/jit/compiler.h (C/C++)

Code before:
    // State information - which phases have completed?
    // These are kept together for easy discoverability

    bool    compAllowStress                = true;
    bool    compCodeGenDone                = false;
    int64_t compNumStatementLinksTraversed = 0;     // # of links traversed while doing debug checks
    bool    fgNormalizeEHDone              = false; // Has the flowgraph EH normalization phase been done?
    size_t  compSizeEstimate;                       // The estimated size of the method as per `gtSetEvalOrder`.
    size_t  compCycleEstimate;                      // The estimated cycle count of the method as per `gtSetEvalOrder`
    bool    compPoisoningAnyImplicitByrefs = false; // Importer inserted IR before returns to poison implicit byrefs

#endif // DEBUG

    bool fgLocalVarLivenessDone         = false; // Note that this one is used outside of debug.
    bool fgDidEarlyLiveness             = false;
    bool compPostImportationCleanupDone = false;
    bool compRegAllocDone               = false;
    bool compRationalIRForm             = false;

    bool compGeneratingProlog       = false;
    bool compGeneratingEpilog       = false;
    bool compGeneratingUnwindProlog = false;
    bool compGeneratingUnwindEpilog = false;
    bool compNeedsGSSecurityCookie  = false; // There is an unsafe buffer (or localloc) on the stack.
                                             // Insert cookie on frame and code to check the cookie, like VC++ -GS.
    bool compGSReorderStackLayout = false;   // There is an unsafe buffer on the stack, reorder locals and make local

#ifdef DEBUG
    const char* compGSSecurityCheckBlocker = nullptr;
#endif

    // copies of susceptible parameters to avoid buffer overrun attacks through locals/params
    bool getNeedsGSSecurityCookie() const
    {
        return compNeedsGSSecurityCookie;
    }

    // Request stack security for this method. Returns false if security cannot be enabled.
    bool setNeedsGSSecurityCookie()
    {
#if defined(TARGET_WASM)
        INDEBUG(compGSSecurityCheckBlocker = "Not currently enabled for Wasm";)
        return false;
#endif

        if (opts.compDbgEnC)
        {
            INDEBUG(compGSSecurityCheckBlocker = "incompatible with EnC";)
            return false;
        }


Review comment (security):
The comment for `compGSReorderStackLayout` appears truncated (ends at “make local”). Since this hunk touched the surrounding area, could you complete the sentence (or wrap to a second comment line) so it clearly explains what “stack re-ordering” entails and what invariants it implies (e.g., relationship to `compNeedsGSSecurityCookie`)?
```suggestion
    bool compGSReorderStackLayout = false;   // There is an unsafe buffer on the stack; reorder locals so that unsafe
                                             // buffers are placed toward the end of the frame (after the GS cookie)
                                             // when compNeedsGSSecurityCookie is true.
```

Code after:
    // State information - which phases have completed?
    // These are kept together for easy discoverability

    bool    compAllowStress                = true;
    bool    compCodeGenDone                = false;
    int64_t compNumStatementLinksTraversed = 0;     // # of links traversed while doing debug checks
    bool    fgNormalizeEHDone              = false; // Has the flowgraph EH normalization phase been done?
    size_t  compSizeEstimate;                       // The estimated size of the method as per `gtSetEvalOrder`.
    size_t  compCycleEstimate;                      // The estimated cycle count of the method as per `gtSetEvalOrder`
    bool    compPoisoningAnyImplicitByrefs = false; // Importer inserted IR before returns to poison implicit byrefs

#endif // DEBUG

    bool fgLocalVarLivenessDone         = false; // Note that this one is used outside of debug.
    bool fgDidEarlyLiveness             = false;
    bool compPostImportationCleanupDone = false;
    bool compRegAllocDone               = false;
    bool compRationalIRForm             = false;

    bool compGeneratingProlog       = false;
    bool compGeneratingEpilog       = false;
    bool compGeneratingUnwindProlog = false;
    bool compGeneratingUnwindEpilog = false;

    // There is an unsafe buffer (or localloc) on the stack.
    bool compNeedsGSSecurityCookie = false;

    // There is an unsafe buffer on the stack, reorder locals and make local
    // copies of susceptible parameters to avoid buffer overrun attacks through locals/params
    bool compGSReorderStackLayout = false;

#ifdef DEBUG
    const char* compGSSecurityCheckBlocker = nullptr;
#endif

    bool getNeedsGSSecurityCookie() const
    {
        return compNeedsGSSecurityCookie;
    }

    // Request stack security for this method. Returns false if security cannot be enabled.
    bool setNeedsGSSecurityCookie()
    {
#if defined(TARGET_WASM)
        INDEBUG(compGSSecurityCheckBlocker = "Not currently enabled for Wasm";)
        return false;
#endif

        if (opts.compDbgEnC)
        {
            INDEBUG(compGSSecurityCheckBlocker = "incompatible with EnC";)