[llvm] [BOLT] Add support for safe-icf (PR #116275)
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 14 19:51:03 PST 2024
================
@@ -1945,6 +2017,27 @@ static void printDebugInfo(raw_ostream &OS, const MCInst &Instruction,
OS << " discriminator:" << Row.Discriminator;
}
+static bool skipInstruction(const MCInst &Inst, const BinaryContext &BC) {
+ const bool IsX86 = BC.isX86();
+ return (BC.MIB->isPseudo(Inst) || BC.MIB->isUnconditionalBranch(Inst) ||
+ (IsX86 && BC.MIB->isConditionalBranch(Inst)) ||
+ BC.MIB->isCall(Inst) || BC.MIB->isBranch(Inst));
+}
+void BinaryContext::processInstructionForFuncReferences(const MCInst &Inst) {
+ if (ICFLevelVar != ICFLevel::Safe || skipInstruction(Inst, *this))
+ return;
+ for (const MCOperand &Op : MCPlus::primeOperands(Inst)) {
+ if (Op.isExpr()) {
----------------
dcci wrote:
you can greatly reduce the indentation of this code, e.g.
```
if (!Op.isExpr())
continue;
[...]
```
https://github.com/llvm/llvm-project/pull/116275
More information about the llvm-commits
mailing list