Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG TARGETPLATFORM
RUN set -e

# Define LLVM version.
ENV llvm_version=16.0.0
ENV llvm_version=21.1.0

# Define home directory
ENV HOME=/home/SVF-tools
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SVFHOME="${SCRIPT_DIR}"
sysOS=$(uname -s)
arch=$(uname -m)
MajorLLVMVer=18
MajorLLVMVer=21
LLVMVer=${MajorLLVMVer}.1.0
UbuntuArmLLVM_RTTI="https://github.com/SVF-tools/SVF/releases/download/SVF-3.2/llvm-${MajorLLVMVer}.1.0-ubuntu22-rtti-aarch64.tar.gz"
UbuntuArmLLVM_RTTI="https://github.com/bjjwwang/SVF-LLVM/releases/download/${LLVMVer}/llvm-${LLVMVer}-ubuntu22-rtti-aarch64.tar.gz"
UbuntuArmLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVMVer}/clang+llvm-${LLVMVer}-aarch64-linux-gnu.tar.xz"
UbuntuLLVM_RTTI="https://github.com/SVF-tools/SVF/releases/download/SVF-3.2/llvm-${MajorLLVMVer}.1.0-ubuntu20-rtti-x86-64.tar.gz"
UbuntuLLVM_RTTI="https://github.com/bjjwwang/SVF-LLVM/releases/download/${LLVMVer}/llvm-${LLVMVer}-ubuntu22-rtti-x86-64.tar.gz"
UbuntuLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVMVer}/clang+llvm-${LLVMVer}-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
SourceLLVM="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${LLVMVer}.zip"
UbuntuZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip"
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function set_llvm {
[[ -n "$LLVM_DIR" ]] && return 0

# use local download directory
LLVM_DIR="$SVF_DIR/llvm-18.1.0.obj"
LLVM_DIR="$SVF_DIR/llvm-21.1.0.obj"
[[ -d "$LLVM_DIR" ]] && return 0

# ... otherwise don't set LLVM_DIR
Expand Down
15 changes: 15 additions & 0 deletions svf-llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ else()
demangle
Passes
)
# When the host LLVM tree already contains an in-tree SVF integration,
# llvm_map_components_to_libnames() can pull in those LLVMSvf* libraries
# transitively. Exclude them so the standalone SVF build links only against
# its own SvfCore/SvfLLVM targets.
list(FILTER LLVM_LIBRARIES EXCLUDE REGEX "^LLVMSvf(Core|LLVM)$|^LLVMSVFAnalysis$")
endif()

# Search in the executables dir for this LLVM's clang instance
Expand Down Expand Up @@ -153,6 +158,16 @@ target_sources(
PRIVATE ${SVF_LLVM_SOURCES}
)

# GCC can report false-positive -Wmaybe-uninitialized warnings from LLVM's
# ValueMap/DenseMap internals when compiling this translation unit with heavy
# inlining. Keep the suppression scoped to the affected file.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(
${CMAKE_CURRENT_LIST_DIR}/lib/LLVMModule.cpp
PROPERTIES COMPILE_OPTIONS "-Wno-maybe-uninitialized"
)
endif()

# Only expose the headers in the source tree to in-tree users of SVF
target_include_directories(SvfLLVM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>)

Expand Down
4 changes: 4 additions & 0 deletions svf-llvm/include/SVF-LLVM/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,21 @@ typedef llvm::MinMaxIntrinsic MinMaxIntrinsic;
typedef llvm::BinaryOpIntrinsic BinaryOpIntrinsic;
typedef llvm::WithOverflowInst WithOverflowInst;
typedef llvm::SaturatingInst SaturatingInst;
#if LLVM_VERSION_MAJOR < 20
typedef llvm::AtomicMemIntrinsic AtomicMemIntrinsic;
typedef llvm::AtomicMemSetInst AtomicMemSetInst;
typedef llvm::AtomicMemTransferInst AtomicMemTransferInst;
typedef llvm::AtomicMemCpyInst AtomicMemCpyInst;
typedef llvm::AtomicMemMoveInst AtomicMemMoveInst;
#endif
typedef llvm::MemIntrinsic MemIntrinsic;
typedef llvm::MemSetInst MemSetInst;
typedef llvm::MemTransferInst MemTransferInst;
typedef llvm::MemCpyInst MemCpyInst;
typedef llvm::MemMoveInst MemMoveInst;
#if LLVM_VERSION_MAJOR < 20
typedef llvm::MemCpyInlineInst MemCpyInlineInst;
#endif
typedef llvm::AnyMemIntrinsic AnyMemIntrinsic;
typedef llvm::AnyMemSetInst AnyMemSetInst;
typedef llvm::AnyMemTransferInst AnyMemTransferInst;
Expand Down
4 changes: 4 additions & 0 deletions svf-llvm/include/SVF-LLVM/LLVMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,11 @@ inline static DataLayout* getDataLayout(Module* mod)
{
static DataLayout *dl = nullptr;
if (dl == nullptr)
#if LLVM_VERSION_MAJOR >= 19
dl = new DataLayout(mod->getDataLayout());
#else
dl = new DataLayout(mod);
#endif
return dl;
}

Expand Down
2 changes: 2 additions & 0 deletions svf-llvm/include/SVF-LLVM/SVFIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>

NodeID getGepValVar(const Value* val, const AccessPath& ap, const SVFType* elementType);

NodeID getDirectAccessFieldZeroValVar(const Value* ptr, const Type* accessTy);

void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);

inline void addBlackHoleAddrEdge(NodeID node)
Expand Down
20 changes: 13 additions & 7 deletions svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void LLVMModuleSet::prePassSchedule()
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
llvm::FunctionPassManager FPM;
// FPM.addPass(llvm::UnifyFunctionExitNodesPass());
FPM.addPass(llvm::UnifyFunctionExitNodesPass());
FPM.run(fun, FAM);
#endif
}
Expand Down Expand Up @@ -518,11 +518,11 @@ void LLVMModuleSet::addSVFMain()
// Collect ctor and dtor functions
for (const GlobalVariable& global : mod.globals())
{
if (global.getName().equals(SVF_GLOBAL_CTORS) && global.hasInitializer())
if (global.getName() == SVF_GLOBAL_CTORS && global.hasInitializer())
{
ctor_funcs = getLLVMGlobalFunctions(&global);
}
else if (global.getName().equals(SVF_GLOBAL_DTORS) && global.hasInitializer())
else if (global.getName() == SVF_GLOBAL_DTORS && global.hasInitializer())
{
dtor_funcs = getLLVMGlobalFunctions(&global);
}
Expand All @@ -533,9 +533,9 @@ void LLVMModuleSet::addSVFMain()
{
auto funName = func.getName();

assert(!funName.equals(SVF_MAIN_FUNC_NAME) && SVF_MAIN_FUNC_NAME " already defined");
assert(!(funName == SVF_MAIN_FUNC_NAME) && SVF_MAIN_FUNC_NAME " already defined");

if (funName.equals("main"))
if (funName == "main")
{
orgMain = &func;
mainMod = &mod;
Expand Down Expand Up @@ -737,8 +737,9 @@ void LLVMModuleSet::buildFunToFunMap()
{
appModule = appFunToReplace->getParent();
}
// Create a new function with the same signature as extFunToClone
Function *clonedFunction = Function::Create(extFunToClone->getFunctionType(), Function::ExternalLinkage, extFunToClone->getName(), appModule);
Function* clonedFunction = Function::Create(extFunToClone->getFunctionType(),
Function::ExternalLinkage,
extFunToClone->getName());
// Map the arguments of the new function to the arguments of extFunToClone
llvm::ValueToValueMapTy valueMap;
Function::arg_iterator destArg = clonedFunction->arg_begin();
Expand Down Expand Up @@ -821,8 +822,13 @@ void LLVMModuleSet::buildFunToFunMap()
std::string oldFunctionName = appFunToReplace->getName().str();
// Delete the old function
appFunToReplace->eraseFromParent();
appModule->getFunctionList().push_back(clonedFunction);
clonedFunction->setName(oldFunctionName);
}
else
{
appModule->getFunctionList().push_back(clonedFunction);
}
return clonedFunction;
};

Expand Down
1 change: 1 addition & 0 deletions svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "SVF-LLVM/LLVMUtil.h"
#include "SVFIR/ObjTypeInfo.h"
#include <sstream>
#include <llvm/IRReader/IRReader.h>
#include <llvm/Support/raw_ostream.h>
#include "SVF-LLVM/LLVMModule.h"

Expand Down
Loading
Loading