[llvm-branch-commits] [llvm] [StaticDataLayout] Factor out a helper function for section prefix eligibility and use it in both optimizer and codegen (PR #162348)
Teresa Johnson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Oct 9 08:24:49 PDT 2025
================
@@ -817,13 +825,12 @@ bool MemProfUsePass::annotateGlobalVariables(
for (GlobalVariable &GVar : M.globals()) {
assert(!GVar.getSectionPrefix().has_value() &&
"GVar shouldn't have section prefix yet");
- if (GVar.isDeclarationForLinker())
- continue;
-
- if (hasExplicitSectionName(GVar)) {
- ++NumOfMemProfExplicitSectionGlobalVars;
- LLVM_DEBUG(dbgs() << "Global variable " << GVar.getName()
- << " has explicit section name. Skip annotating.\n");
+ auto Kind = llvm::memprof::getAnnotationKind(GVar);
+ switch (Kind) {
----------------
teresajohnson wrote:
Since the switch now only handles 2 cases, this would be clearer written as an if condition like:
```
if (Kind != llvm::memprof::AnnotationKind::AnnotationOK) {
HandleUnsupportedAnnotationKinds(GVar, Kind);
continue;
}
```
https://github.com/llvm/llvm-project/pull/162348
More information about the llvm-branch-commits
mailing list