diff options
| author | JF Bastien <jfb@chromium.org> | 2013-10-22 10:16:49 -0700 |
|---|---|---|
| committer | JF Bastien <jfb@chromium.org> | 2013-10-22 10:16:49 -0700 |
| commit | 7287c45c13dc887cebe3db6abfa2f1080186bb97 (patch) | |
| tree | d069a03bd84ecbebe825851feec883d38844bac3 /lib/Transforms/NaCl | |
| parent | 7c801d10ad719a7e0b875943b18504d7575524d9 (diff) | |
Make sure flatten globals doesn't insert uses of globals that previously had no uses.
This was the deeper cause of the issues I fixed in https://codereview.chromium.org/33233002/ and is therefore a better fix. (The problem was that StripDeadPrototypes was not stripping a variable that was actually dead because the bitcast constexpr inserted by FlattenGlobals referred to it.) I reverted most of that CL's changes, though not the comment and test cleanup.
R=dschuff@chromium.org
TEST= pnacl-clang++ pnacl/git/libcxx/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp -stdlib=libc++
Review URL: https://codereview.chromium.org/34843003
Diffstat (limited to 'lib/Transforms/NaCl')
| -rw-r--r-- | lib/Transforms/NaCl/FlattenGlobals.cpp | 5 | ||||
| -rw-r--r-- | lib/Transforms/NaCl/GlobalCleanup.cpp | 7 |
2 files changed, 4 insertions, 8 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; ) { |
