[PATCH] D10942: CodeGen: Test that we do not assign a comdat to available_externally globals.

Peter Collingbourne peter at pcc.me.uk
Fri Jul 3 20:46:19 PDT 2015


pcc created this revision.
pcc added a reviewer: majnemer.
pcc added a subscriber: cfe-commits.

>From the linker's perspective, an available_externally global is equivalent to
an external declaration, therefore it should not have a comdat. The presence
of a comdat can cause problems later on during LTO if a comdat containing
an available_externally global is chosen over a comdat containing a real
definition of the global.

Depends on http://reviews.llvm.org/D10941

http://reviews.llvm.org/D10942

Files:
  test/CodeGenCXX/microsoft-abi-static-initializers-available-externally.cpp

Index: test/CodeGenCXX/microsoft-abi-static-initializers-available-externally.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/microsoft-abi-static-initializers-available-externally.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -std=c++11 -emit-llvm -O %s -o - | FileCheck %s
+
+// CHECK: = available_externally
+// CHECK-NOT: comdat
+
+template <typename>
+class A {
+public:
+  static void f() { static int a = *new int; }
+};
+
+extern template class A<int>;
+void f() { A<int>::f(); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10942.29044.patch
Type: text/x-patch
Size: 578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150704/9cea154c/attachment.bin>


More information about the cfe-commits mailing list