Skip to content

Commit 1264ec6

Browse files
authored
Merge pull request #2027 from yingcong-wu/yc/0829-buffer-alignment-ub
[DeviceSanitizer] Fix MemBuffer::getAlignment will UB under optimization with new compiler change.
2 parents 4517290 + 5c49ec8 commit 1264ec6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/loader/layers/sanitizer/asan_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ size_t MemBuffer::getAlignment() {
183183
// usually choose a very large size (more than 1k). Then sanitizer will
184184
// allocate extra unnessary memory. Not sure if this will impact
185185
// performance.
186-
size_t MsbIdx = 63 - __builtin_clz(Size);
187-
size_t Alignment = (1 << (MsbIdx + 1));
186+
size_t MsbIdx = 63 - __builtin_clzl(Size);
187+
size_t Alignment = (1ULL << (MsbIdx + 1));
188188
if (Alignment > 128) {
189189
Alignment = 128;
190190
}

0 commit comments

Comments
 (0)