[PATCH] Don't perform init-order checking for globals with no user-defined constructors.

Alexey Samsonov samsonov at google.com
Thu Apr 4 04:01:25 PDT 2013



================
Comment at: lib/CodeGen/CodeGenModule.cpp:1823
@@ +1822,3 @@
+      const CXXConstructorDecl *CD = E->getConstructor();
+      IsTrivialDefaultCtor = (CD->isTrivial() && CD->isDefaultConstructor());
+    }
----------------
Richard Smith wrote:
> This should never happen -- NeedsGlobalCtor should be false if the initialization is trivial. If not, we should fix EmitConstantInit to handle this case.
Ok. EmitConstantInit() had an explicit check that the destructor should be trivial. I looked at callers of this function, and it doesn't seem to be needed at first glance. Deleting it.

================
Comment at: lib/CodeGen/CodeGenModule.cpp:1816
@@ -1819,3 +1815,3 @@
   // If we are compiling with ASan, add metadata indicating dynamically
-  // initialized globals.
+  // initialized globals. Do this before we emit initializer function.
   if (SanOpts.Address && NeedsGlobalCtor) {
----------------
Richard Smith wrote:
> Why does this need to be before we emit the initializer?
InitDecl->getInit() doesn't cast to CXXConstructExpr after we called EmitCXXGlobalVarDeclInitFunc. Reverting all changes in this file anyway.


http://llvm-reviews.chandlerc.com/D608



More information about the cfe-commits mailing list