Skip to content

Refactor/optimisation : Reduction of LLVM Analysis Algorithmic Cost through Shared Traversals and Intermediate Artifacts #60

Description

@SizzleUnrlsd

Description

This plan aims to reduce the algorithmic cost of LLVM analyses by sharing traversals and intermediate artifacts, without changing the semantics of diagnostics. The approach prioritizes a pipeline engine with requires/provides dependencies, then a shared fact collector to reduce redundant traversals.

Decisions

  • Primary objective: reduction of real time (wall-clock).
  • Delivery strategy: migration in 2 phases.
  • Analysis selection: review module by module in phase 1 to classify subscriber-compatible vs independent (dataflow/fixpoint).

Scope

In

  • Evolution of analysis architecture (orchestration of modules, sharing of data between analyses, cache of derived artifacts, performance/functional validation).

Out

  • Change of diagnostic business rules
  • Modification of test files
  • Complete migration of all analyses in a single iteration

Action items

  • Phase 1 - Establish the target real performance baseline (timing + xctrace) and define primary/secondary KPIs (real priority, user/sys in support).
  • Phase 1 - Add technical instrumentation of traversals (Module/Function/Instruction counters per analysis) to measure redundancy level before refactoring.
  • Phase 1 - Review each analysis to classify: subscriber-compatible vs independent (dataflow/fixpoint).
  • Phase 1 - Refactor AnalysisPipeline towards a requires/provides model to explicitly declare dependencies between analyses.
  • Phase 1 - Introduce a minimal skeleton AnalysisArtifactStore type-safe (API + invalidation by module/config), without freezing all artifacts.
  • Phase 1 - Add an IRFactCollector as the first pass of the pipeline (unique traversal Module/Function/BB/Instruction) exposing shared IRFacts.
  • Phase 2 - Introduce a subscriber mechanism (Observer) for analyses classified as subscriber-compatible.
  • Phase 2 - First migrate pilot analyses to shared facts (priority: StackBuffer, ResourceLifetime, Uninitialized; additional candidates: IntegerOverflow, GlobalReadBeforeWrite) and measure incremental gain on real time.
  • Phase 2 - Extend PreparedModule/cache with stable derivable artifacts (debug index, symbol maps, type facts) with versioned key.
  • Phase 2 - Add architectural safeguards: pipeline integration tests, cache invalidation checks, and non-regression diagnostic assertions.
  • Phase 2 - Validate before/after and progressive rollout behind feature flag, driven by real time reduction.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions