[llvm] Metadata: Optimize metadata queries (PR #70700)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 30 12:15:31 PDT 2023
================
@@ -303,8 +303,14 @@ class Instruction : public User,
/// Get the metadata of given kind attached to this Instruction.
/// If the metadata is not found then return null.
MDNode *getMetadata(unsigned KindID) const {
- if (!hasMetadata()) return nullptr;
- return getMetadataImpl(KindID);
+ // Handle 'dbg' as a special case since it is not stored in the hash table.
+ if (KindID == LLVMContext::MD_dbg) {
+ return DbgLoc.getAsMDNode();
+ }
+ if (hasMetadataOtherThanDebugLoc()) {
+ return getMetadataImpl(KindID);
+ }
----------------
nikic wrote:
Braces
https://github.com/llvm/llvm-project/pull/70700
More information about the llvm-commits
mailing list