28 lines · c
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 22// REQUIRES: bpf-registered-target3// RUN: %clang_cc1 -triple bpf -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s4 5// Check that call to preserve.static.offset is generated when field of6// a struct marked with __attribute__((preserve_static_offset)) is accessed.7 8#define __ctx __attribute__((preserve_static_offset))9 10struct foo {11 int a;12} __ctx;13 14// CHECK-LABEL: define dso_local void @lvalue15// CHECK-SAME: (ptr noundef [[P:%.*]]) #[[ATTR0:[0-9]+]] {16// CHECK-NEXT: entry:17// CHECK-NEXT: [[P_ADDR:%.*]] = alloca ptr, align 818// CHECK-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 819// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 820// CHECK-NEXT: [[TMP1:%.*]] = call ptr @llvm.preserve.static.offset(ptr [[TMP0]])21// CHECK-NEXT: [[A:%.*]] = getelementptr inbounds nuw [[STRUCT_FOO:%.*]], ptr [[TMP1]], i32 0, i32 022// CHECK-NEXT: store i32 42, ptr [[A]], align 423// CHECK-NEXT: ret void24//25void lvalue(struct foo *p) {26 p->a = 42;27}28