================
@@ -374,25 +377,40 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
m_fallback.GetFullyQualifiedType(context, callback);
}
+bool DebugNamesDWARFIndex::SameAsEntryATName(
+ llvm::StringRef query_name, const DebugNames::Entry &entry) const {
+ auto maybe_dieoffset = entry.getDIEUnitOffset();
+ if (!maybe_dieoffset)
+ return false;
+
+ // [Optimization] instead of parsing the entry from dwo file, we simply
+ // check if the query_name can point to an entry of the same DIE offset.
+ // This greatly reduced number of dwo file parsed and thus improved the
+ // performance.
+ for (const DebugNames::Entry &query_entry :
+ entry.getNameIndex()->equal_range(query_name)) {
+ auto query_dieoffset = query_entry.getDIEUnitOffset();
+ if (!query_dieoffset)
+ continue;
+
+ if (*query_dieoffset == *maybe_dieoffset) {
+ return true;
+ } else if (*query_dieoffset > *maybe_dieoffset) {
+ // The pool entries of the same name are sequentially cluttered together
+ // so if the query name from `query_name` is after the target entry, this
+ // is definitely not the correct one, we can stop searching.
+ return false;
+ }
+ }
+ return false;
+}
+
bool DebugNamesDWARFIndex::SameParentChain(
llvm::ArrayRef<llvm::StringRef> parent_names,
llvm::ArrayRef<DebugNames::Entry> parent_entries) const {
-
if (parent_entries.size() != parent_names.size())
return false;
- auto SameAsEntryATName = [this](llvm::StringRef name,
- const DebugNames::Entry &entry) {
- // Peek at the AT_name of `entry` and test equality to `name`.
- auto maybe_dieoffset = entry.getDIEUnitOffset();
- if (!maybe_dieoffset)
- return false;
- DWARFUnit *unit = GetNonSkeletonUnit(entry);
- if (!unit)
- return false;
- return name == unit->PeekDIEName(unit->GetOffset() + *maybe_dieoffset);
----------------
jeffreytan81 wrote:
@felipepiovezan , I am having trouble finding a context without split dwarf to
measure the performance. Our target is way too big to build without split dwarf
(linker error). I am trying to debug clang++ per your benchmark, but the
evaluation is very fast `293ms` which I do not think it is slow enough to
measure perf. How do you get 5~6 seconds from this?
```
devbig623:~/llvm-sand/build/Debug/fbcode-x86_64/toolchain$ lldb -o "b
CodeGenFunction::GenerateCode" -o r -o "timeit expr Fn" --
~/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/clang++ -std=c++17 -pthread
-glldb -c ~/personal/main.cpp -o ~/personal/a
(lldb) target create
"/home/jeffreytan/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/clang++"
Current executable set to
'/home/jeffreytan/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/clang++'
(x86_64).
(lldb) settings set -- target.run-args "-std=c++17" "-pthread" "-glldb" "-c"
"/home/jeffreytan/personal/main.cpp" "-o" "/home/jeffreytan/personal/a"
(lldb) b CodeGenFunction::GenerateCode
Breakpoint 1: where =
clang++`clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 59 at
CodeGenFunction.cpp:1440:3, address = 0x00000000083c507b
(lldb) r
Process 233320 launched:
'/home/jeffreytan/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/clang++'
(x86_64)
Process 233320 stopped
* thread #1, name = 'clang++', stop reason = breakpoint 1.1
frame #0: 0x000055555d91907b
clang++`clang::CodeGen::CodeGenFunction::GenerateCode(this=0x00007fffffff5bb0,
GD=GlobalDecl @ 0x00007fffffff5b48, Fn=0x000002921787f228,
FnInfo=0x0000029218308200) at CodeGenFunction.cpp:1440:3
1437
1438 void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
1439 const CGFunctionInfo &FnInfo) {
-> 1440 assert(Fn && "generating code for null Function");
1441 const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
1442 CurGD = GD;
1443
(lldb) timeit expr Fn
(llvm::Function *) $0 = 0x000002921787f228
time: 0m0.293s
```
https://github.com/llvm/llvm-project/pull/108907
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits