[PATCH] D156446: [BPF] Emit better error on missing line info
Tamir Duberstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 09:00:31 PDT 2023
tamird created this revision.
tamird added reviewers: ast, yonghong-song, eddyz87.
Herald added subscribers: JDevlieghere, hiraditya.
Herald added a project: All.
tamird requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When compiling Rust code we may end up with calls to functions provided
by other code units. Presently this code crashes on a null pointer
dereference - this patch changes that to an explicit crash with an
informative message.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156446
Files:
llvm/lib/Target/BPF/BTFDebug.cpp
Index: llvm/lib/Target/BPF/BTFDebug.cpp
===================================================================
--- llvm/lib/Target/BPF/BTFDebug.cpp
+++ llvm/lib/Target/BPF/BTFDebug.cpp
@@ -1372,7 +1372,16 @@
// This instruction will be skipped, no LineInfo has
// been generated, construct one based on function signature.
if (LineInfoGenerated == false) {
- auto *S = MI->getMF()->getFunction().getSubprogram();
+ const Function &F = MI->getMF()->getFunction();
+ auto *S = F.getSubprogram();
+ if (!S) {
+ std::string Str;
+ {
+ raw_string_ostream OS(Str);
+ OS << "call to subprogram '" << F.getName() << "' without line info";
+ }
+ report_fatal_error(Str.c_str());
+ }
MCSymbol *FuncLabel = Asm->getFunctionBegin();
constructLineInfo(S->getFile(), FuncLabel, S->getLine(), 0);
LineInfoGenerated = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156446.544809.patch
Type: text/x-patch
Size: 912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/e583b965/attachment.bin>
More information about the llvm-commits
mailing list