diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-12-01 11:07:05 +0000 | 
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-12-01 11:07:05 +0000 | 
| commit | 06f9d4012fb8acea3e9861d5722b5965dbb724d9 (patch) | |
| tree | ffe0478472eaa0686f11cb02c6df7d257b8719b0 /lib/Transforms/IPO/GlobalOpt.cpp | |
| parent | 76e2e0ebfdd3d91b07a75822865ea3e9121a99ce (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
| -rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 442f2fb65528..4635d0e61c39 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1898,6 +1898,15 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) {      // Global variables without names cannot be referenced outside this module.      if (!GV->hasName() && !GV->isDeclaration())        GV->setLinkage(GlobalValue::InternalLinkage); +    // Simplify the initializer. +    if (GV->hasInitializer()) +      if (ConstantExpr *CE = dyn_cast<ConstantExpr>(GV->getInitializer())) { +        TargetData *TD = getAnalysisIfAvailable<TargetData>(); +        Constant *New = ConstantFoldConstantExpression(CE, TD); +        if (New && New != CE) +          GV->setInitializer(New); +      } +    // Do more involved optimizations if the global is internal.      if (!GV->isConstant() && GV->hasLocalLinkage() &&          GV->hasInitializer())        Changed |= ProcessInternalGlobal(GV, GVI); | 
