Skip to content

Commit 71e1dfc

Browse files
committed
[TSAR, Transform] Add client-server interaction.
1 parent 9c5f75d commit 71e1dfc

File tree

5 files changed

+472
-95
lines changed

5 files changed

+472
-95
lines changed
Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,88 @@
1+
//=== LoopSwapping.h - Loop Swapping (Clang) ----*- C++ -*===//
2+
//
3+
// Traits Static Analyzer (SAPFOR)
4+
//
5+
// Copyright 2018 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+
// The file declares a pass to perform swapping of specific loops.
22+
//
23+
//===---------------------------------------------------------------------===//
24+
125
#ifndef TSAR_CLANG_LOOP_SWAPPING_H
226
#define TSAR_CLANG_LOOP_SWAPPING_H
327

28+
#include "tsar/Support/Tags.h"
429
#include "tsar/Transform/Clang/Passes.h"
30+
#include "tsar/Analysis/AnalysisServer.h"
31+
#include "tsar/Analysis/Memory/DIDependencyAnalysis.h"
32+
#include "tsar/Support/GlobalOptions.h"
533
#include <bcl/utility.h>
634
#include <llvm/Pass.h>
735

36+
namespace tsar {
37+
class TransformationContext;
38+
class DIAliasNode;
39+
class DIAliasTree;
40+
class MemoryMatchInfo;
41+
}
42+
43+
namespace clang {
44+
class SourceRange;
45+
class Rewriter;
46+
}
47+
848
namespace llvm {
949

50+
class Loop;
51+
class MDNode;
52+
class GlobalsAAResult;
53+
1054
class ClangLoopSwapping : public FunctionPass, private bcl::Uncopyable {
1155
public:
1256
static char ID;
1357

1458
ClangLoopSwapping() : FunctionPass(ID) {
1559
initializeClangLoopSwappingPass(*PassRegistry::getPassRegistry());
1660
}
17-
1861
bool runOnFunction(Function &F) override;
1962
void getAnalysisUsage(AnalysisUsage &AU) const override;
63+
void releaseMemory() override;
64+
65+
private:
66+
void initializeProviderOnClient(llvm::Module &M);
67+
void initializeProviderOnServer();
68+
69+
bool LoadDependenceAnalysisInfo(Function &F);
70+
void SwapLoops(const std::vector<std::vector<clang::SourceRange>> &mRangePairs,
71+
const std::vector<std::vector<Loop *>> &mLoopPairs);
72+
bool IsNoLoopID(llvm::MDNode *LoopID);
73+
std::vector<tsar::DIAliasNode *> GetLoopNodes(llvm::MDNode *LoopID);
74+
bool IsSwappingAvailable(std::vector<Loop *> loops);
75+
76+
tsar::TransformationContext *mTfmCtx = nullptr;
77+
tsar::DIDependencInfo *DIDepInfo = nullptr;
78+
tsar::DIAliasTree *DIAT = nullptr;
79+
const tsar::GlobalOptions *mGlobalOpts = nullptr;
80+
GlobalsAAResult * mGlobalsAA = nullptr;
81+
tsar::AnalysisSocket *mSocket = nullptr;
82+
tsar::MemoryMatchInfo *mMemoryMatcher = nullptr;
83+
std::function<tsar::ObjectID(tsar::ObjectID)> getLoopID;
2084
};
85+
2186
}
2287

2388
#endif//TSAR_CLANG_LOOP_SWAPPING_H

include/tsar/Transform/Clang/Passes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,12 @@ void initializeClangOpenMPParalleizationPass(PassRegistry &Registry);
7979
/// Create a pass to perform OpenMP-based parallelization.
8080
ModulePass* createClangOpenMPParallelization();
8181

82+
/// Creates a pass to perform swapping of loops.
83+
FunctionPass * createClangLoopSwapping();
84+
85+
/// Initializes a pass to perform swapping of loops.
86+
void initializeClangLoopSwappingPass(PassRegistry &Registry);
87+
88+
}
89+
8290
#endif//TSAR_CLANG_TRANSFORM_PASSES_H

lib/Transform/Clang/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
set(TRANSFORM_SOURCES Passes.cpp ExprPropagation.cpp Inline.cpp RenameLocal.cpp
2-
<<<<<<< HEAD
3-
DeadDeclsElimination.cpp FormatPass.cpp LoopSwapping.cpp)
4-
=======
5-
DeadDeclsElimination.cpp FormatPass.cpp OpenMPAutoPar.cpp)
6-
>>>>>>> upstream/master
2+
DeadDeclsElimination.cpp FormatPass.cpp OpenMPAutoPar.cpp LoopSwapping.cpp)
73

84
if(MSVC_IDE)
95
file(GLOB_RECURSE TRANSFORM_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}

0 commit comments

Comments
 (0)