[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu May 29 12:05:47 PDT 2025


================
@@ -0,0 +1,90 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+; sinf clobbering errno, but %p cannot alias errno per C/C++ strict aliasing rules via TBAA.
+; Hence, can do constant store-to-load forwarding.
+define float @does_not_alias_errno(ptr noundef %p, float noundef %f) {
+; CHECK-LABEL: define float @does_not_alias_errno(
+; CHECK-SAME: ptr noundef [[P:%.*]], float noundef [[F:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    store float 0.000000e+00, ptr [[P]], align 4, !tbaa [[TBAA4:![0-9]+]]
+; CHECK-NEXT:    [[CALL:%.*]] = call float @sinf(float noundef [[F]])
+; CHECK-NEXT:    ret float 0.000000e+00
+;
+entry:
+  store float 0.000000e+00, ptr %p, align 4, !tbaa !4
----------------
nikic wrote:

Missing negative test that uses `!0` instead.

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


More information about the cfe-commits mailing list