File: 207-Rewrite-_jump_if_none-to-match-pre-py3.11.patch

package info (click to toggle)
numba 0.56.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,672 kB
  • sloc: python: 183,651; ansic: 15,370; cpp: 2,259; javascript: 424; sh: 308; makefile: 174
file content (47 lines) | stat: -rw-r--r-- 1,808 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From f9ce8b4018e87b6fd3e6a5978b077f16bfd97a3b Mon Sep 17 00:00:00 2001
From: Stuart Archibald <stuartarchibald@users.noreply.github.com>
Origin: https://github.com/numba/numba/pull/8639
Date: Fri, 25 Nov 2022 14:07:37 +0000
Subject: [PATCH 07/20] Rewrite _jump_if_none to match pre-py3.11

As title
---
 numba/core/interpreter.py | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

--- a/numba/core/interpreter.py
+++ b/numba/core/interpreter.py
@@ -2904,15 +2904,26 @@
         falsebr = brs[not iftrue]
 
         op = BINOPS_TO_OPERATORS["is"]
-
-        lhs = self.store(value=ir.Const(None, loc=self.loc),
-                         name=f"${inst.offset}constnone")
-        rhs = self.get(pred)
+        rhs = self.store(value=ir.Const(None, loc=self.loc),
+                         name=f"$constNone{inst.offset}")
+        lhs = self.get(pred)
         isnone = ir.Expr.binop(op, lhs=lhs, rhs=rhs, loc=self.loc)
 
-        pname = "$%spred" % (inst.offset)
-        predicate = self.store(value=isnone, name=pname)
-        branch = ir.Branch(cond=predicate, truebr=truebr, falsebr=falsebr,
+        maybeNone = f"$maybeNone{inst.offset}"
+        self.store(value=isnone, name=maybeNone)
+
+        name = f"$bool{inst.offset}"
+        gv_fn = ir.Global("bool", bool, loc=self.loc)
+        self.store(value=gv_fn, name=name)
+
+        callres = ir.Expr.call(self.get(name), (self.get(maybeNone),), (),
+                               loc=self.loc)
+
+        pname = f"$pred{inst.offset}"
+        predicate = self.store(value=callres, name=pname)
+        branch = ir.Branch(cond=predicate,
+                           truebr=truebr,
+                           falsebr=falsebr,
                            loc=self.loc)
         self.current_block.append(branch)