[PATCH] D131979: [clang][UBSan] Fix __builtin_assume_aligned crash

Wang Yihan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 06:54:13 PDT 2022


yihanaa updated this revision to Diff 456646.
yihanaa added a comment.

Use custom seam checking on __builtin_assume_aligned.

C++ not allow implicit cast from volatile void * to const void *, but C allowed and only emit a warning. This is a general case, volatile in __builtin_assume_aligned just use to ignore generate 'call void @__ubsan_handle_alignment_assumption' in CodeGen. So, I use GatherArgumentsForCall to handle the common case(e.g. emit diag message) except 1st arg, we ignore the implicit cast from user-written-type to 'const void *' on the 1st arg, because CodeGen need user-written-type to generate correct TypeDescriptor (this class in compiler-rt/UBSan), then, clang will emit cast instruction which cast type from user-written-type to VoidPtr in CodeGen.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131979/new/

https://reviews.llvm.org/D131979

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/catch-alignment-assumption-array.c
  clang/test/CodeGen/catch-alignment-assumption-ignorelist.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131979.456646.patch
Type: text/x-patch
Size: 10068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220830/2b764501/attachment-0001.bin>


More information about the cfe-commits mailing list