[llvm] [BOLT] Add support for safe-icf (PR #116275)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 20:48:03 PST 2024


================
@@ -1513,6 +1513,19 @@ MCSymbol *BinaryFunction::registerBranch(uint64_t Src, uint64_t Dst) {
   return Target;
 }
 
+void BinaryFunction::analyzeInstructionForFuncReference(const MCInst &Inst) {
+  for (const MCOperand &Op : MCPlus::primeOperands(Inst)) {
+    if (!Op.isExpr())
+      continue;
+    const MCExpr &Expr = *Op.getExpr();
+    if (Expr.getKind() != MCExpr::SymbolRef)
+      continue;
+    const MCSymbol &Symbol = cast<MCSymbolRefExpr>(Expr).getSymbol();
+    if (BinaryFunction *BF = BC.getFunctionForSymbol(&Symbol))
+      BF->setHasAddressTaken(true);
----------------
maksfb wrote:

Note that you are setting `HasAddressTaken` regardless of ICF level (which is correct).

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


More information about the llvm-commits mailing list