[llvm] [TargetLibraryInfo] Use the default move constructor/assignment operator (PR #95685)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 15 19:54:29 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/95685

  commit ecea8371ff03c15fb3dc27ee4108b98335fd2d63
  Author: Kazu Hirata <kazu at google.com>
  Date:   Sat Jun 15 14:02:42 2024 -0700

added std::move to the move constructor and assignment operator, but
we can just use = default to have the compiler to generate them.

As expected, the number of heap allocations is virtually unchanged.

>From 0949f8cec1056632fc079e404f169ead7bf1a041 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 15 Jun 2024 16:24:10 -0700
Subject: [PATCH] [TargetLibraryInfo] Use the default move
 constructor/assignment operator

  commit ecea8371ff03c15fb3dc27ee4108b98335fd2d63
  Author: Kazu Hirata <kazu at google.com>
  Date:   Sat Jun 15 14:02:42 2024 -0700

added std::move to the move constructor and assignment operator, but
we can just use = default to have the compiler to generate them.

As expected, the number of heap allocations is virtually unchanged.
---
 llvm/include/llvm/Analysis/TargetLibraryInfo.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index ee19bc816b4e0..37e8bcbcc009e 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -315,15 +315,9 @@ class TargetLibraryInfo {
 
   // Provide value semantics.
   TargetLibraryInfo(const TargetLibraryInfo &TLI) = default;
-  TargetLibraryInfo(TargetLibraryInfo &&TLI)
-      : Impl(TLI.Impl),
-        OverrideAsUnavailable(std::move(TLI.OverrideAsUnavailable)) {}
+  TargetLibraryInfo(TargetLibraryInfo &&TLI) = default;
   TargetLibraryInfo &operator=(const TargetLibraryInfo &TLI) = default;
-  TargetLibraryInfo &operator=(TargetLibraryInfo &&TLI) {
-    Impl = TLI.Impl;
-    OverrideAsUnavailable = std::move(TLI.OverrideAsUnavailable);
-    return *this;
-  }
+  TargetLibraryInfo &operator=(TargetLibraryInfo &&TLI) = default;
 
   /// Determine whether a callee with the given TLI can be inlined into
   /// caller with this TLI, based on 'nobuiltin' attributes. When requested,



More information about the llvm-commits mailing list