-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[X86][NewPM] Port DynAllocaExpander to New PM #167740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
boomanaiden154
merged 2 commits into
main
from
users/boomanaiden154/x86newpm-port-dynallocaexpander-to-new-pm
Nov 12, 2025
Merged
[X86][NewPM] Port DynAllocaExpander to New PM #167740
boomanaiden154
merged 2 commits into
main
from
users/boomanaiden154/x86newpm-port-dynallocaexpander-to-new-pm
Nov 12, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.7
Member
|
@llvm/pr-subscribers-backend-x86 Author: Aiden Grossman (boomanaiden154) ChangesNo tests modified as there are none that explicitly stop at Full diff: https://github.com/llvm/llvm-project/pull/167740.diff 4 Files Affected:
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 2b83d575ace91..17acf0415540a 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -84,7 +84,13 @@ FunctionPass *createX86AvoidStoreForwardingBlocks();
FunctionPass *createX86FlagsCopyLoweringPass();
/// Return a pass that expands DynAlloca pseudo-instructions.
-FunctionPass *createX86DynAllocaExpander();
+class X86DynAllocaExpanderPass : public PassInfoMixin<X86DynAllocaExpanderPass> {
+public:
+ PreservedAnalyses run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM);
+};
+
+FunctionPass *createX86DynAllocaExpanderLegacyPass();
/// Return a pass that config the tile registers.
FunctionPass *createX86TileConfigPass();
@@ -237,7 +243,7 @@ void initializeX86CallFrameOptimizationPass(PassRegistry &);
void initializeX86CmovConverterPassPass(PassRegistry &);
void initializeX86DAGToDAGISelLegacyPass(PassRegistry &);
void initializeX86DomainReassignmentPass(PassRegistry &);
-void initializeX86DynAllocaExpanderPass(PassRegistry &);
+void initializeX86DynAllocaExpanderLegacyPass(PassRegistry &);
void initializeX86ExecutionDomainFixPass(PassRegistry &);
void initializeX86ExpandPseudoPass(PassRegistry &);
void initializeX86FastPreTileConfigPass(PassRegistry &);
diff --git a/llvm/lib/Target/X86/X86DynAllocaExpander.cpp b/llvm/lib/Target/X86/X86DynAllocaExpander.cpp
index c2a06efd4d46e..10f46f71bbbbd 100644
--- a/llvm/lib/Target/X86/X86DynAllocaExpander.cpp
+++ b/llvm/lib/Target/X86/X86DynAllocaExpander.cpp
@@ -20,22 +20,22 @@
#include "X86Subtarget.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/CodeGen/MachineFunctionAnalysisManager.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/IR/Analysis.h"
#include "llvm/IR/Function.h"
using namespace llvm;
namespace {
-class X86DynAllocaExpander : public MachineFunctionPass {
+class X86DynAllocaExpander {
public:
- X86DynAllocaExpander() : MachineFunctionPass(ID) {}
-
- bool runOnMachineFunction(MachineFunction &MF) override;
+ bool run(MachineFunction &MF);
private:
/// Strategies for lowering a DynAlloca.
@@ -61,22 +61,30 @@ class X86DynAllocaExpander : public MachineFunctionPass {
unsigned SlotSize = 0;
int64_t StackProbeSize = 0;
bool NoStackArgProbe = false;
+};
+
+class X86DynAllocaExpanderLegacy : public MachineFunctionPass {
+public:
+ X86DynAllocaExpanderLegacy() : MachineFunctionPass(ID) {}
+
+ bool runOnMachineFunction(MachineFunction &MF) override;
+private:
StringRef getPassName() const override { return "X86 DynAlloca Expander"; }
public:
static char ID;
};
-char X86DynAllocaExpander::ID = 0;
+char X86DynAllocaExpanderLegacy::ID = 0;
} // end anonymous namespace
-INITIALIZE_PASS(X86DynAllocaExpander, "x86-dyn-alloca-expander",
+INITIALIZE_PASS(X86DynAllocaExpanderLegacy, "x86-dyn-alloca-expander",
"X86 DynAlloca Expander", false, false)
-FunctionPass *llvm::createX86DynAllocaExpander() {
- return new X86DynAllocaExpander();
+FunctionPass *llvm::createX86DynAllocaExpanderLegacyPass() {
+ return new X86DynAllocaExpanderLegacy();
}
/// Return the allocation amount for a DynAlloca instruction, or -1 if unknown.
@@ -277,7 +285,7 @@ void X86DynAllocaExpander::lower(MachineInstr *MI, Lowering L) {
AmountDef->eraseFromParent();
}
-bool X86DynAllocaExpander::runOnMachineFunction(MachineFunction &MF) {
+bool X86DynAllocaExpander::run(MachineFunction &MF) {
if (!MF.getInfo<X86MachineFunctionInfo>()->hasDynAlloca())
return false;
@@ -299,3 +307,19 @@ bool X86DynAllocaExpander::runOnMachineFunction(MachineFunction &MF) {
return true;
}
+
+bool X86DynAllocaExpanderLegacy::runOnMachineFunction(MachineFunction &MF) {
+ return X86DynAllocaExpander().run(MF);
+}
+
+PreservedAnalyses
+X86DynAllocaExpanderPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ bool Changed = X86DynAllocaExpander().run(MF);
+ if (!Changed)
+ return PreservedAnalyses::all();
+
+ PreservedAnalyses PA = PreservedAnalyses::none();
+ PA.preserveSet<CFGAnalyses>();
+ return PA;
+}
diff --git a/llvm/lib/Target/X86/X86PassRegistry.def b/llvm/lib/Target/X86/X86PassRegistry.def
index 52463622026d7..0d7095b18daa8 100644
--- a/llvm/lib/Target/X86/X86PassRegistry.def
+++ b/llvm/lib/Target/X86/X86PassRegistry.def
@@ -30,6 +30,7 @@ DUMMY_FUNCTION_PASS("x86-winehstate", WinEHStatePass())
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
#endif
MACHINE_FUNCTION_PASS("x86-avoid-trailing-call", X86AvoidTrailingCallPass())
+MACHINE_FUNCTION_PASS("x86-dyn-alloca-expander", X86DynAllocaExpanderPass())
MACHINE_FUNCTION_PASS("x86-isel", X86ISelDAGToDAGPass(*this))
#undef MACHINE_FUNCTION_PASS
@@ -42,7 +43,6 @@ DUMMY_MACHINE_FUNCTION_PASS("x86-cmov-conversion", X86CmovConverterPass())
DUMMY_MACHINE_FUNCTION_PASS("x86-codege", FPS())
DUMMY_MACHINE_FUNCTION_PASS("x86-compress-evex", CompressEVEXPass())
DUMMY_MACHINE_FUNCTION_PASS("x86-domain-reassignment", X86DomainReassignment())
-DUMMY_MACHINE_FUNCTION_PASS("x86-dyn-alloca-expander", X86DynAllocaExpander())
DUMMY_MACHINE_FUNCTION_PASS("x86-execution-domain-fix", X86ExecutionDomainFix())
DUMMY_MACHINE_FUNCTION_PASS("fastpretileconfig", X86FastPreTileConfig())
DUMMY_MACHINE_FUNCTION_PASS("fasttileconfig", X86FastTileConfig())
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index d4ad98af9b30c..c1214149dfa1d 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -104,7 +104,7 @@ extern "C" LLVM_C_ABI void LLVMInitializeX86Target() {
initializeX86AsmPrinterPass(PR);
initializeX86FixupInstTuningPassPass(PR);
initializeX86FixupVectorConstantsPassPass(PR);
- initializeX86DynAllocaExpanderPass(PR);
+ initializeX86DynAllocaExpanderLegacyPass(PR);
initializeX86SuppressAPXForRelocationPassPass(PR);
initializeX86WinEHUnwindV2Pass(PR);
}
@@ -516,7 +516,7 @@ void X86PassConfig::addPreRegAlloc() {
addPass(createX86SpeculativeLoadHardeningPass());
addPass(createX86FlagsCopyLoweringPass());
- addPass(createX86DynAllocaExpander());
+ addPass(createX86DynAllocaExpanderLegacyPass());
if (getOptLevel() != CodeGenOptLevel::None)
addPass(createX86PreTileConfigPass());
|
boomanaiden154
added a commit
to boomanaiden154/llvm-project
that referenced
this pull request
Nov 12, 2025
No tests modified as there are none that explicitly stop at DynAllocaExpander, and we do not have enough of a pipeline to run those yet anyways. Pull Request: llvm#167740
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
arsenm
approved these changes
Nov 12, 2025
Created using spr 1.3.7
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Nov 12, 2025
No tests modified as there are none that explicitly stop at DynAllocaExpander, and we do not have enough of a pipeline to run those yet anyways. Reviewers: phoebewang, RKSimon, paperchalice, arsenm Reviewed By: arsenm Pull Request: llvm/llvm-project#167740
git-crd
pushed a commit
to git-crd/crd-llvm-project
that referenced
this pull request
Nov 13, 2025
No tests modified as there are none that explicitly stop at DynAllocaExpander, and we do not have enough of a pipeline to run those yet anyways. Reviewers: phoebewang, RKSimon, paperchalice, arsenm Reviewed By: arsenm Pull Request: llvm#167740
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No tests modified as there are none that explicitly stop at
DynAllocaExpander, and we do not have enough of a pipeline to run those
yet anyways.