diff options
author | Owen Anderson <resistor@mac.com> | 2007-06-19 07:35:36 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2007-06-19 07:35:36 +0000 |
commit | d0954105f0b1fb72008e2f734ed34510309d5048 (patch) | |
tree | d1161a16bf89e1050d8e68c013fa16ebc16e31a7 | |
parent | 20c2b35c2f2cfeda290ae3e4c08a80cd85a4785b (diff) | |
download | external_llvm-d0954105f0b1fb72008e2f734ed34510309d5048.zip external_llvm-d0954105f0b1fb72008e2f734ed34510309d5048.tar.gz external_llvm-d0954105f0b1fb72008e2f734ed34510309d5048.tar.bz2 |
Handle constants in phi nodes properly. This fixes test/Transforms/GVNPRE/2007-06-18-ConstantInPhi.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37655 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/GVNPRE.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp index 9b06664..15fecca 100644 --- a/lib/Transforms/Scalar/GVNPRE.cpp +++ b/lib/Transforms/Scalar/GVNPRE.cpp @@ -927,7 +927,16 @@ bool GVNPRE::runOnFunction(Function &F) { for (std::set<Value*>::iterator I = S.begin(), E = S.end(); I != E; ++I) { - if (find_leader(anticIn, VN.lookup(*I)) == 0) + // For non-opaque values, we should already have a value numbering. + // However, for opaques, such as constants within PHI nodes, it is + // possible that they have not yet received a number. Make sure they do + // so now. + uint32_t valNum = 0; + if (isa<BinaryOperator>(*I) || isa<CmpInst>(*I)) + valNum = VN.lookup(*I); + else + valNum = VN.lookup_or_add(*I); + if (find_leader(anticIn, valNum) == 0) val_insert(anticIn, *I); } |