[clang] -fsanitize=alignment: check memcpy/memmove arguments (PR #67766)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 13:10:38 PDT 2023


================
@@ -47,6 +50,16 @@ int main(int, char **argv) {
     return *p && 0;
     // CHECK-STACK-LOAD: #0 {{.*}}main{{.*}}misaligned.cpp
 
+  case 'L': {
+    int x;
+    // CHECK-MEMCPY-LOAD: misaligned.cpp:[[#@LINE+4]]{{(:16)?}}: runtime error: load of misaligned address [[PTR:0x[0-9a-f]*]] for type 'const void *', which requires 4 byte alignment
----------------
MaskRay wrote:

Yes, the issue was mentioned in the description
```
The error message refers to void * instead of int *, which is not perfect
but should be acceptable.

runtime error: store to misaligned address [[PTR:0x[0-9a-f]*]] for type 'void *'
```

Anyhow, `BI__builtin_HEXAGON_V6_vmaskedstoreq` strips an implicit cast. I added a similar mechanism in 9b705127b17513ee17e76fb903e85500c832d8aa

https://github.com/llvm/llvm-project/pull/67766


More information about the cfe-commits mailing list