[all-commits] [llvm/llvm-project] af010e: Metadata: Optimize metadata queries (#70700)
Matthias Braun via All-commits
all-commits at lists.llvm.org
Tue Oct 31 16:40:54 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: af010e79163b373e49fb45bf39878fd35d8dcd49
https://github.com/llvm/llvm-project/commit/af010e79163b373e49fb45bf39878fd35d8dcd49
Author: Matthias Braun <matze at braunis.de>
Date: 2023-10-31 (Tue, 31 Oct 2023)
Changed paths:
M llvm/include/llvm/IR/Instruction.h
M llvm/include/llvm/IR/Value.h
M llvm/lib/IR/Metadata.cpp
Log Message:
-----------
Metadata: Optimize metadata queries (#70700)
Optimize metadata query code:
- Avoid `DenseMap::operator[]` in situations where it is known that the
key exists in the map. Instead use `DenseMap::at()`/
`DenseMap::find()->second`. This avoids code-bloat and bad inlining
decisions for the unused insertion/growing code in `operator[]`.
- Avoid a redundant `Value::hasMetadata()` check.
- Move the `KindID == LLVMContext::MD_dbg` case to
`Instruction::getMetadata` and check it first assuming that it can be
constant folded after inlining in many situations.
The motivation for this change is a regression triggered by
e3cf80c5c1fe55efd8216575ccadea0ab087e79c which could attributed to the
compiler inlining the insertion part of `DenseMap::operator[]` in more
cases while unbeknownst to a compiler (without PGO) that code is never
used in this context. This change improves performance and eliminates
difference before and after that change in my measurements.
More information about the All-commits
mailing list