aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/NaCl/FlattenGlobals.cpp5
-rw-r--r--lib/Transforms/NaCl/GlobalCleanup.cpp7
-rw-r--r--test/Transforms/NaCl/globalcleanup.ll8
3 files changed, 4 insertions, 16 deletions
diff --git a/lib/Transforms/NaCl/FlattenGlobals.cpp b/lib/Transforms/NaCl/FlattenGlobals.cpp
index 74ecda168e..11d4466235 100644
--- a/lib/Transforms/NaCl/FlattenGlobals.cpp
+++ b/lib/Transforms/NaCl/FlattenGlobals.cpp
@@ -286,8 +286,9 @@ bool FlattenGlobals::runOnModule(Module &M) {
NewGlobal->setAlignment(DL.getPrefTypeAlignment(GlobalType));
NewGlobal->setExternallyInitialized(Global->isExternallyInitialized());
NewGlobal->takeName(Global);
- Global->replaceAllUsesWith(
- ConstantExpr::getBitCast(NewGlobal, Global->getType()));
+ if (!Global->use_empty())
+ Global->replaceAllUsesWith(
+ ConstantExpr::getBitCast(NewGlobal, Global->getType()));
Global->eraseFromParent();
}
return Modified;
diff --git a/lib/Transforms/NaCl/GlobalCleanup.cpp b/lib/Transforms/NaCl/GlobalCleanup.cpp
index d3c58b400a..d489fefc1d 100644
--- a/lib/Transforms/NaCl/GlobalCleanup.cpp
+++ b/lib/Transforms/NaCl/GlobalCleanup.cpp
@@ -84,12 +84,7 @@ bool GlobalCleanup::runOnModule(Module &M) {
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ) {
GlobalVariable *GV = I++;
- if (GV->use_empty()) {
- GV->eraseFromParent();
- Modified = true;
- } else {
- Modified |= CleanUpLinkage(GV);
- }
+ Modified |= CleanUpLinkage(GV);
}
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
diff --git a/test/Transforms/NaCl/globalcleanup.ll b/test/Transforms/NaCl/globalcleanup.ll
index 7e1fa3d8a5..5f976e22da 100644
--- a/test/Transforms/NaCl/globalcleanup.ll
+++ b/test/Transforms/NaCl/globalcleanup.ll
@@ -16,14 +16,6 @@
; CHECK: @weak_gv = internal global
@weak_gv = weak global i32 0
-; Libc++'s declarations of iostream values are purely ``extern`` and
-; unused otherwise which led to a bug when used as ``(void)std::clog``:
-; the global would survive as ``external global`` post-link but without
-; a proper definition. Global cleanup should take care of it.
-; GV-NOT: ostream
-%"class.fake_ostream" = type { i32 }
-@ostream = external global %"class.fake_ostream"
-
; CHECK: define void @_start
define void @_start() {
ret void