From e3e07ef695f5e328d70413342ea329aa3de7ca8c Mon Sep 17 00:00:00 2001 From: Aditya Vardhan Padala Date: Mon, 1 Apr 2024 17:38:12 -0400 Subject: [PATCH 1/2] builds with llvm 17.0.6 --- svf-llvm/include/SVF-LLVM/BasicTypes.h | 2 +- svf-llvm/lib/LLVMUtil.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/svf-llvm/include/SVF-LLVM/BasicTypes.h b/svf-llvm/include/SVF-LLVM/BasicTypes.h index 16371651a..20cd8fc49 100644 --- a/svf-llvm/include/SVF-LLVM/BasicTypes.h +++ b/svf-llvm/include/SVF-LLVM/BasicTypes.h @@ -191,7 +191,7 @@ typedef llvm::IntrinsicInst IntrinsicInst; typedef llvm::DbgInfoIntrinsic DbgInfoIntrinsic; typedef llvm::DbgVariableIntrinsic DbgVariableIntrinsic; typedef llvm::DbgDeclareInst DbgDeclareInst; -typedef llvm::DbgAddrIntrinsic DbgAddrIntrinsic; +typedef llvm::DbgInfoIntrinsic DbgInfoIntrinsic; typedef llvm::DbgValueInst DbgValueInst; typedef llvm::DbgLabelInst DbgLabelInst; typedef llvm::VPIntrinsic VPIntrinsic; diff --git a/svf-llvm/lib/LLVMUtil.cpp b/svf-llvm/lib/LLVMUtil.cpp index 36a66b4e4..8123f1e47 100644 --- a/svf-llvm/lib/LLVMUtil.cpp +++ b/svf-llvm/lib/LLVMUtil.cpp @@ -217,7 +217,6 @@ bool LLVMUtil::isPtrInUncalledFunction (const Value* value) bool LLVMUtil::isIntrinsicFun(const Function* func) { if (func && (func->getIntrinsicID() == llvm::Intrinsic::donothing || - func->getIntrinsicID() == llvm::Intrinsic::dbg_addr || func->getIntrinsicID() == llvm::Intrinsic::dbg_declare || func->getIntrinsicID() == llvm::Intrinsic::dbg_label || func->getIntrinsicID() == llvm::Intrinsic::dbg_value)) @@ -511,7 +510,7 @@ void LLVMUtil::removeFunAnnotations(Set& removedFuncList) glob->setName("llvm.global.annotations.old"); GlobalVariable *GV = new GlobalVariable(newCA->getType(), glob->isConstant(), glob->getLinkage(), newCA, "llvm.global.annotations"); GV->setSection(glob->getSection()); - module->getGlobalList().push_back(GV); + module->insertGlobalVariable(GV); glob->replaceAllUsesWith(GV); glob->eraseFromParent(); @@ -693,7 +692,7 @@ const std::string LLVMUtil::getSourceLoc(const Value* val ) { if (SVFUtil::isa(inst)) { - for (llvm::DbgInfoIntrinsic *DII : FindDbgAddrUses(const_cast(inst))) + for (llvm::DbgInfoIntrinsic *DII : FindDbgDeclareUses(const_cast(inst))) { if (llvm::DbgDeclareInst *DDI = SVFUtil::dyn_cast(DII)) { From 3d23dbd1b75ec74e2e3c75d105272cc35adecb3a Mon Sep 17 00:00:00 2001 From: Aditya Vardhan Padala Date: Tue, 2 Apr 2024 11:57:42 -0400 Subject: [PATCH 2/2] Fix global variable insertion in LLVMUtil.cpp --- svf-llvm/lib/LLVMUtil.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/svf-llvm/lib/LLVMUtil.cpp b/svf-llvm/lib/LLVMUtil.cpp index 8123f1e47..2827ea385 100644 --- a/svf-llvm/lib/LLVMUtil.cpp +++ b/svf-llvm/lib/LLVMUtil.cpp @@ -510,7 +510,14 @@ void LLVMUtil::removeFunAnnotations(Set& removedFuncList) glob->setName("llvm.global.annotations.old"); GlobalVariable *GV = new GlobalVariable(newCA->getType(), glob->isConstant(), glob->getLinkage(), newCA, "llvm.global.annotations"); GV->setSection(glob->getSection()); + +#if (LLVM_VERSION_MAJOR < 17) + module->getGlobalList().push_back(GV); +#elif (LLVM_VERSION_MAJOR >= 17) module->insertGlobalVariable(GV); +#else + assert(false && "llvm version not supported!"); +#endif glob->replaceAllUsesWith(GV); glob->eraseFromParent();