<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 --- - Implement support in clang-cl for the /GT option"
   href="http://llvm.org/bugs/show_bug.cgi?id=19177">19177</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Implement support in clang-cl for the /GT option
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rafael.espindola@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>bigcheesegs@gmail.com, llvmbugs@cs.uiuc.edu, rnk@google.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The option is defined in
<a href="http://msdn.microsoft.com/en-us/library/6e298fy4.aspx">http://msdn.microsoft.com/en-us/library/6e298fy4.aspx</a>

In summary, it means that we cannot assume that the address of a tls doesn't
change across a call, since the call might causes a fiber to move to another
thread.

This has implications for both IR and codegen. For the IR issue, consider

struct foo {
  int v[10];
};
static __thread struct foo var;
struct foo *h(void) { return &var; }
void f(int *);
void g(int x, int y) {
  for (int i = 0; i < x; ++i) {
    f(&var.v[y]);
  }
}

This currently produces
------------------------------
for.body.lr.ph:
...
%arrayidx = getelementptr inbounds %struct.foo* @var, i64 0, i32 0, i64
%idxprom
br label %for.body

for.body:
...
tail call void @f(i32* %arrayidx)
...
br i1 %exitcond, label %for.end, label %for.body
----------------------------------

but the address is not actually loop invariant.

For codegen, consider

static __thread int var;
int *h(void) { return &var; }
void f(int);
void g(void) {
  f(var);
  f(var);
}

We only call __tls_get_addr@PLT once with the local dynamic model.

We chatted a bit about it and it looks like we would need to change clang's
IRGen when the option is given to use an intrinsic to get the actual address.
Something like

%addr = llvm.get_tls_addr(@var)

so that the optimizers know that %addr can be different in each loop iteration.</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>