Avoid repeated checks and context lookup in llvm::Instruction::getAAMetadata
authorserge-sans-paille <sguelton@mozilla.com>
Fri, 21 Oct 2022 18:49:52 +0000 (20:49 +0200)
committerserge-sans-paille <sguelton@mozilla.com>
Sat, 22 Oct 2022 06:30:53 +0000 (08:30 +0200)
commitf2e4ba0e3d40b9f3d5630dcda5e82b1a98f28410
treea83e8ebf91d0a95939ca4df2a319d4bdec445595
parent45b6fe8c69548581eec52771e3d3a4b73fdc7ed5
Avoid repeated checks and context lookup in llvm::Instruction::getAAMetadata

Repeated call to Instruction::hasMetadata() and lookup in
getContext().pImpl->ValueMetadata are not needed when we always work on
the same instruction, avoid them.

This simple change leads to interesting and consistent speedups in
compile time, around -0.5% according to http://llvm-compile-time-tracker.com, see

        http://llvm-compile-time-tracker.com/compare.php?from=9708d88017d0c9adaea65a4f5a5b589b67f292e2&to=88482b9addd5917e9c5226847efeb5451c5f78c0&stat=instructions

Differential Revision: https://reviews.llvm.org/D136503
llvm/lib/IR/Metadata.cpp