Skip to content

Commit dcb9f00

Browse files
resolve comments
1 parent 331888b commit dcb9f00

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/Analysis/StaticDataProfileInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ static bool hasExplicitSectionName(const GlobalVariable &GVar) {
2929
AnnotationKind getAnnotationKind(const GlobalVariable &GV) {
3030
if (GV.isDeclarationForLinker())
3131
return AnnotationKind::DeclForLinker;
32+
// Skip 'llvm.'-prefixed global variables conservatively because they are
33+
// often handled specially,
3234
StringRef Name = GV.getName();
3335
if (Name.starts_with("llvm."))
3436
return AnnotationKind::ReservedName;
37+
// Respect user-specified custom data sections.
3538
if (hasExplicitSectionName(GV))
3639
return AnnotationKind::ExplicitSection;
3740
return AnnotationKind::AnnotationOK;

llvm/lib/CodeGen/StaticDataSplitter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ StaticDataSplitter::getConstant(const MachineOperand &Op,
130130
if (Op.isGlobal()) {
131131
// Find global variables with local linkage.
132132
const GlobalVariable *GV = getLocalLinkageGlobalVariable(Op.getGlobal());
133-
// Skip 'llvm.'-prefixed global variables conservatively because they are
134-
// often handled specially, and skip those not in static data
135-
// sections.
136-
if (!GV || GV->getName().starts_with("llvm.") ||
133+
// Skip those not eligible for annotation or not in static data sections.
134+
if (!GV || !llvm::memprof::IsAnnotationOK(*GV) ||
137135
!inStaticDataSection(*GV, TM))
138136
return nullptr;
139137
return GV;

0 commit comments

Comments
 (0)