Skip to content

Commit 4d8bf6e

Browse files
authored
[CodeGen][GC] Remove GCInfoPrinter (#75033)
This pass is broken and looks like no one uses it for the last 15+ years. ```c++ bool Printer::runOnFunction(Function &F) { if (F.hasGC()) return false; GCFunctionInfo *FD = &getAnalysis<GCModuleInfo>().getFunctionInfo(F); ``` ```c++ GCFunctionInfo &GCModuleInfo::getFunctionInfo(const Function &F) { assert(!F.isDeclaration() && "Can only get GCFunctionInfo for a definition!"); assert(F.hasGC()); // Equivalent to `assert(false);` when called by `Printer::runOnFunction` ``` See also #74972.
1 parent 62b21c6 commit 4d8bf6e

File tree

5 files changed

+4
-86
lines changed

5 files changed

+4
-86
lines changed

llvm/include/llvm/CodeGen/MachinePassRegistry.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ DUMMY_FUNCTION_PASS("cfguard-check", CFGuardCheckPass, ())
126126
DUMMY_FUNCTION_PASS("cfguard-dispatch", CFGuardDispatchPass, ())
127127
DUMMY_FUNCTION_PASS("codegenprepare", CodeGenPreparePass, ())
128128
DUMMY_FUNCTION_PASS("expandmemcmp", ExpandMemCmpPass, ())
129-
DUMMY_FUNCTION_PASS("gc-info-printer", GCInfoPrinterPass, ())
130129
DUMMY_FUNCTION_PASS("gc-lowering", GCLoweringPass, ())
131130
DUMMY_FUNCTION_PASS("indirectbr-expand", IndirectBrExpandPass, ())
132131
DUMMY_FUNCTION_PASS("select-optimize", SelectOptimizePass, ())

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,6 @@ namespace llvm {
324324
/// branch folding).
325325
extern char &GCMachineCodeAnalysisID;
326326

327-
/// Creates a pass to print GC metadata.
328-
///
329-
FunctionPass *createGCInfoPrinter(raw_ostream &OS);
330-
331327
/// MachineCSE - This pass performs global CSE on machine instructions.
332328
extern char &MachineCSEID;
333329

llvm/include/llvm/Target/CGPassBuilderOption.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct CGPassBuilderOption {
4242
bool DisableConstantHoisting = false;
4343
bool DisableSelectOptimize = true;
4444
bool PrintISelInput = false;
45-
bool PrintGCInfo = false;
4645
bool RequiresCodeGenSCCOrder = false;
4746

4847
RunOutliner EnableMachineOutliner = RunOutliner::TargetDefault;

llvm/lib/CodeGen/GCMetadata.cpp

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,6 @@
2424

2525
using namespace llvm;
2626

27-
namespace {
28-
29-
class Printer : public FunctionPass {
30-
static char ID;
31-
32-
raw_ostream &OS;
33-
34-
public:
35-
explicit Printer(raw_ostream &OS) : FunctionPass(ID), OS(OS) {}
36-
37-
StringRef getPassName() const override;
38-
void getAnalysisUsage(AnalysisUsage &AU) const override;
39-
40-
bool runOnFunction(Function &F) override;
41-
bool doFinalization(Module &M) override;
42-
};
43-
44-
} // end anonymous namespace
45-
4627
INITIALIZE_PASS(GCModuleInfo, "collector-metadata",
4728
"Create Garbage Collector Module Metadata", false, false)
4829

@@ -84,58 +65,6 @@ void GCModuleInfo::clear() {
8465

8566
// -----------------------------------------------------------------------------
8667

87-
char Printer::ID = 0;
88-
89-
FunctionPass *llvm::createGCInfoPrinter(raw_ostream &OS) {
90-
return new Printer(OS);
91-
}
92-
93-
StringRef Printer::getPassName() const {
94-
return "Print Garbage Collector Information";
95-
}
96-
97-
void Printer::getAnalysisUsage(AnalysisUsage &AU) const {
98-
FunctionPass::getAnalysisUsage(AU);
99-
AU.setPreservesAll();
100-
AU.addRequired<GCModuleInfo>();
101-
}
102-
103-
bool Printer::runOnFunction(Function &F) {
104-
if (F.hasGC())
105-
return false;
106-
107-
GCFunctionInfo *FD = &getAnalysis<GCModuleInfo>().getFunctionInfo(F);
108-
109-
OS << "GC roots for " << FD->getFunction().getName() << ":\n";
110-
for (GCFunctionInfo::roots_iterator RI = FD->roots_begin(),
111-
RE = FD->roots_end();
112-
RI != RE; ++RI)
113-
OS << "\t" << RI->Num << "\t" << RI->StackOffset << "[sp]\n";
114-
115-
OS << "GC safe points for " << FD->getFunction().getName() << ":\n";
116-
for (GCFunctionInfo::iterator PI = FD->begin(), PE = FD->end(); PI != PE;
117-
++PI) {
118-
119-
OS << "\t" << PI->Label->getName() << ": " << "post-call"
120-
<< ", live = {";
121-
122-
ListSeparator LS(",");
123-
for (const GCRoot &R : make_range(FD->live_begin(PI), FD->live_end(PI)))
124-
OS << LS << " " << R.Num;
125-
126-
OS << " }\n";
127-
}
128-
129-
return false;
130-
}
131-
132-
bool Printer::doFinalization(Module &M) {
133-
GCModuleInfo *GMI = getAnalysisIfAvailable<GCModuleInfo>();
134-
assert(GMI && "Printer didn't require GCModuleInfo?!");
135-
GMI->clear();
136-
return false;
137-
}
138-
13968
GCStrategy *GCModuleInfo::getGCStrategy(const StringRef Name) {
14069
// TODO: Arguably, just doing a linear search would be faster for small N
14170
auto NMI = GCStrategyMap.find(Name);

llvm/lib/CodeGen/TargetPassConfig.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ static cl::opt<bool> DisableMergeICmps("disable-mergeicmps",
113113
cl::init(false), cl::Hidden);
114114
static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden,
115115
cl::desc("Print LLVM IR produced by the loop-reduce pass"));
116-
static cl::opt<bool> PrintISelInput("print-isel-input", cl::Hidden,
117-
cl::desc("Print LLVM IR input to isel pass"));
118-
static cl::opt<bool> PrintGCInfo("print-gc", cl::Hidden,
119-
cl::desc("Dump garbage collector data"));
116+
static cl::opt<bool>
117+
PrintISelInput("print-isel-input", cl::Hidden,
118+
cl::desc("Print LLVM IR input to isel pass"));
120119
static cl::opt<cl::boolOrDefault>
121120
VerifyMachineCode("verify-machineinstrs", cl::Hidden,
122121
cl::desc("Verify generated machine code"));
@@ -491,7 +490,6 @@ CGPassBuilderOption llvm::getCGPassBuilderOption() {
491490
SET_BOOLEAN_OPTION(DisableSelectOptimize)
492491
SET_BOOLEAN_OPTION(PrintLSR)
493492
SET_BOOLEAN_OPTION(PrintISelInput)
494-
SET_BOOLEAN_OPTION(PrintGCInfo)
495493

496494
return Opt;
497495
}
@@ -1211,10 +1209,7 @@ void TargetPassConfig::addMachinePasses() {
12111209
}
12121210

12131211
// GC
1214-
if (addGCPasses()) {
1215-
if (PrintGCInfo)
1216-
addPass(createGCInfoPrinter(dbgs()));
1217-
}
1212+
addGCPasses();
12181213

12191214
// Basic block placement.
12201215
if (getOptLevel() != CodeGenOptLevel::None)

0 commit comments

Comments
 (0)