<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/96912>96912</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [DirectX backend] Illegal Dwarf Version emitted to final dxil.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:DirectX
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          python3kgae
      </td>
    </tr>
</table>

<pre>
    Module flag !{i32 7, !"Dwarf Version", i32 5} could be send to DirectX backend in [Module Flags Metadata](https://llvm.org/docs/LangRef.html#id2008).

There're 2 things DXIL not supported due to DXIL is based on llvm 3.7.
1. The behavior flag 7 (Max).
    llvm 3.7 only support behavior flags up to 6.
    Set it to 7 will hit error when create llvm 3.7 module.
2. Dwarf Version 5.
    llvm 3.7 only support Dwarf Version up to 4.

For behavior flag, clang 3.7 will set it to 2 (Warning) for "Dwarf Version".
The fix could be to do the same thing when targeting DXIL.

The Dwarf Version issue could be fixed by force the CodeGenOpts.DwarfVersion to 4 when targeting DXIL.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU01vozAQ_TXmMiqCIeBw4NAWZVWp1Uq71W6vBg_grWNHtmmTf78ySZtNVGkvIH_Mm_fm-Qnv1WiIGlbesbJNxBwm65rdIUzWFK-joKSz8tA8WTlrgkGLERjmjN-pAoEzvF-WiO27cAP8IueVNQwxnsQrJeMt9HbWEjoCT0ZCsNAqR314gU70r3FLGWDl3anJRovRwxMFIUUQrGwZrqcQdp4Vtww3DDdav21T60aGG2l7z3DzKMz4g4Z0ClvNsFASs2zNsE5Z1rLs9vh9nsgRQ-4IEMKkzOihfXl4BGMD-Hm3sy6QBDnTwjGeKA-d8CTBGohdoUj5CTNP4Xki6GgSb8q642w4MFw_if25NQB8VoI1-vDR6bLSw7yLXat_yn5SABXiLod3pTVMKgA5Zx28T2SgdyQCndG3y_xOAJjChSdQ_pfQ5f0jn9XFBDfWXdKONvdamHFBW0j6T9YYh_FbOKPMyLCGwTr44qmkn-7AoPbnxxIsSAthIvBiS0fDjsKDcCOFuIwmXXt8pUN5P9MZdVB7ktAdIpueFvh7K-kbme-74NOl9qM06v-yYyKbQtZFLRJqcp7Xq5qvc55MDS9rWWPHRSGLvC_WZVnlQ9F1Vbmu-5pniWoww1VWIc9XeVXylNdrFEU_VFndD0VFbJXRViidfjzyZBHQ1FWdY6JFR9ovaUU8pYcVt6c8xdyVbeKaWHvTzaNnq0wrH_wZLaigl7hfZZCVLTxoTaPQVwOkrQoxF8HCoIzQIPdKp8nsdHMZy1GFae7S3m5PGT39bnbO_qE-MNwsWmJgj3LeGvwbAAD__wH4bvQ">