Skip to content

Commit 47f13bf

Browse files
author
whitequark
committedJul 27, 2015
Always load the personality library in JIT testbench, if available.
·
8.01.0rc1
1 parent 14c7b15 commit 47f13bf

File tree

9 files changed

+20
-16
lines changed

9 files changed

+20
-16
lines changed
 

‎artiq/compiler/testbench/jit.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import sys, fileinput
2-
from ctypes import CFUNCTYPE
1+
import os, sys, fileinput, ctypes
32
from pythonparser import diagnostic
43
from llvmlite import binding as llvm
54
from .. import Module
@@ -10,10 +9,9 @@
109
llvm.check_jit_execution()
1110

1211
def main():
13-
while sys.argv[1].startswith("+"):
14-
if sys.argv[1] == "+load":
15-
llvm.load_library_permanently(sys.argv[2])
16-
del sys.argv[1:3]
12+
libartiq_personality = os.getenv('LIBARTIQ_PERSONALITY')
13+
if libartiq_personality is not None:
14+
llvm.load_library_permanently(libartiq_personality)
1715

1816
def process_diagnostic(diag):
1917
print("\n".join(diag.render()))
@@ -34,7 +32,7 @@ def process_diagnostic(diag):
3432
lljit = llvm.create_mcjit_compiler(llparsedmod, llmachine)
3533
lljit.finalize_object()
3634
llmain = lljit.get_pointer_to_global(llparsedmod.get_function(llmod.name + ".__modinit__"))
37-
CFUNCTYPE(None)(llmain)()
35+
ctypes.CFUNCTYPE(None)(llmain)()
3836

3937
if __name__ == "__main__":
4038
main()

‎artiq/compiler/transforms/artiq_ir_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def visit_SubscriptT(self, node):
789789
lambda: self.alloc_exn(builtins.TValueError(),
790790
ir.Constant("slice size {0} is larger than iterable length {1}",
791791
builtins.TStr()),
792-
slice_size, iterable_len))
792+
slice_size, length))
793793

794794
if self.current_assign is None:
795795
is_neg_size = self.append(ir.Compare(ast.Lt(loc=None),

‎artiq/compiler/transforms/llvm_ir_generator.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ def llconst_of_const(self, const):
103103
linkage = "private"
104104
unnamed_addr = True
105105

106-
llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
107-
llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
108-
llconst.global_constant = True
109-
llconst.initializer = ll.Constant(llstrty, bytearray(as_bytes))
110-
llconst.linkage = linkage
111-
llconst.unnamed_addr = unnamed_addr
106+
llconst = self.llmodule.get_global(name)
107+
if llconst is None:
108+
llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
109+
llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
110+
llconst.global_constant = True
111+
llconst.initializer = ll.Constant(llstrty, bytearray(as_bytes))
112+
llconst.linkage = linkage
113+
llconst.unnamed_addr = unnamed_addr
112114

113115
return llconst.bitcast(ll.IntType(8).as_pointer())
114116
else:

‎lit-test/test/exceptions/raise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: %python -m artiq.compiler.testbench.jit +load %personality %s
1+
# RUN: %python -m artiq.compiler.testbench.jit %s
22
# REQUIRES: exceptions
33

44
1/0

‎lit-test/test/integration/arithmetics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
22
# RUN: %python %s
3+
# REQUIRES: exceptions
34

45
assert -(-1) == 1
56
assert -(-1.0) == 1.0

‎lit-test/test/integration/builtin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
22
# RUN: %python %s
3+
# REQUIRES: exceptions
34

45
assert bool() is False
56
# bool(x) is tested in bool.py

‎lit-test/test/integration/list.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
22
# RUN: %python %s
3+
# REQUIRES: exceptions
34

45
[x, y] = [1, 2]
56
assert (x, y) == (1, 2)

‎lit-test/test/integration/subscript.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
22
# RUN: %python %s
3+
# REQUIRES: exceptions
34

45
lst = list(range(10))
56
assert lst[0] == 0

‎lit-test/test/lit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ if os.name == 'posix':
1818
lit_config.fatal("Unable to build JIT support library")
1919

2020
personality_lib = os.path.join(personality_build, 'libartiq_personality.so')
21-
config.substitutions.append( ('%personality', personality_lib) )
21+
config.environment['LIBARTIQ_PERSONALITY'] = personality_lib
2222

2323
config.available_features.add('exceptions')

0 commit comments

Comments
 (0)
Please sign in to comment.