[PATCH] D155528: [SimplifyCFG][FIX] Update GlobalsAA after an assumption was created

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 17:17:48 PDT 2023


jdoerfert created this revision.
jdoerfert added reviewers: nikic, aeubanks, jeroen.dobbelaere, paquette, fhahn.
Herald added subscribers: khei4, ormris, StephenFan, wenlei, steven_wu, bollu, hiraditya.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When SimplifyCFG, and probably other passes, create a call to
`llvm.assume` to retain some knowledge, they need to update the state of
GlobalsAA. If not, later passes might think the function is side-effect
free, or read only, which it is not, due to the `llvm.assume` call.
Deducing the wrong memory effects can lead to problems, e.g., hoisting
of a call and thereby introducing UB.

Fixes: https://github.com/llvm/llvm-project/issues/63925


https://reviews.llvm.org/D155528

Files:
  llvm/include/llvm/Analysis/GlobalsModRef.h
  llvm/include/llvm/Transforms/Utils/SimplifyCFGOptions.h
  llvm/lib/Analysis/GlobalsModRef.cpp
  llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Analysis/GlobalsModRef/simplify_cfg_add_assume_call.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/unittests/IR/PassManagerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155528.541278.patch
Type: text/x-patch
Size: 14533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230718/829896b5/attachment.bin>


More information about the llvm-commits mailing list