[llvm] 76b7d73 - BPF: report better error message for BTF_TYPE_ID_REMOTE relo failure
Yonghong Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 20 21:14:46 PST 2021
Author: Yonghong Song
Date: 2021-12-20T21:06:19-08:00
New Revision: 76b7d734291c7991368c7f6f00d9c67c8f160790
URL: https://github.com/llvm/llvm-project/commit/76b7d734291c7991368c7f6f00d9c67c8f160790
DIFF: https://github.com/llvm/llvm-project/commit/76b7d734291c7991368c7f6f00d9c67c8f160790.diff
LOG: BPF: report better error message for BTF_TYPE_ID_REMOTE relo failure
Matteo Croce reported a bpf backend fatal error in
https://github.com/llvm/llvm-project/issues/52779
A simplified case looks like:
$ cat bug.c
extern int do_smth(int);
int test() {
return __builtin_btf_type_id(*(typeof(do_smth) *)do_smth, 1);
}
$ clang -target bpf -O2 -g -c bug.c
fatal error: error in backend: Empty type name for BTF_TYPE_ID_REMOTE reloc
...
The reason for the fatal error is that the relocation is against
a DISubroutineType like type 13 below:
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !{}
!12 = !DILocation(line: 3, column: 10, scope: !7)
!13 = !DISubroutineType(types: !14)
!14 = !{!10, !10}
The DISubroutineType doesn't have a name and there is no way for
downstream bpfloader/kernel to do proper relocation for it.
But we can improve error message to be more specific for this case.
The patch improved the error message to be:
fatal error: error in backend: SubroutineType not supported for BTF_TYPE_ID_REMOTE reloc
Differential Revision: https://reviews.llvm.org/D116063
Added:
Modified:
llvm/lib/Target/BPF/BPFPreserveDIType.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
index 0348e2200acbc..36237b2fc4fdc 100644
--- a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
+++ b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
@@ -93,8 +93,13 @@ static bool BPFPreserveDITypeImpl(Function &F) {
Ty = DTy->getBaseType();
}
- if (Ty->getName().empty())
- report_fatal_error("Empty type name for BTF_TYPE_ID_REMOTE reloc");
+ if (Ty->getName().empty()) {
+ if (isa<DISubroutineType>(Ty))
+ report_fatal_error(
+ "SubroutineType not supported for BTF_TYPE_ID_REMOTE reloc");
+ else
+ report_fatal_error("Empty type name for BTF_TYPE_ID_REMOTE reloc");
+ }
MD = Ty;
}
More information about the llvm-commits
mailing list