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 | b3025864e5765ad4e9d0958e96c4812aeda263f4 (patch) | |
tree | 842c40ffbd213848e71fb33fe2e3ff62526544b5 /lib/Bitcode | |
parent | 86d34100cf164f6ba5c0c2344b7dff86cc0a0980 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/Writer/BitcodeVerifier.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/Bitcode/Writer/BitcodeVerifier.cpp b/lib/Bitcode/Writer/BitcodeVerifier.cpp new file mode 100644 index 0000000000..9296e2916a --- /dev/null +++ b/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"; +} |