[PATCH] D93117: LNT: Fix Perf profiling support

Tamar Christina via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 11 06:02:29 PST 2020


tnfchris created this revision.
tnfchris added a reviewer: thopre.
tnfchris requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In Python3 the C interface has changed. [1]

During the upgrade the Creation of the perf
interface was upgraded to Python3 but the initialization
itself was not. As a consequence the module was not actually
registered and trying to use perf results in an error.

This would not be noticed as the import in the Python module
has the import in a try: .. except: pass block presumably
because perf support is optional.

[1] http://python3porting.com/cextensions.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93117

Files:
  lnt/testing/profile/cPerf.cpp
  lnt/testing/profile/perf.py


Index: lnt/testing/profile/perf.py
===================================================================
--- lnt/testing/profile/perf.py
+++ lnt/testing/profile/perf.py
@@ -7,9 +7,14 @@
 import traceback
 
 try:
+    # Python 2
     import cPerf
 except Exception:
-    pass
+    try:
+        # Python 3
+        import lnt.testing.profile.cPerf as cPerf
+    except Exception:
+        pass
 
 
 class LinuxPerfProfile(ProfileImpl):
Index: lnt/testing/profile/cPerf.cpp
===================================================================
--- lnt/testing/profile/cPerf.cpp
+++ lnt/testing/profile/cPerf.cpp
@@ -824,13 +824,15 @@
                                      nullptr};
 #endif
 
-PyMODINIT_FUNC initcPerf(void) {
 #if PY_MAJOR_VERSION >= 3
+PyMODINIT_FUNC PyInit_cPerf(void) {
   return PyModule_Create(&cPerfModuleDef);
+}
 #else
+PyMODINIT_FUNC initcPerf(void) {
   (void)Py_InitModule("cPerf", cPerfMethods);
-#endif
 }
+#endif
 
 #else // STANDALONE
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93117.311206.patch
Type: text/x-patch
Size: 963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201211/3210ad20/attachment.bin>


More information about the llvm-commits mailing list