Skip to content

Commit 51636c3

Browse files
committed
[TSAR, Analysis] Fix sets intersection failure.
1 parent 3e11177 commit 51636c3

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

include/tsar/Analysis/Memory/RestrictionArgumentsPass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace llvm {
2727

2828
namespace tsar {
2929

30-
typedef llvm::DenseSet<llvm::Value*> MemorySources;
30+
// llvm::DenseSet<llvm::Value*> showed unstable behaviour in sets intersection
31+
typedef std::set<llvm::Value*> MemorySources;
3132

3233
struct FunctionCallWithMemorySources {
3334
llvm::CallInst* mCallI;

lib/Analysis/Memory/RestrictionArgumentsPass.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ DenseMap<Function*, DenseMap<int, DenseSet<CallInst*>>> collectRestrictFunctions
216216
auto otherArgumentIndex = ArgumentsIndexes[j];
217217
auto& argumentSources = ArgumentsSources[argumentIndex];
218218
auto& otherArgumentSources = ArgumentsSources[otherArgumentIndex];
219+
LLVM_DEBUG(
220+
dbgs() << "\tSources for intersection: \n\t\tFirst arg sources:\n";
221+
for (auto* S : argumentSources) {
222+
dbgs() << "\t\t\t";
223+
S->dump();
224+
}
225+
dbgs() << "\t\tSecond arg sources:\n";
226+
for (auto* S : otherArgumentSources) {
227+
dbgs() << "\t\t\t";
228+
S->dump();
229+
}
230+
);
219231
std::vector<Value*> sourcesIntersection;
220232
std::set_intersection(
221233
argumentSources.begin(),
@@ -224,12 +236,16 @@ DenseMap<Function*, DenseMap<int, DenseSet<CallInst*>>> collectRestrictFunctions
224236
otherArgumentSources.end(),
225237
std::back_inserter(sourcesIntersection));
226238
LLVM_DEBUG(
227-
dbgs() << "\tSources intersection: \n";
228-
for (auto* S : sourcesIntersection) {
229-
dbgs() << "\t\t";
230-
S->dump();
239+
if (sourcesIntersection.empty()) {
240+
dbgs() << "\t\tEmpty\n";
241+
} else {
242+
for (auto *S : sourcesIntersection) {
243+
dbgs() << "\t\t";
244+
S->dump();
245+
}
231246
}
232247
);
248+
233249
if (!sourcesIntersection.empty()) {
234250
bool allArgumentSourcesReturnUniqueValues = true;
235251
for (auto* commonSource : sourcesIntersection) {

0 commit comments

Comments
 (0)