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

Fixing issues with unreachable function #22

Open
mcopik opened this issue Apr 26, 2020 · 0 comments
Open

Fixing issues with unreachable function #22

mcopik opened this issue Apr 26, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mcopik
Copy link
Collaborator

mcopik commented Apr 26, 2020

We need to hijack a return from a function to commit results from it. However, there are problems when return from main is rerouted to a different routine, like in MILC:

void normal_exit()
{
  exit(0);
}
int main()
{
  ...
  normal_exit();
}

Running simplifycfg works on MILC, turning the return from main into an unreachable, but not on all examples of the problem.

#include <cmath>
#include <cstdlib>

#include "ExtraPInstrumenter.hpp"

// Reproduces a bug scenario where return from function is unreachable.
// Running `simplify-cfg` pass is necessary to turn return into unreachable
// code and putting loop commit calls correctly before the exit.

void exit_program()
{
  exit(0);
}

int main(int argc, char ** argv)
{
  int x1 EXTRAP = atoi(argv[1]);
  int x2 EXTRAP = 2*atoi(argv[2]);
  register_variable(&x1, VARIABLE_NAME(x1));
  register_variable(&x2, VARIABLE_NAME(x2));
  
  int sum = 0;
  for(int i = x1; i < x2; i++)
    ++sum;

  exit_program();
  return 0;
}
@mcopik mcopik added the bug Something isn't working label Apr 26, 2020
@mcopik mcopik self-assigned this Apr 26, 2020
@mcopik mcopik mentioned this issue Aug 16, 2021
5 tasks
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