<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Clang should include more information about the target in the IR to help reproducing issues"
   href="http://llvm.org/bugs/show_bug.cgi?id=19483">19483</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang should include more information about the target in the IR to help reproducing issues
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>qcolombet@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12409" name="attach_12409" title="An example">attachment 12409</a> <a href="attachment.cgi?id=12409&action=edit" title="An example">[details]</a></span>
An example

It would be nice if we could have the exact same codegen from ‘clang -S’ and
'clang -S -emit-llvm | llc’.

Currently, clang sets the triple information and some function attributes in
the IR file, but this is not enough. In particular, the target features as well
as the cpu are important pieces of information that are missing.

One can get this information with 'clang -v’, but this does not fit nicely in
the work flow.

I’ve attached an example that demonstrates that on MacOS X:
clang -O3 -S -o orig.s reproduce.c -arch x86_64h
clang -O3 -S -o - reproduce.c -arch x86_64h -emit-llvm | llc -o new.s
diff -U 10 orig.s new.s
--- orig.s    2014-04-18 16:53:31.000000000 -0700
+++ new.s    2014-04-18 16:52:56.000000000 -0700
@@ -6,20 +6,20 @@
     .cfi_startproc
 ## BB#0:                                ## %entry
     pushq    %rbp
 Ltmp0:
     .cfi_def_cfa_offset 16
 Ltmp1:
     .cfi_offset %rbp, -16
     movq    %rsp, %rbp
 Ltmp2:
     .cfi_def_cfa_register %rbp
-    vxorps    %xmm0, %xmm0, %xmm0
-    vxorps    %xmm1, %xmm1, %xmm1
-    vxorps    %xmm2, %xmm2, %xmm2
-    vxorps    %xmm3, %xmm3, %xmm3
+    xorps    %xmm0, %xmm0
+    xorps    %xmm1, %xmm1
+    xorps    %xmm2, %xmm2
+    xorps    %xmm3, %xmm3
     popq    %rbp
     jmp    _bar                    ## TAILCALL
     .cfi_endproc

clang -O3 -S -o orig.s reproduce.c -arch arm64
clang -O3 -S -o - reproduce.c -arch arm64 -emit-llvm | llc -o new.s
diff -U 10 orig.s new.s
--- orig.s    2014-04-18 17:11:18.000000000 -0700
+++ new.s    2014-04-18 17:11:53.000000000 -0700
@@ -1,14 +1,14 @@
     .section    __TEXT,__text,regular,pure_instructions
     .ios_version_min 5, 0
     .globl    _foo
     .align    2
 _foo:                                   ; @foo
 ; BB#0:                                 ; %entry
-    movi.2d    v0, #0000000000000000
-    movi.2d    v1, #0000000000000000
-    movi.2d    v2, #0000000000000000
-    movi.2d    v3, #0000000000000000
+    fmov    d0, xzr
+    orr.16b    v1, v0, v0
+    orr.16b    v2, v0, v0
+    orr.16b    v3, v0, v0
     b    _bar


 .subsections_via_symbols</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>