================
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=alignment,null \
+// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-UBSAN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-UBSAN
+
+// Test that EmitAggregateCopy emits null and alignment checks when sanitizers
+// are enabled for aggregate copy operations with pointers.
+
+struct alignas(16) AlignedStruct {
+ int a;
+ int b;
+ int c;
+ int d;
+};
+
+struct NormalStruct {
+ int x;
+ int y;
+ int z;
+};
+
+// Stack-to-stack copies are optimized away (compiler knows they're valid)
----------------
vasu-the-sharma wrote:
Agreed. I've focused this test on verifying that we're correctly calling the
UBSAN APIs when copying through pointers, rather than testing optimization
behavior. The compiler's ability to elide checks for stack-to-stack copies is
already covered by existing tests, and the main goal here is to demonstrate
that EmitAggregateCopy properly invokes sanitizer checks for pointer-based
aggregate operations.
https://github.com/llvm/llvm-project/pull/164548
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits