Skip to content

Commit 0512966

Browse files
committed
[TSAR, Transform] Remove the declaration of a function that does not have an implementation.
2 parents 4998aa5 + 35a4a80 commit 0512966

File tree

878 files changed

+10619
-5405
lines changed

Some content is hidden

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

878 files changed

+10619
-5405
lines changed

include/tsar/ADT/DataFlow.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,17 @@ class SmallDFNode : private bcl::Uncopyable {
521521
void removeSuccessor(NodeTy *Node) { removeAdjacentNode(Node, SUCC); }
522522

523523
/// Returns number of adjacent nodes in the specified direction.
524-
size_type numberOfAdjacentNodes(Direction Dir) {
524+
size_type numberOfAdjacentNodes(Direction Dir) const {
525525
assert(FIRST_DIRECTION <= Dir && Dir <= LAST_DIRECTION &&
526526
"Direction is out of range!");
527527
return mAdjacentNodes[Dir].size();
528528
}
529529

530530
/// Returns number of successors for the specified node.
531-
size_type numberOfSuccessors() { return numberOfAdjacentNodes(SUCC); }
531+
size_type numberOfSuccessors() const { return numberOfAdjacentNodes(SUCC); }
532532

533533
/// Returns number of predecessors for the specified node.
534-
size_type numberOfPredecessors() { return numberOfAdjacentNodes(PRED); }
534+
size_type numberOfPredecessors() const { return numberOfAdjacentNodes(PRED); }
535535

536536
private:
537537
llvm::SmallVector<NodeTy *, N> mAdjacentNodes[NUMBER_DIRECTION];

include/tsar/ADT/ItemRegister.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <bcl/tagged.h>
3232
#include <bcl/utility.h>
3333
#include <llvm/ADT/DenseMap.h>
34-
#include <llvm/IR/Type.h>
3534
#include <type_traits>
3635

3736
namespace tsar {

include/tsar/Analysis/AnalysisServer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class AnalysisServer : public ModulePass, private bcl::Uncopyable {
9696

9797
/// Run server.
9898
bool runOnModule(Module &M) override {
99-
auto &Socket = getAnalysis<AnalysisSocketImmutableWrapper>().get();
99+
auto &SocketInfo = getAnalysis<AnalysisSocketImmutableWrapper>().get();
100+
auto &Socket = SocketInfo.emplace(getPassID(), true).first->second;
100101
bcl::IntrusiveConnection::connect(
101102
&Socket, tsar::AnalysisSocket::Delimiter,
102103
[this, &M](bcl::IntrusiveConnection C) {

include/tsar/Analysis/AnalysisSocket.h

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,82 @@ class AnalysisSocket final : public bcl::Socket<std::string> {
236236
mutable MessageKind mResponseKind;
237237
mutable std::vector<void *> mAnalysis;
238238
};
239+
240+
/// This is a container to store sockets.
241+
class AnalysisSocketInfo {
242+
public:
243+
using ServerToSocket = std::pair<llvm::AnalysisID, AnalysisSocket>;
244+
using iterator = llvm::SmallVectorImpl<ServerToSocket>::iterator;
245+
using const_iterator = llvm::SmallVectorImpl<ServerToSocket>::const_iterator;
246+
247+
/// Add new socket, return true on success and false if there is a socket
248+
/// for a specified `ServerID` in the list.
249+
std::pair<iterator, bool> emplace(llvm::AnalysisID ServerID, bool IsActive) {
250+
auto Itr = find(ServerID);
251+
if (Itr != end()) {
252+
if (IsActive)
253+
mActiveIdx = std::distance(mAnalysis.begin(), Itr) + 1;
254+
return std::make_pair(Itr, false);
255+
}
256+
mAnalysis.emplace_back();
257+
mAnalysis.back().first = ServerID;
258+
if (IsActive)
259+
mActiveIdx = size();
260+
return std::make_pair(end() - 1, true);
261+
}
262+
263+
iterator begin() { return mAnalysis.begin(); }
264+
iterator end() { return mAnalysis.end(); }
265+
266+
const_iterator begin() const { return mAnalysis.begin(); }
267+
const_iterator end() const { return mAnalysis.end(); }
268+
269+
/// Return socket to access a specified server.
270+
iterator find(llvm::AnalysisID ServerID) {
271+
return llvm::find_if(mAnalysis, [ServerID](const ServerToSocket &Info) {
272+
return Info.first == ServerID;
273+
});
274+
}
275+
276+
/// Return socket to access a specified server.
277+
const_iterator find(llvm::AnalysisID ServerID) const {
278+
return llvm::find_if(mAnalysis, [ServerID](const ServerToSocket &Info) {
279+
return Info.first == ServerID;
280+
});
281+
}
282+
283+
unsigned size() const { return mAnalysis.size(); }
284+
bool empty() const { return mAnalysis.empty(); }
285+
operator bool() const { return !empty(); }
286+
287+
/// Return socket to access a specified server, create a new socket if it is
288+
/// not exist.
289+
AnalysisSocket & operator[](llvm::AnalysisID ServerID) {
290+
return emplace(ServerID, false).first->second;
291+
}
292+
293+
iterator getActive() { return mAnalysis.begin() + mActiveIdx - 1; }
294+
const_iterator getActive() const { return mAnalysis.begin() + mActiveIdx - 1; }
295+
296+
bool setActive(llvm::AnalysisID ServerID) {
297+
auto Itr = find(ServerID);
298+
if (Itr == end())
299+
return false;
300+
mActiveIdx = std::distance(mAnalysis.begin(), Itr) + 1;
301+
}
302+
303+
AnalysisSocket * getActiveSocket() {
304+
return getActive() == end() ? nullptr : &getActive()->second;
305+
}
306+
307+
const AnalysisSocket * getActiveSocket() const {
308+
return getActive() == end() ? nullptr : &getActive()->second;
309+
}
310+
311+
private:
312+
llvm::SmallVector<ServerToSocket, 2> mAnalysis;
313+
unsigned mActiveIdx = 0;
314+
};
239315
}
240316

241317
namespace json {
@@ -328,7 +404,7 @@ JSON_DEFAULT_TRAITS(tsar::, AnalysisResponse)
328404
namespace llvm {
329405
/// Wrapper to allow client passes access analysis socket.
330406
using AnalysisSocketImmutableWrapper =
331-
AnalysisWrapperPass<tsar::AnalysisSocket>;
407+
AnalysisWrapperPass<tsar::AnalysisSocketInfo>;
332408

333409
/// Wrapper to allow server passes access analysis connection.
334410
///
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//===-- ASTDependenceAnalysis.h - Dependence Analyzer -- (Clang) -*- C++ -*===//
2+
//
3+
// Traits Static Analyzer (SAPFOR)
4+
//
5+
// Copyright 2020 DVM System Group
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
//
21+
// This file implements classes pass to perform source-level dependence
22+
// analysis.
23+
//
24+
//===----------------------------------------------------------------------===//
25+
26+
#ifndef TSAR_CLANG_DEPENDENCE_ANALYZER_H
27+
#define TSAR_CLANG_DEPENDENCE_ANALYZER_H
28+
29+
#include "tsar/Analysis/Clang/VariableCollector.h"
30+
#include "tsar/Analysis/Memory/DIMemoryTrait.h"
31+
#include "tsar/Support/GlobalOptions.h"
32+
#include <bcl/tagged.h>
33+
#include <bcl/utility.h>
34+
#include <llvm/Pass.h>
35+
#include <array>
36+
#include <set>
37+
38+
namespace tsar {
39+
class ClangDependenceAnalyzer {
40+
public:
41+
using ClangDIMemoryMatcher = llvm::ClangDIMemoryMatcherPass::DIMemoryMatcher;
42+
43+
/// Sorted list of variables (to print their in algoristic order).
44+
using SortedVarListT = std::set<std::string, std::less<std::string>>;
45+
46+
/// Lists of reduction variables.
47+
using ReductionVarListT =
48+
std::array<SortedVarListT, trait::DIReduction::RK_NumberOf>;
49+
50+
/// List of traits.
51+
using ASTRegionTraitInfo =
52+
bcl::tagged_tuple<bcl::tagged<SortedVarListT, trait::Private>,
53+
bcl::tagged<SortedVarListT, trait::FirstPrivate>,
54+
bcl::tagged<SortedVarListT, trait::LastPrivate>,
55+
bcl::tagged<SortedVarListT, trait::ReadOccurred>,
56+
bcl::tagged<SortedVarListT, trait::WriteOccurred>,
57+
bcl::tagged<ReductionVarListT, trait::Reduction>>;
58+
59+
ClangDependenceAnalyzer(clang::Stmt *Region, const GlobalOptions &GO,
60+
clang::DiagnosticsEngine &Diags, DIAliasTree &DIAT,
61+
DIDependenceSet &DIDepSet, ClonedDIMemoryMatcher &DIMemoryMatcher,
62+
const ClangDIMemoryMatcher &ASTToClient)
63+
: mRegion(Region), mGlobalOpts(GO), mDiags(Diags), mDIAT(DIAT),
64+
mDIDepSet(DIDepSet), mDIMemoryMatcher(DIMemoryMatcher),
65+
mASTToClient(ASTToClient) {
66+
assert(Region && "Source-level region must not be null!");
67+
}
68+
69+
bool evaluateDependency();
70+
bool evaluateDefUse();
71+
72+
const ASTRegionTraitInfo & getDependenceInfo() const noexcept {
73+
return mDependenceInfo;
74+
}
75+
76+
private:
77+
clang::Stmt *mRegion;
78+
const GlobalOptions &mGlobalOpts;
79+
clang::DiagnosticsEngine &mDiags;
80+
DIAliasTree &mDIAT;
81+
DIDependenceSet &mDIDepSet;
82+
ClonedDIMemoryMatcher &mDIMemoryMatcher;
83+
const ClangDIMemoryMatcher &mASTToClient;
84+
ASTRegionTraitInfo mDependenceInfo;
85+
86+
VariableCollector mASTVars;
87+
llvm::SmallVector<DIAliasTrait *, 32> mInToLocalize;
88+
llvm::SmallVector<DIAliasTrait *, 32> mOutToLocalize;
89+
};
90+
}
91+
#endif//TSAR_CLANG_DEPENDENCE_ANALYZER_H

include/tsar/Analysis/Clang/ControlFlowTraits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class RegionCFInfoBase {
316316
/// exist.
317317
std::pair<iterator, bool> insert_call(const FuncT &F, CFTraits &&T) {
318318
auto Info = mTraits.insert(std::move(T));
319-
if (Info.second) {
319+
if (F && Info.second) {
320320
auto &Calls = mCalls.try_emplace(F).first->second;
321321
Calls.emplace_back(Info.first);
322322
}

include/tsar/Analysis/Clang/Passes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,11 @@ void initializeClangCFTraitsPassPass(PassRegistry &Registry);
109109
/// Create an AST-level pass which collects control-flow traits
110110
/// for function and its loops.
111111
FunctionPass * createClangCFTraitsPass();
112+
113+
// Initialize a pass to collect '#pragma spf region' directives.
114+
void initializeClangRegionCollectorPass(PassRegistry &Registry);
115+
116+
// Create a pass to collect '#pragma spf region' directives.
117+
ModulePass * createClangRegionCollector();
112118
}
113119
#endif//TSAR_CLANG_ANALYSIS_PASSES_H

0 commit comments

Comments
 (0)