[PATCH] D148827: -fsanitize=function: support C

2023-06-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. In D148827#4424237 , @uabelho wrote: > Hi, > > A question: it seems like this messes with alignment on functions? > So with input program al.c: > > __attribute__((aligned(64))) > void alignedfn(void) { > __asm("nop"); >

[PATCH] D148827: -fsanitize=function: support C

2023-06-15 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment. Hi, A question: it seems like this messes with alignment on functions? So with input program al.c: __attribute__((aligned(64))) void alignedfn(void) { __asm("nop"); } void alignedfn2(void) { __asm("nop"); } int main(void){} if we compile with

[PATCH] D148827: -fsanitize=function: support C

2023-06-14 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment. In D148827#4422794 , @MaskRay wrote: > 6.3.2.3.1 is about a pointer casting rule, which is different from type > compatibility. Pointer _conversion_ rule. Specifically, these are implicit conversions that require no casting.

[PATCH] D148827: -fsanitize=function: support C

2023-06-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. In D148827#4422709 , @glandium wrote: > OTOH. 6.2.7.3: > >> A composite type can be constructed from two types that are compatible; it >> is a type that is compatible with both of the two types (...) > > 6.2.7.5: > >> EXAMPLE

[PATCH] D148827: -fsanitize=function: support C

2023-06-14 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment. OTOH. 6.2.7.3: > A composite type can be constructed from two types that are compatible; it is > a type that is compatible with both of the two types (...) 6.2.7.5: > EXAMPLE Given the following two file scope declarations: > int f(int (*)(), double (*)[3]); > int

[PATCH] D148827: -fsanitize=function: support C

2023-06-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. In D148827#4422498 , @glandium wrote: > In D148827#4379764 , @MaskRay wrote: > >> These cases are UB and should be caught. It's not an excuse that they use C. > > Are they really though?

[PATCH] D148827: -fsanitize=function: support C

2023-06-14 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment. In D148827#4379764 , @MaskRay wrote: > These cases are UB and should be caught. It's not an excuse that they use C. Are they really though? struct A { int a; }; int foo(struct A *a) { return 42; } int

[PATCH] D148827: -fsanitize=function: support C

2023-05-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. In D148827#4379560 , @glandium wrote: > This breaks sqlite: > > /builds/worker/checkouts/gecko/third_party/sqlite3/src/sqlite3.c:137791:5: > runtime error: call to function sqlite3DeleteTable through pointer to > incorrect

[PATCH] D148827: -fsanitize=function: support C

2023-05-29 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment. This breaks sqlite: /builds/worker/checkouts/gecko/third_party/sqlite3/src/sqlite3.c:137791:5: runtime error: call to function sqlite3DeleteTable through pointer to incorrect function type 'void (*)(struct sqlite3 *, void *)'

[PATCH] D148827: -fsanitize=function: support C

2023-05-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG279a4d0d67c8: -fsanitize=function: support C (authored by MaskRay). Changed prior to commit: https://reviews.llvm.org/D148827?vs=524110=524374#toc Repository: rG LLVM Github Monorepo CHANGES SINCE

[PATCH] D148827: -fsanitize=function: support C

2023-05-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 524110. MaskRay added a comment. rebase. unsupport powerpc64-* as ppc64be ELFv1 may have an existing `error: Cannot represent a difference across sections` issue unrelated to the -fsanitize=function. Repository: rG LLVM Github Monorepo CHANGES SINCE

[PATCH] D148827: -fsanitize=function: support C

2023-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 522287. MaskRay added a comment. rebase the final patch in the series Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148827/new/ https://reviews.llvm.org/D148827 Files:

[PATCH] D148827: -fsanitize=function: support C

2023-05-15 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment. I agree with the reasoning. Can you update the documentation in clang/docs/UndefinedBehaviorSanitizer.rst to include C and state the known limitation. After D148573 it says: - ``-fsanitize=function``: Indirect call of a

[PATCH] D148827: -fsanitize=function: support C

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment. This patch is also available https://github.com/MaskRay/llvm-project/tree/function-c , which may make inspecting stacked patches easier. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148827/new/

[PATCH] D148827: -fsanitize=function: support C

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision. MaskRay added reviewers: Sanitizers, efriedma, pcc, peter.smith, sberg, samitolvanen. Herald added a subscriber: Enna1. Herald added a project: All. MaskRay requested review of this revision. Herald added projects: clang, Sanitizers. Herald added a subscriber: