Remove alignment from ctors/dtors lists in an attempt to placate LTO.
authorJohn McCall <rjmccall@apple.com>
Sat, 19 Nov 2016 20:12:25 +0000 (20:12 +0000)
committerJohn McCall <rjmccall@apple.com>
Sat, 19 Nov 2016 20:12:25 +0000 (20:12 +0000)
llvm-svn: 287458

clang/lib/CodeGen/CodeGenModule.cpp

index c931bbf..869f009 100644 (file)
@@ -756,9 +756,15 @@ void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) {
     ctors.add(ctor.finish());
   }
 
-  (void) ctors.finishAndCreateGlobal(GlobalName, getPointerAlign(),
-                                     /*constant*/ false,
-                                     llvm::GlobalValue::AppendingLinkage);
+  auto list =
+    ctors.finishAndCreateGlobal(GlobalName, getPointerAlign(),
+                                /*constant*/ false,
+                                llvm::GlobalValue::AppendingLinkage);
+
+  // The LTO linker doesn't seem to like it when we set an alignment
+  // on appending variables.  Take it off as a workaround.
+  list->setAlignment(0);
+
   Fns.clear();
 }