Skip to content

Commit ca6b648

Browse files
author
Yonghong Song
committed
Fix issues in BTFDebug for potential missing __bpf_trap btf
The funciton __bpf_trap is created during selectiondag lowering. But the function usage could be removed during later machine-level optimization. In such cases, we will generate btf for __bpf_trap in endModule().
1 parent 65f1f62 commit ca6b648

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Target/BPF/BTFDebug.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,13 @@ void BTFDebug::endModule() {
16221622
// Collect global types/variables except MapDef globals.
16231623
processGlobals(false);
16241624

1625+
// In case that BPF_TRAP usage is removed during machine-level optimization,
1626+
// generate btf for BPF_TRAP function here.
1627+
for (const Function &F : *MMI->getModule()) {
1628+
if (F.getName() == BPF_TRAP)
1629+
processFuncPrototypes(&F);
1630+
}
1631+
16251632
for (auto &DataSec : DataSecEntries)
16261633
addType(std::move(DataSec.second));
16271634

0 commit comments

Comments
 (0)