[PATCH] D123531: [GlobalsModRef][FIX] Ensure we honor synchronizing effects of intrinsics
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 11 11:38:33 PDT 2022
jdoerfert created this revision.
jdoerfert added reviewers: tra, arsenm, nikic, efriedma.
Herald added subscribers: bollu, hiraditya.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
This is a long standing problem that resurfaces once in a while [0].
There might actually be two problems because I'm not 100% sure if the
issue underlying https://reviews.llvm.org/D115302 would be solved by
this or not. Anyway.
In 2008 we thought intrinsics do not read/write globals passed to them:
https://github.com/llvm/llvm-project/commit/d4133ac31535ce5176f97e9fc81825af8a808760
This is not correct given that intrinsics can synchronize threads and
cause effects to effectively become visible.
NOTE: I did not yet modify any tests but only tried out the reproducer
of https://github.com/llvm/llvm-project/issues/54851.
Fixes: https://github.com/llvm/llvm-project/issues/54851
[0] https://discourse.llvm.org/t/bug-gvn-memdep-bug-in-the-presence-of-intrinsics/59402
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123531
Files:
llvm/lib/Analysis/GlobalsModRef.cpp
Index: llvm/lib/Analysis/GlobalsModRef.cpp
===================================================================
--- llvm/lib/Analysis/GlobalsModRef.cpp
+++ llvm/lib/Analysis/GlobalsModRef.cpp
@@ -533,7 +533,8 @@
FI.addModRefInfo(ModRefInfo::ModRef);
if (!F->onlyAccessesArgMemory())
FI.setMayReadAnyGlobal();
- if (!F->isIntrinsic()) {
+ // Intrinsics, like any other synchronizing function, can make effects of other threads visible. Without nosync we know nothing really.
+ if (!F->hasNoSync()) {
KnowNothing = true;
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123531.421987.patch
Type: text/x-patch
Size: 626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220411/26fa7aae/attachment.bin>
More information about the llvm-commits
mailing list