Skip to content

Commit 9b6ba5c

Browse files
committed
working on IDEIIAA fix
1 parent a27b1a5 commit 9b6ba5c

6 files changed

Lines changed: 49 additions & 22 deletions

File tree

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEInstInteractionAnalysis.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,17 @@ class IDEInstInteractionAnalysisT
286286
Problem.OnlyConsiderLocalAliases)) {}
287287

288288
container_type computeTargets(d_t Src) override {
289+
// Override old value(s), i.e., kill value(s) that is written to and
290+
// generate from value that is stored.
291+
if (Store->getPointerOperand() == Src || PointerPTS->count(Src)) {
292+
return {};
293+
}
289294
container_type Facts;
290295
Facts.insert(Src);
291296
if (IDEInstInteractionAnalysisT::isZeroValueImpl(Src)) {
292297
return Facts;
293298
}
299+
// y/Y now obtains its new value(s) from x/X
294300
// If a value is stored that holds we must generate all potential
295301
// memory locations the store might write to.
296302
if (Store->getValueOperand() == Src || ValuePTS->count(Src)) {
@@ -324,9 +330,9 @@ class IDEInstInteractionAnalysisT
324330
//
325331
// Flow function:
326332
//
327-
// 0 x
328-
// | |\
329-
// store x y | | \
333+
// 0 x y
334+
// | |\ |
335+
// store x y | | \|
330336
// v v v
331337
// 0 x y
332338
//
@@ -343,7 +349,13 @@ class IDEInstInteractionAnalysisT
343349
~IIAAFlowFunction() override = default;
344350

345351
container_type computeTargets(d_t Src) override {
352+
// Override old value, i.e., kill value that is written to and
353+
// generate from value that is stored.
354+
if (Store->getPointerOperand() == Src) {
355+
return {};
356+
}
346357
container_type Facts;
358+
// y now obtains its new value from x
347359
if (Load == Src || Load->getPointerOperand() == Src) {
348360
Facts.insert(Src);
349361
Facts.insert(Load->getPointerOperand());

test/llvm_test_code/inst_interaction/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ set(Sources
99
basic_08.cpp
1010
basic_09.cpp
1111
basic_10.cpp
12-
basic_11.cpp
1312
call_01.cpp
1413
call_02.cpp
1514
call_03.cpp
@@ -19,7 +18,8 @@ set(Sources
1918
global_01.cpp
2019
global_02.cpp
2120
heap_01.cpp
22-
KillTest.cpp
21+
KillTest_01.cpp
22+
KillTest_02.cpp
2323
return_01.cpp
2424
rvo_01.cpp
2525
struct_01.cpp

test/llvm_test_code/inst_interaction/KillTest.cpp renamed to test/llvm_test_code/inst_interaction/KillTest_01.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ int main() {
44
int k = i;
55
j = 42;
66
return 0;
7-
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int A = 42;
2+
int B;
3+
4+
void initB() { B = 21; }
5+
6+
int main() {
7+
int C = B;
8+
9+
initB();
10+
11+
return A + B + C;
12+
}

test/llvm_test_code/inst_interaction/basic_11.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

unittests/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEInstInteractionAnalysisTest.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,6 @@ TEST_F(IDEInstInteractionAnalysisTest, HandleBasicTest_10) {
378378
doAnalysisAndCompareResults("basic_10_cpp.ll", GroundTruth, false);
379379
}
380380

381-
TEST_F(IDEInstInteractionAnalysisTest, HandleBasicTest_11) {
382-
std::set<IIACompactResult_t> GroundTruth;
383-
doAnalysisAndCompareResults("basic_11_cpp.ll", GroundTruth, false);
384-
}
385-
386381
// TEST_F(IDEInstInteractionAnalysisTest, RetFail) {
387382
// std::set<IIACompactResult_t> GroundTruth;
388383
// doAnalysisAndCompareResults("dump_trace_ld-te.ll", GroundTruth, true);
@@ -572,7 +567,25 @@ TEST_F(IDEInstInteractionAnalysisTest, KillTest_01) {
572567
GroundTruth.emplace(
573568
std::tuple<std::string, size_t, std::string, BitVectorSet<std::string>>(
574569
"main", 12, "k", {"3", "9", "8", "1", "5", "6"}));
575-
doAnalysisAndCompareResults("KillTest_cpp.ll", GroundTruth, false);
570+
doAnalysisAndCompareResults("KillTest_01_cpp.ll", GroundTruth, false);
571+
}
572+
573+
TEST_F(IDEInstInteractionAnalysisTest, KillTest_02) {
574+
std::set<IIACompactResult_t> GroundTruth;
575+
GroundTruth.emplace(
576+
std::tuple<std::string, size_t, std::string, BitVectorSet<std::string>>(
577+
"main", 12, "retval", {"4", "6"}));
578+
GroundTruth.emplace(
579+
std::tuple<std::string, size_t, std::string, BitVectorSet<std::string>>(
580+
"main", 12, "A", {"0", "10"}));
581+
GroundTruth.emplace(
582+
std::tuple<std::string, size_t, std::string, BitVectorSet<std::string>>(
583+
"main", 12, "B", {"1", "2", "7", "11"}));
584+
// GroundTruth.emplace(
585+
// std::tuple<std::string, size_t, std::string,
586+
// BitVectorSet<std::string>>(
587+
// "main", 12, "C", {"5", "8", "13"}));
588+
doAnalysisAndCompareResults("KillTest_02_cpp.ll", GroundTruth, true);
576589
}
577590

578591
TEST_F(IDEInstInteractionAnalysisTest, HandleReturnTest_01) {

0 commit comments

Comments
 (0)