summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-10-10 17:59:15 +0000
committerAdrian Prantl <aprantl@apple.com>2019-10-10 17:59:15 +0000
commit418893d8f2f33693c0aedf8fcde63167a8a3101c (patch)
treeb57dd4197833dd77775e31c5b8bc4918864999c9 /lldb/packages/Python/lldbsuite/test
parent715bfa4ef800d8aacc150f81ab3838332e02b08f (diff)
downloadbcm5719-llvm-418893d8f2f33693c0aedf8fcde63167a8a3101c.tar.gz
bcm5719-llvm-418893d8f2f33693c0aedf8fcde63167a8a3101c.zip
Speed up accelerator table lookups
When debugging a large program like clang and doing "frame variable *this", the ValueObject pretty printer is doing hundreds of scoped FindTypes lookups. The ones that take longest are the ones where the DWARFDeclContext ends in something like ::Iterator which produces many false positives that need to be filtered out *after* extracting the DIEs. This patch demonstrates a way to filter out false positives at the accerator table lookup step. With this patch lldb clang-10 -o "b EmitFunctionStart" -o r -o "f 2" -o "fr v *this" -b -- ... goes (in user time) from 5.6s -> 4.8s or (in wall clock) from 6.9s -> 6.0s. Differential Revision: https://reviews.llvm.org/D68678 llvm-svn: 374401
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile7
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py31
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp2
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp28
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h12
11 files changed, 92 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
new file mode 100644
index 00000000000..4c053a09c75
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
@@ -0,0 +1,7 @@
+# There is no guaranteed order in which the linker will order these
+# files, so we just have a lot of them to make it unlikely that we hit
+# the right one first by pure luck.
+
+CXX_SOURCES := main.cpp a.cpp b.cpp c.cpp d.cpp e.cpp f.cpp g.cpp
+
+include Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
new file mode 100644
index 00000000000..3705e95c600
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
@@ -0,0 +1,31 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CPPAcceleratorTableTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @skipIf(debug_info=no_match(["dwarf"]))
+ def test(self):
+ """Test that type lookups fail early (performance)"""
+ self.build()
+ logfile = self.getBuildArtifact('dwarf.log')
+ self.expect('log enable dwarf lookups -f' + logfile)
+ target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+ self, 'break here', lldb.SBFileSpec('main.cpp'))
+ # Pick one from the middle of the list to have a high chance
+ # of it not being in the first file looked at.
+ self.expect('frame variable inner_d')
+
+ log = open(logfile, 'r')
+ n = 0
+ for line in log:
+ if re.findall(r'[abcdefg]\.o: FindByNameAndTag\(\)', line):
+ self.assertTrue("d.o" in line)
+ n += 1
+
+ self.assertEqual(n, 1, log)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
new file mode 100644
index 00000000000..d9f758e1991
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(A)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
new file mode 100644
index 00000000000..a0cdffa14f1
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(B)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
new file mode 100644
index 00000000000..1bd7172b771
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(C)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
new file mode 100644
index 00000000000..e43c2ad05aa
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(D)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
new file mode 100644
index 00000000000..a3008f71f65
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(E)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
new file mode 100644
index 00000000000..77df296183e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(F)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
new file mode 100644
index 00000000000..e1446918891
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(G)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
new file mode 100644
index 00000000000..b7eb252bad8
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+ class NAME { \
+ public: \
+ struct Inner; \
+ Inner *i = nullptr; \
+ }; \
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+ A::Inner &inner_a = getInnerA();
+ B::Inner &inner_b = getInnerB();
+ C::Inner &inner_c = getInnerC();
+ D::Inner &inner_d = getInnerD();
+ E::Inner &inner_e = getInnerE();
+ F::Inner &inner_f = getInnerF();
+ G::Inner &inner_g = getInnerG();
+
+ return 0; // break here
+}
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
new file mode 100644
index 00000000000..214e7dada2e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+ class NAME { \
+ public: \
+ class Inner { \
+ int j = #NAME[0]; \
+ }; \
+ Inner *i = nullptr; \
+ }; \
+ \
+ static NAME::Inner inner; \
+ static NAME obj; \
+ NAME::Inner &getInner##NAME() { return inner; }
OpenPOWER on IntegriCloud