[cfe-commits] r123773 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGenCXX/global-init.cpp test/CodeGenObjC/constant-string-class.m
Rafael Espindola
rafael.espindola at gmail.com
Tue Jan 18 13:07:57 PST 2011
Author: rafael
Date: Tue Jan 18 15:07:57 2011
New Revision: 123773
URL: http://llvm.org/viewvc/llvm-project?rev=123773&view=rev
Log:
Add unnamed_addr in CreateRuntimeVariable.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/global-init.cpp
cfe/trunk/test/CodeGenObjC/constant-string-class.m
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=123773&r1=123772&r2=123773&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan 18 15:07:57 2011
@@ -922,7 +922,8 @@
llvm::Constant *
CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
const llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool UnnamedAddr) {
// Lookup the entry, lazily creating it if necessary.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry) {
@@ -933,6 +934,9 @@
WeakRefReferences.erase(Entry);
}
+ if (UnnamedAddr)
+ Entry->setUnnamedAddr(true);
+
if (Entry->getType() == Ty)
return Entry;
@@ -1008,7 +1012,8 @@
llvm::Constant *
CodeGenModule::CreateRuntimeVariable(const llvm::Type *Ty,
llvm::StringRef Name) {
- return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 0);
+ return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 0,
+ true);
}
void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=123773&r1=123772&r2=123773&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Jan 18 15:07:57 2011
@@ -519,7 +519,8 @@
GlobalDecl D);
llvm::Constant *GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
const llvm::PointerType *PTy,
- const VarDecl *D);
+ const VarDecl *D,
+ bool UnnamedAddr = false);
/// SetCommonAttributes - Set attributes which are common to any
/// form of a global definition (alias, Objective-C method,
Modified: cfe/trunk/test/CodeGenCXX/global-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/global-init.cpp?rev=123773&r1=123772&r2=123773&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/global-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/global-init.cpp Tue Jan 18 15:07:57 2011
@@ -12,6 +12,7 @@
struct D { ~D(); };
+// CHECK: @__dso_handle = external unnamed_addr global i8*
// CHECK: @c = global %struct.C zeroinitializer, align 8
// It's okay if we ever implement the IR-generation optimization to remove this.
Modified: cfe/trunk/test/CodeGenObjC/constant-string-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/constant-string-class.m?rev=123773&r1=123772&r2=123773&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/constant-string-class.m (original)
+++ cfe/trunk/test/CodeGenObjC/constant-string-class.m Tue Jan 18 15:07:57 2011
@@ -32,3 +32,4 @@
// CHECK-FRAGILE: @_FooClassReference = common global
// CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global
+// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = unnamed_addr global
More information about the cfe-commits
mailing list