forked from OSchip/llvm-project
Add unnamed_addr in CreateRuntimeVariable.
llvm-svn: 123773
This commit is contained in:
parent
e6290ccf9b
commit
d661a853fd
|
@ -922,7 +922,8 @@ static bool DeclIsConstantGlobal(ASTContext &Context, const VarDecl *D) {
|
|||
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 @@ CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
|
|||
WeakRefReferences.erase(Entry);
|
||||
}
|
||||
|
||||
if (UnnamedAddr)
|
||||
Entry->setUnnamedAddr(true);
|
||||
|
||||
if (Entry->getType() == Ty)
|
||||
return Entry;
|
||||
|
||||
|
@ -1008,7 +1012,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
|
|||
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) {
|
||||
|
|
|
@ -519,7 +519,8 @@ private:
|
|||
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,
|
||||
|
|
|
@ -12,6 +12,7 @@ struct C { void *field; };
|
|||
|
||||
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.
|
||||
|
|
|
@ -32,3 +32,4 @@ int main () {
|
|||
|
||||
// CHECK-FRAGILE: @_FooClassReference = common global
|
||||
// CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global
|
||||
// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = unnamed_addr global
|
||||
|
|
Loading…
Reference in New Issue