[llvm] [SampleProfileLoader] Fix integer overflow in generateMDProfMetadata (PR #90217)

Nabeel Omer via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 06:27:36 PDT 2024


================
@@ -1713,13 +1713,16 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) {
       // if needed. Sample counts in profiles are 64-bit unsigned values,
       // but internally branch weights are expressed as 32-bit values.
       if (Weight > std::numeric_limits<uint32_t>::max()) {
-        LLVM_DEBUG(dbgs() << " (saturated due to uint32_t overflow)");
+        LLVM_DEBUG(dbgs() << " (saturated due to uint32_t overflow)\n");
         Weight = std::numeric_limits<uint32_t>::max();
----------------
omern1 wrote:

Hi @WenleiHe, we probably do need some form of scaling here. In one of the codebases we (Sony) have we're seeing losses due to weights being saturated which will be helped scaling the values.

I'll try and address this in a future patch.

https://github.com/llvm/llvm-project/pull/90217


More information about the llvm-commits mailing list