Skip to content

Commit

Permalink
use 64bit alignment for map counter atomic add
Browse files Browse the repository at this point in the history
For an atomic inc of a map counter (ringbuf loss counter), generate
IR with 64bit alignment. This is more correct, and will avoid problems
with upcoming LLVM versions, as they will emit a function call for
a potentially unaligned atomicrmw. This will lead to an error like this:

error: <unknown>:0:0: in function BEGIN i64 (ptr): t15: i64 = GlobalAddress<ptr @__atomic_compare_exchange> 0 too many arguments
  • Loading branch information
Frank van der Linden authored and danobi committed Mar 11, 2024
1 parent 6a41d8e commit e8d088b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ and this project adheres to
- [#2964](https://github.com/bpftrace/bpftrace/pull/2964)
- Fix security hole checking unpacked kernel headers
- [#3033](https://github.com/bpftrace/bpftrace/pull/3033)
- Fix alignment of atomic map counter update
- [#3045](https://github.com/bpftrace/bpftrace/pull/3045)
#### Docs
#### Tools

Expand Down
2 changes: 1 addition & 1 deletion src/ast/irbuilderbpf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ void IRBuilderBPF::CreateAtomicIncCounter(const std::string &map_name,
CREATE_ATOMIC_RMW(AtomicRMWInst::BinOp::Add,
val,
getInt64(1),
1,
8,
AtomicOrdering::SequentiallyConsistent);
CreateBr(lookup_merge_block);

Expand Down

0 comments on commit e8d088b

Please sign in to comment.