Issue 109718
Summary [clang] Missed optimization: dead store to thread-local not optimized out
Labels clang
Assignees
Reporter tavianator
    For this code

```c
void foo(void **ptr) {
    static _Thread_local void *tmp;
    tmp = *ptr;
    *ptr = 0;
}
```

Clang generates

```asm
foo:
        movq    (%rdi), %rax
 movq    %rax, %fs:foo.tmp@TPOFF
        movq    $0, (%rdi)
 retq
```

I think it's an alias analysis issue, because a `_Thread_local int` is optimized out.  But even without alias analysis, we know that `tmp` hasn't had its address taken.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to