Skip to content

Commit 16e051f

Browse files
authored
[win] NFC: Rename EHCatchret to EHCont to allow for EH Continuation targets that aren't catchret instructions (llvm#129953)
This change splits out the renaming and comment updates from llvm#129612 as a non-functional change.
1 parent ba9aeed commit 16e051f

File tree

73 files changed

+150
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+150
-153
lines changed

llvm/include/llvm/CodeGen/MIRYamlMapping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ struct MachineFunction {
762762

763763
bool CallsEHReturn = false;
764764
bool CallsUnwindInit = false;
765-
bool HasEHCatchret = false;
765+
bool HasEHContTarget = false;
766766
bool HasEHScopes = false;
767767
bool HasEHFunclets = false;
768768
bool IsOutlined = false;
@@ -810,7 +810,7 @@ template <> struct MappingTraits<MachineFunction> {
810810

811811
YamlIO.mapOptional("callsEHReturn", MF.CallsEHReturn, false);
812812
YamlIO.mapOptional("callsUnwindInit", MF.CallsUnwindInit, false);
813-
YamlIO.mapOptional("hasEHCatchret", MF.HasEHCatchret, false);
813+
YamlIO.mapOptional("hasEHContTarget", MF.HasEHContTarget, false);
814814
YamlIO.mapOptional("hasEHScopes", MF.HasEHScopes, false);
815815
YamlIO.mapOptional("hasEHFunclets", MF.HasEHFunclets, false);
816816
YamlIO.mapOptional("isOutlined", MF.IsOutlined, false);

llvm/include/llvm/CodeGen/MachineBasicBlock.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ class MachineBasicBlock
205205
/// LLVM IR.
206206
bool IsEHScopeEntry = false;
207207

208-
/// Indicates if this is a target block of a catchret.
209-
bool IsEHCatchretTarget = false;
208+
/// Indicates if this is a target of Windows EH Continuation Guard.
209+
bool IsEHContTarget = false;
210210

211211
/// Indicate that this basic block is the entry block of an EH funclet.
212212
bool IsEHFuncletEntry = false;
@@ -234,8 +234,8 @@ class MachineBasicBlock
234234
/// is only computed once and is cached.
235235
mutable MCSymbol *CachedMCSymbol = nullptr;
236236

237-
/// Cached MCSymbol for this block (used if IsEHCatchRetTarget).
238-
mutable MCSymbol *CachedEHCatchretMCSymbol = nullptr;
237+
/// Cached MCSymbol for this block (used if IsEHContTarget).
238+
mutable MCSymbol *CachedEHContMCSymbol = nullptr;
239239

240240
/// Marks the end of the basic block. Used during basic block sections to
241241
/// calculate the size of the basic block, or the BB section ending with it.
@@ -652,11 +652,11 @@ class MachineBasicBlock
652652
/// that used to have a catchpad or cleanuppad instruction in the LLVM IR.
653653
void setIsEHScopeEntry(bool V = true) { IsEHScopeEntry = V; }
654654

655-
/// Returns true if this is a target block of a catchret.
656-
bool isEHCatchretTarget() const { return IsEHCatchretTarget; }
655+
/// Returns true if this is a target of Windows EH Continuation Guard.
656+
bool isEHContTarget() const { return IsEHContTarget; }
657657

658-
/// Indicates if this is a target block of a catchret.
659-
void setIsEHCatchretTarget(bool V = true) { IsEHCatchretTarget = V; }
658+
/// Indicates if this is a target of Windows EH Continuation Guard.
659+
void setIsEHContTarget(bool V = true) { IsEHContTarget = V; }
660660

661661
/// Returns true if this is the entry block of an EH funclet.
662662
bool isEHFuncletEntry() const { return IsEHFuncletEntry; }
@@ -1238,8 +1238,8 @@ class MachineBasicBlock
12381238
/// Return the MCSymbol for this basic block.
12391239
MCSymbol *getSymbol() const;
12401240

1241-
/// Return the EHCatchret Symbol for this basic block.
1242-
MCSymbol *getEHCatchretSymbol() const;
1241+
/// Return the Windows EH Continuation Symbol for this basic block.
1242+
MCSymbol *getEHContSymbol() const;
12431243

12441244
std::optional<uint64_t> getIrrLoopHeaderWeight() const {
12451245
return IrrLoopHeaderWeight;

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ class LLVM_ABI MachineFunction {
359359
/// construct a table of valid longjmp targets for Windows Control Flow Guard.
360360
std::vector<MCSymbol *> LongjmpTargets;
361361

362-
/// List of basic blocks that are the target of catchrets. Used to construct
363-
/// a table of valid targets for Windows EHCont Guard.
364-
std::vector<MCSymbol *> CatchretTargets;
362+
/// List of basic blocks that are the targets for Windows EH Continuation
363+
/// Guard.
364+
std::vector<MCSymbol *> EHContTargets;
365365

366366
/// \name Exception Handling
367367
/// \{
@@ -383,7 +383,7 @@ class LLVM_ABI MachineFunction {
383383

384384
bool CallsEHReturn = false;
385385
bool CallsUnwindInit = false;
386-
bool HasEHCatchret = false;
386+
bool HasEHContTarget = false;
387387
bool HasEHScopes = false;
388388
bool HasEHFunclets = false;
389389
bool HasFakeUses = false;
@@ -1197,17 +1197,15 @@ class LLVM_ABI MachineFunction {
11971197
/// Control Flow Guard.
11981198
void addLongjmpTarget(MCSymbol *Target) { LongjmpTargets.push_back(Target); }
11991199

1200-
/// Returns a reference to a list of symbols that we have catchrets.
1201-
/// Used to construct the catchret target table used by Windows EHCont Guard.
1202-
const std::vector<MCSymbol *> &getCatchretTargets() const {
1203-
return CatchretTargets;
1200+
/// Returns a reference to a list of symbols that are targets for Windows
1201+
/// EH Continuation Guard.
1202+
const std::vector<MCSymbol *> &getEHContTargets() const {
1203+
return EHContTargets;
12041204
}
12051205

1206-
/// Add the specified symbol to the list of valid catchret targets for Windows
1207-
/// EHCont Guard.
1208-
void addCatchretTarget(MCSymbol *Target) {
1209-
CatchretTargets.push_back(Target);
1210-
}
1206+
/// Add the specified symbol to the list of targets for Windows EH
1207+
/// Continuation Guard.
1208+
void addEHContTarget(MCSymbol *Target) { EHContTargets.push_back(Target); }
12111209

12121210
/// Tries to get the global and target flags for a call site, if the
12131211
/// instruction is a call to a global.
@@ -1236,8 +1234,8 @@ class LLVM_ABI MachineFunction {
12361234
bool callsUnwindInit() const { return CallsUnwindInit; }
12371235
void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
12381236

1239-
bool hasEHCatchret() const { return HasEHCatchret; }
1240-
void setHasEHCatchret(bool V) { HasEHCatchret = V; }
1237+
bool hasEHContTarget() const { return HasEHContTarget; }
1238+
void setHasEHContTarget(bool V) { HasEHContTarget = V; }
12411239

12421240
bool hasEHScopes() const { return HasEHScopes; }
12431241
void setHasEHScopes(bool V) { HasEHScopes = V; }

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ namespace llvm {
550550
/// \see CFGuardLongjmp.cpp
551551
FunctionPass *createCFGuardLongjmpPass();
552552

553-
/// Creates EHContGuard catchret target identification pass.
554-
/// \see EHContGuardCatchret.cpp
555-
FunctionPass *createEHContGuardCatchretPass();
553+
/// Creates Windows EH Continuation Guard target identification pass.
554+
/// \see EHContGuardTargets.cpp
555+
FunctionPass *createEHContGuardTargetsPass();
556556

557557
/// Create Hardware Loop pass. \see HardwareLoops.cpp
558558
FunctionPass *createHardwareLoopsLegacyPass();

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void initializeEarlyIfPredicatorPass(PassRegistry &);
104104
void initializeEarlyMachineLICMPass(PassRegistry &);
105105
void initializeEarlyTailDuplicateLegacyPass(PassRegistry &);
106106
void initializeEdgeBundlesWrapperLegacyPass(PassRegistry &);
107-
void initializeEHContGuardCatchretPass(PassRegistry &);
107+
void initializeEHContGuardTargetsPass(PassRegistry &);
108108
void initializeExpandLargeFpConvertLegacyPassPass(PassRegistry &);
109109
void initializeExpandLargeDivRemLegacyPassPass(PassRegistry &);
110110
void initializeExpandMemCmpLegacyPassPass(PassRegistry &);

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4288,9 +4288,9 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
42884288
}
42894289
}
42904290

4291-
if (MBB.isEHCatchretTarget() &&
4291+
if (MBB.isEHContTarget() &&
42924292
MAI->getExceptionHandlingType() == ExceptionHandling::WinEH) {
4293-
OutStreamer->emitLabel(MBB.getEHCatchretSymbol());
4293+
OutStreamer->emitLabel(MBB.getEHContSymbol());
42944294
}
42954295

42964296
// With BB sections, each basic block must handle CFI information on its own

llvm/lib/CodeGen/AsmPrinter/WinException.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ void WinException::endFunction(const MachineFunction *MF) {
160160
Asm->OutStreamer->popSection();
161161
}
162162

163-
if (!MF->getCatchretTargets().empty()) {
164-
// Copy the function's catchret targets to a module-level list.
165-
EHContTargets.insert(EHContTargets.end(), MF->getCatchretTargets().begin(),
166-
MF->getCatchretTargets().end());
163+
if (!MF->getEHContTargets().empty()) {
164+
// Copy the function's EH Continuation targets to a module-level list.
165+
EHContTargets.insert(EHContTargets.end(), MF->getEHContTargets().begin(),
166+
MF->getEHContTargets().end());
167167
}
168168
}
169169

llvm/lib/CodeGen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ add_llvm_component_library(LLVMCodeGen
5454
DwarfEHPrepare.cpp
5555
EarlyIfConversion.cpp
5656
EdgeBundles.cpp
57-
EHContGuardCatchret.cpp
57+
EHContGuardTargets.cpp
5858
ExecutionDomainFix.cpp
5959
ExpandLargeDivRem.cpp
6060
ExpandLargeFpConvert.cpp

llvm/lib/CodeGen/EHContGuardCatchret.cpp renamed to llvm/lib/CodeGen/EHContGuardTargets.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- EHContGuardCatchret.cpp - Catchret target symbols -------*- C++ -*-===//
1+
//===-- EHContGuardTargets.cpp - EH continuation target symbols -*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,9 +8,10 @@
88
///
99
/// \file
1010
/// This file contains a machine function pass to insert a symbol before each
11-
/// valid catchret target and store this in the MachineFunction's
12-
/// CatchRetTargets vector. This will be used to emit the table of valid targets
13-
/// used by EHCont Guard.
11+
/// valid target where the unwinder in Windows may continue exectution after an
12+
/// exception is thrown and store this in the MachineFunction's EHContTargets
13+
/// vector. This will be used to emit the table of valid targets used by Windows
14+
/// EH Continuation Guard.
1415
///
1516
//===----------------------------------------------------------------------===//
1617

@@ -26,19 +27,18 @@ using namespace llvm;
2627

2728
#define DEBUG_TYPE "ehcontguard-catchret"
2829

29-
STATISTIC(EHContGuardCatchretTargets,
30-
"Number of EHCont Guard catchret targets");
30+
STATISTIC(EHContGuardTargetsFound, "Number of EHCont Guard targets");
3131

3232
namespace {
3333

3434
/// MachineFunction pass to insert a symbol before each valid catchret target
3535
/// and store these in the MachineFunction's CatchRetTargets vector.
36-
class EHContGuardCatchret : public MachineFunctionPass {
36+
class EHContGuardTargets : public MachineFunctionPass {
3737
public:
3838
static char ID;
3939

40-
EHContGuardCatchret() : MachineFunctionPass(ID) {
41-
initializeEHContGuardCatchretPass(*PassRegistry::getPassRegistry());
40+
EHContGuardTargets() : MachineFunctionPass(ID) {
41+
initializeEHContGuardTargetsPass(*PassRegistry::getPassRegistry());
4242
}
4343

4444
StringRef getPassName() const override {
@@ -50,31 +50,31 @@ class EHContGuardCatchret : public MachineFunctionPass {
5050

5151
} // end anonymous namespace
5252

53-
char EHContGuardCatchret::ID = 0;
53+
char EHContGuardTargets::ID = 0;
5454

55-
INITIALIZE_PASS(EHContGuardCatchret, "EHContGuardCatchret",
56-
"Insert symbols at valid catchret targets for /guard:ehcont",
57-
false, false)
58-
FunctionPass *llvm::createEHContGuardCatchretPass() {
59-
return new EHContGuardCatchret();
55+
INITIALIZE_PASS(EHContGuardTargets, "EHContGuardTargets",
56+
"Insert symbols at valid targets for /guard:ehcont", false,
57+
false)
58+
FunctionPass *llvm::createEHContGuardTargetsPass() {
59+
return new EHContGuardTargets();
6060
}
6161

62-
bool EHContGuardCatchret::runOnMachineFunction(MachineFunction &MF) {
62+
bool EHContGuardTargets::runOnMachineFunction(MachineFunction &MF) {
6363

6464
// Skip modules for which the ehcontguard flag is not set.
6565
if (!MF.getFunction().getParent()->getModuleFlag("ehcontguard"))
6666
return false;
6767

68-
// Skip functions that do not have catchret
69-
if (!MF.hasEHCatchret())
68+
// Skip functions that do not have targets
69+
if (!MF.hasEHContTarget())
7070
return false;
7171

7272
bool Result = false;
7373

7474
for (MachineBasicBlock &MBB : MF) {
75-
if (MBB.isEHCatchretTarget()) {
76-
MF.addCatchretTarget(MBB.getEHCatchretSymbol());
77-
EHContGuardCatchretTargets++;
75+
if (MBB.isEHContTarget()) {
76+
MF.addEHContTarget(MBB.getEHContSymbol());
77+
EHContGuardTargetsFound++;
7878
Result = true;
7979
}
8080
}

llvm/lib/CodeGen/MIRParser/MIRParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
551551

552552
MF.setCallsEHReturn(YamlMF.CallsEHReturn);
553553
MF.setCallsUnwindInit(YamlMF.CallsUnwindInit);
554-
MF.setHasEHCatchret(YamlMF.HasEHCatchret);
554+
MF.setHasEHContTarget(YamlMF.HasEHContTarget);
555555
MF.setHasEHScopes(YamlMF.HasEHScopes);
556556
MF.setHasEHFunclets(YamlMF.HasEHFunclets);
557557
MF.setIsOutlined(YamlMF.IsOutlined);

0 commit comments

Comments
 (0)