diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /lib/Transforms/Scalar/BDCE.cpp | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/Scalar/BDCE.cpp')
| -rw-r--r-- | lib/Transforms/Scalar/BDCE.cpp | 18 | 
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/BDCE.cpp b/lib/Transforms/Scalar/BDCE.cpp index 2e5618686ec2..851efa000f65 100644 --- a/lib/Transforms/Scalar/BDCE.cpp +++ b/lib/Transforms/Scalar/BDCE.cpp @@ -20,11 +20,8 @@  #include "llvm/ADT/Statistic.h"  #include "llvm/Analysis/DemandedBits.h"  #include "llvm/Analysis/GlobalsModRef.h" -#include "llvm/IR/CFG.h"  #include "llvm/IR/InstIterator.h"  #include "llvm/IR/Instructions.h" -#include "llvm/IR/IntrinsicInst.h" -#include "llvm/IR/Operator.h"  #include "llvm/Pass.h"  #include "llvm/Support/Debug.h"  #include "llvm/Support/raw_ostream.h" @@ -48,8 +45,18 @@ static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {      // If all bits of a user are demanded, then we know that nothing below that      // in the def-use chain needs to be changed.      auto *J = dyn_cast<Instruction>(JU); -    if (J && !DB.getDemandedBits(J).isAllOnesValue()) +    if (J && J->getType()->isSized() && +        !DB.getDemandedBits(J).isAllOnesValue())        WorkList.push_back(J); + +    // Note that we need to check for unsized types above before asking for +    // demanded bits. Normally, the only way to reach an instruction with an +    // unsized type is via an instruction that has side effects (or otherwise +    // will demand its input bits). However, if we have a readnone function +    // that returns an unsized type (e.g., void), we must avoid asking for the +    // demanded bits of the function call's return value. A void-returning +    // readnone function is always dead (and so we can stop walking the use/def +    // chain here), but the check is necessary to avoid asserting.    }    // DFS through subsequent users while tracking visits to avoid cycles. @@ -70,7 +77,8 @@ static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {        // If all bits of a user are demanded, then we know that nothing below        // that in the def-use chain needs to be changed.        auto *K = dyn_cast<Instruction>(KU); -      if (K && !Visited.count(K) && !DB.getDemandedBits(K).isAllOnesValue()) +      if (K && !Visited.count(K) && K->getType()->isSized() && +          !DB.getDemandedBits(K).isAllOnesValue())          WorkList.push_back(K);      }    }  | 
