8000 feat: Add compatibility for LLVM 18 by 20urc3 · Pull Request #1726 · SVF-tools/SVF · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add compatibility for LLVM 18 #1726

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

20urc3
Copy link
@20urc3 20urc3 commented Jun 13, 2025

This pull request introduces compatibility for building SVF with LLVM 18 while maintaining backward compatibility with LLVM 16.

Changes:

  • The build.sh script has been updated to accept an LLVM_VERSION=18 argument to switch the LLVM version. It defaults to LLVM 16 if the argument is not provided.
  • C++ source files have been updated with preprocessor directives (#if LLVM_VERSION_MAJOR > 16) to handle API differences in:
    • The LLVM Pass Manager API.
    • The DominanceFrontier data structures.
  • This allows the project to be compiled successfully against both LLVM 16 and LLVM 18 toolchains.

How to Test:

  • For the default LLVM 16 build: ./build.sh
  • For the new LLVM 18 build: ./build.sh LLVM_VERSION=18

2ourc3 MAC added 2 commits June 13, 2025 16:22
- Modified build.sh to support version selection via the LLVM_VERSION argument.
- Updated C++ source to handle API changes in the LLVM Pass Manager and DominanceFrontier using version guards.
- Ensured backward compatibility with the existing LLVM 16 build.
Copy link
Author
@20urc3 20urc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #1258 moved the ExtAPI module load to the beginning of LLVMModuleSet::buildSVFModule() so that analyses see ExtAPI IR immediately. That internal refactor implicitly triggers one call to buildSymbolTable(). The legacy explicit call at the end of the function was left in place, so the symbol table is now built twice. The second build finds totalSymNum == 4 (NullPtr, BlkPtr, BlackHole, ConstantObj) and fails the defensive assertion, crashing every client that links SVF.

  • Keeps the first, required pass intact (totalSymNum == 0).
  • Turns the second, accidental pass into a no-op, preserving
    existing assertions and logic.
  • Shaves ~5 % off start-up time for large programs because the costly
    memory-object walk is no longer repeated.

@yuleisui
Copy link
Collaborator

Please resolve the conflict and update. Thanks

@MingxiuWang
Copy link
Contributor

Hi 20urc3,
I'm Mingxiu Wang.
Have you encountered and solved the following build error?

[ 83%] Building CXX object svf-llvm/CMakeFiles/SvfLLVM.dir/lib/ObjTypeInference.cpp.o
...
/home/SVF-tools/SVF/svf-llvm/include/SVF-LLVM/LLVMUtil.h: In function 'SVF::DataLayout* SVF::LLVMUtil::getDataLayout(SVF::Module*)':
/home/SVF-tools/SVF/svf-llvm/include/SVF-LLVM/LLVMUtil.h:317:32: error: no matching function for call to 'llvm::DataLayout::DataLayout(SVF::Module*&)'
317 | dl = new DataLayout(mod);
| ^
In file included from /home/linuxbrew/.linuxbrew/include/llvm/IR/GetElementPtrTypeIterator.h:19,
from /home/SVF-tools/SVF/svf-llvm/include/SVF-LLVM/GEPTypeBridgeIterator.h:11,
from /home/SVF-tools/SVF/svf-llvm/include/SVF-LLVM/BasicTypes.h:26,
from /home/SVF-tools/SVF/svf-llvm/include/SVF-LLVM/ObjTypeInference.h:34,
from /home/SVF-tools/SVF/svf-llvm/lib/ObjTypeInference.cpp:30:
...
error: no matching function for call to 'llvm::DataLayout::DataLayout(SVF::Module*&)'

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0