[NFC][IR] PHINode: assert we aren't trying to create token-typed PHI
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 27 Apr 2021 17:40:15 +0000 (20:40 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 27 Apr 2021 17:49:42 +0000 (20:49 +0300)
Verifier will complain, but by then it may be too late,
because we might have never reached it because
we already crashed with some bogus bug.
It is best to catch this the moment it happens.

llvm/include/llvm/IR/Instructions.h

index 14ba509..650746c 100644 (file)
@@ -2583,6 +2583,7 @@ class PHINode : public Instruction {
                    Instruction *InsertBefore = nullptr)
     : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertBefore),
       ReservedSpace(NumReservedValues) {
+    assert(!Ty->isTokenTy() && "PHI nodes cannot have token type!");
     setName(NameStr);
     allocHungoffUses(ReservedSpace);
   }