Skip to content

Commit 2324893

Browse files
committed
[TSAR, APC] Exclude APC passes from a list of analysis passes that can be run separately.
1 parent 274b885 commit 2324893

File tree

5 files changed

+15
-65
lines changed

5 files changed

+15
-65
lines changed

lib/APC/ArrayInfo.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "tsar/Analysis/Memory/Utils.h"
3737
#include "tsar/APC/APCContext.h"
3838
#include "tsar/APC/Passes.h"
39-
#include "tsar/Core/Query.h"
4039
#include "tsar/Support/Diagnostic.h"
4140
#include "tsar/Support/MetadataUtils.h"
4241
#include "tsar/Support/NumericUtils.h"
@@ -74,24 +73,21 @@ class APCArrayInfoPass : public FunctionPass, private bcl::Uncopyable {
7473

7574
private:
7675
std::vector<apc::Array *> mArrays;
77-
bool mMultipleLaunch = false;
7876
};
7977
}
8078

8179
char APCArrayInfoPass::ID = 0;
8280

83-
INITIALIZE_PASS_IN_GROUP_BEGIN(APCArrayInfoPass, "apc-array-info",
84-
"Array Collector (APC)", true, true,
85-
DefaultQueryManager::PrintPassGroup::getPassRegistry())
81+
INITIALIZE_PASS_BEGIN(APCArrayInfoPass, "apc-array-info",
82+
"Array Collector (APC)", true, true)
8683
INITIALIZE_PASS_DEPENDENCY(DelinearizationPass)
8784
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
8885
INITIALIZE_PASS_DEPENDENCY(APCContextWrapper)
8986
INITIALIZE_PASS_DEPENDENCY(EstimateMemoryPass)
9087
INITIALIZE_PASS_DEPENDENCY(DIEstimateMemoryPass)
9188
INITIALIZE_PASS_DEPENDENCY(ClangDIMemoryMatcherPass)
92-
INITIALIZE_PASS_IN_GROUP_END(APCArrayInfoPass, "apc-array-info",
93-
"Array Collector (APC)", true, true,
94-
DefaultQueryManager::PrintPassGroup::getPassRegistry())
89+
INITIALIZE_PASS_END(APCArrayInfoPass, "apc-array-info",
90+
"Array Collector (APC)", true, true)
9591

9692
FunctionPass * llvm::createAPCArrayInfoPass() { return new APCArrayInfoPass; }
9793

@@ -249,10 +245,6 @@ bool APCArrayInfoPass::runOnFunction(Function &Func) {
249245
Var.get<MD>() = &ClientDIEM;
250246
if (auto *A{APCCtx.findArray(ClientRawDIM)}) {
251247
auto S{A->GetDeclSymbol()};
252-
// This pass may be executed in analysis mode. It depends on -print-only
253-
// and -print-step options. In case of parallelization pass manager must
254-
// invokes this pass only once for each function.
255-
mMultipleLaunch |= S->getVariable(&Func).hasValue();
256248
S->addRedeclaration(std::move(Var));
257249
continue;
258250
}
@@ -267,7 +259,6 @@ bool APCArrayInfoPass::runOnFunction(Function &Func) {
267259
llvm_unreachable("Unable to add new array to an APC context!");
268260
delete APCArray;
269261
mArrays.push_back(APCCtx.findArray(ClientRawDIM));
270-
mMultipleLaunch = true;
271262
continue;
272263
}
273264
mArrays.push_back(APCArray);
@@ -289,9 +280,6 @@ bool APCArrayInfoPass::runOnFunction(Function &Func) {
289280
}
290281

291282
void APCArrayInfoPass::print(raw_ostream &OS, const Module *M) const {
292-
if (mMultipleLaunch)
293-
OS << "warning: possible multiple launches of the pass for the same "
294-
"function: print merged results\n";
295283
for (auto *A : mArrays) {
296284
OS << format("%s [short=%s, unique=%s, id=%d]\n", A->GetName().c_str(),
297285
A->GetShortName().c_str(), A->GetArrayUniqKey().c_str(), A->GetId());

lib/APC/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(APC_SOURCES Passes.cpp APCContext.cpp Utils.cpp LoopInfoBase.cpp
1+
set(APC_SOURCES Passes.cpp APCContext.cpp Utils.cpp LoopInfo.cpp
22
ArrayInfo.cpp FunctionInfo.cpp Parallelization.cpp ClangDVMHWriter.cpp
33
DistributionLimits.cpp DirectivesCollector.cpp DiagnosticPrinter.cpp)
44

lib/APC/FunctionInfo.cpp

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "tsar/Analysis/Memory/Utils.h"
3232
#include "tsar/APC/APCContext.h"
3333
#include "tsar/APC/Passes.h"
34-
#include "tsar/Core/Query.h"
3534
#include "tsar/Support/Diagnostic.h"
3635
#include "tsar/Support/MetadataUtils.h"
3736
#include "tsar/Support/Utils.h"
@@ -58,16 +57,6 @@ using APCFunctionInfoPassProvider =
5857
FunctionPassAAProvider<DIEstimateMemoryPass, EstimateMemoryPass,
5958
DominatorTreeWrapperPass, AAResultsWrapperPass>;
6059

61-
class APCFunctionInfoPassInfo final : public PassGroupInfo {
62-
bool isNecessaryPass(llvm::AnalysisID ID) const override {
63-
static llvm::AnalysisID Passes[] = {
64-
getPassIDAndErase(createAPCLoopInfoBasePass()),
65-
getPassIDAndErase(createAPCArrayInfoPass()),
66-
};
67-
return count(Passes, ID);
68-
}
69-
};
70-
7160
class APCFunctionInfoPass: public ModulePass, private bcl::Uncopyable {
7261
public:
7362
static char ID;
@@ -137,10 +126,8 @@ char APCFunctionInfoPass::ID = 0;
137126
INITIALIZE_PROVIDER(APCFunctionInfoPassProvider, "apc-function-info-provider",
138127
"Function Collector (APC, Provider")
139128

140-
INITIALIZE_PASS_IN_GROUP_BEGIN(APCFunctionInfoPass, "apc-function-info",
141-
"Function Collector (APC)", true, true,
142-
DefaultQueryManager::PrintPassGroup::getPassRegistry())
143-
INITIALIZE_PASS_IN_GROUP_INFO(APCFunctionInfoPassInfo);
129+
INITIALIZE_PASS_BEGIN(APCFunctionInfoPass, "apc-function-info",
130+
"Function Collector (APC)", true, true)
144131
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
145132
INITIALIZE_PASS_DEPENDENCY(DIMemoryEnvironmentWrapper)
146133
INITIALIZE_PASS_DEPENDENCY(DIEstimateMemoryPass)
@@ -151,9 +138,8 @@ INITIALIZE_PASS_IN_GROUP_BEGIN(APCFunctionInfoPass, "apc-function-info",
151138
INITIALIZE_PASS_DEPENDENCY(APCContextWrapper)
152139
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
153140
INITIALIZE_PASS_DEPENDENCY(APCFunctionInfoPassProvider)
154-
INITIALIZE_PASS_IN_GROUP_END(APCFunctionInfoPass, "apc-function-info",
155-
"Function Collector (APC)", true, true,
156-
DefaultQueryManager::PrintPassGroup::getPassRegistry())
141+
INITIALIZE_PASS_END(APCFunctionInfoPass, "apc-function-info",
142+
"Function Collector (APC)", true, true)
157143

158144
ModulePass * llvm::createAPCFunctionInfoPass() {
159145
return new APCFunctionInfoPass;
@@ -195,13 +181,6 @@ bool APCFunctionInfoPass::runOnModule(Module &M) {
195181
continue;
196182
auto Pair = registerFunction(const_cast<Function &>(*Caller.first), APCCtx);
197183
mFunctions.push_back(Pair.first);
198-
if (!Pair.second) {
199-
// This pass may be executed in analysis mode. It depends on -print-only
200-
// and -print-step options. In case of parallelization pass manager must
201-
// invokes this pass only once for each function.
202-
mMultipleLaunch = true;
203-
continue;
204-
}
205184
auto &FI = *Pair.first;
206185
auto DIFunc = Caller.first->getSubprogram();
207186
/// TODO ([email protected]): should we emit warning or error if filename
@@ -382,9 +361,6 @@ bool APCFunctionInfoPass::runOnModule(Module &M) {
382361
}
383362

384363
void APCFunctionInfoPass::print(raw_ostream &OS, const Module *M) const {
385-
if (mMultipleLaunch)
386-
OS << "warning: possible multiple launches of the pass for the same "
387-
"module: print merged results\n";
388364
auto printParams = [&OS](const apc::FuncParam &Params, const Twine &Prefix) {
389365
for (std::size_t I = 0, EI = Params.countOfPars; I < EI; ++I) {
390366
OS << Prefix << "idx: " << I << "\n";

lib/APC/LoopInfoBase.cpp renamed to lib/APC/LoopInfo.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===---- LoopInfoBase.cpp ----- APC Loop Graph Builder --------*- C++ -*-===//
1+
//===---- LoopInfo.cpp ----- APC Loop Graph Builder --------*- C++ -*-===//
22
//
33
// Traits Static Analyzer (SAPFOR)
44
//
@@ -44,7 +44,6 @@
4444
#include "tsar/APC/APCContext.h"
4545
#include "tsar/APC/Passes.h"
4646
#include "tsar/APC/Utils.h"
47-
#include "tsar/Core/Query.h"
4847
#include "tsar/Frontend/Clang/TransformationContext.h"
4948
#include "tsar/Support/GlobalOptions.h"
5049
#include "tsar/Support/NumericUtils.h"
@@ -68,7 +67,7 @@ using namespace llvm;
6867
using namespace tsar;
6968

7069
#undef DEBUG_TYPE
71-
#define DEBUG_TYPE "apc-loop-base"
70+
#define DEBUG_TYPE "apc-loop-info"
7271

7372
namespace {
7473
class APCLoopInfoBasePass : public FunctionPass, private bcl::Uncopyable {
@@ -138,9 +137,8 @@ class APCLoopInfoBasePass : public FunctionPass, private bcl::Uncopyable {
138137

139138
char APCLoopInfoBasePass::ID = 0;
140139

141-
INITIALIZE_PASS_IN_GROUP_BEGIN(APCLoopInfoBasePass, "apc-loop-info",
142-
"Loop Graph Builder (APC)", true, true,
143-
DefaultQueryManager::PrintPassGroup::getPassRegistry())
140+
INITIALIZE_PASS_BEGIN(APCLoopInfoBasePass, "apc-loop-info",
141+
"Loop Graph Builder (APC)", true, true)
144142
INITIALIZE_PASS_DEPENDENCY(AnalysisSocketImmutableWrapper)
145143
INITIALIZE_PASS_DEPENDENCY(APCContextWrapper)
146144
INITIALIZE_PASS_DEPENDENCY(ClangDIMemoryMatcherPass)
@@ -155,9 +153,8 @@ INITIALIZE_PASS_IN_GROUP_BEGIN(APCLoopInfoBasePass, "apc-loop-info",
155153
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
156154
INITIALIZE_PASS_DEPENDENCY(ParallelLoopPass)
157155
INITIALIZE_PASS_DEPENDENCY(TransformationEnginePass)
158-
INITIALIZE_PASS_IN_GROUP_END(APCLoopInfoBasePass, "apc-loop-info",
159-
"Loop Graph Builder (APC)", true, true,
160-
DefaultQueryManager::PrintPassGroup::getPassRegistry())
156+
INITIALIZE_PASS_END(APCLoopInfoBasePass, "apc-loop-info",
157+
"Loop Graph Builder (APC)", true, true)
161158

162159
FunctionPass * llvm::createAPCLoopInfoBasePass() {
163160
return new APCLoopInfoBasePass;

lib/Core/Query.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,10 @@ void DefaultQueryManager::run(llvm::Module *M, TransformationInfo *TfmInfo) {
335335
// avoid dangling handles. So, we add pool before environment in the manager.
336336
Passes.add(createDIMemoryTraitPoolStorage());
337337
Passes.add(createDIMemoryEnvironmentStorage());
338-
#ifdef APC_FOUND
339-
Passes.add(createAPCContextStorage());
340-
addIfNecessary(createAPCLoopInfoBasePass(), mPrintPasses,
341-
PrintPassGroup::getPassRegistry(), Passes);
342-
#endif
343338
addBeforeTfmAnalysis(Passes);
344339
addPrint(BeforeTfmAnalysis);
345340
addOutput(BeforeTfmAnalysis);
346341
addAfterSROAAnalysis(*mGlobalOptions, M->getDataLayout(), Passes);
347-
#ifdef APC_FOUND
348-
addIfNecessary(createAPCFunctionInfoPass(), mPrintPasses,
349-
PrintPassGroup::getPassRegistry(), Passes);
350-
addIfNecessary(createAPCArrayInfoPass(), mPrintPasses,
351-
PrintPassGroup::getPassRegistry(), Passes);
352-
#endif
353342
addPrint(AfterSroaAnalysis);
354343
addOutput(AfterSroaAnalysis);
355344
addAfterFunctionInlineAnalysis(

0 commit comments

Comments
 (0)