[BOLT] LongJmp: Check for shouldEmit
authorVladislav Khmelevsky <och95@yandex.ru>
Sun, 20 Mar 2022 13:10:27 +0000 (16:10 +0300)
committerVladislav Khmelevsky <och95@yandex.ru>
Thu, 31 Mar 2022 19:33:09 +0000 (22:33 +0300)
Check that the function will be emitted in the final binary. Preserving
old function address is needed in case it is PLT trampiline, that is
currently not moved by the BOLT.

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

bolt/lib/Core/BinaryContext.cpp
bolt/lib/Passes/LongJmp.cpp

index 8a9835d..a848fdc 100644 (file)
@@ -1534,6 +1534,9 @@ void BinaryContext::preprocessDebugInfo() {
 }
 
 bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
+  if (Function.isPseudo())
+    return false;
+
   if (opts::processAllFunctions())
     return true;
 
index 56b50cb..24139f2 100644 (file)
@@ -345,6 +345,11 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
   CurrentIndex = 0;
   bool ColdLayoutDone = false;
   for (BinaryFunction *Func : SortedFunctions) {
+    if (!BC.shouldEmit(*Func)) {
+      HotAddresses[Func] = Func->getAddress();
+      continue;
+    }
+
     if (!ColdLayoutDone && CurrentIndex >= LastHotIndex) {
       DotAddress =
           tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);