diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-23 21:47:46 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-23 21:47:46 +0000 |
commit | 248c719a6879d31fcdec760d46b8b50ec2d8761e (patch) | |
tree | e60c679f9cad19f9b1a5276736d19db58528f84b /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 4a75be24c98b2e285229160d41319c685d32797b (diff) | |
download | bcm5719-llvm-248c719a6879d31fcdec760d46b8b50ec2d8761e.tar.gz bcm5719-llvm-248c719a6879d31fcdec760d46b8b50ec2d8761e.zip |
Patch fixes an obscure bug when 'used' attribute is applied to
variables in ObjC's Next runtime mode. Next runtime also implicitly applies
'used' attribute on some of its meta-data. This results in two
'llvm.used' arrays to be generated, and one of them is renamed to
'llvm.used1'.
llvm-svn: 74008
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f926c05a998..0a531e9b21a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -406,11 +406,12 @@ void CodeGenModule::AddUsedGlobal(llvm::GlobalValue *GV) { void CodeGenModule::EmitLLVMUsed() { // Don't create llvm.used if there is no need. - if (LLVMUsed.empty()) + // FIXME. Runtime indicates that there might be more 'used' symbols; but not + // necessariy. So, this test is not accurate for emptiness. + if (LLVMUsed.empty() && !Runtime) return; llvm::Type *i8PTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); - llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, LLVMUsed.size()); // Convert LLVMUsed to what ConstantArray needs. std::vector<llvm::Constant*> UsedArray; @@ -420,6 +421,12 @@ void CodeGenModule::EmitLLVMUsed() { llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(&*LLVMUsed[i]), i8PTy); } + if (Runtime) + Runtime->MergeMetadataGlobals(UsedArray); + if (UsedArray.empty()) + return; + llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, UsedArray.size()); + llvm::GlobalVariable *GV = new llvm::GlobalVariable(ATy, false, llvm::GlobalValue::AppendingLinkage, |