[llvm] [BOLT] Reset output addresses for deleted blocks (PR #73429)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 25 22:49:33 PST 2023


https://github.com/maksfb created https://github.com/llvm/llvm-project/pull/73429

This is a follow-up to #73076. We need to reset output addresses for deleted blocks, otherwise the address translation may mistakenly attribute input address of a deleted block to a non-zero address.

While working on a test case, I've discovered that DWARF output ranges were already broken for deleted basic blocks: #73428. I will provide a test case for this PR with a DWARF address range fix PR.

>From b6f163714c7f95c8e30352742ae680ff8701bbd9 Mon Sep 17 00:00:00 2001
From: Maksim Panchenko <maks at fb.com>
Date: Sat, 25 Nov 2023 14:34:13 -0800
Subject: [PATCH] [BOLT] Reset output addresses for deleted blocks

This is a follow-up to #73076. We need to reset output addresses for
deleted blocks, otherwise the address translation may mistakenly
attribute input address of a deleted block to a non-zero address.

While working on a test case, I've discovered that DWARF output ranges
were already broken for deleted basic blocks: #73428. I will provide
a test case for this PR with a DWARF address range fix PR.
---
 bolt/lib/Core/BinaryFunction.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 99d18893e4c54e8..30c34a82c32d720 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -4190,6 +4190,12 @@ void BinaryFunction::updateOutputValues(const BOLTLinker &Linker) {
                                     ? FF.getAddress() + FF.getImageSize()
                                     : getOutputAddress() + getOutputSize());
   }
+
+  // Reset output addresses for deleted blocks.
+  for (BinaryBasicBlock *BB : DeletedBasicBlocks) {
+    BB->setOutputStartAddress(0);
+    BB->setOutputEndAddress(0);
+  }
 }
 
 DebugAddressRangesVector BinaryFunction::getOutputAddressRanges() const {



More information about the llvm-commits mailing list