[llvm] [BOLT] Push code to higher addresses under options (PR #146180)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 27 20:53:12 PDT 2025


================
@@ -3918,15 +3918,42 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
       return Address;
     };
 
+    // Try to allocate sections before the \p Address and return an address for
+    // the allocation of the first section, or 0 if [0, Address) range is not
+    // big enough to fit all sections.
+    auto allocateBefore = [&](uint64_t Address) -> uint64_t {
+      for (auto SI = CodeSections.rbegin(), SE = CodeSections.rend(); SI != SE;
+           ++SI) {
+        BinarySection *Section = *SI;
----------------
aaupov wrote:

```suggestion
      for (BinarySection *Section : llvm::reverse(CodeSections)) {
```

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


More information about the llvm-commits mailing list