[llvm-commits] [llvm] r43578 - /llvm/trunk/lib/VMCore/Verifier.cpp
Chris Lattner
clattner at apple.com
Wed Oct 31 20:50:31 PDT 2007
On Oct 31, 2007, at 2:04 PM, Owen Anderson wrote:
> Author: resistor
> Date: Wed Oct 31 16:04:18 2007
> New Revision: 43578
>
> URL: http://llvm.org/viewvc/llvm-project?rev=43578&view=rev
> Log:
> Add a preverifier pass to check that every basic block ends in a
> terminator, so that we don't segfault when verifying invalid code.
Oh, for the love of tabs... The tabs are stabbing by eyeballs
out! :) :)
-Chris
>
> Modified:
> llvm/trunk/lib/VMCore/Verifier.cpp
>
> Modified: llvm/trunk/lib/VMCore/Verifier.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=43578&r1=43577&r2=43578&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Verifier.cpp (original)
> +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Oct 31 16:04:18 2007
> @@ -71,7 +71,25 @@
> cl::opt<bool>
> Pedantic("verify-pedantic",
> cl::desc("Reject code with undefined behaviour"));
> -
> +
> + struct VISIBILITY_HIDDEN PreVerifier : public FunctionPass {
> + static char ID; // Pass ID, replacement for typeid
> +
> + PreVerifier() : FunctionPass((intptr_t)&ID) { }
> +
> + bool runOnFunction(Function &F) {
> + for (Function::iterator I = F.begin(), E = F.end(); I != E; +
> +I)
> + assert(I->back().isTerminator()
> + && "Block does not end with a terminator?");
> +
> + return false;
> + }
> + };
> +
> + char PreVerifier::ID = 0;
> + RegisterPass<PreVerifier> PreVer("preverify", "Preliminary module
> verification");
> + const PassInfo *PreVerifyID = PreVer.getPassInfo();
> +
> struct VISIBILITY_HIDDEN
> Verifier : public FunctionPass, InstVisitor<Verifier> {
> static char ID; // Pass ID, replacement for typeid
> @@ -161,6 +179,7 @@
>
> virtual void getAnalysisUsage(AnalysisUsage &AU) const {
> AU.setPreservesAll();
> + AU.addRequiredID(PreVerifyID);
> if (RealPass)
> AU.addRequired<DominatorTree>();
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list