Issue 180871
Summary [LifetimeSafety] Build time regression (mid-single-digit)
Labels clang:temporal-safety
Assignees
Reporter emaxx-google
    Adding `-Wlifetime-safety` causes a 4.5% build performance hit (~1 sec on a sample builder) on the following file from V8: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/compiler/turboshaft/csa-branch-elimination-phase.cc;drc=f2d33c2193fc819b5b92f284fc7f84b37db0ee87 (with extra lifetime annotations added).

Excerpt from `perf diff` between the profiles recorded via `perf record -g` for `-Wno-lifetime-safety` and `-Wlifetime-safety`:

```
# Event 'cycles:Pu'
#
# Baseline  Delta Abs Shared Object         Symbol 
# ........  .........  .................... ...........................................................................................................................................................
#
 +0.30%  clang-23              [.] clang::lifetimes::internal::LoanPropagationAnalysis::LoanPropagationAnalysis(clang::CFG const&, clang::AnalysisDeclContext&, clang::lifetimes::internal
     0.79% +0.22%  libc.so.6             [.] _int_malloc
               +0.17% clang-23              [.] clang::lifetimes::internal::LiveOriginsAnalysis::LiveOriginsAnalysis(clang::CFG const&, clang::AnalysisDeclContext&, clang::lifetimes::internal::FactMa
 +0.14%  clang-23              [.] llvm::DenseMap<clang::CFGBlock const*, clang::lifetimes::internal::(anonymous namespace)::Lattice, llvm::DenseMapInfo<clang::CFGBlock const*, void>, ll
     0.44%     -0.12% clang-23              [.] clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
     0.64% +0.12%  libc.so.6             [.] cfree@GLIBC_2.2.5
     0.49%     -0.11% clang-23              [.] clang::RecordDecl::field_begin() const
     0.56% -0.11%  clang-23              [.] clang::TypeLoc::getFullDataSizeForType(clang::QualType)
 +0.11%  clang-23              [.] clang::lifetimes::internal::OriginManager::getOrCreateList(clang::Expr const*)
     0.00%     +0.11%  clang-23              [.] clang::lifetimes::isGslPointerType(clang::QualType)
     0.83%     +0.10% libc.so.6             [.] malloc
               +0.09%  clang-23 [.] llvm::ImutAVLTree<llvm::ImutKeyValueInfo<clang::lifetimes::internal::utils::ID<clang::lifetimes::internal::OriginTag>, llvm::ImmutableSet<clang::lifeti
               +0.09%  clang-23 [.] clang::lifetimes::internal::FactsGenerator::run()
     1.39%     -0.09% clang-23              [.] clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, clang::DefaultArguments const&, b
     3.12%     -0.08%  clang-23 [.] llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&, llvm::FoldingSetBase::FoldingSetInfo const&)
 +0.08%  clang-23              [.] clang::StmtVisitorBase<llvm::make_const_ptr, clang::lifetimes::internal::FactsGenerator, void>::Visit(clang::Stmt const*)
     1.02%     -0.08%  clang-23              [.] clang::FunctionProtoType::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&)
```

I won't attach the artifacts on the bug publicly, but some stats for the preprocessed file: 20MB, ~3'000 `[[clang::lifetimebound]]` annotations, ~50 `[[gsl::Owner]]`s, ~90 `[[gsl::Pointer]]`s.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to