Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wiki example doesn't work with master branch #28

Open
Blopeur opened this issue Aug 18, 2021 · 1 comment
Open

wiki example doesn't work with master branch #28

Blopeur opened this issue Aug 18, 2021 · 1 comment

Comments

@Blopeur
Copy link

Blopeur commented Aug 18, 2021

Hi,
I am trying to run the wiki example and while i can do basic jit operations ( even basic custom matrix code for the sake of it)
I am having an issue when passing the type. I am using the wiki example :

#include <iostream>

struct F {
  int i;
  double d;
};

template <typename T, int S>
struct G {
  T arr[S];
};

template <typename T>
[[clang::jit]] void run() {
  std::cout << "I was compiled at runtime, sizeof(T) = " << sizeof(T) << "\n";
}

int main(int argc, char *argv[]) {
  std::string t(argv[1]);
  run<t>();
}

When i run i get the following error :

./jit-t "double"
Declaration may not be in a Comdat!
void (i8*)* @__clang_call_terminate
in function __clang_call_terminate
LLVM ERROR: Broken function found, compilation aborted!

I have tried to pass the type in another custom examples and I hit the same error every time ?

Am I missing something?

Also, i saw in the issues that there is a new [[clang::for_dynamic_instantiation]] API in 9.0-ni branch. Any pointer to updated documentation can be helpful.

@Blopeur
Copy link
Author

Blopeur commented Aug 18, 2021

Update :

the issue seems strange , the following code works :

#include <iostream>
using namespace std;
struct F {
    int i;
    double d;
};

template <typename T, int S>
struct G {
    T arr[S];
};

template <typename T>
[[clang::jit]] void run() {
    std::cout << "I was compiled at runtime, sizeof(T) = " << sizeof(T) << "\n";
}

int main(int argc, char *argv[]) {
    run<"double">();
}

if I use the very basic example and add a single line : creating a string in main , even without using the string for anything the jit process fail

#include <iostream>
#include <cstdlib>

template <int x>
[[clang::jit]] void run() {
  int z = 0;
  for (int i = 0 ; i < x ; i++){
    z = x + 5 * x;
  }
  std::cout << "I was compiled at runtime, x = " << x <<  " z = " << z << "\n";
}

int main(int argc, char *argv[]) {
  int a = std::atoi(argv[1]);
  std::string t("double");
  run<a>();
}

Same error .. looks like allocating a string is what trigger the issue ..

./jit 1
Declaration may not be in a Comdat!
void (i8*)* @__clang_call_terminate
in function __clang_call_terminate
LLVM ERROR: Broken function found, compilation aborted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant