Skip to content

Commit 50d1fb9

Browse files
committed
Revert "CodeGen: Add LibcallLoweringInfo analysis pass (llvm#168622)"
This reverts commit 04c81a9.
1 parent fa511cd commit 50d1fb9

37 files changed

+66
-331
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "llvm/ADT/StringExtras.h"
2020
#include "llvm/ADT/StringSwitch.h"
2121
#include "llvm/Analysis/GlobalsModRef.h"
22-
#include "llvm/Analysis/RuntimeLibcallInfo.h"
2322
#include "llvm/Analysis/TargetLibraryInfo.h"
2423
#include "llvm/Analysis/TargetTransformInfo.h"
2524
#include "llvm/Bitcode/BitcodeReader.h"
@@ -656,11 +655,6 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses,
656655
llvm::driver::createTLII(TargetTriple, CodeGenOpts.getVecLib()));
657656
CodeGenPasses.add(new TargetLibraryInfoWrapperPass(*TLII));
658657

659-
const llvm::TargetOptions &Options = TM->Options;
660-
CodeGenPasses.add(new RuntimeLibraryInfoWrapper(
661-
TargetTriple, Options.ExceptionModel, Options.FloatABIType,
662-
Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
663-
664658
// Normal mode, emit a .s or .o file by running the code generator. Note,
665659
// this also adds codegenerator level optimization passes.
666660
CodeGenFileType CGFT = getCodeGenFileType(Action);

llvm/include/llvm/Analysis/RuntimeLibcallInfo.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ class LLVM_ABI RuntimeLibraryAnalysis
2222
RuntimeLibraryAnalysis() = default;
2323
RuntimeLibraryAnalysis(RTLIB::RuntimeLibcallsInfo &&BaselineInfoImpl)
2424
: LibcallsInfo(std::move(BaselineInfoImpl)) {}
25-
RuntimeLibraryAnalysis(
26-
const Triple &TT,
27-
ExceptionHandling ExceptionModel = ExceptionHandling::None,
28-
FloatABI::ABIType FloatABI = FloatABI::Default,
29-
EABI EABIVersion = EABI::Default, StringRef ABIName = "",
30-
VectorLibrary VecLib = VectorLibrary::NoLibrary);
25+
explicit RuntimeLibraryAnalysis(const Triple &T) : LibcallsInfo(T) {}
3126

3227
RTLIB::RuntimeLibcallsInfo run(const Module &M, ModuleAnalysisManager &);
3328

@@ -45,19 +40,12 @@ class LLVM_ABI RuntimeLibraryInfoWrapper : public ImmutablePass {
4540
public:
4641
static char ID;
4742
RuntimeLibraryInfoWrapper();
48-
RuntimeLibraryInfoWrapper(
49-
const Triple &TT,
50-
ExceptionHandling ExceptionModel = ExceptionHandling::None,
51-
FloatABI::ABIType FloatABI = FloatABI::Default,
52-
EABI EABIVersion = EABI::Default, StringRef ABIName = "",
53-
VectorLibrary VecLib = VectorLibrary::NoLibrary);
43+
explicit RuntimeLibraryInfoWrapper(const Triple &T);
44+
explicit RuntimeLibraryInfoWrapper(const RTLIB::RuntimeLibcallsInfo &RTLCI);
5445

5546
const RTLIB::RuntimeLibcallsInfo &getRTLCI(const Module &M) {
56-
if (!RTLCI) {
57-
ModuleAnalysisManager DummyMAM;
58-
RTLCI = RTLA.run(M, DummyMAM);
59-
}
60-
47+
ModuleAnalysisManager DummyMAM;
48+
RTLCI = RTLA.run(M, DummyMAM);
6149
return *RTLCI;
6250
}
6351

llvm/include/llvm/CodeGen/LibcallLoweringInfo.h

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99
#ifndef LLVM_CODEGEN_LIBCALLLOWERINGINFO_H
1010
#define LLVM_CODEGEN_LIBCALLLOWERINGINFO_H
1111

12-
#include "llvm/ADT/DenseMap.h"
1312
#include "llvm/IR/RuntimeLibcalls.h"
14-
#include "llvm/Pass.h"
1513

1614
namespace llvm {
1715

1816
class TargetSubtargetInfo;
19-
class TargetMachine;
2017

21-
/// Tracks which library functions to use for a particular subtarget.
2218
class LibcallLoweringInfo {
2319
private:
2420
const RTLIB::RuntimeLibcallsInfo &RTLCI;
@@ -77,70 +73,6 @@ class LibcallLoweringInfo {
7773
}
7874
};
7975

80-
/// Record a mapping from subtarget to LibcallLoweringInfo.
81-
class LibcallLoweringModuleAnalysisResult {
82-
private:
83-
using LibcallLoweringMap =
84-
DenseMap<const TargetSubtargetInfo *, LibcallLoweringInfo>;
85-
mutable LibcallLoweringMap LoweringMap;
86-
const RTLIB::RuntimeLibcallsInfo *RTLCI = nullptr;
87-
88-
public:
89-
LibcallLoweringModuleAnalysisResult() = default;
90-
LibcallLoweringModuleAnalysisResult(RTLIB::RuntimeLibcallsInfo &RTLCI)
91-
: RTLCI(&RTLCI) {}
92-
93-
void init(const RTLIB::RuntimeLibcallsInfo *RT) { RTLCI = RT; }
94-
95-
void clear() {
96-
RTLCI = nullptr;
97-
LoweringMap.clear();
98-
}
99-
100-
LLVM_ABI bool invalidate(Module &, const PreservedAnalyses &,
101-
ModuleAnalysisManager::Invalidator &);
102-
103-
const LibcallLoweringInfo &
104-
getLibcallLowering(const TargetSubtargetInfo &Subtarget) const {
105-
return LoweringMap.try_emplace(&Subtarget, *RTLCI, Subtarget).first->second;
106-
}
107-
};
108-
109-
class LibcallLoweringModuleAnalysis
110-
: public AnalysisInfoMixin<LibcallLoweringModuleAnalysis> {
111-
private:
112-
friend AnalysisInfoMixin<LibcallLoweringModuleAnalysis>;
113-
static AnalysisKey Key;
114-
115-
LibcallLoweringModuleAnalysisResult LibcallLoweringMap;
116-
117-
public:
118-
using Result = LibcallLoweringModuleAnalysisResult;
119-
120-
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &);
121-
};
122-
123-
class LLVM_ABI LibcallLoweringInfoWrapper : public ImmutablePass {
124-
LibcallLoweringModuleAnalysisResult Result;
125-
126-
public:
127-
static char ID;
128-
LibcallLoweringInfoWrapper();
129-
130-
const LibcallLoweringInfo &
131-
getLibcallLowering(const TargetSubtargetInfo &Subtarget) const {
132-
return Result.getLibcallLowering(Subtarget);
133-
}
134-
135-
const LibcallLoweringModuleAnalysisResult &getResult() const {
136-
return Result;
137-
}
138-
139-
bool doInitialization(Module &M) override;
140-
void getAnalysisUsage(AnalysisUsage &AU) const override;
141-
void releaseMemory() override;
142-
};
143-
14476
} // end namespace llvm
14577

14678
#endif // LLVM_CODEGEN_LIBCALLLOWERINGINFO_H

llvm/include/llvm/InitializePasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ LLVM_ABI void initializeGlobalMergeFuncPassWrapperPass(PassRegistry &);
134134
LLVM_ABI void initializeGlobalMergePass(PassRegistry &);
135135
LLVM_ABI void initializeGlobalsAAWrapperPassPass(PassRegistry &);
136136
LLVM_ABI void initializeHardwareLoopsLegacyPass(PassRegistry &);
137-
LLVM_ABI void initializeLibcallLoweringInfoWrapperPass(PassRegistry &);
138137
LLVM_ABI void initializeMIRProfileLoaderPassPass(PassRegistry &);
139138
LLVM_ABI void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry &);
140139
LLVM_ABI void initializeIRTranslatorPass(PassRegistry &);

llvm/lib/Analysis/RuntimeLibcallInfo.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ using namespace llvm;
1313

1414
AnalysisKey RuntimeLibraryAnalysis::Key;
1515

16-
RuntimeLibraryAnalysis::RuntimeLibraryAnalysis(const Triple &TT,
17-
ExceptionHandling ExceptionModel,
18-
FloatABI::ABIType FloatABI,
19-
EABI EABIVersion,
20-
StringRef ABIName,
21-
VectorLibrary VecLib)
22-
: LibcallsInfo(std::in_place, TT, ExceptionModel, FloatABI, EABIVersion,
23-
ABIName, VecLib) {}
24-
2516
RTLIB::RuntimeLibcallsInfo
2617
RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) {
2718
if (!LibcallsInfo)
@@ -35,13 +26,6 @@ INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info",
3526
RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper()
3627
: ImmutablePass(ID), RTLA(RTLIB::RuntimeLibcallsInfo(Triple())) {}
3728

38-
RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper(
39-
const Triple &TT, ExceptionHandling ExceptionModel,
40-
FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName,
41-
VectorLibrary VecLib)
42-
: ImmutablePass(ID), RTLCI(std::in_place, TT, ExceptionModel, FloatABI,
43-
EABIVersion, ABIName, VecLib) {}
44-
4529
char RuntimeLibraryInfoWrapper::ID = 0;
4630

4731
ModulePass *llvm::createRuntimeLibraryInfoWrapperPass() {

llvm/lib/CodeGen/CodeGen.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
5757
initializeInterleavedLoadCombinePass(Registry);
5858
initializeInterleavedAccessPass(Registry);
5959
initializeJMCInstrumenterPass(Registry);
60-
initializeLibcallLoweringInfoWrapperPass(Registry);
6160
initializeLiveDebugValuesLegacyPass(Registry);
6261
initializeLiveDebugVariablesWrapperLegacyPass(Registry);
6362
initializeLiveIntervalsWrapperPassPass(Registry);

llvm/lib/CodeGen/ExpandFp.cpp

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -975,12 +975,11 @@ static RTLIB::Libcall fremToLibcall(Type *Ty) {
975975
/* Return true if, according to \p LibInfo, the target either directly
976976
supports the frem instruction for the \p Ty, has a custom lowering,
977977
or uses a libcall. */
978-
static bool targetSupportsFrem(const TargetLowering &TLI,
979-
const LibcallLoweringInfo &Libcalls, Type *Ty) {
978+
static bool targetSupportsFrem(const TargetLowering &TLI, Type *Ty) {
980979
if (!TLI.isOperationExpand(ISD::FREM, EVT::getEVT(Ty)))
981980
return true;
982981

983-
return Libcalls.getLibcallName(fremToLibcall(Ty->getScalarType()));
982+
return TLI.getLibcallName(fremToLibcall(Ty->getScalarType()));
984983
}
985984

986985
static void addToWorklist(Instruction &I,
@@ -992,7 +991,7 @@ static void addToWorklist(Instruction &I,
992991
}
993992

994993
static bool runImpl(Function &F, const TargetLowering &TLI,
995-
const LibcallLoweringInfo &Libcalls, AssumptionCache *AC) {
994+
AssumptionCache *AC) {
996995
SmallVector<Instruction *, 4> Worklist;
997996

998997
unsigned MaxLegalFpConvertBitWidth =
@@ -1011,7 +1010,7 @@ static bool runImpl(Function &F, const TargetLowering &TLI,
10111010

10121011
switch (I.getOpcode()) {
10131012
case Instruction::FRem:
1014-
return !targetSupportsFrem(TLI, Libcalls, Ty) &&
1013+
return !targetSupportsFrem(TLI, Ty) &&
10151014
FRemExpander::canExpandType(Ty->getScalarType());
10161015

10171016
case Instruction::FPToUI:
@@ -1091,27 +1090,20 @@ class ExpandFpLegacyPass : public FunctionPass {
10911090

10921091
bool runOnFunction(Function &F) override {
10931092
auto *TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
1094-
const TargetSubtargetInfo *Subtarget = TM->getSubtargetImpl(F);
1095-
auto *TLI = Subtarget->getTargetLowering();
1093+
auto *TLI = TM->getSubtargetImpl(F)->getTargetLowering();
10961094
AssumptionCache *AC = nullptr;
10971095

1098-
const LibcallLoweringInfo &Libcalls =
1099-
getAnalysis<LibcallLoweringInfoWrapper>().getLibcallLowering(
1100-
*Subtarget);
1101-
11021096
if (OptLevel != CodeGenOptLevel::None && !F.hasOptNone())
11031097
AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1104-
return runImpl(F, *TLI, Libcalls, AC);
1098+
return runImpl(F, *TLI, AC);
11051099
}
11061100

11071101
void getAnalysisUsage(AnalysisUsage &AU) const override {
1108-
AU.addRequired<LibcallLoweringInfoWrapper>();
11091102
AU.addRequired<TargetPassConfig>();
11101103
if (OptLevel != CodeGenOptLevel::None)
11111104
AU.addRequired<AssumptionCacheTracker>();
11121105
AU.addPreserved<AAResultsWrapperPass>();
11131106
AU.addPreserved<GlobalsAAWrapperPass>();
1114-
AU.addRequired<LibcallLoweringInfoWrapper>();
11151107
}
11161108
};
11171109
} // namespace
@@ -1134,29 +1126,13 @@ PreservedAnalyses ExpandFpPass::run(Function &F, FunctionAnalysisManager &FAM) {
11341126
AssumptionCache *AC = nullptr;
11351127
if (OptLevel != CodeGenOptLevel::None)
11361128
AC = &FAM.getResult<AssumptionAnalysis>(F);
1137-
1138-
auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1139-
1140-
const LibcallLoweringModuleAnalysisResult *LibcallLowering =
1141-
MAMProxy.getCachedResult<LibcallLoweringModuleAnalysis>(*F.getParent());
1142-
1143-
if (!LibcallLowering) {
1144-
F.getContext().emitError("'" + LibcallLoweringModuleAnalysis::name() +
1145-
"' analysis required");
1146-
return PreservedAnalyses::all();
1147-
}
1148-
1149-
const LibcallLoweringInfo &Libcalls =
1150-
LibcallLowering->getLibcallLowering(*STI);
1151-
1152-
return runImpl(F, TLI, Libcalls, AC) ? PreservedAnalyses::none()
1153-
: PreservedAnalyses::all();
1129+
return runImpl(F, TLI, AC) ? PreservedAnalyses::none()
1130+
: PreservedAnalyses::all();
11541131
}
11551132

11561133
char ExpandFpLegacyPass::ID = 0;
11571134
INITIALIZE_PASS_BEGIN(ExpandFpLegacyPass, "expand-fp",
11581135
"Expand certain fp instructions", false, false)
1159-
INITIALIZE_PASS_DEPENDENCY(LibcallLoweringInfoWrapper)
11601136
INITIALIZE_PASS_END(ExpandFpLegacyPass, "expand-fp", "Expand fp", false, false)
11611137

11621138
FunctionPass *llvm::createExpandFpPass(CodeGenOptLevel OptLevel) {

llvm/lib/CodeGen/LibcallLoweringInfo.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/CodeGen/LibcallLoweringInfo.h"
10-
#include "llvm/Analysis/RuntimeLibcallInfo.h"
1110
#include "llvm/CodeGen/TargetSubtargetInfo.h"
12-
#include "llvm/InitializePasses.h"
13-
#include "llvm/Target/TargetMachine.h"
1411

1512
using namespace llvm;
1613

@@ -31,42 +28,3 @@ LibcallLoweringInfo::LibcallLoweringInfo(
3128

3229
Subtarget.initLibcallLoweringInfo(*this);
3330
}
34-
35-
AnalysisKey LibcallLoweringModuleAnalysis::Key;
36-
37-
bool LibcallLoweringModuleAnalysisResult::invalidate(
38-
Module &, const PreservedAnalyses &PA,
39-
ModuleAnalysisManager::Invalidator &) {
40-
// Passes that change the runtime libcall set must explicitly invalidate this
41-
// pass.
42-
auto PAC = PA.getChecker<LibcallLoweringModuleAnalysis>();
43-
return !PAC.preservedWhenStateless();
44-
}
45-
46-
LibcallLoweringModuleAnalysisResult
47-
LibcallLoweringModuleAnalysis::run(Module &M, ModuleAnalysisManager &MAM) {
48-
LibcallLoweringMap.init(&MAM.getResult<RuntimeLibraryAnalysis>(M));
49-
return LibcallLoweringMap;
50-
}
51-
52-
INITIALIZE_PASS_BEGIN(LibcallLoweringInfoWrapper, "libcall-lowering-info",
53-
"Library Function Lowering Analysis", false, true)
54-
INITIALIZE_PASS_DEPENDENCY(RuntimeLibraryInfoWrapper)
55-
INITIALIZE_PASS_END(LibcallLoweringInfoWrapper, "libcall-lowering-info",
56-
"Library Function Lowering Analysis", false, true)
57-
58-
char LibcallLoweringInfoWrapper::ID = 0;
59-
60-
LibcallLoweringInfoWrapper::LibcallLoweringInfoWrapper() : ImmutablePass(ID) {}
61-
62-
bool LibcallLoweringInfoWrapper::doInitialization(Module &M) {
63-
Result.init(&getAnalysis<RuntimeLibraryInfoWrapper>().getRTLCI(M));
64-
return false;
65-
}
66-
67-
void LibcallLoweringInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
68-
AU.addRequired<RuntimeLibraryInfoWrapper>();
69-
AU.setPreservesAll();
70-
}
71-
72-
void LibcallLoweringInfoWrapper::releaseMemory() { Result.clear(); }

0 commit comments

Comments
 (0)