<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/clang/lib/CodeGen/CGAtomic.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[clang][NFC] Inline Frontend/FrontendDiagnostic.h -&gt; Basic/DiagnosticFrontend.h (#162883)</title>
<updated>2025-11-21T03:39:49+00:00</updated>
<author>
<name>Jordan Rupprecht</name>
<email>rupprecht@google.com</email>
</author>
<published>2025-11-21T03:39:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3d3307ecd8bdd6d9af0d82245c5fc50e4d624a7a'/>
<id>3d3307ecd8bdd6d9af0d82245c5fc50e4d624a7a</id>
<content type='text'>
d076608d58d1ec55016eb747a995511e3a3f72aa moved some deps around to avoid
cycles and left clang/Frontend/FrontendDiagnostic.h as a shim that
simply includes clang/Basic/DiagnosticFrontend.h. This PR inlines it so
that nothing in tree still includes clang/Frontend/FrontendDiagnostic.h.

Doing this will help prevent future layering issues. See #162865.

Frontend already depends on Basic, so no new deps need to be added
anywhere except for places that do strict dep checking.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
d076608d58d1ec55016eb747a995511e3a3f72aa moved some deps around to avoid
cycles and left clang/Frontend/FrontendDiagnostic.h as a shim that
simply includes clang/Basic/DiagnosticFrontend.h. This PR inlines it so
that nothing in tree still includes clang/Frontend/FrontendDiagnostic.h.

Doing this will help prevent future layering issues. See #162865.

Frontend already depends on Basic, so no new deps need to be added
anywhere except for places that do strict dep checking.</pre>
</div>
</content>
</entry>
<entry>
<title>[Clang][NFC] Rename UnqualPtrTy to DefaultPtrTy (#163207)</title>
<updated>2025-10-20T12:34:21+00:00</updated>
<author>
<name>Juan Manuel Martinez Caamaño</name>
<email>jmartinezcaamao@gmail.com</email>
</author>
<published>2025-10-20T12:34:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=74d77dc2ec2f93c151bd98687799ed90e9bea849'/>
<id>74d77dc2ec2f93c151bd98687799ed90e9bea849</id>
<content type='text'>
`UnqualPtrTy` didn't always match `llvm::PointerType::getUnqual`:
sometimes it returned a pointer that is not in address space 0 (notably
for SPIRV).

Since `UnqualPtrTy` was used as the "generic" or "default" pointer type,
this patch renames it to `DefaultPtrTy` to avoid confusion with LLVM's
`PointerType::getUnqual`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`UnqualPtrTy` didn't always match `llvm::PointerType::getUnqual`:
sometimes it returned a pointer that is not in address space 0 (notably
for SPIRV).

Since `UnqualPtrTy` was used as the "generic" or "default" pointer type,
this patch renames it to `DefaultPtrTy` to avoid confusion with LLVM's
`PointerType::getUnqual`.</pre>
</div>
</content>
</entry>
<entry>
<title>[clang] [libc++] fix _Atomic c11 compare exchange does not update expected results (#78707)</title>
<updated>2025-10-19T18:25:00+00:00</updated>
<author>
<name>Hui</name>
<email>hui.xie1990@gmail.com</email>
</author>
<published>2025-10-19T18:25:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b2574c9dad487be92605316efd929738a5f6d851'/>
<id>b2574c9dad487be92605316efd929738a5f6d851</id>
<content type='text'>
fixes #30023

The issue is that for compare exchange builtin, if the type's size is
not power of 2, it creates a temporary of size power of 2, then emit the
compare exchange operation. And later, the results of the compare
exchange operation has two components: 1. a boolean whether or not the
exchange happens. 2. the old value
we are supposed to write the old value into user's "expected" value.
However, in case the type is not power of 2, what we actually wrote to
is the temporary that was created.

The fix is to pass the "expected" address all the way down so it can
wrote to the correct address</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
fixes #30023

The issue is that for compare exchange builtin, if the type's size is
not power of 2, it creates a temporary of size power of 2, then emit the
compare exchange operation. And later, the results of the compare
exchange operation has two components: 1. a boolean whether or not the
exchange happens. 2. the old value
we are supposed to write the old value into user's "expected" value.
However, in case the type is not power of 2, what we actually wrote to
is the temporary that was created.

The fix is to pass the "expected" address all the way down so it can
wrote to the correct address</pre>
</div>
</content>
</entry>
<entry>
<title>[Clang] Add support for fp when using min_fetch/max_fetch atomics (#160330)</title>
<updated>2025-10-13T10:36:24+00:00</updated>
<author>
<name>Amina Chabane</name>
<email>amina.chabane@arm.com</email>
</author>
<published>2025-10-13T10:36:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=34c7cf07507841a8e6480dcaad88c6a4dfa40e4b'/>
<id>34c7cf07507841a8e6480dcaad88c6a4dfa40e4b</id>
<content type='text'>
Previously when using min_fetch/max_fetch atomics with floating point
types, LLVM would emit a crash. This patch updates the
EmitPostAtomicMinMax function in CGAtomic.cpp to take floating point
types. Included is a clang CodeGen test atomic-ops-float-check-minmax.c
and Sema test atomic-ops-fp-minmax.c.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously when using min_fetch/max_fetch atomics with floating point
types, LLVM would emit a crash. This patch updates the
EmitPostAtomicMinMax function in CGAtomic.cpp to take floating point
types. Included is a clang CodeGen test atomic-ops-float-check-minmax.c
and Sema test atomic-ops-fp-minmax.c.</pre>
</div>
</content>
</entry>
<entry>
<title>[AST] Give `CharUnits::operator%` a consistent type. NFC (#160781)</title>
<updated>2025-10-01T19:15:46+00:00</updated>
<author>
<name>Justin Bogner</name>
<email>mail@justinbogner.com</email>
</author>
<published>2025-10-01T19:15:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=78c65545d4694e043b593e4cca7c7281a639247b'/>
<id>78c65545d4694e043b593e4cca7c7281a639247b</id>
<content type='text'>
Update the `operator%` overload that accepts `CharUnits` to return
`CharUnits` to match the other `operator%`. This is more logical than
returning an `int64` and cleans up users that want to continue to do
math with the result.

Many users of this were explicitly comparing against 0. I considered
updating these to compare against `CharUnits::Zero` or even introducing
an `explicit operator bool()`, but they all feel clearer if we update
them to use the existing `isMultipleOf()` function instead.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Update the `operator%` overload that accepts `CharUnits` to return
`CharUnits` to match the other `operator%`. This is more logical than
returning an `int64` and cleans up users that want to continue to do
math with the result.

Many users of this were explicitly comparing against 0. I considered
updating these to compare against `CharUnits::Zero` or even introducing
an `explicit operator bool()`, but they all feel clearer if we update
them to use the existing `isMultipleOf()` function instead.</pre>
</div>
</content>
</entry>
<entry>
<title>[clang][CodeGen] Fix sub-optimal clang CodeGen for __atomic_test_and_set (#160098)</title>
<updated>2025-09-26T15:58:45+00:00</updated>
<author>
<name>Sirui Mu</name>
<email>msrlancern@gmail.com</email>
</author>
<published>2025-09-26T15:58:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d2239fbf432ecf3df64966a421340aaa6b518d2c'/>
<id>d2239fbf432ecf3df64966a421340aaa6b518d2c</id>
<content type='text'>
Clang CodeGen for `__atomic_test_and_set` would emit a `store`
instruction that stores an `i1` value:

```cpp
bool f(void *ptr) {
  return __atomic_test_and_set(ptr, __ATOMIC_RELAXED);
}
```

```llvm
%1 = atomicrmw xchg ptr %0, i8 1 monotonic, align 1
%tobool = icmp ne i8 %1, 0
store i1 %tobool, ptr %atomic-temp, align 1
```

which could lead to suboptimal binary code, for example on x86_64:

```asm
f:
    mov     al, 1
    xchg    byte ptr [rdi], al
    test    al, al
    setne   al
    setne   byte ptr [rsp - 1]
    ret
```

The last `setne` instruction is obviously redundant. This patch fixes
this issue by first zero-extending `%tobool` to an `i8` before the
store. This effectively eliminates the last `setne` instruction in the
binary code sequence. The `test` and `setne` on `al` is kept still,
though.

-----

I'm quite conservative about the codegen in this patch. Vanilla gcc
actually emits simpler code for `__atomic_test_and_set`:

```cpp
bool f(void *ptr) {
  return __atomic_test_and_set(ptr, __ATOMIC_RELAXED);
}
```

```asm
f:
    mov     eax, 1
    xchg    al, BYTE PTR [rdi]
    ret
```

It seems like gcc assumes `ptr` would always point to a valid `bool`
value as required by the ABI. I'm not sure if we should also make this
assumption.

Related to #121943 .</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clang CodeGen for `__atomic_test_and_set` would emit a `store`
instruction that stores an `i1` value:

```cpp
bool f(void *ptr) {
  return __atomic_test_and_set(ptr, __ATOMIC_RELAXED);
}
```

```llvm
%1 = atomicrmw xchg ptr %0, i8 1 monotonic, align 1
%tobool = icmp ne i8 %1, 0
store i1 %tobool, ptr %atomic-temp, align 1
```

which could lead to suboptimal binary code, for example on x86_64:

```asm
f:
    mov     al, 1
    xchg    byte ptr [rdi], al
    test    al, al
    setne   al
    setne   byte ptr [rsp - 1]
    ret
```

The last `setne` instruction is obviously redundant. This patch fixes
this issue by first zero-extending `%tobool` to an `i8` before the
store. This effectively eliminates the last `setne` instruction in the
binary code sequence. The `test` and `setne` on `al` is kept still,
though.

-----

I'm quite conservative about the codegen in this patch. Vanilla gcc
actually emits simpler code for `__atomic_test_and_set`:

```cpp
bool f(void *ptr) {
  return __atomic_test_and_set(ptr, __ATOMIC_RELAXED);
}
```

```asm
f:
    mov     eax, 1
    xchg    al, BYTE PTR [rdi]
    ret
```

It seems like gcc assumes `ptr` would always point to a valid `bool`
value as required by the ABI. I'm not sure if we should also make this
assumption.

Related to #121943 .</pre>
</div>
</content>
</entry>
<entry>
<title>[KeyInstr][Clang] Atomic ops atoms (#141624)</title>
<updated>2025-06-24T11:20:44+00:00</updated>
<author>
<name>Orlando Cazalet-Hyams</name>
<email>orlando.hyams@sony.com</email>
</author>
<published>2025-06-24T11:20:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ddecfa696c4929ac364053f3eef66fefe4873448'/>
<id>ddecfa696c4929ac364053f3eef66fefe4873448</id>
<content type='text'>
This patch is part of a stack that teaches Clang to generate Key
Instructions metadata for C and C++.

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be
removed.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch is part of a stack that teaches Clang to generate Key
Instructions metadata for C and C++.

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be
removed.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668</pre>
</div>
</content>
</entry>
<entry>
<title>clang: Remove dest LangAS argument from performAddrSpaceCast (#138866)</title>
<updated>2025-05-09T12:24:54+00:00</updated>
<author>
<name>Matt Arsenault</name>
<email>Matthew.Arsenault@amd.com</email>
</author>
<published>2025-05-09T12:24:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5ae2aed218470783e6c7a2d255c7946f4549cb46'/>
<id>5ae2aed218470783e6c7a2d255c7946f4549cb46</id>
<content type='text'>
It isn't used and is redundant with the result pointer type argument.
A more reasonable API would only have LangAS parameters, or IR parameters,
not both. Not all values have a meaningful value for this. I'm also
not sure why we have this at all, it's not overridden by any targets and
further simplification is possible.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It isn't used and is redundant with the result pointer type argument.
A more reasonable API would only have LangAS parameters, or IR parameters,
not both. Not all values have a meaningful value for this. I'm also
not sure why we have this at all, it's not overridden by any targets and
further simplification is possible.</pre>
</div>
</content>
</entry>
<entry>
<title>[clang][CodeGen] Add range metadata for atomic load of boolean type. #131476 (#133546)</title>
<updated>2025-04-14T21:26:10+00:00</updated>
<author>
<name>Jan Górski</name>
<email>jan.a.gorski@wp.pl</email>
</author>
<published>2025-04-14T21:26:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ff687af04f5b0e85305250587b524cb0b3849aa0'/>
<id>ff687af04f5b0e85305250587b524cb0b3849aa0</id>
<content type='text'>
Fixes #131476.

For `x86_64` it folds
```
movzbl	t1(%rip), %eax
andb	$1, %al
```
into
```
movzbl	t1(%rip), %eax
```
when run: `clang -S atomic-ops-load.c -o atomic-ops-load.s -O1
--target=x86_64`.

But for riscv replaces:
```
lb	a0, %lo(t1)(a0)
andi	a0, a0, 1
```
with
```
lb	a0, %lo(t1)(a0)
zext.b	a0, a0
``` 
when run: `clang -S atomic-ops-load.c -o atomic-ops-load.s -O1
--target=riscv64`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #131476.

For `x86_64` it folds
```
movzbl	t1(%rip), %eax
andb	$1, %al
```
into
```
movzbl	t1(%rip), %eax
```
when run: `clang -S atomic-ops-load.c -o atomic-ops-load.s -O1
--target=x86_64`.

But for riscv replaces:
```
lb	a0, %lo(t1)(a0)
andi	a0, a0, 1
```
with
```
lb	a0, %lo(t1)(a0)
zext.b	a0, a0
``` 
when run: `clang -S atomic-ops-load.c -o atomic-ops-load.s -O1
--target=riscv64`.</pre>
</div>
</content>
</entry>
<entry>
<title>[Clang] Use "syncscope" instead of "synchscope". NFC. (#134616)</title>
<updated>2025-04-07T12:32:36+00:00</updated>
<author>
<name>Jay Foad</name>
<email>jay.foad@amd.com</email>
</author>
<published>2025-04-07T12:32:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e2fe78797fa39e22ebb3c65383d1bd30490535e5'/>
<id>e2fe78797fa39e22ebb3c65383d1bd30490535e5</id>
<content type='text'>
This matches the spelling of the keyword in LLVM IR.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This matches the spelling of the keyword in LLVM IR.</pre>
</div>
</content>
</entry>
</feed>
