[cfe-commits] r63636 - in /cfe/trunk/lib/CodeGen: CGDecl.cpp CodeGenFunction.h
Sanjiv Gupta
sanjiv.gupta at microchip.com
Tue Feb 3 10:07:51 PST 2009
Author: sgupta
Date: Tue Feb 3 12:07:49 2009
New Revision: 63636
URL: http://llvm.org/viewvc/llvm-project?rev=63636&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=63636&r1=63635&r2=63636&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Feb 3 12:07:49 2009
@@ -77,7 +77,9 @@
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 @@
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 @@
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 @@
// 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 @@
// 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);
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=63636&r1=63635&r2=63636&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Feb 3 12:07:49 2009
@@ -627,9 +627,11 @@
/// GenerateStaticBlockVarDecl - return the the static
/// declaration of local variable.
- llvm::GlobalValue *GenerateStaticBlockVarDecl(const VarDecl &D,
- bool NoInit,
- const char *Separator);
+ llvm::GlobalValue * GenerateStaticBlockVarDecl(const VarDecl &D,
+ bool NoInit,
+ const char *Separator,
+ llvm::GlobalValue
+ ::LinkageTypes Linkage);
// GenerateStaticCXXBlockVarDecl - return the static declaration of
// a local variable. Performs initialization of the variable if necessary.
More information about the cfe-commits
mailing list