[cfe-commits] r146441 - in /cfe/trunk: include/clang/CodeGen/BackendUtil.h include/clang/CodeGen/CodeGenAction.h include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendOptions.h lib/CodeGen/BackendUtil.cpp lib/CodeGen/CodeGenAction.cpp lib/Frontend/CompilerInvocation.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp

Chad Rosier mcrosier at apple.com
Mon Dec 12 15:05:47 PST 2011


Author: mcrosier
Date: Mon Dec 12 17:05:47 2011
New Revision: 146441

URL: http://llvm.org/viewvc/llvm-project?rev=146441&view=rev
Log:
Add frontend flags to enable bitcode verifier pass.

Modified:
    cfe/trunk/include/clang/CodeGen/BackendUtil.h
    cfe/trunk/include/clang/CodeGen/CodeGenAction.h
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Frontend/FrontendOptions.h
    cfe/trunk/lib/CodeGen/BackendUtil.cpp
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Mon Dec 12 17:05:47 2011
@@ -25,6 +25,7 @@
   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

Modified: cfe/trunk/include/clang/CodeGen/CodeGenAction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenAction.h?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenAction.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenAction.h Mon Dec 12 17:05:47 2011
@@ -72,6 +72,11 @@
   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);

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Dec 12 17:05:47 2011
@@ -395,6 +395,9 @@
   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">,

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Mon Dec 12 17:05:47 2011
@@ -28,6 +28,7 @@
     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.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Dec 12 17:05:47 2011
@@ -373,7 +373,10 @@
     break;
 
   case Backend_EmitBC:
+  case Backend_EmitBCVerify:
     getPerModulePasses()->add(createBitcodeWriterPass(*OS));
+    if (Action == Backend_EmitBCVerify)
+      getPerModulePasses()->add(createBitcodeVerifierPass(*OS));
     break;
 
   case Backend_EmitLL:

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Dec 12 17:05:47 2011
@@ -301,6 +301,7 @@
   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 @@
 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) {}
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Dec 12 17:05:47 2011
@@ -406,6 +406,7 @@
   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 @@
       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:

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=146441&r1=146440&r2=146441&view=diff
==============================================================================
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Mon Dec 12 17:05:47 2011
@@ -43,6 +43,7 @@
   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();





More information about the cfe-commits mailing list