[llvm-dev] Question

Samaneh Berenjian via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 26 13:48:54 PDT 2017


​Hello all,

I have implemented my code in llvmlite which is partly like the following:

for stmt in irsb.statements:
    if isinstance(stmt, pyvex.IRStmt.IMark):
        print "------ IMark(0x%x, %d, %d) ------" % (stmt.addr, stmt.len, stmt.delta)
    if isinstance(stmt, pyvex.IRStmt.Put):
       #if isinstance(stmt.data, pyvex.IRExpr.Const):
       if isinstance(stmt.data, pyvex.IRExpr.RdTmp):
           irbuilder.store_reg(ll.Constant(ll.IntType(64), stmt.data), ll.IntType(64), stmt.offset )
    if isinstance(stmt, pyvex.IRStmt.WrTmp):
        expr = stmt.expressions[0]
        mehran = stmt.tmp
        if isinstance(expr, pyvex.IRExpr.Get):
            #mehran, expr.offset, expr.t
            irbuilder.store_reg(ll.Constant(ll.IntType(64), expr.offset), ll.IntType(64), stmt.data)
        elif isinstance(expr, pyvex.IRExpr.Load):
            irbuilder.store_reg(ll.Constant(ll.IntType(64), stmt.tmp), ll.IntType(64), expr.addr)
    elif isinstance(stmt, pyvex.IRStmt.Store):
        irbuilder.store_reg(ll.Constant(ll.IntType(64), stmt.addr), ll.IntType(64), stmt.data)


int_type = ll.IntType(64);
ret = irbuilder.ret(ll.Constant(int_type, 1))
print(str(module))

llvm_module = llvm.parse_assembly(str(module))
tm = llvm.Target.from_default_triple().create_target_machine()

with llvm.create_mcjit_compiler(llvm_module, tm) as ee:
     ee.finalize_object()
     cfptr = ee.get_pointer_to_function(llvm_module.get_function('read_amd64'))
     cfunc = CFUNCTYPE(c_void)(cfptr)
     res = cfunc(42)

when running it in by python, I get an error like the following:

  File "comp.py", line 100, in <module>
    llvm_module = llvm.parse_assembly(str(module))
  File "/usr/local/lib/python2.7/dist-packages/llvmlite/binding/module.py", line 22, in parse_assembly
    raise RuntimeError("LLVM IR parsing error\n{0}".format(errmsg))
RuntimeError: LLVM IR parsing error
<string>:13:6: error: expected value token
(i64 t3)
     ^
Does anyone know how can I resolve it?
-- 
This email was Anti Virus checked by  Security Gateway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170627/613ee635/attachment.html>


More information about the llvm-dev mailing list