diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-12-12 23:05:47 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-12-12 23:05:47 +0000 |
commit | ff7892758f1e46221b552486c1e329db92147ebc (patch) | |
tree | 90d93af406f805b3628f2d2fcfa5c758095c4059 | |
parent | 8ef8f431aaeed3d7418959c81dfaa677b44f05ed (diff) |
Add frontend flags to enable bitcode verifier pass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146441 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/CodeGen/BackendUtil.h | 1 | ||||
-rw-r--r-- | include/clang/CodeGen/CodeGenAction.h | 5 | ||||
-rw-r--r-- | include/clang/Driver/CC1Options.td | 3 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendOptions.h | 1 | ||||
-rw-r--r-- | lib/CodeGen/BackendUtil.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenAction.cpp | 4 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | lib/FrontendTool/ExecuteCompilerInvocation.cpp | 1 |
8 files changed, 21 insertions, 0 deletions
diff --git a/include/clang/CodeGen/BackendUtil.h b/include/clang/CodeGen/BackendUtil.h index 135b6a927f..85f8aa0803 100644 --- a/include/clang/CodeGen/BackendUtil.h +++ b/include/clang/CodeGen/BackendUtil.h @@ -25,6 +25,7 @@ namespace clang { enum BackendAction { Backend_EmitAssembly, ///< Emit native assembly files Backend_EmitBC, ///< Emit LLVM bitcode files + Backend_EmitBCVerify, ///< Emit LLVM bitcode files and verify Backend_EmitLL, ///< Emit human-readable LLVM assembly Backend_EmitNothing, ///< Don't emit anything (benchmarking mode) Backend_EmitMCNull, ///< Run CodeGen, but don't emit anything diff --git a/include/clang/CodeGen/CodeGenAction.h b/include/clang/CodeGen/CodeGenAction.h index 9697bc62af..6545a470f5 100644 --- a/include/clang/CodeGen/CodeGenAction.h +++ b/include/clang/CodeGen/CodeGenAction.h @@ -72,6 +72,11 @@ public: EmitBCAction(llvm::LLVMContext *_VMContext = 0); }; +class EmitBCVerifyAction : public CodeGenAction { +public: + EmitBCVerifyAction(llvm::LLVMContext *_VMContext = 0); +}; + class EmitLLVMAction : public CodeGenAction { public: EmitLLVMAction(llvm::LLVMContext *_VMContext = 0); diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index e8c5398dec..ad891272b1 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -395,6 +395,9 @@ def emit_llvm : Flag<"-emit-llvm">, HelpText<"Build ASTs then convert to LLVM, emit .ll file">; def emit_llvm_bc : Flag<"-emit-llvm-bc">, HelpText<"Build ASTs then convert to LLVM, emit .bc file">; +def emit_llvm_bc_verify : Flag<"-emit-llvm-bc-verify">, + HelpText<"Build ASTs then convert to LLVM, emit .bc file" + " and finally verify bitcode serialization/deserialization">; def emit_llvm_only : Flag<"-emit-llvm-only">, HelpText<"Build ASTs and convert to LLVM, discarding output">; def emit_codegen_only : Flag<"-emit-codegen-only">, diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index fa6d044ce0..0af5b4574c 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -28,6 +28,7 @@ namespace frontend { DumpTokens, ///< Dump out preprocessed tokens. EmitAssembly, ///< Emit a .s file. EmitBC, ///< Emit a .bc file. + EmitBCVerify, ///< Emit and verify .bc file. EmitHTML, ///< Translate input source into HTML. EmitLLVM, ///< Emit a .ll file. EmitLLVMOnly, ///< Generate LLVM IR, but do not emit anything. diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 5ef72d486e..54150e426b 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -373,7 +373,10 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) { break; case Backend_EmitBC: + case Backend_EmitBCVerify: getPerModulePasses()->add(createBitcodeWriterPass(*OS)); + if (Action == Backend_EmitBCVerify) + getPerModulePasses()->add(createBitcodeVerifierPass(*OS)); break; case Backend_EmitLL: diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index 2ddcc3e5dc..3d21ef9af3 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -301,6 +301,7 @@ static raw_ostream *GetOutputStream(CompilerInstance &CI, case Backend_EmitLL: return CI.createDefaultOutputFile(false, InFile, "ll"); case Backend_EmitBC: + case Backend_EmitBCVerify: return CI.createDefaultOutputFile(true, InFile, "bc"); case Backend_EmitNothing: return 0; @@ -412,6 +413,9 @@ EmitAssemblyAction::EmitAssemblyAction(llvm::LLVMContext *_VMContext) EmitBCAction::EmitBCAction(llvm::LLVMContext *_VMContext) : CodeGenAction(Backend_EmitBC, _VMContext) {} +EmitBCVerifyAction::EmitBCVerifyAction(llvm::LLVMContext *_VMContext) + : CodeGenAction(Backend_EmitBCVerify, _VMContext) {} + EmitLLVMAction::EmitLLVMAction(llvm::LLVMContext *_VMContext) : CodeGenAction(Backend_EmitLL, _VMContext) {} diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 797147e5af..85475ad02b 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -406,6 +406,7 @@ static const char *getActionName(frontend::ActionKind Kind) { case frontend::DumpTokens: return "-dump-tokens"; case frontend::EmitAssembly: return "-S"; case frontend::EmitBC: return "-emit-llvm-bc"; + case frontend::EmitBCVerify: return "-emit-llvm-bc-verify"; case frontend::EmitHTML: return "-emit-html"; case frontend::EmitLLVM: return "-emit-llvm"; case frontend::EmitLLVMOnly: return "-emit-llvm-only"; @@ -1269,6 +1270,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, Opts.ProgramAction = frontend::EmitAssembly; break; case OPT_emit_llvm_bc: Opts.ProgramAction = frontend::EmitBC; break; + case OPT_emit_llvm_bc_verify: + Opts.ProgramAction = frontend::EmitBCVerify; break; case OPT_emit_html: Opts.ProgramAction = frontend::EmitHTML; break; case OPT_emit_llvm: diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index fec12e3b11..52c5624c16 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -43,6 +43,7 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) { case DumpTokens: return new DumpTokensAction(); case EmitAssembly: return new EmitAssemblyAction(); case EmitBC: return new EmitBCAction(); + case EmitBCVerify: return new EmitBCVerifyAction(); case EmitHTML: return new HTMLPrintAction(); case EmitLLVM: return new EmitLLVMAction(); case EmitLLVMOnly: return new EmitLLVMOnlyAction(); |