From 7fa27ce4a07f19b07799a767fc29416f3b625afb Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 26 Jul 2023 21:03:47 +0200 Subject: Vendor import of llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the last commit before the upstream release/17.x branch was created. --- llvm/lib/Transforms/Utils/Mem2Reg.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Transforms/Utils/Mem2Reg.cpp') diff --git a/llvm/lib/Transforms/Utils/Mem2Reg.cpp b/llvm/lib/Transforms/Utils/Mem2Reg.cpp index 5ad7aeb463ec..fbc6dd7613de 100644 --- a/llvm/lib/Transforms/Utils/Mem2Reg.cpp +++ b/llvm/lib/Transforms/Utils/Mem2Reg.cpp @@ -74,15 +74,19 @@ namespace { struct PromoteLegacyPass : public FunctionPass { // Pass identification, replacement for typeid static char ID; + bool ForcePass; /// If true, forces pass to execute, instead of skipping. - PromoteLegacyPass() : FunctionPass(ID) { + PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) { + initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry()); + } + PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) { initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry()); } // runOnFunction - To run this pass, first we calculate the alloca // instructions that are safe for promotion, then we promote each one. bool runOnFunction(Function &F) override { - if (skipFunction(F)) + if (!ForcePass && skipFunction(F)) return false; DominatorTree &DT = getAnalysis().getDomTree(); @@ -111,6 +115,6 @@ INITIALIZE_PASS_END(PromoteLegacyPass, "mem2reg", "Promote Memory to Register", false, false) // createPromoteMemoryToRegister - Provide an entry point to create this pass. -FunctionPass *llvm::createPromoteMemoryToRegisterPass() { - return new PromoteLegacyPass(); +FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) { + return new PromoteLegacyPass(IsForced); } -- cgit v1.2.3