[llvm-branch-commits] [llvm] [nfc][StaticDataLayout] Factor out helper functions for section prefix eligibility (PR #162348)
Teresa Johnson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 7 14:26:39 PDT 2025
================
@@ -6,6 +6,43 @@
#include "llvm/ProfileData/InstrProf.h"
using namespace llvm;
+
+namespace llvm {
+namespace memprof {
+// Returns true iff the global variable has custom section either by
+// __attribute__((section("name")))
+// (https://clang.llvm.org/docs/AttributeReference.html#section-declspec-allocate)
+// or #pragma clang section directives
+// (https://clang.llvm.org/docs/LanguageExtensions.html#specifying-section-names-for-global-objects-pragma-clang-section).
+static bool hasExplicitSectionName(const GlobalVariable &GVar) {
+ if (GVar.hasSection())
+ return true;
+
+ auto Attrs = GVar.getAttributes();
+ if (Attrs.hasAttribute("bss-section") || Attrs.hasAttribute("data-section") ||
+ Attrs.hasAttribute("relro-section") ||
+ Attrs.hasAttribute("rodata-section"))
+ return true;
+ return false;
+}
+
+AnnotationKind getAnnotationKind(const GlobalVariable &GV) {
+ if (GV.isDeclarationForLinker())
+ return AnnotationKind::DeclForLinker;
+ StringRef Name = GV.getName();
+ if (Name.starts_with("llvm."))
----------------
teresajohnson wrote:
This check is new afaict - so is this NFC?
https://github.com/llvm/llvm-project/pull/162348
More information about the llvm-branch-commits
mailing list