title: Make an LLVM ModulePass available on clang command line
body: <p>I have a ModulePass that's working with the opt tool, but I'm having trouble figuring out how to make it available to clang at the command line. My current workflow for using my pass is:</p>
  
  <ol>
  <li>clang -c -emit-llvm [c-source code files]</li>
  <li>llvm-link [llvm bitcode files]</li>
  <li>opt -load [PassName].so -[pass-name] [linked llvm file]</li>
  <li>llc [resulting bitcode file]</li>
  <li>gcc [resulting assembler file] -o [target]</li>
  </ol>
  
  <p>I would like to get my pass integrated with the clang command line so that it could be invoked as part of the build of existing software (e.g. c++ standard library) without having to remake the whole build system for each thing I compile. I've seen hints about how to do this, but I haven't been able to put the pieces together into a working setup.</p>
  
  <p><a href="http://homes.cs.washington.edu/~asampson/blog/clangpass.html" rel="nofollow noreferrer">Run an LLVM Pass Automatically with Clang</a> describes exactly what I want, but the method appears to be deprecated in LLVM 3.4 (PassManagerBuilder has been moved to the legacy namespace).</p>
  
  <p><a href="https://stackoverflow.com/questions/23130821/llvm-run-own-pass-automatically-with-clang">LLVM - Run Own Pass automatically with clang</a> seems to address the basic issue, but I was hoping I could do this without having to modify clang (which seems to be what's suggested there).</p>
  
  <p>What is the best way to make a new pass available from clang using LLVM 3.4?</p>