<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hey all,</p>
    <p>Trying to revive the RFC thread here - we have a need for this
      functionality (or some similar mechanism that lets us have a
      per-thread or per-context setting for options).</p>
    <p>Is there any scope for getting something in that enables our
      (AMD's) graphics drivers and Azul to make use of it, in the short
      term, even if it's not the perfect solution that everyone desires?<br>
    </p>
    <p>Cheers,</p>
    <p>-Neil.<br>
    </p>
    <div class="moz-cite-prefix">On 08/11/2018 07:50, Yevgeny Rouban via
      llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPEhOGnB9KvMLGNFw=QA26T5kBtp0TMNx_PuZQDu7iDCZuQFTA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div>Hello Chris.</div>
          <div><br>
          </div>
          <div>>
            One of the perennial problems with cl::opt is that ...<br>
          </div>
          <div>My RFC does not change the way the options are
            initialized and registered. So the static initialization
            problem is not made worse by this RFC.</div>
          <div><br>
          </div>
          <div>> Personally I very much prefer the idea of having
            *Context objects be responsible for options rather than
            thread-local storage ...</div>
          <div>This RFC defines a *Context* for options. In the patch
            the class is called <span class="" style="" id=":1bu.1"
              tabindex="-1">ContextValues</span>. Essentially, it is
            similar to *Context objects*.<br>
          </div>
        </div>
        <div>With the RFC we will be able to make further changes for
          specific options to get them from any specific Context, not
          only from the thread local one. The thread local is proposed
          as the default context to keep unchanged all places where
          cl::opts are accessed.</div>
        <div><br>
        </div>
        <div>If we have a flag:<br>
        </div>
        <div>
          <div><span style="font-family:monospace,monospace">static
              cl::opt<<span class="" style="" id=":1bu.2"
                tabindex="-1">bool</span>> <span class="" style=""
                id=":1bu.3" tabindex="-1">SomeFlag</span>; // static
              global</span></div>
          <div><br>
          </div>
        </div>
        <div>Flag access code looks like the following:</div>
        <div><span style="font-family:monospace,monospace">if ( 
            <span class="" style="" id=":1bu.4" tabindex="-1">SomeFlag</span>
            ) ... // global flag access</span></div>
        <div><br>
        </div>
        <div>With the RFC (thread specific cl::opt values) this code
          being unchanged becomes equivalent to:<br>
        </div>
        <div>
          <span style="font-family:monospace,monospace">if ( 
            <span class="" style="" id=":1bu.5" tabindex="-1">SomeFlag</span>.<span
              class="" style="" id=":1bu.6" tabindex="-1">getValue</span>(<span
              class="gmail-n">cl</span><span class="gmail-o">::</span><span
              class="gmail-n"><span class="" style="" id=":1bu.7"
                tabindex="-1">ContextValues</span></span><span
              class="gmail-o">::</span><span class="gmail-n"><span
                class="" style="" id=":1bu.8" tabindex="-1">GetThreadOptionContext</span>()</span>)
            ) ... // thread local flag access with fallback to global
            flag access</span>
        </div>
        <div><br>
        </div>
        <div>Then we can manually change this source to:<br>
        </div>
        <div>
          <div>
            <span style="font-family:monospace,monospace">if ( 
              <span class="" style="" id=":1bu.9" tabindex="-1">SomeFlag</span>.<span
                class="" style="" id=":1bu.10" tabindex="-1">getValue</span>(<span
                class="" style="" id=":1bu.11" tabindex="-1">SomeSpecificContext</span>)
              ) ... // context specific flag
              access
              with fallback to
              thread local flag access</span>
          </div>
          <div><br>
          </div>
          <div>In this example <span class="" style="" id=":1bu.12"
              tabindex="-1">SomeSpecificContext</span> can be specific
            to <span class="" style="" id=":1bu.13" tabindex="-1">LLVMContext</span>,
            Pass, ...</div>
          <div><br>
          </div>
          <div>Thanks.</div>
          <div>-<span class="" style="" id=":1bu.14" tabindex="-1">Yevgeny</span>
            <span class="" style="" id=":1bu.15" tabindex="-1">Rouban</span></div>
          <div><br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-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>
  </body>
</html>