Author: Manuel Jacob <m...@manueljacob.de>
Branch: llvm-translation-backend
Changeset: r81680:2aff8b331a70
Date: 2016-01-12 02:44 +0100
http://bitbucket.org/pypy/pypy/changeset/2aff8b331a70/

Log:    hg merge default

diff --git a/rpython/translator/backendopt/graphanalyze.py 
b/rpython/translator/backendopt/graphanalyze.py
--- a/rpython/translator/backendopt/graphanalyze.py
+++ b/rpython/translator/backendopt/graphanalyze.py
@@ -80,12 +80,17 @@
                 funcobj = op.args[0].value._obj
             except DelayedPointer:
                 return self.top_result()
+            if funcobj is None:
+                # We encountered a null pointer.  Calling it will crash.
+                # However, the call could be on a dead path, so we return the
+                # bottom result here.
+                return self.bottom_result()
             if getattr(funcobj, 'external', None) is not None:
                 x = self.analyze_external_call(funcobj, seen)
                 if self.verbose and x:
                     self.dump_info('analyze_external_call %s: %r' % (op, x))
                 return x
-            graph = get_graph(op.args[0], self.translator)
+            graph = funcobj.graph
             assert graph is not None
             x = self.analyze_direct_call(graph, seen)
             if self.verbose and x:
diff --git a/rpython/translator/backendopt/test/test_graphanalyze.py 
b/rpython/translator/backendopt/test/test_graphanalyze.py
--- a/rpython/translator/backendopt/test/test_graphanalyze.py
+++ b/rpython/translator/backendopt/test/test_graphanalyze.py
@@ -65,3 +65,14 @@
     op = SpaceOperation('direct_call', [c_f], None)
     analyzer = BoolGraphAnalyzer(t)
     assert analyzer.analyze(op)
+
+
+def test_null_fnptr():
+    from rpython.flowspace.model import SpaceOperation, Constant
+    from rpython.rtyper.lltypesystem.lltype import Void, FuncType, nullptr
+    from rpython.translator.translator import TranslationContext
+    t = TranslationContext()
+    fnptr = nullptr(FuncType([], Void))
+    op = SpaceOperation('direct_call', [Constant(fnptr)], None)
+    analyzer = BoolGraphAnalyzer(t)
+    assert not analyzer.analyze(op)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to