Hi,
currently the globals emitted by the __uuidof() operator have external
linkage. These globals should be linkonce_odr because they can be
defined by multiple TUs.
-Nico
>From 6e6e2705bd603e334fa037719b244485057f604a Mon Sep 17 00:00:00 2001
From: Nico Rieck <[email protected]>
Date: Mon, 2 Sep 2013 18:32:09 +0200
Subject: [PATCH] Emit uuid globals as linkonce_odr
---
lib/CodeGen/CodeGenModule.cpp | 2 +-
test/CodeGenCXX/microsoft-uuidof.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 465d98b..dbda1f6 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1091,7 +1091,7 @@ llvm::Constant *CodeGenModule::GetAddrOfUuidDescriptor(
llvm::GlobalVariable *GV = new llvm::GlobalVariable(
getModule(), Init->getType(),
- /*isConstant=*/true, llvm::GlobalValue::ExternalLinkage, Init, Name);
+ /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
return GV;
}
diff --git a/test/CodeGenCXX/microsoft-uuidof.cpp b/test/CodeGenCXX/microsoft-uuidof.cpp
index 75b77b2..ab3d9b6 100644
--- a/test/CodeGenCXX/microsoft-uuidof.cpp
+++ b/test/CodeGenCXX/microsoft-uuidof.cpp
@@ -33,7 +33,7 @@ GUID g = __uuidof(S1);
#endif
// First global use of __uuidof(S1) forces the creation of the global.
-// CHECK: @_GUID_12345678_1234_1234_1234_1234567890ab = constant { i32, i16, i16, [8 x i8] } { i32 305419896, i16 4660, i16 4660, [8 x i8] c"\124\124Vx\90\AB" }
+// CHECK: @_GUID_12345678_1234_1234_1234_1234567890ab = linkonce_odr constant { i32, i16, i16, [8 x i8] } { i32 305419896, i16 4660, i16 4660, [8 x i8] c"\124\124Vx\90\AB" }
// CHECK: @gr = constant %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to %struct._GUID*), align 4
const GUID& gr = __uuidof(S1);
@@ -49,7 +49,7 @@ const GUID& zeroiid = __uuidof(0);
// __uuidof(S2) hasn't been used globally yet, so it's emitted when it's used
// in a function and is emitted at the end of the globals section.
-// CHECK: @_GUID_87654321_4321_4321_4321_ba0987654321 = constant { i32, i16, i16, [8 x i8] } { i32 -2023406815, i16 17185, i16 17185, [8 x i8] c"C!\BA\09\87eC!" }
+// CHECK: @_GUID_87654321_4321_4321_4321_ba0987654321 = linkonce_odr constant { i32, i16, i16, [8 x i8] } { i32 -2023406815, i16 17185, i16 17185, [8 x i8] c"C!\BA\09\87eC!" }
// The static initializer for thing.
// CHECK-DEFINE-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* bitcast (%struct._GUID* @thing to i8*), i8* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ac to i8*), i32 16, i32 4, i1 false)
--
1.8.1.msysgit.1
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits