[llvm] 82bc183 - [BPF] Narrow some interfaces
Tamir Duberstein via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 2 11:08:37 PDT 2023
Author: Tamir Duberstein
Date: 2023-08-02T14:08:30-04:00
New Revision: 82bc1839bc53db296be36947ec0c482c8ca3a3d8
URL: https://github.com/llvm/llvm-project/commit/82bc1839bc53db296be36947ec0c482c8ca3a3d8
DIFF: https://github.com/llvm/llvm-project/commit/82bc1839bc53db296be36947ec0c482c8ca3a3d8.diff
LOG: [BPF] Narrow some interfaces
When compiling Rust code we sometimes see incomplete debug info leading
to crashes. Narrow the interfaces so we can see where it happens.
Reviewed By: ajwerner
Differential Revision: https://reviews.llvm.org/D156443
Added:
Modified:
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/lib/Target/BPF/BTFDebug.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index 54427b073cb897..972d0fecedacf8 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -973,8 +973,7 @@ void BTFDebug::visitMapDefType(const DIType *Ty, uint32_t &TypeId) {
}
/// Read file contents from the actual file or from the source
-std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
- auto File = SP->getFile();
+std::string BTFDebug::populateFileContent(const DIFile *File) {
std::string FileName;
if (!File->getFilename().startswith("/") && File->getDirectory().size())
@@ -1005,9 +1004,9 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
return FileName;
}
-void BTFDebug::constructLineInfo(const DISubprogram *SP, MCSymbol *Label,
+void BTFDebug::constructLineInfo(const DIFile *File, MCSymbol *Label,
uint32_t Line, uint32_t Column) {
- std::string FileName = populateFileContent(SP);
+ std::string FileName = populateFileContent(File);
BTFLineInfo LineInfo;
LineInfo.Label = Label;
@@ -1374,7 +1373,7 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
if (LineInfoGenerated == false) {
auto *S = MI->getMF()->getFunction().getSubprogram();
MCSymbol *FuncLabel = Asm->getFunctionBegin();
- constructLineInfo(S, FuncLabel, S->getLine(), 0);
+ constructLineInfo(S->getFile(), FuncLabel, S->getLine(), 0);
LineInfoGenerated = true;
}
@@ -1386,8 +1385,7 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
OS.emitLabel(LineSym);
// Construct the lineinfo.
- auto SP = DL->getScope()->getSubprogram();
- constructLineInfo(SP, LineSym, DL.getLine(), DL.getCol());
+ constructLineInfo(DL->getFile(), LineSym, DL.getLine(), DL.getCol());
LineInfoGenerated = true;
PrevInstLoc = DL;
diff --git a/llvm/lib/Target/BPF/BTFDebug.h b/llvm/lib/Target/BPF/BTFDebug.h
index 7536006ed21ccd..90cfe3af13ecf1 100644
--- a/llvm/lib/Target/BPF/BTFDebug.h
+++ b/llvm/lib/Target/BPF/BTFDebug.h
@@ -341,12 +341,12 @@ class BTFDebug : public DebugHandlerBase {
/// Check whether the type is a forward declaration candidate or not.
bool IsForwardDeclCandidate(const DIType *Base);
- /// Get the file content for the subprogram. Certain lines of the file
+ /// Get the file content. Certain lines of the file
/// later may be put into string table and referenced by line info.
- std::string populateFileContent(const DISubprogram *SP);
+ std::string populateFileContent(const DIFile *File);
/// Construct a line info.
- void constructLineInfo(const DISubprogram *SP, MCSymbol *Label, uint32_t Line,
+ void constructLineInfo(const DIFile *File, MCSymbol *Label, uint32_t Line,
uint32_t Column);
/// Generate types and variables for globals.
More information about the llvm-commits
mailing list