Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / bpf-preserve-static-offset-lvalue.c
blob4289ff7a040eea2a0b2e9ab18e3cf2a377dba14d
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
2 // REQUIRES: bpf-registered-target
3 // RUN: %clang_cc1 -triple bpf -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
5 // Check that call to preserve.static.offset is generated when field of
6 // a struct marked with __attribute__((preserve_static_offset)) is accessed.
8 #define __ctx __attribute__((preserve_static_offset))
10 struct foo {
11 int a;
12 } __ctx;
14 // CHECK-LABEL: define dso_local void @lvalue
15 // CHECK-SAME: (ptr noundef [[P:%.*]]) #[[ATTR0:[0-9]+]] {
16 // CHECK-NEXT: entry:
17 // CHECK-NEXT: [[P_ADDR:%.*]] = alloca ptr, align 8
18 // CHECK-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8
19 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8
20 // 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 0
22 // CHECK-NEXT: store i32 42, ptr [[A]], align 4
23 // CHECK-NEXT: ret void
25 void lvalue(struct foo *p) {
26 p->a = 42;