[PATCH] D133361: [BPF] Attribute preserve_static_offset for structs

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 12:16:45 PDT 2023


aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a comment.

I don't have a whole lot of opinions on the attribute itself (I'm not super familiar with BPF), but did spot some things to do on the Clang side. This will also need reviewers for the LLVM changes -- any ideas on who usually reviews BPF-related changes in LLVM?



================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7597-7604
 
+static void handleBPFPreserveStaticOffsetAttr(Sema &S, Decl *D,
+                                              const ParsedAttr &AL) {
+  auto *Rec = cast<RecordDecl>(D);
+  Rec->addAttr(::new (S.Context) BPFPreserveStaticOffsetAttr(S.Context, AL));
+}
+
----------------



================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8871
+  case ParsedAttr::AT_BPFPreserveStaticOffset:
+    handleBPFPreserveStaticOffsetAttr(S, D, AL);
+    break;
----------------



================
Comment at: clang/test/Sema/bpf-attr-preserve-static-offset.c:1
+// RUN: %clang_cc1 -fsyntax-only -ast-dump -triple bpf-pc-linux-gnu %s | FileCheck %s
+
----------------
You should also add a `-verify` test that verifies we diagnose applying the attribute to something other than a structure or union, accepts no arguments, is diagnosed on a non-BPF target, etc to ensure we've got correct diagnostic behavior.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133361/new/

https://reviews.llvm.org/D133361



More information about the llvm-commits mailing list