summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-13 23:00:51 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-13 23:00:51 +0000
commit7297b864a4a38271d2d4fb6be07c11841bf7c275 (patch)
treefb37643b643f103c6c52d96659db4d41788343ff /llvm/lib/Transforms/IPO/GlobalOpt.cpp
parent3c0ed76a9d433cabaf9df757055dbc3cbccbeed6 (diff)
downloadbcm5719-llvm-7297b864a4a38271d2d4fb6be07c11841bf7c275.tar.gz
bcm5719-llvm-7297b864a4a38271d2d4fb6be07c11841bf7c275.zip
Retain the name of the new internal global that's been shrunk.
It's possible (e.g. after an LTO build) that an internal global may be used for debugging purposes. If that's the case appending a '.b' to it makes it hard to find that variable. Steal the name from the old GV before deleting it so that they can find that variable again. llvm-svn: 175104
Diffstat (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index c753e2a85db..2b9d6670cae 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1846,10 +1846,10 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
bool StoringOther = SI->getOperand(0) == OtherVal;
// Only do this if we weren't storing a loaded value.
Value *StoreVal;
- if (StoringOther || SI->getOperand(0) == InitVal)
+ if (StoringOther || SI->getOperand(0) == InitVal) {
StoreVal = ConstantInt::get(Type::getInt1Ty(GV->getContext()),
StoringOther);
- else {
+ } else {
// Otherwise, we are storing a previously loaded copy. To do this,
// change the copy from copying the original value to just copying the
// bool.
@@ -1888,6 +1888,9 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
UI->eraseFromParent();
}
+ // Retain the name of the old global variable. People who are debugging their
+ // programs may expect these variables to be named the same.
+ NewGV->takeName(GV);
GV->eraseFromParent();
return true;
}
OpenPOWER on IntegriCloud