Skip to content

Commit

Permalink
Merge pull request #2027 from yingcong-wu/yc/0829-buffer-alignment-ub
Browse files Browse the repository at this point in the history
[DeviceSanitizer] Fix MemBuffer::getAlignment will UB under optimization with new compiler change.
  • Loading branch information
pbalcer committed Sep 19, 2024
2 parents 4517290 + 5c49ec8 commit 1264ec6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/loader/layers/sanitizer/asan_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ size_t MemBuffer::getAlignment() {
// usually choose a very large size (more than 1k). Then sanitizer will
// allocate extra unnessary memory. Not sure if this will impact
// performance.
size_t MsbIdx = 63 - __builtin_clz(Size);
size_t Alignment = (1 << (MsbIdx + 1));
size_t MsbIdx = 63 - __builtin_clzl(Size);
size_t Alignment = (1ULL << (MsbIdx + 1));
if (Alignment > 128) {
Alignment = 128;
}
Expand Down

0 comments on commit 1264ec6

Please sign in to comment.