diff options
| author | Tim Northover <tnorthover@apple.com> | 2017-05-22 21:28:08 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2017-05-22 21:28:08 +0000 |
| commit | 997f5f10c6de8f0327225ff4e03582272094811a (patch) | |
| tree | 269bb12909c545959c8fbe668d8c5d487a21f727 /llvm/lib/Analysis | |
| parent | f12ac5b77612c9dbdbbf7f34cfda4a96d5cdc732 (diff) | |
| download | bcm5719-llvm-997f5f10c6de8f0327225ff4e03582272094811a.tar.gz bcm5719-llvm-997f5f10c6de8f0327225ff4e03582272094811a.zip | |
InstructionSimplify: don't speculate about Constants changing.
When presented with an icmp/select pair, we can end up asking what would happen
if we replaced one constant with another in an instruction. This is a mistake,
while non-constant Values could become a constant, constants cannot change and
trying to do so can lead to completely invalid IR (a GEP referencing a
non-existant field in the original case).
llvm-svn: 303580
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 2e72d5aa826..69aa5b98d28 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3539,6 +3539,10 @@ static const Value *SimplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, if (V == Op) return RepOp; + // We cannot replace a constant, and shouldn't even try. + if (isa<Constant>(Op)) + return nullptr; + auto *I = dyn_cast<Instruction>(V); if (!I) return nullptr; |

