Skip to content

Conversation

kazutakahirata
Copy link
Contributor

readNext has two variants:

  • readNext<uint64_t, endian>(ptr)
  • readNext<uint64_t>(ptr, endian)

This patch uses the latter to simplify readBinaryIdsInternal. Both
forms default to unaligned.

readNext has two variants:

- readNext<uint64_t, endian>(ptr)
- readNext<uint64_t>(ptr, endian)

This patch uses the latter to simplify readBinaryIdsInternal.  Both
forms default to unaligned.
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Jun 8, 2024
@kazutakahirata kazutakahirata requested a review from MaskRay June 8, 2024 16:19
@llvmbot
Copy link
Member

llvmbot commented Jun 8, 2024

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

readNext has two variants:

  • readNext<uint64_t, endian>(ptr)
  • readNext<uint64_t>(ptr, endian)

This patch uses the latter to simplify readBinaryIdsInternal. Both
forms default to unaligned.


Full diff: https://github.com/llvm/llvm-project/pull/94862.diff

1 Files Affected:

  • (modified) llvm/lib/ProfileData/InstrProfReader.cpp (+1-6)
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 27855bf92b871..54a2a61c31875 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -113,12 +113,7 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
           instrprof_error::malformed,
           "not enough data to read binary id length");
 
-    uint64_t BILen = 0;
-    if (Endian == llvm::endianness::little)
-      BILen = endian::readNext<uint64_t, llvm::endianness::little>(BI);
-    else
-      BILen = endian::readNext<uint64_t, llvm::endianness::big>(BI);
-
+    uint64_t BILen = endian::readNext<uint64_t>(BI, Endian);
     if (BILen == 0)
       return make_error<InstrProfError>(instrprof_error::malformed,
                                         "binary id length is 0");

@kazutakahirata kazutakahirata merged commit e62c214 into llvm:main Jun 8, 2024
@kazutakahirata kazutakahirata deleted the profiledata_readNext branch June 8, 2024 21:03
nekoshirro pushed a commit to nekoshirro/Alchemist-LLVM that referenced this pull request Jun 9, 2024
…C) (llvm#94862)

readNext has two variants:

- readNext<uint64_t, endian>(ptr)
- readNext<uint64_t>(ptr, endian)

This patch uses the latter to simplify readBinaryIdsInternal.  Both
forms default to unaligned.

Signed-off-by: Hafidz Muzakky <[email protected]>
@HerrCai0907 HerrCai0907 mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants