efriedma added inline comments.

================
Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:580
+    I = DelayedCXXInitPosition.find(D);
+    unsigned LexOrder = I == DelayedCXXInitPosition.end() ? ~0U : I->second;
+    AddGlobalCtor(Fn, 65535, LexOrder, COMDATKey);
----------------
ychen wrote:
> efriedma wrote:
> > This ensures delayed initialization calls are ordered relative to each 
> > other... but are they ordered correctly relative to non-delayed 
> > initialization calls?  I'm skeptical that using a LexOrder of "~0U" is 
> > really correct.  (For example, if you change the variable "b" in your 
> > testcase to a struct with a destructor.)
> Hmm, That's a great point. I didn't think of that. I'll take a look.
Using `CXXGlobalInits.size()` like this is sort of hard to reason about: 
multiple values can end up with the same LexOrder.  (I'm not sure if all the 
values with the same LexOrder end up sorted correctly.)

Instead of trying to reason about whether this is right, can we just use a 
separate counter to assign a unique index to each global init?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127233

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to