aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-02-15 11:54:49 +0000
committerDuncan Sands <baldrick@free.fr>2009-02-15 11:54:49 +0000
commita37d119f63c6aa1a6b93d4aa6ea0019b7bf5ee16 (patch)
tree2526245407b7a9136575b1d31a6bb25bdf0f2211 /lib/Transforms
parent7987e1a2c1fb1ee93b30ce95e82e2ce93cd687b4 (diff)
Make this more useful for cleaning up after the
one-definition-rule llvm-gcc changes (coming soon to a tree near you!). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 4208e9044e..b60982919e 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2405,26 +2405,16 @@ bool GlobalOpt::ResolveAliases(Module &M) {
if (J->hasInternalLinkage())
continue;
- // Be conservative and do not perform the transform if multiple aliases
- // potentially target the aliasee. TODO: Make this more aggressive.
+ // Do not perform the transform if multiple aliases potentially target the
+ // aliasee. This check also ensures that it is safe to replace the section
+ // and other attributes of the aliasee with those of the alias.
if (!hasOneUse)
continue;
- // Do not perform the transform if it would change the visibility.
- if (J->getVisibility() != Target->getVisibility())
- continue;
-
- // Do not perform the transform if it would change the section.
- if (J->hasSection() != Target->hasSection() ||
- (J->hasSection() && J->getSection() != Target->getSection()))
- continue;
-
- // Give the aliasee the name and linkage of the alias.
+ // Give the aliasee the name, linkage and other attributes of the alias.
Target->takeName(J);
Target->setLinkage(J->getLinkage());
-
- // The alignment is the only remaining attribute that may not match.
- Target->setAlignment(std::max(J->getAlignment(), Target->getAlignment()));
+ Target->GlobalValue::copyAttributesFrom(J);
// Delete the alias.
M.getAliasList().erase(J);