summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2019-03-05 01:01:21 +0000
committerYonghong Song <yhs@fb.com>2019-03-05 01:01:21 +0000
commitd82247cb804cfb48ae0e0bc354397b6be0ab60d4 (patch)
tree87fca539a38ecac8b19f8198dfc2724ded47fb9c /llvm/lib
parentfc188448fadc5c9d67c9937112c05c4cd425f1f5 (diff)
downloadbcm5719-llvm-d82247cb804cfb48ae0e0bc354397b6be0ab60d4.tar.gz
bcm5719-llvm-d82247cb804cfb48ae0e0bc354397b6be0ab60d4.zip
[BPF] Do not generate BTF sections unnecessarily
If There is no types/non-empty strings, do not generate .BTF section. If there is no func_info/line_info, do not generate .BTF.ext section. Signed-off-by: Yonghong Song <yhs@fb.com> Differential Revision: https://reviews.llvm.org/D58936 llvm-svn: 355360
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/BPF/BTFDebug.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index ca3a8c5740e..3f5531357a9 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -546,6 +546,10 @@ void BTFDebug::emitCommonHeader() {
}
void BTFDebug::emitBTFSection() {
+ // Do not emit section if no types and only "" string.
+ if (!TypeEntries.size() && StringTable.getSize() == 1)
+ return;
+
MCContext &Ctx = OS.getContext();
OS.SwitchSection(Ctx.getELFSection(".BTF", ELF::SHT_PROGBITS, 0));
@@ -578,6 +582,10 @@ void BTFDebug::emitBTFSection() {
}
void BTFDebug::emitBTFExtSection() {
+ // Do not emit section if empty FuncInfoTable and LineInfoTable.
+ if (!FuncInfoTable.size() && !LineInfoTable.size())
+ return;
+
MCContext &Ctx = OS.getContext();
OS.SwitchSection(Ctx.getELFSection(".BTF.ext", ELF::SHT_PROGBITS, 0));
OpenPOWER on IntegriCloud