[llvm] [BPF] Remove dead code related to __bpf_trap global var (PR #166440)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 12:39:38 PST 2025


https://github.com/yonghong-song created https://github.com/llvm/llvm-project/pull/166440

In [1], the symbol __bpf_trap (macro BPF_TRAP) is removed if it is not used in the code. In the discussion in [1], it is found that the branch "if (Op.isSymbol())" is actually always false. Remove it to avoid confusion.

  [1] https://github.com/llvm/llvm-project/pull/166003

>From 1eb6c2400547aa2a893e29a1ca8a9386086d648f Mon Sep 17 00:00:00 2001
From: Yonghong Song <yonghong.song at linux.dev>
Date: Tue, 4 Nov 2025 12:31:43 -0800
Subject: [PATCH] [BPF] Remove dead code related to __bpf_trap global var

In [1], the symbol __bpf_trap (macro BPF_TRAP) is removed if it
is not used in the code. In the discussion in [1], it is found
that the branch "if (Op.isSymbol())" is actually always false.
Remove it to avoid confusion.

  [1] https://github.com/llvm/llvm-project/pull/166003
---
 llvm/lib/Target/BPF/BPFAsmPrinter.cpp | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
index 378a72ab27dd5..abe081c0c76fd 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
@@ -176,10 +176,6 @@ void BPFAsmPrinter::emitInstruction(const MachineInstr *MI) {
         if (const GlobalValue *GV = Op.getGlobal())
           if (GV->getName() == BPF_TRAP)
             SawTrapCall = true;
-      } else if (Op.isSymbol()) {
-        if (const MCSymbol *Sym = Op.getMCSymbol())
-          if (Sym->getName() == BPF_TRAP)
-            SawTrapCall = true;
       }
     }
   }



More information about the llvm-commits mailing list