aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-02-03 18:07:49 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-02-03 18:07:49 +0000
commit45206ecf708bf03b04db07c2476b9f862127a8b1 (patch)
tree3e84567fa2c7e2f4128aa39a70f177b017e66387 /lib/CodeGen/CGDecl.cpp
parent07da367ca230b88d4b056dd79fefa4f10ab88b7a (diff)
Targets that don't have stack use global address space for parameters.
Specify external linkage for such globals so that llvm optimizer do not assume there values initialized as zero. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63636 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 6774f33337..898c1bfd80 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -77,7 +77,9 @@ void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) {
llvm::GlobalValue *
CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D,
bool NoInit,
- const char *Separator) {
+ const char *Separator,
+ llvm::GlobalValue
+ ::LinkageTypes Linkage) {
QualType Ty = D.getType();
assert(Ty->isConstantSizeType() && "VLAs can't be static");
@@ -108,7 +110,7 @@ CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D,
llvm::GlobalValue *GV =
new llvm::GlobalVariable(Init->getType(), false,
- llvm::GlobalValue::InternalLinkage,
+ Linkage,
Init, ContextName + Separator +D.getNameAsString(),
&CGM.getModule(), 0, Ty.getAddressSpace());
@@ -120,7 +122,9 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
- llvm::GlobalValue *GV = GenerateStaticBlockVarDecl(D, false, ".");
+ llvm::GlobalValue *GV;
+ GV = GenerateStaticBlockVarDecl(D, false, ".",
+ llvm::GlobalValue::InternalLinkage);
if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) {
SourceManager &SM = CGM.getContext().getSourceManager();
@@ -166,7 +170,9 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
// Targets that don't support recursion emit locals as globals.
const char *Class =
D.getStorageClass() == VarDecl::Register ? ".reg." : ".auto.";
- DeclPtr = GenerateStaticBlockVarDecl(D, true, Class);
+ DeclPtr = GenerateStaticBlockVarDecl(D, true, Class,
+ llvm::GlobalValue
+ ::InternalLinkage);
}
if (Ty->isVariablyModifiedType())
@@ -232,7 +238,11 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
// Variable sized values always are passed by-reference.
DeclPtr = Arg;
} else if (Target.useGlobalsForAutomaticVariables()) {
- DeclPtr = GenerateStaticBlockVarDecl(D, true, ".arg.");
+ // Targets that don't have stack use global address space for parameters.
+ // Specify external linkage for such globals so that llvm optimizer do
+ // not assume there values initialized as zero.
+ DeclPtr = GenerateStaticBlockVarDecl(D, true, ".arg.",
+ llvm::GlobalValue::ExternalLinkage);
} else {
// A fixed sized single-value variable becomes an alloca in the entry block.
const llvm::Type *LTy = ConvertType(Ty);