[clang] [llvm] [BPF] Do atomic_fetch_*() pattern matching with memory ordering (PR #107343)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 16:19:04 PDT 2024


================
@@ -800,6 +809,10 @@ void BTFDebug::visitDerivedType(const DIDerivedType *DTy, uint32_t &TypeId,
                                 bool CheckPointer, bool SeenPointer) {
   unsigned Tag = DTy->getTag();
 
+  if (Tag == dwarf::DW_TAG_atomic_type)
+    return visitTypeEntry(DTy->getBaseType(), TypeId, CheckPointer,
+                          SeenPointer);
+
----------------
eddyz87 wrote:

Below there is a check:

```c++
if (CheckPointer && SeenPointer) {
    const DIType *Base = DTy->getBaseType();
if (Base) {
  ...
```

Is it necessary to skip atomic there?
E.g. to handle situation like below:

```c
struct foo {
  void * _Atomic a;
} root;

/*
$ clang -O2 -g -mcpu=v3 --target=bpf -c test4.c -o test4.o && bpftool btf dump file test4.o
[1] STRUCT 'foo' size=8 vlen=1
	'a' type_id=2 bits_offset=0
[2] PTR '(anon)' type_id=0
[3] VAR 'root' type_id=1, linkage=global
[4] DATASEC '.bss' size=0 vlen=1
	type_id=3 offset=0 size=8 (VAR 'root')
*/
```

https://github.com/llvm/llvm-project/pull/107343


More information about the cfe-commits mailing list