[lld] [lld][ELF] Extend profile guided function ordering to ELF binaries (PR #117514)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 11:12:10 PST 2024


================
@@ -0,0 +1,76 @@
+//===- BPSectionOrdererBase.h ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the common interfaces which may be used by
+// BPSectionOrderer.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_COMMON_BP_SECTION_ORDERER_BASE_H
+#define LLD_COMMON_BP_SECTION_ORDERER_BASE_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/xxhash.h"
+
+namespace lld {
+
+class BPSymbol {
+
+public:
+  virtual ~BPSymbol() = default;
+  virtual llvm::StringRef getName() const = 0;
+  virtual BPSymbol *asDefinedSymbol() = 0;
----------------
ellishg wrote:

This function should return `Defined`, but it can't because it needs to work for Mach-O and ELF. Returning `BPSymbol` doesn't make any sense to me. Instead, I think we should implement `Defined *asDefined()` for both Mach-O and ELF and remove this virtual function.

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


More information about the llvm-commits mailing list