Skip to content

Support LLVM 22.1.0, but 4 CFL cases cannot pass. (maybe no need to pass)#1811

Open
bjjwwang wants to merge 1 commit intoSVF-tools:masterfrom
bjjwwang:llvm22
Open

Support LLVM 22.1.0, but 4 CFL cases cannot pass. (maybe no need to pass)#1811
bjjwwang wants to merge 1 commit intoSVF-tools:masterfrom
bjjwwang:llvm22

Conversation

@bjjwwang
Copy link
Copy Markdown
Contributor

@bjjwwang bjjwwang commented Apr 14, 2026

Adapt SVF to build against LLVM 22, following ideas from PR #1685.

Default -ff-eq-base true

TODO:

  1. build.sh wget llvm link
  2. 4 CFL cases failed at arraycopy1.c.bc, maybe not necessary to fix.

Adapt SVF to build against LLVM 22, following ideas from PR SVF-tools#1685.

Build/setup:
- build.sh: bump MajorLLVMVer 18 -> 22, point Linux tarballs at
  bjjwwang/SVF-LLVM 22.1.0 releases (x86_64 and aarch64).
- setup.sh: LLVM_DIR -> llvm-22.1.0.obj.

LLVM 22 API migration:
- BasicTypes.h: guard removed Atomic{Mem,MemSet,MemTransfer,MemCpy,
  MemMove}Intrinsic and MemCpyInlineInst typedefs under
  LLVM_VERSION_MAJOR < 22.
- LLVMUtil.h: getDataLayout() now returns const DataLayout* via
  Module::getDataLayout() on LLVM >= 22 (DataLayout(Module*) removed).
- LLVMModule.cpp: replace StringRef::equals() with operator== (4 sites).
- LLVMUtil.cpp: use findDVRDeclares + DbgVariableRecord on LLVM >= 22
  (findDbgDeclares signature changed).
- SVFIRBuilder.cpp: adapt computeGepOffset to const DataLayout*.
- svf-ex.cpp: skip llvm_shutdown() on LLVM >= 22.

Semantic fixes for new clang codegen:
- Options.cpp: default FirstFieldEqBase to true. LLVM 22 clang more
  often emits opaque-pointer GEPs that collapse base and first field;
  keeping them equivalent avoids spurious NOALIAS/false positives.
- AEDetector.cpp: handle BaseObjVar in updateGepObjOffsetFromBase so
  GEP results that fold to the base under ff-eq-base are treated as
  offset 0 instead of asserting.
- PointerAnalysisImpl.cpp: skip base->fields expansion in expandFIObjs
  when FirstFieldEqBase is on, preserving the equivalence.
- SVFIRBuilder.cpp (InitialGlobal): detect [N x i8] padding fields in
  anonymous literal struct initializers and skip them so logical field
  indices stay aligned with access-side GEPs.

Test results on Test-Suite (Debug-build ctest, -j 1):
92% passed, 1720/1879. Remaining 159 failures are 155 ae_semi_sparse
(upstream incomplete feature) and 4 cfl_tests on one arraycopy1.c.bc
file (pre-existing CFL grammar limitation, not LLVM 22 related).
@yuleisui
Copy link
Copy Markdown
Collaborator

It looks quite good. Could you check the cases of field-sensitive Andersen analysis? I remember 1-2 cases will fail if we treat the first field as base. But we could turn off/on this option in the test-suite's cmakelist to pass those tests.

@yuleisui
Copy link
Copy Markdown
Collaborator

Let us ignore the 4 CFL cases for now and make sure all other tests can pass.

Please also add a few AE tests for loop/recursion and array handling (in case the codecov decreases)

@bjjwwang
Copy link
Copy Markdown
Contributor Author

Let us ignore the 4 CFL cases for now and make sure all other tests can pass.

Please also add a few AE tests for loop/recursion and array handling (in case the codecov decreases)

sure

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.

2 participants