diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-12-12 22:57:31 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-12-12 22:57:31 +0000 |
commit | a549e315be9ca414677fc1af44eb7ab548ca5f9a (patch) | |
tree | 48dc9ccf2d43c333365b7c118074f78662710095 /llvm/lib/Bitcode/Writer | |
parent | dbe2bdf9e7333d8e4fac421201dbd04e0eed38bb (diff) | |
download | bcm5719-llvm-a549e315be9ca414677fc1af44eb7ab548ca5f9a.tar.gz bcm5719-llvm-a549e315be9ca414677fc1af44eb7ab548ca5f9a.zip |
Begin sketching out a bitcode verifier pass. Idea is to emit a .bc file and
then read the file back in to verify use-list serialization/deserialization.
llvm-svn: 146439
Diffstat (limited to 'llvm/lib/Bitcode/Writer')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeVerifier.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeVerifier.cpp b/llvm/lib/Bitcode/Writer/BitcodeVerifier.cpp new file mode 100644 index 00000000000..9296e2916a4 --- /dev/null +++ b/llvm/lib/Bitcode/Writer/BitcodeVerifier.cpp @@ -0,0 +1,54 @@ +//===--- Bitcode/Writer/BitcodeVerifier.cpp - Bitcode Writer ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// BitcodeVerifier implementation. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Pass.h" +#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +namespace { + struct VerifyBitcode : public ModulePass { + raw_ostream &OS; // raw_ostream to read from + public: + static char ID; // Pass identification, replacement for typeid + explicit VerifyBitcode(raw_ostream &o) + : ModulePass(ID), OS(o) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + } + + const char *getPassName() const { return "Bitcode Verifier"; } + + bool runOnModule(Module &M) { + Verify(M); + return false; + } + + void Verify(Module &M); + }; +} + +char VerifyBitcode::ID = 0; + +/// createBitcodeVerifierPass - Create a pass that writes a module to disk and +/// then reads the module back in to verify bitcode serialization and +/// deserialization. +ModulePass *llvm::createBitcodeVerifierPass(raw_ostream &Str) { + return new VerifyBitcode(Str); +} + +void VerifyBitcode::Verify(Module &M) { + dbgs() << "BitcodeVerifier!\n"; +} |