intel / llvm

Intel staging area for llvm.org contribution. Home for Intel LLVM-based projects.
Other
1.26k stars 738 forks source link

Improve metaprogramming codegen #8648

Closed victor-eds closed 1 month ago

victor-eds commented 1 year ago

Describe the bug

cgeist does not handling metaprogramming correctly, as the functions being passed as arguments to other functions are not defined, only declared, in the output module.

To Reproduce

Run:

cgeist -S -o - -O3 <file>

in both provided tests. You'll see how the functions being passed are not defined.

int square(int x) {
  return x*x;
}

int meta(int (*f)(int), int x) {
  return f(x);
}

int main() {
  meta(square, 3);
}
#include <iostream>

template <typename T, typename F>
T call(F func) {
  return func();
}

void foo() {
  std::cout << "Hello\n";
}

int main() {
  call<void>(foo);
}

Additional context:

We may want to use this operation defined in upstream polygeist as getting the address of a function is a C/C++ construct.

Environment (please complete the following information):

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 30 days with no activity. Please, re-open if the issue still exists.