summaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-14 16:53:48 +0000
committerChris Lattner <sabre@nondot.org>2002-03-14 16:53:48 +0000
commitfdec2468cee6503706c787a3d47237852621b244 (patch)
treeb2ae2f6dbcec5c0ce2356c20bc5f8e986988e25b /lib/VMCore/Verifier.cpp
parent754cf415f688d23b7bb2339b12599dc7cbb7e46c (diff)
downloadexternal_llvm-fdec2468cee6503706c787a3d47237852621b244.zip
external_llvm-fdec2468cee6503706c787a3d47237852621b244.tar.gz
external_llvm-fdec2468cee6503706c787a3d47237852621b244.tar.bz2
Add a check to ensure that only PHI nodes are self referential. Code
input to instruction combination was broken, which caused it to explode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1870 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r--lib/VMCore/Verifier.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 6e18a82..d7c209c 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -17,7 +17,7 @@
// . It should be illegal to put a label into any other type (like a structure)
// or to return one. [except constant arrays!]
// . Right now 'add bool 0, 0' is valid. This isn't particularly good.
-// . Only phi nodes can be self referential: 'add int %0, %0 ; <int>:0' is bad
+// * Only phi nodes can be self referential: 'add int %0, %0 ; <int>:0' is bad
// * PHI nodes must have an entry for each predecessor, with no extras.
// * All basic blocks should only end with terminator insts, not contain them
// * The entry node to a method must not have predecessors
@@ -119,7 +119,14 @@ static bool verifyInstruction(const Instruction *I) {
E = Preds.end(); I != E; ++I)
Assert2(0, "PHI node does not have entry for a predecessor basic block!",
PN, *I);
+ } else {
+ // Check that non-phi nodes are not self referential...
+ for (Value::use_const_iterator UI = I->use_begin(), UE = I->use_end();
+ UI != UE; ++UI)
+ Assert1(*UI != (const User*)I,
+ "Only PHI nodes may reference their own value!", I);
}
+
return Broken;
}