[PATCH] D129841: [GlobalOpt] Enable evaluation of atomic stores

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 18 20:33:06 PDT 2022


efriedma added a comment.

I think the LLVM model for "evaluating" global ctors is that we can reorder the constructor function so it runs strictly before before anything else in the program.   (Or in the case of dlopen(), that it runs strictly before anything else that can access a global in the library.)  Once we've imposed that ordering, it doesn't really matter if an operation is atomic; there's nothing else running anyway.  So all the memory operations are, as far as the program can tell, sequentially consistent.

I suspect the way we reorder llvm.global_ctors breaks the rules for C++ partially-ordered initialization, but that's a separate issue.

> so long as globalopt is limited to internal globals

There is no such restriction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129841



More information about the llvm-commits mailing list