title: LLVM/Clang use opt to show linked ll file
body: <p>I had two c files and want show IR for its linked bit code</p>
  
  <p>link1.c</p>
  
  <pre><code>#include "link2.h"
  int main() {
    int a;
    int b;
    foo(a,b);
    return 0;
  }
  </code></pre>
  
  <p>link2.h</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  </code></pre>
  
  <p>link2.c</p>
  
  <pre><code>#include "link2.h"
  void foo(int a, int b) {
    printf("%d\n", a);
    printf("%d\n", b);
  }
  </code></pre>
  
  <p>I did the following command to get bc file.</p>
  
  <pre><code>clang -o0 -emit-llvm file1.c -c -o file1.bc
  clang -o0 -emit-llvm file2.c -c -o file2.bc
  llvm-link -o link.bc link1.bc link2.bc
  </code></pre>
  
  <p>When I tried <code>lli link.bc</code> and <code>llvm-dis link.bc</code> it run correctly and showed linked ll file, but when I use <code>opt link.bc -S -o link.ll</code> to get ll file it just reported segmentation error. Can anyone let me know what to do with <code>opt</code>?</p>