[llvm] 52f6ed0 - Move Personalities array from MachineModuleInfo to DwarfCFIException.
James Y Knight via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 15:17:00 PST 2023
Author: James Y Knight
Date: 2023-01-16T18:15:01-05:00
New Revision: 52f6ed099cba5c67bbcc8f993a6ed29d124ccce5
URL: https://github.com/llvm/llvm-project/commit/52f6ed099cba5c67bbcc8f993a6ed29d124ccce5
DIFF: https://github.com/llvm/llvm-project/commit/52f6ed099cba5c67bbcc8f993a6ed29d124ccce5.diff
LOG: Move Personalities array from MachineModuleInfo to DwarfCFIException.
It was only ever used there, already. The previous location seems
left-over from when the personality function was specified on a
per-landingpad basis, instead of per-function.
Added:
Modified:
llvm/include/llvm/CodeGen/MachineModuleInfo.h
llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfException.h
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/MachineModuleInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
index e747f97c30a1e..ea07e365d465d 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
@@ -94,10 +94,6 @@ class MachineModuleInfo {
/// \name Exception Handling
/// \{
- /// Vector of all personality functions ever seen. Used to emit common EH
- /// frames.
- std::vector<const Function *> Personalities;
-
/// The current call site index being processed, if any. 0 if none.
unsigned CurCallSite;
@@ -195,13 +191,6 @@ class MachineModuleInfo {
/// none.
unsigned getCurrentCallSite() { return CurCallSite; }
- /// Provide the personality function for the exception information.
- void addPersonality(const Function *Personality);
-
- /// Return array of personality functions ever seen.
- const std::vector<const Function *>& getPersonalities() const {
- return Personalities;
- }
/// \}
// MMI owes MCContext. It should never be invalidated.
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
index 72ed2bd78e7a5..df4fe8d49806a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
@@ -27,6 +27,11 @@ DwarfCFIException::DwarfCFIException(AsmPrinter *A) : EHStreamer(A) {}
DwarfCFIException::~DwarfCFIException() = default;
+void DwarfCFIException::addPersonality(const GlobalValue *Personality) {
+ if (!llvm::is_contained(Personalities, Personality))
+ Personalities.push_back(Personality);
+}
+
/// endModule - Emit all exception information that should come after the
/// content.
void DwarfCFIException::endModule() {
@@ -41,13 +46,12 @@ void DwarfCFIException::endModule() {
if ((PerEncoding & 0x80) != dwarf::DW_EH_PE_indirect)
return;
- // Emit references to all used personality functions
- for (const Function *Personality : MMI->getPersonalities()) {
- if (!Personality)
- continue;
+ // Emit indirect reference table for all used personality functions
+ for (const GlobalValue *Personality : Personalities) {
MCSymbol *Sym = Asm->getSymbol(Personality);
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym);
}
+ Personalities.clear();
}
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
@@ -63,9 +67,9 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
- const Function *Per = nullptr;
+ const GlobalValue *Per = nullptr;
if (F.hasPersonalityFn())
- Per = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ Per = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
// Emit a personality function even when there are no landing pads
forceEmitPersonality =
@@ -116,13 +120,10 @@ void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
return;
auto &F = MBB.getParent()->getFunction();
- auto *P = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
assert(P && "Expected personality function");
-
- // If we are forced to emit this personality, make sure to record
- // it because it might not appear in any landingpad
- if (forceEmitPersonality)
- MMI->addPersonality(P);
+ // Record the personality function.
+ addPersonality(P);
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfException.h b/llvm/lib/CodeGen/AsmPrinter/DwarfException.h
index 0dc98314b828e..c2c11c7bc14d1 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfException.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfException.h
@@ -37,6 +37,11 @@ class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public EHStreamer {
/// Per-module flag to indicate if .cfi_section has beeen emitted.
bool hasEmittedCFISections = false;
+ /// Vector of all personality functions seen so far in the module.
+ std::vector<const GlobalValue *> Personalities;
+
+ void addPersonality(const GlobalValue *Personality);
+
public:
//===--------------------------------------------------------------------===//
// Main entry points.
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index ba73abd9f3d96..d70af8bd11f80 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -759,10 +759,6 @@ MCSymbol *MachineFunction::addLandingPad(MachineBasicBlock *LandingPad) {
const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI();
if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
- if (const auto *PF =
- dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()))
- getMMI().addPersonality(PF);
-
// If there's no typeid list specified, then "cleanup" is implicit.
// Otherwise, id 0 is reserved for the cleanup action.
if (LPI->isCleanup() && LPI->getNumClauses() != 0)
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index 7a5a6c294ecf1..a0c0166d06f0f 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -47,8 +47,6 @@ void MachineModuleInfo::initialize() {
}
void MachineModuleInfo::finalize() {
- Personalities.clear();
-
Context.reset();
// We don't clear the ExternalContext.
@@ -89,16 +87,6 @@ MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM,
MachineModuleInfo::~MachineModuleInfo() { finalize(); }
-/// \name Exception Handling
-/// \{
-
-void MachineModuleInfo::addPersonality(const Function *Personality) {
- if (!llvm::is_contained(Personalities, Personality))
- Personalities.push_back(Personality);
-}
-
-/// \}
-
MachineFunction *
MachineModuleInfo::getMachineFunction(const Function &F) const {
auto I = MachineFunctions.find(&F);
More information about the llvm-commits
mailing list