Skip to content

Commit 1597774

Browse files
committed
Reland [LegacyPM] Remove some legacy passes
These are part of the optimization pipeline, of which the legacy pass manager version is deprecated. Namely * Internalize * StripSymbols * StripNonDebugSymbols * StripDeadDebugInfo * StripDeadPrototypes * VectorCombine * WarnMissedTransformations Fixed previously failing ocaml tests (one of them seems to already be failing?)
1 parent a2569a7 commit 1597774

File tree

23 files changed

+1
-523
lines changed

23 files changed

+1
-523
lines changed

llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,3 @@ value llvm_add_ipsccp(LLVMPassManagerRef PM) {
6767
return Val_unit;
6868
}
6969

70-
/* [`Module] Llvm.PassManager.t -> all_but_main:bool -> unit */
71-
value llvm_add_internalize(LLVMPassManagerRef PM, value AllButMain) {
72-
LLVMAddInternalizePass(PM, Bool_val(AllButMain));
73-
return Val_unit;
74-
}
75-
76-
/* [`Module] Llvm.PassManager.t -> unit */
77-
value llvm_add_strip_dead_prototypes(LLVMPassManagerRef PM) {
78-
LLVMAddStripDeadPrototypesPass(PM);
79-
return Val_unit;
80-
}
81-
82-
/* [`Module] Llvm.PassManager.t -> unit */
83-
value llvm_add_strip_symbols(LLVMPassManagerRef PM) {
84-
LLVMAddStripSymbolsPass(PM);
85-
return Val_unit;
86-
}

llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,3 @@ external add_global_optimizer
3030
external add_ipsccp
3131
: [ `Module ] Llvm.PassManager.t -> unit
3232
= "llvm_add_ipsccp"
33-
external add_internalize
34-
: [ `Module ] Llvm.PassManager.t -> all_but_main:bool -> unit
35-
= "llvm_add_internalize"
36-
external add_strip_dead_prototypes
37-
: [ `Module ] Llvm.PassManager.t -> unit
38-
= "llvm_add_strip_dead_prototypes"
39-
external add_strip_symbols
40-
: [ `Module ] Llvm.PassManager.t -> unit
41-
= "llvm_add_strip_symbols"

llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,3 @@ external add_global_optimizer
5050
external add_ipsccp
5151
: [ `Module ] Llvm.PassManager.t -> unit
5252
= "llvm_add_ipsccp"
53-
54-
(** See the [llvm::createInternalizePass] function. *)
55-
external add_internalize
56-
: [ `Module ] Llvm.PassManager.t -> all_but_main:bool -> unit
57-
= "llvm_add_internalize"
58-
59-
(** See the [llvm::createStripDeadPrototypesPass] function. *)
60-
external add_strip_dead_prototypes
61-
: [ `Module ] Llvm.PassManager.t -> unit
62-
= "llvm_add_strip_dead_prototypes"
63-
64-
(** See the [llvm::createStripSymbolsPass] function. *)
65-
external add_strip_symbols
66-
: [ `Module ] Llvm.PassManager.t -> unit
67-
= "llvm_add_strip_symbols"

llvm/include/llvm-c/Transforms/IPO.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,6 @@ void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
5151
/** See llvm::createIPSCCPPass function. */
5252
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
5353

54-
/** See llvm::createInternalizePass function. */
55-
void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
56-
57-
/**
58-
* Create and add the internalize pass to the given pass manager with the
59-
* provided preservation callback.
60-
*
61-
* The context parameter is forwarded to the callback on each invocation.
62-
* As such, it is the responsibility of the caller to extend its lifetime
63-
* until execution of this pass has finished.
64-
*
65-
* @see llvm::createInternalizePass function.
66-
*/
67-
void LLVMAddInternalizePassWithMustPreservePredicate(
68-
LLVMPassManagerRef PM,
69-
void *Context,
70-
LLVMBool (*MustPreserve)(LLVMValueRef, void *));
71-
72-
/** See llvm::createStripDeadPrototypesPass function. */
73-
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
74-
75-
/** See llvm::createStripSymbolsPass function. */
76-
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM);
77-
7854
/**
7955
* @}
8056
*/

llvm/include/llvm/InitializePasses.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ void initializeInstructionCombiningPassPass(PassRegistry&);
175175
void initializeInstructionSelectPass(PassRegistry&);
176176
void initializeInterleavedAccessPass(PassRegistry&);
177177
void initializeInterleavedLoadCombinePass(PassRegistry &);
178-
void initializeInternalizeLegacyPassPass(PassRegistry&);
179178
void initializeIntervalPartitionPass(PassRegistry&);
180179
void initializeJMCInstrumenterPass(PassRegistry&);
181180
void initializeJumpThreadingPass(PassRegistry&);
@@ -380,12 +379,8 @@ void initializeStackSafetyGlobalInfoWrapperPassPass(PassRegistry &);
380379
void initializeStackSafetyInfoWrapperPassPass(PassRegistry &);
381380
void initializeStackSlotColoringPass(PassRegistry&);
382381
void initializeStraightLineStrengthReduceLegacyPassPass(PassRegistry &);
383-
void initializeStripDeadDebugInfoPass(PassRegistry&);
384-
void initializeStripDeadPrototypesLegacyPassPass(PassRegistry&);
385-
void initializeStripDebugDeclarePass(PassRegistry&);
386382
void initializeStripDebugMachineModulePass(PassRegistry &);
387383
void initializeStripGCRelocatesLegacyPass(PassRegistry &);
388-
void initializeStripNonDebugSymbolsPass(PassRegistry&);
389384
void initializeStripNonLineTableDebugLegacyPassPass(PassRegistry &);
390385
void initializeStripSymbolsPass(PassRegistry&);
391386
void initializeStructurizeCFGLegacyPassPass(PassRegistry &);
@@ -404,11 +399,9 @@ void initializeUnifyLoopExitsLegacyPassPass(PassRegistry &);
404399
void initializeUnpackMachineBundlesPass(PassRegistry&);
405400
void initializeUnreachableBlockElimLegacyPassPass(PassRegistry&);
406401
void initializeUnreachableMachineBlockElimPass(PassRegistry&);
407-
void initializeVectorCombineLegacyPassPass(PassRegistry&);
408402
void initializeVerifierLegacyPassPass(PassRegistry&);
409403
void initializeVirtRegMapPass(PassRegistry&);
410404
void initializeVirtRegRewriterPass(PassRegistry&);
411-
void initializeWarnMissedTransformationsLegacyPass(PassRegistry &);
412405
void initializeWasmEHPreparePass(PassRegistry&);
413406
void initializeWinEHPreparePass(PassRegistry&);
414407
void initializeWriteBitcodePassPass(PassRegistry&);

llvm/include/llvm/LinkAllPasses.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ namespace {
104104
(void) llvm::createIndVarSimplifyPass();
105105
(void) llvm::createInstSimplifyLegacyPass();
106106
(void) llvm::createInstructionCombiningPass();
107-
(void) llvm::createInternalizePass();
108107
(void) llvm::createJMCInstrumenterPass();
109108
(void) llvm::createLCSSAPass();
110109
(void) llvm::createLegacyDivergenceAnalysisPass();
@@ -148,10 +147,6 @@ namespace {
148147
(void) llvm::createSafeStackPass();
149148
(void) llvm::createSROAPass();
150149
(void) llvm::createSingleLoopExtractorPass();
151-
(void) llvm::createStripSymbolsPass();
152-
(void) llvm::createStripNonDebugSymbolsPass();
153-
(void) llvm::createStripDeadDebugInfoPass();
154-
(void) llvm::createStripDeadPrototypesPass();
155150
(void) llvm::createTailCallEliminationPass();
156151
(void)llvm::createTLSVariableHoistPass();
157152
(void) llvm::createJumpThreadingPass();
@@ -191,7 +186,6 @@ namespace {
191186
(void) llvm::createLoopVectorizePass();
192187
(void) llvm::createSLPVectorizerPass();
193188
(void) llvm::createLoadStoreVectorizerPass();
194-
(void) llvm::createVectorCombinePass();
195189
(void) llvm::createPartiallyInlineLibCallsPass();
196190
(void) llvm::createScalarizerPass();
197191
(void) llvm::createSeparateConstOffsetFromGEPPass();
@@ -205,7 +199,6 @@ namespace {
205199
(void) llvm::createFloat2IntPass();
206200
(void) llvm::createEliminateAvailableExternallyPass();
207201
(void)llvm::createScalarizeMaskedMemIntrinLegacyPass();
208-
(void) llvm::createWarnMissedTransformationsPass();
209202
(void) llvm::createHardwareLoopsPass();
210203
(void) llvm::createInjectTLIMappingsLegacyPass();
211204
(void) llvm::createUnifyLoopExitsPass();

llvm/include/llvm/Transforms/IPO.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,6 @@ class raw_ostream;
3434
//
3535
ModulePass *createAnnotation2MetadataLegacyPass();
3636

37-
//===----------------------------------------------------------------------===//
38-
//
39-
// These functions removes symbols from functions and modules. If OnlyDebugInfo
40-
// is true, only debugging information is removed from the module.
41-
//
42-
ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
43-
44-
//===----------------------------------------------------------------------===//
45-
//
46-
// These functions strips symbols from functions and modules.
47-
// Only debugging information is not stripped.
48-
//
49-
ModulePass *createStripNonDebugSymbolsPass();
50-
51-
//===----------------------------------------------------------------------===//
52-
//
53-
// This pass removes llvm.dbg.declare intrinsics.
54-
ModulePass *createStripDebugDeclarePass();
55-
56-
//===----------------------------------------------------------------------===//
57-
//
58-
// This pass removes unused symbols' debug info.
59-
ModulePass *createStripDeadDebugInfoPass();
60-
6137
//===----------------------------------------------------------------------===//
6238
/// createConstantMergePass - This function returns a new pass that merges
6339
/// duplicate global constants together into a single constant that is shared.
@@ -110,24 +86,6 @@ Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
11086
bool DisableInlineHotCallSite);
11187
Pass *createFunctionInliningPass(InlineParams &Params);
11288

113-
//===----------------------------------------------------------------------===//
114-
/// createInternalizePass - This pass loops over all of the functions in the
115-
/// input module, internalizing all globals (functions and variables) it can.
116-
////
117-
/// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
118-
/// gives to the client the ability to prevent internalizing specific symbols.
119-
///
120-
/// The symbol in DSOList are internalized if it is safe to drop them from
121-
/// the symbol table.
122-
///
123-
/// Note that commandline options that are used with the above function are not
124-
/// used now!
125-
ModulePass *
126-
createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
127-
128-
/// createInternalizePass - Same as above, but with an empty exportList.
129-
ModulePass *createInternalizePass();
130-
13189
//===----------------------------------------------------------------------===//
13290
/// createDeadArgEliminationPass - This pass removes arguments from functions
13391
/// which are not used by the body of the function.
@@ -158,10 +116,6 @@ Pass *createLoopExtractorPass();
158116
///
159117
Pass *createSingleLoopExtractorPass();
160118

161-
/// createStripDeadPrototypesPass - This pass removes any function declarations
162-
/// (prototypes) that are not used.
163-
ModulePass *createStripDeadPrototypesPass();
164-
165119
//===----------------------------------------------------------------------===//
166120
/// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
167121
/// graph in RPO to deduce and propagate function attributes. Currently it

llvm/include/llvm/Transforms/Scalar.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,6 @@ FunctionPass *createLibCallsShrinkWrapPass();
522522
//
523523
Pass *createLoopSimplifyCFGPass();
524524

525-
//===----------------------------------------------------------------------===//
526-
//
527-
// WarnMissedTransformations - This pass emits warnings for leftover forced
528-
// transformations.
529-
//
530-
Pass *createWarnMissedTransformationsPass();
531-
532525
//===----------------------------------------------------------------------===//
533526
//
534527
// This pass does instruction simplification on each

llvm/include/llvm/Transforms/Scalar/WarnMissedTransforms.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#include "llvm/IR/PassManager.h"
1717

1818
namespace llvm {
19-
class Function;
20-
class Pass;
21-
class PassRegistry;
22-
2319
// New pass manager boilerplate.
2420
class WarnMissedTransformationsPass
2521
: public PassInfoMixin<WarnMissedTransformationsPass> {
@@ -28,10 +24,6 @@ class WarnMissedTransformationsPass
2824

2925
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
3026
};
31-
32-
// Legacy pass manager boilerplate.
33-
Pass *createWarnMissedTransformationsPass();
34-
void initializeWarnMissedTransformationsLegacyPass(PassRegistry &);
3527
} // end namespace llvm
3628

3729
#endif // LLVM_TRANSFORMS_SCALAR_WARNMISSEDTRANSFORMS_H

llvm/include/llvm/Transforms/Utils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ FunctionPass *createPromoteMemoryToRegisterPass();
100100
Pass *createLoopSimplifyPass();
101101
extern char &LoopSimplifyID;
102102

103-
/// This function returns a new pass that downgrades the debug info in the
104-
/// module to line tables only.
105-
ModulePass *createStripNonLineTableDebugLegacyPass();
106-
107103
//===----------------------------------------------------------------------===//
108104
//
109105
// InjectTLIMappingsLegacy - populates the VFABI attribute with the

llvm/include/llvm/Transforms/Vectorize.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ bool vectorizeBasicBlock(Pass *P, BasicBlock &BB,
138138
//
139139
Pass *createLoadStoreVectorizerPass();
140140

141-
//===----------------------------------------------------------------------===//
142-
//
143-
// Optimize partial vector operations using target cost models.
144-
//
145-
Pass *createVectorCombinePass();
146-
147141
} // End llvm namespace
148142

149143
#endif

llvm/lib/Transforms/IPO/IPO.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,13 @@ void llvm::initializeIPO(PassRegistry &Registry) {
3535
initializeAlwaysInlinerLegacyPassPass(Registry);
3636
initializeSimpleInlinerPass(Registry);
3737
initializeInferFunctionAttrsLegacyPassPass(Registry);
38-
initializeInternalizeLegacyPassPass(Registry);
3938
initializeLoopExtractorLegacyPassPass(Registry);
4039
initializeSingleLoopExtractorPass(Registry);
4140
initializeAttributorLegacyPassPass(Registry);
4241
initializeAttributorCGSCCLegacyPassPass(Registry);
4342
initializePostOrderFunctionAttrsLegacyPassPass(Registry);
4443
initializeReversePostOrderFunctionAttrsLegacyPassPass(Registry);
4544
initializeIPSCCPLegacyPassPass(Registry);
46-
initializeStripDeadPrototypesLegacyPassPass(Registry);
47-
initializeStripSymbolsPass(Registry);
48-
initializeStripDebugDeclarePass(Registry);
49-
initializeStripDeadDebugInfoPass(Registry);
50-
initializeStripNonDebugSymbolsPass(Registry);
5145
initializeBarrierNoopPass(Registry);
5246
initializeEliminateAvailableExternallyLegacyPassPass(Registry);
5347
}
@@ -87,27 +81,3 @@ void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
8781
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
8882
unwrap(PM)->add(createIPSCCPPass());
8983
}
90-
91-
void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
92-
auto PreserveMain = [=](const GlobalValue &GV) {
93-
return AllButMain && GV.getName() == "main";
94-
};
95-
unwrap(PM)->add(createInternalizePass(PreserveMain));
96-
}
97-
98-
void LLVMAddInternalizePassWithMustPreservePredicate(
99-
LLVMPassManagerRef PM,
100-
void *Context,
101-
LLVMBool (*Pred)(LLVMValueRef, void *)) {
102-
unwrap(PM)->add(createInternalizePass([=](const GlobalValue &GV) {
103-
return Pred(wrap(&GV), Context) == 0 ? false : true;
104-
}));
105-
}
106-
107-
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
108-
unwrap(PM)->add(createStripDeadPrototypesPass());
109-
}
110-
111-
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
112-
unwrap(PM)->add(createStripSymbolsPass());
113-
}

llvm/lib/Transforms/IPO/Internalize.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -284,48 +284,3 @@ PreservedAnalyses InternalizePass::run(Module &M, ModuleAnalysisManager &AM) {
284284
PA.preserve<CallGraphAnalysis>();
285285
return PA;
286286
}
287-
288-
namespace {
289-
class InternalizeLegacyPass : public ModulePass {
290-
// Client supplied callback to control wheter a symbol must be preserved.
291-
std::function<bool(const GlobalValue &)> MustPreserveGV;
292-
293-
public:
294-
static char ID; // Pass identification, replacement for typeid
295-
296-
InternalizeLegacyPass() : ModulePass(ID), MustPreserveGV(PreserveAPIList()) {}
297-
298-
InternalizeLegacyPass(std::function<bool(const GlobalValue &)> MustPreserveGV)
299-
: ModulePass(ID), MustPreserveGV(std::move(MustPreserveGV)) {
300-
initializeInternalizeLegacyPassPass(*PassRegistry::getPassRegistry());
301-
}
302-
303-
bool runOnModule(Module &M) override {
304-
if (skipModule(M))
305-
return false;
306-
307-
CallGraphWrapperPass *CGPass =
308-
getAnalysisIfAvailable<CallGraphWrapperPass>();
309-
CallGraph *CG = CGPass ? &CGPass->getCallGraph() : nullptr;
310-
return internalizeModule(M, MustPreserveGV, CG);
311-
}
312-
313-
void getAnalysisUsage(AnalysisUsage &AU) const override {
314-
AU.setPreservesCFG();
315-
AU.addPreserved<CallGraphWrapperPass>();
316-
}
317-
};
318-
}
319-
320-
char InternalizeLegacyPass::ID = 0;
321-
INITIALIZE_PASS(InternalizeLegacyPass, "internalize",
322-
"Internalize Global Symbols", false, false)
323-
324-
ModulePass *llvm::createInternalizePass() {
325-
return new InternalizeLegacyPass();
326-
}
327-
328-
ModulePass *llvm::createInternalizePass(
329-
std::function<bool(const GlobalValue &)> MustPreserveGV) {
330-
return new InternalizeLegacyPass(std::move(MustPreserveGV));
331-
}

0 commit comments

Comments
 (0)