[all-commits] [llvm/llvm-project] f7a226: [IR] Skip remove_if scan for empty maps in removeN...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri May 29 00:26:48 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f7a2267de9e3088bafe241da9bd90c710ccc9c3c
      https://github.com/llvm/llvm-project/commit/f7a2267de9e3088bafe241da9bd90c710ccc9c3c
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-05-29 (Fri, 29 May 2026)

  Changed paths:
    M llvm/lib/IR/LegacyPassManager.cpp

  Log Message:
  -----------
  [IR] Skip remove_if scan for empty maps in removeNotPreservedAnalysis (#200292)

removeNotPreservedAnalysis runs after every legacy-PM pass. #198982
changed it to DenseMap::remove_if, which iterates the raw bucket array
even when the map is empty. The old begin()/end() loop did not:
begin()'s
makeBegin returns end() directly for an empty map (its "avoid advancing
past empty buckets" shortcut), so the loop touched no buckets. These
maps
are usually empty here but keep a grown bucket array after their entries
are erased (a 64-bucket array when compiling sqlite3.i at -O0 -g), so
remove_if walks empty buckets for nothing, regressing instructions:u
(most visible at -O0). #199571 was a small fix for the out-of-lined
remove_if call; this addresses the dominant cost.

Skip empty maps, which fixes the regression:

https://llvm-compile-time-tracker.com/compare.php?from=8ab00f2c21e5975f5de977ca68607b4acc23c856&to=6a33135fad599da0c2c9919ec37f81217e5c8f6b&stat=instructions:u



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list