summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-12-19 16:40:25 +0000
committerYonghong Song <yhs@fb.com>2018-12-19 16:40:25 +0000
commit7b410ac352bea299441a34f3b899e728bae460a7 (patch)
treebc17e744edff0a02e91472f79f9d88c39f657223 /llvm/lib/Target/BPF/BPFAsmPrinter.cpp
parent8d221b40a7963caf19eaedf29f0512f6a09cd994 (diff)
downloadbcm5719-llvm-7b410ac352bea299441a34f3b899e728bae460a7.tar.gz
bcm5719-llvm-7b410ac352bea299441a34f3b899e728bae460a7.zip
[BPF] Generate BTF DebugInfo under BPF target
This patch implements BTF (BPF Type Format). The BTF is the debug info format for BPF, introduced in the below linux patch: https://github.com/torvalds/linux/commit/69b693f0aefa0ed521e8bd02260523b5ae446ad7#diff-06fb1c8825f653d7e539058b72c83332 and further extended several times, e.g., https://www.spinics.net/lists/netdev/msg534640.html https://www.spinics.net/lists/netdev/msg538464.html https://www.spinics.net/lists/netdev/msg540246.html The main advantage of implementing in LLVM is: . better integration/deployment as no extra tools are needed. . bpf JIT based compilation (like bcc, bpftrace, etc.) can get BTF without much extra effort. . BTF line_info needs selective source codes, which can be easily retrieved when inside the compiler. This patch implemented BTF generation by registering a BPF specific DebugHandler in BPFAsmPrinter. Signed-off-by: Yonghong Song <yhs@fb.com> Differential Revision: https://reviews.llvm.org/D55752 llvm-svn: 349640
Diffstat (limited to 'llvm/lib/Target/BPF/BPFAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/BPF/BPFAsmPrinter.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
index 705211b486b..ada5eb923f4 100644
--- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
+++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp
@@ -16,6 +16,7 @@
#include "BPFInstrInfo.h"
#include "BPFMCInstLower.h"
#include "BPFTargetMachine.h"
+#include "BTFDebug.h"
#include "InstPrinter/BPFInstPrinter.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
@@ -40,6 +41,7 @@ public:
: AsmPrinter(TM, std::move(Streamer)) {}
StringRef getPassName() const override { return "BPF Assembly Printer"; }
+ bool doInitialization(Module &M) override;
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant, const char *ExtraCode,
@@ -52,6 +54,18 @@ public:
};
} // namespace
+bool BPFAsmPrinter::doInitialization(Module &M) {
+ AsmPrinter::doInitialization(M);
+
+ if (MAI->doesSupportDebugInformation()) {
+ Handlers.push_back(HandlerInfo(new BTFDebug(this), "emit",
+ "Debug Info Emission", "BTF",
+ "BTF Emission"));
+ }
+
+ return false;
+}
+
void BPFAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
raw_ostream &O) {
const MachineOperand &MO = MI->getOperand(OpNum);
OpenPOWER on IntegriCloud