Skip to content

Commit 331888b

Browse files
save irrelevant change for the next PR to make this one focused
1 parent f68b06f commit 331888b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

llvm/lib/CodeGen/StaticDataAnnotator.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,19 @@ bool StaticDataAnnotator::runOnModule(Module &M) {
7878
if (!llvm::memprof::IsAnnotationOK(GV))
7979
continue;
8080

81+
// The implementation below assumes prior passes don't set section prefixes,
82+
// and specifically do 'assign' rather than 'update'. So report error if a
83+
// section prefix is already set.
84+
if (auto maybeSectionPrefix = GV.getSectionPrefix();
85+
maybeSectionPrefix && !maybeSectionPrefix->empty())
86+
llvm::report_fatal_error("Global variable " + GV.getName() +
87+
" already has a section prefix " +
88+
*maybeSectionPrefix);
89+
8190
StringRef SectionPrefix = SDPI->getConstantSectionPrefix(&GV, PSI);
82-
// setSectionPrefix returns true if the section prefix is changed.
91+
if (SectionPrefix.empty())
92+
continue;
93+
8394
Changed |= GV.setSectionPrefix(SectionPrefix);
8495
}
8596

0 commit comments

Comments
 (0)