Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Input File Support #121

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,48 @@ if(NOT LLVM_IR2VEC)
find_package(LLVM 17.0.0 REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})

find_package(Clang 17.0.0 REQUIRED CONFIG)
message(STATUS "Found Clang ${CLANG_PACKAGE_VERSION}")
message(STATUS "Using ClangConfig.cmake in: ${CLANG_DIR}")
include_directories(SYSTEM ${CLANG_INCLUDE_DIRS})

# llvm_map_components_to_libnames(llvm_libs all)
llvm_map_components_to_libnames(llvm_libs support core irreader analysis TransformUtils)
# llvm_map_components_to_libnames(llvm_libs support core irreader analysis TransformUtils)

add_executable(${PROJECT_NAME} ${binsrc})
target_link_libraries (${PROJECT_NAME} ${llvm_libs} objlib)
target_link_libraries (
${PROJECT_NAME}
PRIVATE
clangHandleCXX
clangFormat
clangIndex
clangDirectoryWatcher
clangFrontendTool
clangRewrite
clangCrossTU
clangASTMatchers
clangTooling
clangBasic
clangFrontend
clangDriver
clangSema
clangAST
clangCodeGen
clangSerialization
clangParse
clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangAnalysis
clangARCMigrate
clangRewriteFrontend
clangEdit
clangLex
LLVM
objlib
)
target_include_directories(${PROJECT_NAME} PRIVATE .)

add_library(objlib OBJECT ${libsrc})
Expand Down
8 changes: 2 additions & 6 deletions src/FlowAware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ void IR2Vec_FA::getTransitiveUse(
if (auto use = dyn_cast<Instruction>(U)) {
if (std::find(visitedList.begin(), visitedList.end(), use) ==
visitedList.end()) {
IR2VEC_DEBUG(outs() << "\nDef " << /* def << */ " ";
def->print(outs(), true); outs() << "\n";);
IR2VEC_DEBUG(outs() << "Use " << /* use << */ " ";
use->print(outs(), true); outs() << "\n";);
if (isMemOp(use->getOpcodeName(), operandNum, memWriteOps) &&
use->getOperand(operandNum) == def) {
writeDefsMap[root].push_back(use);
std::cout << "Found dependency - " << use->getOpcodeName() << " ON "
<< root->getOpcodeName() << std::endl;
} else if (isMemOp(use->getOpcodeName(), operandNum, memAccessOps) &&
use->getOperand(operandNum) == def) {
getTransitiveUse(root, use, visitedList, toAppend);
Expand All @@ -77,8 +75,6 @@ void IR2Vec_FA::collectWriteDefsMap(Module &M) {
std::find(visitedList.begin(), visitedList.end(), &I) ==
visitedList.end()) {
if (I.getNumOperands() > 0) {
IR2VEC_DEBUG(I.print(outs()); outs() << "\n");
IR2VEC_DEBUG(outs() << "operandnum = " << operandNum << "\n");
if (auto parent =
dyn_cast<Instruction>(I.getOperand(operandNum))) {
if (std::find(visitedList.begin(), visitedList.end(), parent) ==
Expand Down
Loading
Loading