This is an archive of the discontinued LLVM Phabricator instance.

[AssumeBundles] Fix Bug in Assume Queries
ClosedPublic

Authored by Tyker on Jul 9 2020, 2:11 PM.

Details

Summary

this bug was causing miscompile.
now clang cant properly selfhost with -mllvm --enable-knowledge-retention

Diff Detail

Event Timeline

Tyker created this revision.Jul 9 2020, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2020, 2:11 PM
Tyker added a comment.EditedJul 9 2020, 2:35 PM

Test?

i would also like to add a test for it, but the smallest reproduction example is still very big 30k+ line of IR
and depend on what is present in the AssumptionCache so i could only reproduce it under -O3 run.
it isn't minimized at all but minimizing it in a way that still exibit the bug is quite hard

Test?

i would also like to add a test for it, but the smallest reproduction example is still very big 30k+ line of IR
and depend on what is present in the AssumptionCache so i could only reproduce it under -O3 run.
it isn't minimized at all but minimizing it in a way that still exibit the bug is quite hard

Can you at least post the reproducer+steps as-is?

lebedev.ri requested changes to this revision.Jul 10 2020, 4:15 PM

Also, this either needs a rebase, or this isn't against master but the stack doesn't say so.

This revision now requires changes to proceed.Jul 10 2020, 4:15 PM
Tyker added a comment.Jul 14 2020, 4:09 PM

Also, this either needs a rebase, or this isn't against master but the stack doesn't say so.

The patch should apply cleanly now. it was conflicting with an other path that landed.

Test?

i would also like to add a test for it, but the smallest reproduction example is still very big 30k+ line of IR
and depend on what is present in the AssumptionCache so i could only reproduce it under -O3 run.
it isn't minimized at all but minimizing it in a way that still exibit the bug is quite hard

Can you at least post the reproducer+steps as-is?

one way to see the effect of the bug is to try to run ADT unitest compiled with stage1 clang with -O3 -mllvm --enable-knowledge-retention.
this test should have test failures caused by this bug.

one of the files in which a miscompile occurs is /home/tyker/opensource/llvm-project/llvm/unittests/ADT/ImmutableSetTest.cpp
here is the unoptimized IR that triggers the bug.


running: opt -O3 --enable-knowledge-retention tmp.ll

Tyker requested review of this revision.Aug 7 2020, 10:26 AM
lebedev.ri requested changes to this revision.Aug 13 2020, 6:14 AM

Please rebase and update the affected test :)

This revision now requires changes to proceed.Aug 13 2020, 6:14 AM
Tyker updated this revision to Diff 285759.Aug 14 2020, 2:19 PM

Please rebase and update the affected test :)

thank you, but how did you reduced it ?

lebedev.ri accepted this revision.Aug 14 2020, 2:28 PM

LG
@jdoerfert ?

Please rebase and update the affected test :)

thank you, but how did you reduced it ?

By not treating compiler as a black box - there is a (an unreduced) testcase already, and a fix, that changes the IR after optimizations.
So one just has to write an interestingness test that checks that 1. the bug is still triggered, and 2. the final IR differs with/without the fix.

I would be lying if i said that llvm-reduce got those 2mb down to these 40 lines all by itself,
there are still some rough edges that required manual intervention..

This revision is now accepted and ready to land.Aug 14 2020, 2:28 PM
jdoerfert accepted this revision.Aug 14 2020, 2:39 PM

This seems to fix a problem.

This revision was automatically updated to reflect the committed changes.