Skip to content

Commit

Permalink
Always load the personality library in JIT testbench, if available.
Browse files Browse the repository at this point in the history
whitequark committed Jul 27, 2015
1 parent 14c7b15 commit 47f13bf
Showing 9 changed files with 20 additions and 16 deletions.
12 changes: 5 additions & 7 deletions artiq/compiler/testbench/jit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys, fileinput
from ctypes import CFUNCTYPE
import os, sys, fileinput, ctypes
from pythonparser import diagnostic
from llvmlite import binding as llvm
from .. import Module
@@ -10,10 +9,9 @@
llvm.check_jit_execution()

def main():
while sys.argv[1].startswith("+"):
if sys.argv[1] == "+load":
llvm.load_library_permanently(sys.argv[2])
del sys.argv[1:3]
libartiq_personality = os.getenv('LIBARTIQ_PERSONALITY')
if libartiq_personality is not None:
llvm.load_library_permanently(libartiq_personality)

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

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -789,7 +789,7 @@ def visit_SubscriptT(self, node):
lambda: self.alloc_exn(builtins.TValueError(),
ir.Constant("slice size {0} is larger than iterable length {1}",
builtins.TStr()),
slice_size, iterable_len))
slice_size, length))

if self.current_assign is None:
is_neg_size = self.append(ir.Compare(ast.Lt(loc=None),
14 changes: 8 additions & 6 deletions artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -103,12 +103,14 @@ def llconst_of_const(self, const):
linkage = "private"
unnamed_addr = True

llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
llconst.global_constant = True
llconst.initializer = ll.Constant(llstrty, bytearray(as_bytes))
llconst.linkage = linkage
llconst.unnamed_addr = unnamed_addr
llconst = self.llmodule.get_global(name)
if llconst is None:
llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
llconst.global_constant = True
llconst.initializer = ll.Constant(llstrty, bytearray(as_bytes))
llconst.linkage = linkage
llconst.unnamed_addr = unnamed_addr

return llconst.bitcast(ll.IntType(8).as_pointer())
else:
2 changes: 1 addition & 1 deletion lit-test/test/exceptions/raise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: %python -m artiq.compiler.testbench.jit +load %personality %s
# RUN: %python -m artiq.compiler.testbench.jit %s
# REQUIRES: exceptions

1/0
1 change: 1 addition & 0 deletions lit-test/test/integration/arithmetics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s
# REQUIRES: exceptions

assert -(-1) == 1
assert -(-1.0) == 1.0
1 change: 1 addition & 0 deletions lit-test/test/integration/builtin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s
# REQUIRES: exceptions

assert bool() is False
# bool(x) is tested in bool.py
1 change: 1 addition & 0 deletions lit-test/test/integration/list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s
# REQUIRES: exceptions

[x, y] = [1, 2]
assert (x, y) == (1, 2)
1 change: 1 addition & 0 deletions lit-test/test/integration/subscript.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s
# REQUIRES: exceptions

lst = list(range(10))
assert lst[0] == 0
2 changes: 1 addition & 1 deletion lit-test/test/lit.cfg
Original file line number Diff line number Diff line change
@@ -18,6 +18,6 @@ if os.name == 'posix':
lit_config.fatal("Unable to build JIT support library")

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

config.available_features.add('exceptions')

0 comments on commit 47f13bf

Please sign in to comment.