[all-commits] [llvm/llvm-project] 2d14ea: [flang][NFC] speed-up external name conversion pas...
jeanPerier via All-commits
all-commits at lists.llvm.org
Tue Apr 2 01:22:25 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2d14ea68b8c0acdff7c040d581f7fde15d2683d9
https://github.com/llvm/llvm-project/commit/2d14ea68b8c0acdff7c040d581f7fde15d2683d9
Author: jeanPerier <jperier at nvidia.com>
Date: 2024-04-02 (Tue, 02 Apr 2024)
Changed paths:
M flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
Log Message:
-----------
[flang][NFC] speed-up external name conversion pass (#86814)
The ExternalNameConversion pass can be surprisingly slow on big
programs. On an example with a 50kloc Fortran file with about 10000
calls to external procedures, the pass alone took 25s on my machine.
This patch reduces this to 0.16s.
The root cause is that using `replaceAllSymbolUses` on each modified
FuncOp is very expensive: it is walking all operations and attribute
every time.
An alternative would be to use mlir::SymbolUserMap to avoid walking the
module again and again, but this is still much more expensive than what
is needed because it is essentially caching all symbol uses of the
module, and there is no need to such caching here.
Instead:
- Do a shallow walk of the module (only top level operation) to detect
FuncOp/GlobalOp that needs to be updated. Update them and place the name
remapping in a DenseMap.
- If any remapping were done, do a single deep walk of the module
operation, and update any SymbolRefAttr that matches a name that was
remapped.
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