<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body 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<br>
    <br>
    <div class="moz-cite-prefix">On 27/01/17 16:33, Kumail Ahmed via
      llvm-dev wrote:<br>
    </div>
    <blockquote
cite="mid:CAEJeK8nD1wR9pn8zVr-vOkCfzftnoY2nEZUoHjpMY_bURzDQZw@mail.gmail.com"
      type="cite">
      <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="gmail_signature">Best Regards,<br>
                                Kumail Ahmed<br>
                                <br>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
    <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>