Skip to content

[PPC] Replace PPCMergeStringPool with GlobalMerge for Linux #114850

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
merged 7 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions llvm/lib/CodeGen/GlobalMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
Expand Down Expand Up @@ -632,10 +633,13 @@ void GlobalMergeImpl::setMustKeepGlobalVariables(Module &M) {
for (Function &F : M) {
for (BasicBlock &BB : F) {
Instruction *Pad = BB.getFirstNonPHI();
if (!Pad->isEHPad())
auto *II = dyn_cast<IntrinsicInst>(Pad);
if (!Pad->isEHPad() &&
!(II && II->getIntrinsicID() == Intrinsic::eh_typeid_for))
continue;
Comment on lines +636 to 639
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
auto *II = dyn_cast<IntrinsicInst>(Pad);
if (!Pad->isEHPad() &&
!(II && II->getIntrinsicID() == Intrinsic::eh_typeid_for))
continue;
if (!Pad->isEHPad())
continue;
if (auto *II = dyn_cast<IntrinsicInst>(Pad))
if (II->getIntrinsicID() == Intrinsic::eh_typeid_for))
continue;

nit: I'd separate the two ifs here.

Copy link
Contributor Author

@syzaara syzaara Nov 7, 2024

Choose a reason for hiding this comment

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

We can't split the if statements this way since we want to continue if its neither an EHPad instruction or an Intrinsic::eh_typeid_for instruction.

Alternate could be:

      if (!Pad->isEHPad()) {
        auto *II = dyn_cast<IntrinsicInst>(Pad);
        if (!II)
          continue;
        if (II->getIntrinsicID() != Intrinsic::eh_typeid_for)
          continue;
      }

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry, I completely misread the code here. I think your original version was already the best one then.


// Keep globals used by landingpads and catchpads.
// Keep globals used by landingpads, catchpads,
// or intrinsics that require a plain global.
for (const Use &U : Pad->operands()) {
if (const GlobalVariable *GV =
dyn_cast<GlobalVariable>(U->stripPointerCasts()))
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Target/PowerPC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ add_llvm_target(PowerPCCodeGen
PPCMachineFunctionInfo.cpp
PPCMachineScheduler.cpp
PPCMacroFusion.cpp
PPCMergeStringPool.cpp
PPCMIPeephole.cpp
PPCRegisterInfo.cpp
PPCSubtarget.cpp
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Target/PowerPC/PPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ModulePass;
FunctionPass *createPPCPreEmitPeepholePass();
FunctionPass *createPPCExpandAtomicPseudoPass();
FunctionPass *createPPCCTRLoopsPass();
ModulePass *createPPCMergeStringPoolPass();
void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
AsmPrinter &AP);
bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO,
Expand All @@ -79,7 +78,6 @@ class ModulePass;
void initializePPCExpandAtomicPseudoPass(PassRegistry &);
void initializePPCCTRLoopsPass(PassRegistry &);
void initializePPCDAGToDAGISelLegacyPass(PassRegistry &);
void initializePPCMergeStringPoolPass(PassRegistry &);

extern char &PPCVSXFMAMutateID;

Expand Down
334 changes: 0 additions & 334 deletions llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp

This file was deleted.

Loading
Loading