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

Directly calling callback functions causes a crash #40

Closed
ahueck opened this issue Dec 29, 2020 · 0 comments
Closed

Directly calling callback functions causes a crash #40

ahueck opened this issue Dec 29, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@ahueck
Copy link
Contributor

ahueck commented Dec 29, 2020

A crash during the compilation is caused by explicit/direct calls to the various callback functions:

#include <stddef.h>
void __typeart_leave_scope(int alloca_count);
int main(void) {
  __typeart_leave_scope(0);
  return 0;
}

Potential fix

In TypeARTFunctions.cpp, check if the function is already declared in the module.

Rough fix outline
TAFunctionDeclarator::make_function(...)  {
  ...
  const auto do_make = [&](auto& name, auto f_type) {
    const bool has_f = m.getFunction(name) != nullptr;
    auto fc          = m.getOrInsertFunction(name, f_type);
    if (has_f) {
      auto fcc = fc.getCallee();
      return dyn_cast<Function>(fc.getCallee()->stripPointerCasts());
    }
    ...
@ahueck ahueck added the bug Something isn't working label Dec 29, 2020
ahueck added a commit that referenced this issue Dec 29, 2020
ahueck added a commit that referenced this issue Dec 29, 2020
@ahueck ahueck closed this as completed Dec 29, 2020
ahueck added a commit that referenced this issue Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant