-
Notifications
You must be signed in to change notification settings - Fork 111
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
controlflow fixes #1425
controlflow fixes #1425
Conversation
@wsmoses Could you say something about the viability of these changes before I start changing all of your doc tests? |
Yeah, I'll take a look in the next few days |
I inspected this more deeply, and at least one problem that this partially fixes is the fact that Enzyme (incorrectly) assumed that an exit block only had one loop predecessor. I fixed that assumption here: #1430 . That is effectively your change, however, the I'm not sure that is the entirety of the issue you saw, but try that out and take a look? |
Yes, there are two issues that the AB loops illuminate. Your PR does (1). What remains is (2) the antivars may be loaded uninitialized in the reverse pass. You can see these in the llvm in EnzymeLogic after enzyme has done its thing but before the post optimization passes are run. The promote pass from llvm is what obscures the bad loads. There is a function computeIndexOfChunk that loads from uninitialized antivars. This happens in ...'merge blocks that only initialize one of the antivars. This doesn't work because the whole tower of antivars needs initialization. Try looking at the llvm (before post optimization) for the C code I posted. |
@wsmoses I see that you did have a try at (2) in #1430 for v0.0.84. This gets closer, but it is not there yet. Here is the problem very specifically:
Now, ivC'ac, ivB'ac, ivA'ac are uninitialized allocas to circumvent the SSA requirement. As for the reverse code:
This is doubly wrong because ivA'ac and ivB'ac are uninitialized when read, and ivA'ac and ivB'ac are not set. As a consequence of the first, llcC[ivA'ac][ivB'ac] reads from an undefined address.
This is getting closer but is still bad because ivA'ac and ivB'ac are uninitialized when used.
Since I considered this an invasive change, in this PR I just put the initializations of ivA'ac, ivB'ac, and ivC'ac in the primal part. |
Excellent catch, I believe #1443 should remedy what you found |
Looks good. Would you like the test code here in the integration folder? |
Yeah, the more the merrier. Rebase and let's merge? |
57f3e5e
to
5bcc9e9
Compare
5bcc9e9
to
dfe725a
Compare
This has only the test code now. By the way, the following tests broke sometime between v0.0.70 and v.0.0.80
|
test code from #1392