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

report a bug and my fix code #667

Closed
RainMolisa opened this issue Oct 18, 2024 · 3 comments
Closed

report a bug and my fix code #667

RainMolisa opened this issue Oct 18, 2024 · 3 comments

Comments

@RainMolisa
Copy link

hello Discopop!
I find Discopop will crash in following target code.

#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int a = 0;
int C(int a) {
    int sum = 0;
    vector<int> c {1,2,3,4,5,6,7,8};
    for_each(c.begin(), c.end(), [&](int item) {
          sum += item * a;
    });
    return sum;
}
int B() {
    int b = 1;
    a++;
    return C(a);
}
void A() {
   a = 100;
}
int main()
{
    A();
    int b = B();
    int c = C(2);
    cout<<"b="<<b<<",c="<<c<<endl;
    return 0;
}

And , I find the bug is in Discopop/DiscoPoP.cpp

        // Remove values from locals if dereferenced
        if (isa<StoreInst>(I)) {
          V = I.getOperand(0);
          for (Value *w : staticallyPredictableValues) {
            if (w == V) {
              staticallyPredictableValues.erase(V);
            }
          }

To fix the bug, I change the code into following:

          while(staticallyPredictableValues.end() != staticallyPredictableValues.find(V)){
            staticallyPredictableValues.erase(V);
          }

It's work!

Best Wish!

@lukasrothenberger
Copy link
Collaborator

Hi @RainMolisa
this bug is one of multiples that should be fixed by the upcoming Release 4.0 (#615).
Until the release, i would suggest to try your code again using the DiscoPoP version in branch "release/4.0.0", as this is the most reliable state as of now.

I will try to prepare the release as soon as possible.

Regarding your code snippet: I have tested it and it did work with branch "release/4.0.0". If you encounter any issue, please feel free to let me know, I'll be happy to help!

Best regards
Lukas

@lukasrothenberger
Copy link
Collaborator

Hi @RainMolisa
could you please re-try with the latest release 4.0.0?

@RainMolisa
Copy link
Author

Hi @RainMolisa could you please re-try with the latest release 4.0.0?

I will try, later.

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

2 participants