svf-tools 1.0.694 → 1.0.696
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +3 -0
- package/package.json +1 -1
- package/svf/include/Graphs/CHG.h +4 -1
- package/svf/include/Graphs/GenericGraph.h +5 -0
- package/svf/include/Graphs/ICFG.h +1 -0
- package/svf/include/Graphs/ICFGEdge.h +4 -0
- package/svf/include/Graphs/ICFGNode.h +28 -2
- package/svf/include/Graphs/IRGraph.h +1 -0
- package/svf/include/MemoryModel/LocationSet.h +1 -0
- package/svf/include/MemoryModel/SVFLoop.h +1 -0
- package/svf/include/SVFIR/SVFIR.h +1 -0
- package/svf/include/SVFIR/SVFIRRW.h +864 -186
- package/svf/include/SVFIR/SVFModule.h +1 -0
- package/svf/include/SVFIR/SVFModuleRW.h +2 -2
- package/svf/include/SVFIR/SVFStatements.h +65 -15
- package/svf/include/SVFIR/SVFType.h +4 -0
- package/svf/include/SVFIR/SVFValue.h +22 -0
- package/svf/include/SVFIR/SVFVariables.h +42 -0
- package/svf/include/SVFIR/SymbolTableInfo.h +17 -1
- package/svf/include/Util/Options.h +1 -0
- package/svf/include/Util/SVFUtil.h +49 -0
- package/svf/include/Util/SparseBitVector.h +2 -0
- package/svf/lib/SVFIR/SVFIRRW.cpp +1509 -127
- package/svf/lib/SVFIR/SVFModuleRW.cpp +6 -6
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +1 -1
- package/svf/lib/Util/Options.cpp +7 -1
- package/svf-llvm/lib/LLVMModule.cpp +1 -1
- package/svf-llvm/lib/SVFIRBuilder.cpp +1 -1
- package/svf-llvm/tools/CMakeLists.txt +1 -0
- package/svf-llvm/tools/LLVM2SVF/CMakeLists.txt +10 -0
- package/svf-llvm/tools/LLVM2SVF/llvm2svf.cpp +72 -0
- package/svf-llvm/tools/WPA/wpa.cpp +17 -14
|
@@ -816,14 +816,14 @@ SVFModule* SVFModuleRead::readSvfModule(cJSON* iter)
|
|
|
816
816
|
|
|
817
817
|
// Fill incomplete values in valuePool and typePool
|
|
818
818
|
for (size_t i = 0; i < typePool.size(); ++i)
|
|
819
|
-
|
|
819
|
+
fillSVFTypeAt(i);
|
|
820
820
|
for (size_t i = 0; i < valuePool.size(); ++i)
|
|
821
|
-
|
|
821
|
+
fillSVFValueAt(i);
|
|
822
822
|
|
|
823
823
|
return svfModule;
|
|
824
824
|
}
|
|
825
825
|
|
|
826
|
-
void SVFModuleRead::
|
|
826
|
+
void SVFModuleRead::fillSVFTypeAt(size_t i)
|
|
827
827
|
{
|
|
828
828
|
cJSON* childIter = typeArray[i]->child;
|
|
829
829
|
SVFType* type = typePool[i];
|
|
@@ -833,7 +833,7 @@ void SVFModuleRead::fillSvfTypeAt(size_t i)
|
|
|
833
833
|
{
|
|
834
834
|
default:
|
|
835
835
|
SVFUtil::errs() << "Impossible SVFType kind " << kind
|
|
836
|
-
<< " in
|
|
836
|
+
<< " in fillSVFTypeAt()\n";
|
|
837
837
|
assert(false);
|
|
838
838
|
|
|
839
839
|
#define CASE(Kind) \
|
|
@@ -854,7 +854,7 @@ void SVFModuleRead::fillSvfTypeAt(size_t i)
|
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
void SVFModuleRead::
|
|
857
|
+
void SVFModuleRead::fillSVFValueAt(size_t i)
|
|
858
858
|
{
|
|
859
859
|
cJSON* childIter = valueArray[i]->child;
|
|
860
860
|
SVFValue* value = valuePool[i];
|
|
@@ -863,7 +863,7 @@ void SVFModuleRead::fillSvfValueAt(size_t i)
|
|
|
863
863
|
{
|
|
864
864
|
default:
|
|
865
865
|
SVFUtil::errs() << "Impossible SVFValue kind " << kind
|
|
866
|
-
<< " in
|
|
866
|
+
<< " in fillSVFValueAt()\n";
|
|
867
867
|
assert(false);
|
|
868
868
|
|
|
869
869
|
#define CASE(kind, type) \
|
package/svf/lib/Util/Options.cpp
CHANGED
|
@@ -322,6 +322,12 @@ const Option<std::string> Options::DumpJson(
|
|
|
322
322
|
""
|
|
323
323
|
);
|
|
324
324
|
|
|
325
|
+
const Option<bool> Options::ReadJson(
|
|
326
|
+
"read-json",
|
|
327
|
+
"Read the SVFIR in JSON format",
|
|
328
|
+
false
|
|
329
|
+
);
|
|
330
|
+
|
|
325
331
|
const Option<bool> Options::CallGraphDotGraph(
|
|
326
332
|
"dump-callgraph",
|
|
327
333
|
"Dump dot graph of Call Graph",
|
|
@@ -867,4 +873,4 @@ const Option<u32_t> Options::LoopBound(
|
|
|
867
873
|
1
|
|
868
874
|
);
|
|
869
875
|
|
|
870
|
-
} // namespace SVF.
|
|
876
|
+
} // namespace SVF.
|
|
@@ -101,7 +101,7 @@ SVFModule* LLVMModuleSet::buildSVFModule(const std::vector<std::string> &moduleN
|
|
|
101
101
|
|
|
102
102
|
loadModules(moduleNameVec);
|
|
103
103
|
|
|
104
|
-
if(!moduleNameVec.empty())
|
|
104
|
+
if (!moduleNameVec.empty())
|
|
105
105
|
svfModule = std::make_unique<SVFModule>(*moduleNameVec.begin());
|
|
106
106
|
else
|
|
107
107
|
svfModule = std::make_unique<SVFModule>();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
if(DEFINED IN_SOURCE_BUILD)
|
|
2
|
+
add_llvm_tool(llvm2svf llvm2svf.cpp)
|
|
3
|
+
else()
|
|
4
|
+
add_executable(llvm2svf llvm2svf.cpp)
|
|
5
|
+
|
|
6
|
+
target_link_libraries(llvm2svf SvfLLVM ${llvm_libs})
|
|
7
|
+
|
|
8
|
+
set_target_properties(llvm2svf PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
9
|
+
${CMAKE_BINARY_DIR}/bin)
|
|
10
|
+
endif()
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//===- llvm2svf.cpp -- LLVM IR to SVF IR conversion -------------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-2023> <Yulei Sui>
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// This program is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
|
|
13
|
+
// This program is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU Affero General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===-----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* llvm2svf.cpp
|
|
25
|
+
*
|
|
26
|
+
* Created on: 21 Apr 2023
|
|
27
|
+
* Authors: Xudong Wang
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#include "SVF-LLVM/SVFIRBuilder.h"
|
|
31
|
+
#include "Util/CommandLine.h"
|
|
32
|
+
#include "Util/Options.h"
|
|
33
|
+
#include "SVFIR/SVFIRRW.h"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
using namespace std;
|
|
37
|
+
using namespace SVF;
|
|
38
|
+
|
|
39
|
+
#include <iostream>
|
|
40
|
+
#include <string>
|
|
41
|
+
|
|
42
|
+
std::string replaceExtension(const std::string& path)
|
|
43
|
+
{
|
|
44
|
+
size_t pos = path.rfind('.');
|
|
45
|
+
if (pos == std::string::npos || path.substr(pos) != ".bc")
|
|
46
|
+
{
|
|
47
|
+
SVFUtil::errs() << "Error: file extension is not .bc\n";
|
|
48
|
+
exit(EXIT_FAILURE);
|
|
49
|
+
}
|
|
50
|
+
return path.substr(0, pos) + ".svf.json";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
int main(int argc, char** argv)
|
|
54
|
+
{
|
|
55
|
+
auto moduleNameVec = OptionBase::parseOptions(
|
|
56
|
+
argc, argv, "llvm2svf", "[options] <input-bitcode...>");
|
|
57
|
+
|
|
58
|
+
LLVMModuleSet* moduleSet = LLVMModuleSet::getLLVMModuleSet();
|
|
59
|
+
if (Options::WriteAnder() == "ir_annotator")
|
|
60
|
+
{
|
|
61
|
+
moduleSet->preProcessBCs(moduleNameVec);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
SVFModule* svfModule = moduleSet->buildSVFModule(moduleNameVec);
|
|
65
|
+
const std::string jsonPath = replaceExtension(moduleNameVec.front());
|
|
66
|
+
// PAG is borrowed from a unique_ptr, so we don't need to delete it.
|
|
67
|
+
const SVFIR* pag = SVFIRBuilder(svfModule).build();
|
|
68
|
+
SVFIRWriter::writeJsonToPath(pag, jsonPath);
|
|
69
|
+
SVFUtil::outs() << "SVF IR is written to '" << jsonPath << "'\n";
|
|
70
|
+
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
@@ -31,8 +31,6 @@
|
|
|
31
31
|
#include "WPA/WPAPass.h"
|
|
32
32
|
#include "Util/CommandLine.h"
|
|
33
33
|
#include "Util/Options.h"
|
|
34
|
-
|
|
35
|
-
|
|
36
34
|
#include "SVFIR/SVFIRRW.h"
|
|
37
35
|
|
|
38
36
|
|
|
@@ -42,28 +40,33 @@ using namespace SVF;
|
|
|
42
40
|
|
|
43
41
|
int main(int argc, char** argv)
|
|
44
42
|
{
|
|
45
|
-
|
|
46
|
-
char** arg_value = new char*[argc];
|
|
47
|
-
std::vector<std::string> moduleNameVec;
|
|
48
|
-
moduleNameVec =
|
|
43
|
+
auto moduleNameVec =
|
|
49
44
|
OptionBase::parseOptions(argc, argv, "Whole Program Points-to Analysis",
|
|
50
45
|
"[options] <input-bitcode...>");
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
SVFIR* pag;
|
|
48
|
+
|
|
49
|
+
if (Options::ReadJson())
|
|
53
50
|
{
|
|
54
|
-
|
|
51
|
+
pag = SVFIRReader::read(moduleNameVec.front());
|
|
55
52
|
}
|
|
53
|
+
else
|
|
54
|
+
{
|
|
55
|
+
LLVMModuleSet* moduleSet = LLVMModuleSet::getLLVMModuleSet();
|
|
56
|
+
if (Options::WriteAnder() == "ir_annotator")
|
|
57
|
+
{
|
|
58
|
+
moduleSet->preProcessBCs(moduleNameVec);
|
|
59
|
+
}
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
LLVMModuleSet::getLLVMModuleSet()->buildSVFModule(moduleNameVec);
|
|
61
|
+
SVFModule* svfModule = moduleSet->buildSVFModule(moduleNameVec);
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
/// Build SVFIR
|
|
64
|
+
SVFIRBuilder builder(svfModule);
|
|
65
|
+
pag = builder.build();
|
|
66
|
+
}
|
|
63
67
|
|
|
64
68
|
WPAPass wpa;
|
|
65
69
|
wpa.runOnModule(pag);
|
|
66
70
|
|
|
67
|
-
delete[] arg_value;
|
|
68
71
|
return 0;
|
|
69
72
|
}
|