[all-commits] [llvm/llvm-project] 93d33a: [PatternMatch] Refactor `m_SpecificInt` to avoid c...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Tue Mar 26 06:33:20 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 93d33a1355438638232e66991f3a90c376c61fea
      https://github.com/llvm/llvm-project/commit/93d33a1355438638232e66991f3a90c376c61fea
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2024-03-26 (Tue, 26 Mar 2024)

  Changed paths:
    M llvm/include/llvm/IR/PatternMatch.h

  Log Message:
  -----------
  [PatternMatch] Refactor `m_SpecificInt` to avoid constructing APInt. NFC. (#86259)

This patch passes APInt by const reference in m_SpecificInt instead of
by value. Specifically, it refactors `m_SpecificInt(uint64_t V)` to
avoid APInt construction and dangling reference.

I believe it is safe to pass the APInt by const reference into
`m_SpecificInt` even if it is a temporary.
See also https://en.cppreference.com/w/cpp/language/lifetime
> All temporary objects are destroyed as the last step in evaluating the
[full-expression](https://en.cppreference.com/w/cpp/language/expressions#Full-expressions)
that (lexically) contains the point where they were created

Compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=d1f182c895728d89c5c3d198b133e212a5d9d4a3&to=7edf459b95ab2be33b70ec67faf87b3b8cc84f09&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