aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-12-12 02:53:41 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-12-12 02:53:41 +0000
commitad36cf9e7028365ac0c8fb3107a939a22c69d58a (patch)
tree6d341fef7453b7584a50ffb20365a078f8f56413 /lib
parent01b27de35c6595dbf5f34ed6e00c3d6bd8a7a25c (diff)
downloadexternal_llvm-ad36cf9e7028365ac0c8fb3107a939a22c69d58a.zip
external_llvm-ad36cf9e7028365ac0c8fb3107a939a22c69d58a.tar.gz
external_llvm-ad36cf9e7028365ac0c8fb3107a939a22c69d58a.tar.bz2
Don't muck with phi nodes; bug fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44905 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 37a645f..47e60cd 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -930,8 +930,8 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
return false;
// Only safe to perform the optimization if the source is also defined in
- // this block.
- if (DefBB != cast<Instruction>(Src)->getParent())
+ // this block.
+ if (!isa<Instruction>(Src) || DefBB != cast<Instruction>(Src)->getParent())
return false;
bool DefIsLiveOut = false;
@@ -948,6 +948,15 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
if (!DefIsLiveOut)
return false;
+ // Make sure non of the uses are PHI nodes.
+ for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end();
+ UI != E; ++UI) {
+ Instruction *User = cast<Instruction>(*UI);
+ if (User->getParent() == DefBB) continue;
+ if (isa<PHINode>(User))
+ return false;
+ }
+
// InsertedTruncs - Only insert one trunc in each block once.
DenseMap<BasicBlock*, Instruction*> InsertedTruncs;