summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/BDCE.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2015-02-18 03:12:28 +0000
committerHal Finkel <hfinkel@anl.gov>2015-02-18 03:12:28 +0000
commit4393559621a3b2784086ba4d30be635426d2da31 (patch)
tree4458f87bf55f553d3279f1406b3e80d509043cd3 /llvm/lib/Transforms/Scalar/BDCE.cpp
parent5927e7b6815d19c5381053d948925b621d17bdfc (diff)
downloadbcm5719-llvm-4393559621a3b2784086ba4d30be635426d2da31.tar.gz
bcm5719-llvm-4393559621a3b2784086ba4d30be635426d2da31.zip
[BDCE] Don't forget uses of root instructions seen before the instruction itself
When visiting the initial list of "root" instructions (those which must always be alive), for those that are integer-valued (such as invokes returning an integer), we mark their bits as (initially) all dead (we might, obviously, find uses of those bits later, but all bits are assumed dead until proven otherwise). Don't do so, however, if we're already seen a use of those bits by another root instruction (such as a store). Fixes a miscompile of the sanitizer unit tests on x86_64. Also, add a debug line for visiting the root instructions, and remove a debug line which tried to print instructions being removed (printing dead instructions is dangerous, and can sometimes crash). llvm-svn: 229618
Diffstat (limited to 'llvm/lib/Transforms/Scalar/BDCE.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/BDCE.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp
index afe0cd13e22..e5a7ad6388d 100644
--- a/llvm/lib/Transforms/Scalar/BDCE.cpp
+++ b/llvm/lib/Transforms/Scalar/BDCE.cpp
@@ -277,13 +277,17 @@ bool BDCE::runOnFunction(Function& F) {
if (!isAlwaysLive(&I))
continue;
+ DEBUG(dbgs() << "BDCE: Root: " << I);
// For integer-valued instructions, set up an initial empty set of alive
// bits and add the instruction to the work list. For other instructions
// add their operands to the work list (for integer values operands, mark
// all bits as live).
if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) {
- AliveBits[&I] = APInt(IT->getBitWidth(), 0);
- Worklist.push_back(&I);
+ if (!AliveBits.count(&I)) {
+ AliveBits[&I] = APInt(IT->getBitWidth(), 0);
+ Worklist.push_back(&I);
+ }
+
continue;
}
@@ -388,7 +392,6 @@ bool BDCE::runOnFunction(Function& F) {
if (isAlwaysLive(&I))
continue;
- DEBUG(dbgs() << "BDCE: Removing: " << I << " (unused)\n");
Worklist.push_back(&I);
I.dropAllReferences();
Changed = true;
OpenPOWER on IntegriCloud