Skip to content

Commit 52f6ed0

Browse files
committed
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.
1 parent a1551fd commit 52f6ed0

File tree

5 files changed

+18
-39
lines changed

5 files changed

+18
-39
lines changed

llvm/include/llvm/CodeGen/MachineModuleInfo.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ class MachineModuleInfo {
9494
/// \name Exception Handling
9595
/// \{
9696

97-
/// Vector of all personality functions ever seen. Used to emit common EH
98-
/// frames.
99-
std::vector<const Function *> Personalities;
100-
10197
/// The current call site index being processed, if any. 0 if none.
10298
unsigned CurCallSite;
10399

@@ -195,13 +191,6 @@ class MachineModuleInfo {
195191
/// none.
196192
unsigned getCurrentCallSite() { return CurCallSite; }
197193

198-
/// Provide the personality function for the exception information.
199-
void addPersonality(const Function *Personality);
200-
201-
/// Return array of personality functions ever seen.
202-
const std::vector<const Function *>& getPersonalities() const {
203-
return Personalities;
204-
}
205194
/// \}
206195

207196
// MMI owes MCContext. It should never be invalidated.

llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ DwarfCFIException::DwarfCFIException(AsmPrinter *A) : EHStreamer(A) {}
2727

2828
DwarfCFIException::~DwarfCFIException() = default;
2929

30+
void DwarfCFIException::addPersonality(const GlobalValue *Personality) {
31+
if (!llvm::is_contained(Personalities, Personality))
32+
Personalities.push_back(Personality);
33+
}
34+
3035
/// endModule - Emit all exception information that should come after the
3136
/// content.
3237
void DwarfCFIException::endModule() {
@@ -41,13 +46,12 @@ void DwarfCFIException::endModule() {
4146
if ((PerEncoding & 0x80) != dwarf::DW_EH_PE_indirect)
4247
return;
4348

44-
// Emit references to all used personality functions
45-
for (const Function *Personality : MMI->getPersonalities()) {
46-
if (!Personality)
47-
continue;
49+
// Emit indirect reference table for all used personality functions
50+
for (const GlobalValue *Personality : Personalities) {
4851
MCSymbol *Sym = Asm->getSymbol(Personality);
4952
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym);
5053
}
54+
Personalities.clear();
5155
}
5256

5357
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
@@ -63,9 +67,9 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
6367

6468
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
6569
unsigned PerEncoding = TLOF.getPersonalityEncoding();
66-
const Function *Per = nullptr;
70+
const GlobalValue *Per = nullptr;
6771
if (F.hasPersonalityFn())
68-
Per = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
72+
Per = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
6973

7074
// Emit a personality function even when there are no landing pads
7175
forceEmitPersonality =
@@ -116,13 +120,10 @@ void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
116120
return;
117121

118122
auto &F = MBB.getParent()->getFunction();
119-
auto *P = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
123+
auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
120124
assert(P && "Expected personality function");
121-
122-
// If we are forced to emit this personality, make sure to record
123-
// it because it might not appear in any landingpad
124-
if (forceEmitPersonality)
125-
MMI->addPersonality(P);
125+
// Record the personality function.
126+
addPersonality(P);
126127

127128
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
128129
unsigned PerEncoding = TLOF.getPersonalityEncoding();

llvm/lib/CodeGen/AsmPrinter/DwarfException.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public EHStreamer {
3737
/// Per-module flag to indicate if .cfi_section has beeen emitted.
3838
bool hasEmittedCFISections = false;
3939

40+
/// Vector of all personality functions seen so far in the module.
41+
std::vector<const GlobalValue *> Personalities;
42+
43+
void addPersonality(const GlobalValue *Personality);
44+
4045
public:
4146
//===--------------------------------------------------------------------===//
4247
// Main entry points.

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,6 @@ MCSymbol *MachineFunction::addLandingPad(MachineBasicBlock *LandingPad) {
759759

760760
const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI();
761761
if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
762-
if (const auto *PF =
763-
dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()))
764-
getMMI().addPersonality(PF);
765-
766762
// If there's no typeid list specified, then "cleanup" is implicit.
767763
// Otherwise, id 0 is reserved for the cleanup action.
768764
if (LPI->isCleanup() && LPI->getNumClauses() != 0)

llvm/lib/CodeGen/MachineModuleInfo.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ void MachineModuleInfo::initialize() {
4747
}
4848

4949
void MachineModuleInfo::finalize() {
50-
Personalities.clear();
51-
5250
Context.reset();
5351
// We don't clear the ExternalContext.
5452

@@ -89,16 +87,6 @@ MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM,
8987

9088
MachineModuleInfo::~MachineModuleInfo() { finalize(); }
9189

92-
/// \name Exception Handling
93-
/// \{
94-
95-
void MachineModuleInfo::addPersonality(const Function *Personality) {
96-
if (!llvm::is_contained(Personalities, Personality))
97-
Personalities.push_back(Personality);
98-
}
99-
100-
/// \}
101-
10290
MachineFunction *
10391
MachineModuleInfo::getMachineFunction(const Function &F) const {
10492
auto I = MachineFunctions.find(&F);

0 commit comments

Comments
 (0)