This is an archive of the discontinued LLVM Phabricator instance.

[GlobalOpt] Fix another incorrect Modified status
ClosedPublic

Authored by dstenb on Aug 18 2020, 9:35 AM.

Details

Summary

When removing a non-constant store to a global in
CleanupPointerRootUsers(), the GlobalOpt pass could incorrectly return
false.

This was caught using the check introduced by D80916.

Diff Detail

Event Timeline

dstenb created this revision.Aug 18 2020, 9:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2020, 9:35 AM
dstenb requested review of this revision.Aug 18 2020, 9:35 AM
efriedma added inline comments.Aug 18 2020, 11:55 AM
llvm/test/Transforms/GlobalOpt/dead-store-status.ll
11

This test passes on master, I think?

dstenb added inline comments.Aug 18 2020, 11:41 PM
llvm/test/Transforms/GlobalOpt/dead-store-status.ll
11

Yes. The return status check is hidden under EXPENSIVE_CHECKS. With that enabled you get a failed assertion on this test case on master:

Script:
--
: 'RUN: at line 1';   /home/edasten/upstream/monorepo/build-expensive/bin/opt < /home/edasten/upstream/monorepo/llvm/test/Transforms/GlobalOpt/dead-store-status.ll -globalopt -S | /home/edasten/upstream/monorepo/build-expensive/bin/FileCheck /home/edasten/upstream/monorepo/llvm/test/Transforms/GlobalOpt/dead-store-status.ll
--
Exit Code: 2

Command Output (stderr):
--
opt: /home/edasten/upstream/monorepo/llvm/lib/IR/LegacyPassManager.cpp:1706: bool {anonymous}::MPPassManager::runOnModule(llvm::Module&): Assertion `(LocalChanged || (RefHash == StructuralHash(M))) && "Pass modifies its input and doesn't report it."' failed.

Should I perhaps add a comment about that?

efriedma accepted this revision.Aug 19 2020, 2:03 PM

LGTM

llvm/test/Transforms/GlobalOpt/dead-store-status.ll
11

Probably worth adding a short comment noting that this is depending on the EXPENSIVE_CEHCKS check.

Alternatively, have you considered sticking the check under a flag that the user could enable on non-EXPENSIVE_CHECKS builds? We do this in other contexts (e.g. MachineVerifier).

This revision is now accepted and ready to land.Aug 19 2020, 2:03 PM
dstenb added inline comments.Aug 19 2020, 2:52 PM
llvm/test/Transforms/GlobalOpt/dead-store-status.ll
11

Sorry, I have myself not been involved with the introduction of this check; I just encountered this issue and some others when using the check with our downstream target. Any thoughts on the above, @serge-sans-paille?

I'll land this with a comment added to the test case in the meanwhile.

This revision was automatically updated to reflect the committed changes.