llvm-c166/llvm/lib/CodeGen/CodeGen.cpp
Bill Wendling 6e967f688a
[NewPM] Port EHContGuardTargets to the new pass manager (#217843)
Adds a newPM pass for EHContGuardTargets (eh-cont-guard-targets).

- Extracts the pass's logic (which has no per-instance state) into a
shared runEHContGuardTargets free function, called by both the legacy
pass and the new pass manager pass.
- Renames the old pass with the "Legacy" suffix, and (matching the same
convention already applied to CFIInstrInserter) renames
createEHContGuardTargetsPass() to createEHContGuardTargetsLegacy() at
all three legacy call sites (X86, AArch64, ARM).
- Adds the new pass manager pass EHContGuardTargetsPass, using
RequiredPassInfoMixin: the legacy pass's runOnMachineFunction never
calls skipFunction, so it always runs unconditionally and should not be
skippable in the new PM either.
- Updates MachinePassRegistry.def and PassBuilder.
- Wires the pass into X86's newPM pipeline, replacing an existing TODO
inside the already-correct TT.isOSWindows() conditional in
X86CodeGenPassBuilder.cpp. AArch64 and ARM have no newPM
CodeGenPassBuilder yet (legacy-only), so no wiring was needed there.
- Adds a -enable-new-pm RUN line to ehcontguard.ll (X86 only, the only
target with newPM support), since no dedicated unit test existed to
extend, and updates llc-pipeline-npm.ll's O0-WINDOWS/O3-WINDOWS
pipeline-dump expectations (verified empirically where the pass lands in
the dump).

Assisted-by: Claude Sonnet 5
2026-08-22 17:51:32 -07:00

171 lines
8.1 KiB
C++

//===-- CodeGen.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements the common initialization routines for the
// CodeGen library.
//
//===----------------------------------------------------------------------===//
#include "llvm/InitializePasses.h"
#include "llvm/PassRegistry.h"
using namespace llvm;
/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeAssignmentTrackingAnalysisPass(Registry);
initializeAtomicExpandLegacyPass(Registry);
initializeBasicBlockMatchingAndInferencePass(Registry);
initializeBasicBlockPathCloningPass(Registry);
initializeBasicBlockSectionsPass(Registry);
initializeBasicBlockSectionsProfileReaderWrapperPassPass(Registry);
initializeBranchFolderLegacyPass(Registry);
initializeBranchRelaxationLegacyPass(Registry);
initializeBreakFalseDepsLegacyPass(Registry);
initializeCFGuardLongjmpPass(Registry);
initializeCFIFixupLegacyPass(Registry);
initializeCFIInstrInserterLegacyPass(Registry);
initializeCheckDebugMachineModuleLegacyPass(Registry);
initializeCodeGenPrepareLegacyPassPass(Registry);
initializeComplexDeinterleavingLegacyPassPass(Registry);
initializeDeadMachineInstructionElimPass(Registry);
initializeDebugifyMachineModulePass(Registry);
initializeDetectDeadLanesLegacyPass(Registry);
initializeDummyCGSCCPassPass(Registry);
initializeDwarfEHPrepareLegacyPassPass(Registry);
initializeEHContGuardTargetsLegacyPass(Registry);
initializeEarlyIfConverterLegacyPass(Registry);
initializeEarlyIfPredicatorPass(Registry);
initializeEarlyMachineLICMPass(Registry);
initializeEarlyTailDuplicateLegacyPass(Registry);
initializeExpandIRInstsLegacyPassPass(Registry);
initializeExpandPostRALegacyPass(Registry);
initializeExpandReductionsPass(Registry);
initializeFEntryInserterLegacyPass(Registry);
initializeFinalizeISelPass(Registry);
initializeFixupStatepointCallerSavedLegacyPass(Registry);
initializeFuncletLayoutLegacyPass(Registry);
initializeGCEmptyBasicBlocksLegacyPass(Registry);
initializeGCMachineCodeAnalysisPass(Registry);
initializeGCModuleInfoPass(Registry);
initializeGlobalMergePass(Registry);
initializeGlobalMergeFuncPassWrapperPass(Registry);
initializeHardwareLoopsLegacyPass(Registry);
initializeIfConverterPass(Registry);
initializeImplicitNullChecksLegacyPass(Registry);
initializeIndirectBrExpandLegacyPassPass(Registry);
initializeInsertCodePrefetchPass(Registry);
initializeInitUndefLegacyPass(Registry);
initializeInlineAsmPreparePass(Registry);
initializeInterleavedLoadCombinePass(Registry);
initializeInterleavedAccessPass(Registry);
initializeJMCInstrumenterPass(Registry);
initializeLazyMachineBlockFrequencyInfoPassPass(Registry);
initializeLibcallLoweringInfoWrapperPass(Registry);
initializeLiveDebugValuesLegacyPass(Registry);
initializeLiveDebugVariablesWrapperLegacyPass(Registry);
initializeLiveIntervalsWrapperPassPass(Registry);
initializeLiveRangeShrinkPass(Registry);
initializeLiveStacksWrapperLegacyPass(Registry);
initializeLiveVariablesWrapperPassPass(Registry);
initializeLocalStackSlotPassPass(Registry);
initializeLowerEmuTLSPass(Registry);
initializeLowerGlobalDtorsLegacyPassPass(Registry);
initializeLowerIntrinsicsPass(Registry);
initializeMIRAddFSDiscriminatorsPass(Registry);
initializeMIRCanonicalizerPass(Registry);
initializeMIRNamerPass(Registry);
initializeMIRProfileLoaderPassPass(Registry);
initializeMachineBlockFrequencyInfoWrapperPassPass(Registry);
initializeMachineBlockHashInfoPass(Registry);
initializeMachineBlockPlacementLegacyPass(Registry);
initializeMachineBlockPlacementStatsLegacyPass(Registry);
initializeMachineBranchProbabilityInfoWrapperPassPass(Registry);
initializeMachineCFGPrinterLegacyPass(Registry);
initializeMachineCSELegacyPass(Registry);
initializeMachineCombinerLegacyPass(Registry);
initializeMachineDominanceFrontierWrapperPassPass(Registry);
initializeMachineCopyPropagationLegacyPass(Registry);
initializeMachineCycleInfoPrinterLegacyPass(Registry);
initializeMachineCycleInfoWrapperPassPass(Registry);
initializeMachineDominatorTreeWrapperPassPass(Registry);
initializeMachineFunctionPrinterPassPass(Registry);
initializeMachineFunctionSplitterPass(Registry);
initializeMachineLateInstrsCleanupLegacyPass(Registry);
initializeMachineLICMPass(Registry);
initializeMachineLoopInfoWrapperPassPass(Registry);
initializeMachineModuleInfoWrapperPassPass(Registry);
initializeMachineOptimizationRemarkEmitterPassPass(Registry);
initializeMachineOutlinerPass(Registry);
initializeMachinePipelinerPass(Registry);
initializeMachineSanitizerBinaryMetadataLegacyPass(Registry);
initializeModuloScheduleTestPass(Registry);
initializeMachinePostDominatorTreeWrapperPassPass(Registry);
initializeMachineRegionInfoPassPass(Registry);
initializeMachineSchedulerLegacyPass(Registry);
initializeMachineSinkingLegacyPass(Registry);
initializeMachineUniformityAnalysisPassPass(Registry);
initializeMIR2VecVocabLegacyAnalysisPass(Registry);
initializeMIR2VecVocabPrinterLegacyPassPass(Registry);
initializeMIR2VecPrinterLegacyPassPass(Registry);
initializeMachineUniformityInfoPrinterPassPass(Registry);
initializeMachineVerifierLegacyPassPass(Registry);
initializeObjCARCContractLegacyPassPass(Registry);
initializeOptimizePHIsLegacyPass(Registry);
initializePEILegacyPass(Registry);
initializePHIEliminationPass(Registry);
initializePatchableFunctionLegacyPass(Registry);
initializePeepholeOptimizerLegacyPass(Registry);
initializePhysicalRegisterUsageInfoWrapperLegacyPass(Registry);
initializePostMachineSchedulerLegacyPass(Registry);
initializePostRAMachineSinkingLegacyPass(Registry);
initializePostRAHazardRecognizerLegacyPass(Registry);
initializePostRASchedulerLegacyPass(Registry);
initializePreISelIntrinsicLoweringLegacyPassPass(Registry);
initializeProcessImplicitDefsLegacyPass(Registry);
initializePseudoProbeInserterPass(Registry);
initializeRABasicPass(Registry);
initializeRAGreedyLegacyPass(Registry);
initializeReachingDefInfoWrapperPassPass(Registry);
initializeRegAllocFastPass(Registry);
initializeRegAllocScoringPass(Registry);
initializeRegUsageInfoCollectorLegacyPass(Registry);
initializeRegUsageInfoPropagationLegacyPass(Registry);
initializeRegisterCoalescerLegacyPass(Registry);
initializeRemoveLoadsIntoFakeUsesLegacyPass(Registry);
initializeRemoveRedundantDebugValuesLegacyPass(Registry);
initializeRenameIndependentSubregsLegacyPass(Registry);
initializeReplaceWithVeclibLegacyPass(Registry);
initializeSafeStackLegacyPassPass(Registry);
initializeSelectOptimizePass(Registry);
initializeShadowStackGCLoweringPass(Registry);
initializeShrinkWrapLegacyPass(Registry);
initializeSjLjEHPreparePass(Registry);
initializeSlotIndexesWrapperPassPass(Registry);
initializeStackColoringLegacyPass(Registry);
initializeStackFrameLayoutAnalysisLegacyPass(Registry);
initializeStackMapLivenessPass(Registry);
initializeStackProtectorPass(Registry);
initializeStackSlotColoringLegacyPass(Registry);
initializeStaticDataSplitterLegacyPass(Registry);
initializeStaticDataAnnotatorLegacyPass(Registry);
initializeStripDebugMachineModulePass(Registry);
initializeTailDuplicateLegacyPass(Registry);
initializeTargetPassConfigPass(Registry);
initializeTwoAddressInstructionLegacyPassPass(Registry);
initializeTypePromotionLegacyPass(Registry);
initializeUnpackMachineBundlesLegacyPass(Registry);
initializeUnreachableBlockElimLegacyPassPass(Registry);
initializeUnreachableMachineBlockElimLegacyPass(Registry);
initializeVirtRegMapWrapperLegacyPass(Registry);
initializeVirtRegRewriterLegacyPass(Registry);
initializeWasmEHPreparePass(Registry);
initializeWinEHPreparePass(Registry);
initializeWindowsSecureHotPatchingPass(Registry);
initializeXRayInstrumentationLegacyPass(Registry);
}