jmmartinez / easy-just-in-time

LLVM Optimization to extract a function, embedded in its intermediate representation in the binary, and execute it using the LLVM Just-In-Time compiler.
BSD 3-Clause "New" or "Revised" License
511 stars 31 forks source link

Every example fails with an Assertion Error #43

Open mame98 opened 5 years ago

mame98 commented 5 years ago

I am currently experimenting with this tool / library, but every example that I want to try fails with the following assertion error:

a.out: /path/to/easy-just-in-time/runtime/pass/InlineParameters.cpp:31: easy::HighLevelLayout GetNewLayout(const easy::Context &, easy::HighLevelLayout &): Assertion `C.size() == HLL.Args_.size()' failed.

Since I have no Idea about the internals of this project I do not know what to do. Do you have any idea whats wrong (or what I am missing?)?

Additional Information:

jmmartinez commented 5 years ago

Hi Marius. Thanks for posting the Issue.

Do the tests of the library compile? Can you show me the code that you're trying to compile?

mame98 commented 5 years ago

No the library tests did not work either I think....

I used the following code to test:

#include <iostream>
#include <easy/jit.h>

using namespace std;

static void EASY_JIT_EXPOSE kernel(const int a, const int b, int  * const res)
{
    for(int x = 1; x < a; x++)
    {
        for(int y = 1; y < b; y++)
        {
            *res += a*b - b;
        }
    }
}

int main(int argc, char **argv)
{
    int res = 0;
    kernel(1000, 250000, &res);

    using namespace std::placeholders;
    auto kernel_opt = easy::jit(kernel, 1000, 250000, _1);
    kernel_opt(&res);

    cout << res << endl;
    return 0;
}
jmmartinez commented 5 years ago

It works for me in my local configuration. I created a pull request where I added the code as a new test to see what the Continuous Integration says.

What version of the llvm are you using?

mame98 commented 5 years ago

As I am using a pretty old Debian System, I build a custom LLVM 6.0.1

jmmartinez commented 5 years ago

That's strange.

Could you try to send me the generated CMakeCache.txt ?

And also compile the previous code that you send with the options -S -emit-llvm to obtain an .ll and send it to me. The command line should be something like "clang -S -emit-llvm -I /easyjitdir/include issue_43.cpp -O2 -o issue_43.ll" .

Thanks for the help!

On Thu, 21 Feb 2019 at 15:37, Marius Messerschmidt notifications@github.com wrote:

As I am using a pretty old Debian System, I build a custom LLVM 6.0.1

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/jmmartinez/easy-just-in-time/issues/43#issuecomment-466022812, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5536WClF_dUFqcTU2ZeIijuuAlcrRlks5vPq8-gaJpZM4bG0Vf .

mame98 commented 5 years ago

Sorry that it took so long, but here are the files that you requested.

CMakeCache.txt

issue_43.ll.gz

(I had to gzip the LLVM file, as GitHub would reject it otherwise)

mame98 commented 5 years ago

is there still activity in this?

jmmartinez commented 5 years ago

Sorry for the delay @mame98 . I wasn't able to reproduce it, and I did not have enough time to test with more configurations to see if I could trigger the error.