[compiler-rt] 9a77a6f - [memprof] Avoid meaningless pod copy

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 17:39:05 PST 2023


Author: Wu, Yingcong
Date: 2023-03-02T01:39:01Z
New Revision: 9a77a6f80252288d536b3aa471f241786a54068b

URL: https://github.com/llvm/llvm-project/commit/9a77a6f80252288d536b3aa471f241786a54068b
DIFF: https://github.com/llvm/llvm-project/commit/9a77a6f80252288d536b3aa471f241786a54068b.diff

LOG: [memprof] Avoid meaningless pod copy

The pointer `Buffer` is not changed, so there is no need to use reference, and the `Pod` here should use reference to avoid meaningless copy.

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D145024

Added: 
    

Modified: 
    compiler-rt/lib/memprof/memprof_rawprofile.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/memprof/memprof_rawprofile.cpp b/compiler-rt/lib/memprof/memprof_rawprofile.cpp
index f065e8dbcabc0..88f3c34f85549 100644
--- a/compiler-rt/lib/memprof/memprof_rawprofile.cpp
+++ b/compiler-rt/lib/memprof/memprof_rawprofile.cpp
@@ -20,7 +20,7 @@ using SegmentEntry = ::llvm::memprof::SegmentEntry;
 using Header = ::llvm::memprof::Header;
 
 namespace {
-template <class T> char *WriteBytes(T Pod, char *&Buffer) {
+template <class T> char *WriteBytes(const T &Pod, char *Buffer) {
   *(T *)Buffer = Pod;
   return Buffer + sizeof(T);
 }


        


More information about the llvm-commits mailing list