[PATCH] D154915: [ARM][AArch64] Add ARM specific builtin for clz that is not undefined for 0 in ubsan.

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 10 20:21:39 PDT 2023


craig.topper created this revision.
craig.topper added reviewers: dmgreen, efriedma, SjoerdMeijer, tmatheson, kongyi.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: clang.

D152023 <https://reviews.llvm.org/D152023> made ubsan consider __builtin_clz of 0 undefined regardless of
the target. This ensures portability and matches gcc.

This causes the ACLE intrinsics to also be considered to also be
considered to be undefined for 0 since they used the generic builtins
as their implementation.

This patch adds builtins for ARM that ubsan doesn't know about to make
the behavior defined for 0. Alternatively, I could have added a zero
check to the intrinsics, but the dedicated builtin will give better -O0
codegen.

Fixes #63113.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154915

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/include/clang/Basic/BuiltinsARM.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154915.538901.patch
Type: text/x-patch
Size: 4651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230711/054f9e30/attachment-0001.bin>


More information about the cfe-commits mailing list