[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 12:36:03 PDT 2022


jdoerfert updated this revision to Diff 422006.
jdoerfert added a comment.

Handle optnone conservatively


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123531/new/

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,15 @@
           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.
+          // Similarly, if `nocallback` is missing the function, or intrinsic,
+          // can call into the module arbitrarily. If both are set the function
+          // has an effect but will not interact with accesses of internal
+          // globals inside the module. We are conservative here for optnone
+          // functions, might not be necessary.
+          if (!F->isDeclaration() || !F->hasNoSync() ||
+              !F->hasFnAttribute(Attribute::NoCallback)) {
             KnowNothing = true;
             break;
           }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123531.422006.patch
Type: text/x-patch
Size: 1088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220411/3413f962/attachment.bin>


More information about the llvm-commits mailing list