<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi Kumail,</p>
    <p>That's strange.<br>
    </p>
    <p>When you are generating the .ll file from clang, do you have two
      intrinsic calls in the IR?</p>
    <p>If that's the case, I'd run llc with -print-after-all to identify
      which LLVM pass removes the second call, and then debug the pass
      to see what is going on.</p>
    <p>Pierre-Andre<br>
    </p>
    <div class="moz-cite-prefix">On 27/01/17 17:50, Kumail Ahmed wrote:<br>
    </div>
    <blockquote
cite="mid:CAEJeK8n5EWAhBEL3AB7CQxmpH41PdT9u5kdL5oZ1kbyXXC-nEw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>Hi Pierre, <br>
                <br>
              </div>
              Thank you for your swift response! <br>
              <br>
            </div>
            I've tried almost everything that you mentioned, but it
            seems like LLVM simply doesn't care about the flags I pass
            to it.<br>
            <br>
          </div>
          Best regards,<br>
        </div>
        Kumail Ahmed<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Jan 27, 2017 at 6:05 PM,
          Pierre-Andre Saulais <span dir="ltr"><<a
              moz-do-not-send="true"
              href="mailto:pierre-andre@codeplay.com" target="_blank">pierre-andre@codeplay.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <p>Hi Kumail,</p>
              <p>There is a flag that does what you are looking for (see
                Intrinsics.td for definitions):</p>
              <p>// IntrNoduplicate - Calls to this intrinsic cannot be
                duplicated.<br>
                // Parallels the noduplicate attribute on LLVM IR
                functions.<br>
                def IntrNoDuplicate : IntrinsicProperty;<br>
              </p>
              <p>Another thing to check is whether your intrinsic is
                marked as having side-effects or not. Intrinsics with no
                side effects may be optimized by LLVM. If you inspect
                the DAG using llc, an intrinsic with side-effects should
                have a chain (blue dashed edge) going to and coming from
                its node:</p>
              <p>llc -O1 foo.ll -view-isel-dags<br>
              </p>
              <p>If it doesn't, you can mark it as having side-effects
                using one of the following attributes:<br>
              </p>
              <p>// IntrReadMem - This intrinsic only reads from memory.
                It does not write to<br>
                // memory and has no other side effects. Therefore, it
                cannot be moved across<br>
                // potentially aliasing stores. However, it can be
                reordered otherwise and can<br>
                // be deleted if dead.<br>
                def IntrReadMem : IntrinsicProperty;<br>
                <br>
                // IntrWriteMem - This intrinsic only writes to memory,
                but does not read from<br>
                // memory, and has no other side effects. This means
                dead stores before calls<br>
                // to this intrinsics may be removed.<br>
                def IntrWriteMem : IntrinsicProperty;<br>
              </p>
              By default intrinsics returning void are assumed to have
              side effects.<br>
              <br>
              Pierre-Andre
              <div>
                <div class="h5"><br>
                  <br>
                  <div class="m_2281149532246530638moz-cite-prefix">On
                    27/01/17 16:33, Kumail Ahmed via llvm-dev wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">
                      <div>
                        <div>
                          <div>
                            <div>
                              <div>
                                <div>
                                  <div>
                                    <div>Hello everyone,<br>
                                      <br>
                                      <br>
                                    </div>
                                    Consider we have this following set
                                    of code: <br>
                                    <br>
                                  </div>
                                  int foo() {<br>
                                  <br>
                                </div>
                                int a,b;<br>
                              </div>
                              a = __builtin_XX(0x11);<br>
                            </div>
                            b = __builtin_XX(0x11);<br>
                          </div>
                          return a+b;<br>
                          }<br>
                          <br>
                        </div>
                        The problem currently is that LLVM eliminated
                        the second call and copied the result from the
                        first call into a new set of registers. Is there
                        is a way to force LLVM to generate two explicit
                        calls to a builtin function. The builtin takes
                        in an integer type, and also returns back an
                        integer type:<br>
                        <br>
                          def int_XX : GCCBuiltin<"__builtin_XX">,
                        Intrinsic<[llvm_i32_ty], [llvm_i32_ty]>;<br>
                        <br>
                      </div>
                      Is there some flag that I'm missing? Your help
                      will be really appreciated.<br>
                      <div>
                        <div>
                          <div>
                            <div>
                              <div>
                                <div>
                                  <div>
                                    <div>
                                      <div>
                                        <div>
                                          <div><br>
                                            <br>
                                            <div
                                              class="m_2281149532246530638gmail_signature">Best
                                              Regards,<br>
                                              Kumail Ahmed<br>
                                              <br>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <br>
                    <fieldset
                      class="m_2281149532246530638mimeAttachmentHeader"></fieldset>
                    <br>
                  </div>
                </div>
                <pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="m_2281149532246530638moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="m_2281149532246530638moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    

    <pre class="m_2281149532246530638moz-signature" cols="72">-- 
Pierre-Andre Saulais
Principal Software Engineer, Compilers
Codeplay Software Ltd
Level C Argyle House, 3 Lady Lawson Street, Edinburgh, United Kingdom, EH3 9DR
Tel: <a moz-do-not-send="true" href="tel:+44%20131%20466%200503" value="+441314660503" target="_blank">+44 (0)131 466 0503</a>
Website: <a moz-do-not-send="true" class="m_2281149532246530638moz-txt-link-freetext" href="http://www.codeplay.com" target="_blank">http://www.codeplay.com</a>
Twitter: <a moz-do-not-send="true" class="m_2281149532246530638moz-txt-link-freetext" href="https://twitter.com/codeplaysoft" target="_blank">https://twitter.com/<wbr>codeplaysoft</a>

This email and any attachments may contain confidential and /or privileged information and is for use by the addressee only. If you are not the intended recipient, please notify Codeplay Software Ltd immediately and delete the message from your computer. You may not copy or forward it, or use or disclose its contents to any other person. Any views or other information in this message which do not relate to our business are not authorized by Codeplay software Ltd, nor does this message form part of any contract unless so stated.
As internet communications are capable of data corruption Codeplay Software Ltd does not accept any responsibility for any changes made to this message after it was sent. Please note that Codeplay Software Ltd does not accept any liability or responsibility for viruses and it is your responsibility to scan any attachments.
Company registered in England and Wales, number: <a moz-do-not-send="true" href="tel:04567%20874" value="+494567874" target="_blank">04567874</a>
Registered office: Regent House, 316 Beulah Hill, London, United Kingdom, SE19 3HF
</pre>
  </div>

</blockquote></div>


-- 
<div class="gmail_signature" data-smartmail="gmail_signature">Best Regards,
Kumail Ahmed
M.Sc. Student 
TU Kaiserslautern</div>
</div>



</blockquote>
<pre class="moz-signature" cols="72">-- 
Pierre-Andre Saulais
Principal Software Engineer, Compilers
Codeplay Software Ltd
Level C Argyle House, 3 Lady Lawson Street, Edinburgh, United Kingdom, EH3 9DR
Tel: +44 (0)131 466 0503
Website: <a class="moz-txt-link-freetext" href="http://www.codeplay.com">http://www.codeplay.com</a>
Twitter: <a class="moz-txt-link-freetext" href="https://twitter.com/codeplaysoft">https://twitter.com/codeplaysoft</a>

This email and any attachments may contain confidential and /or privileged information and is for use by the addressee only. If you are not the intended recipient, please notify Codeplay Software Ltd immediately and delete the message from your computer. You may not copy or forward it, or use or disclose its contents to any other person. Any views or other information in this message which do not relate to our business are not authorized by Codeplay software Ltd, nor does this message form part of any contract unless so stated.
As internet communications are capable of data corruption Codeplay Software Ltd does not accept any responsibility for any changes made to this message after it was sent. Please note that Codeplay Software Ltd does not accept any liability or responsibility for viruses and it is your responsibility to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: Regent House, 316 Beulah Hill, London, United Kingdom, SE19 3HF
</pre></body></html>