Skip to content

Commit 13e563e

Browse files
[NFCI][StaticDataLayout] Get rid of section prefix validation in codegen (llvm#162349)
The section prefix validation was initially added when global variable's section prefix is only added in the codegen pass. Now the optimizer pass MemProfUse can annotate data section prefix by making use of data access profiles, so we can remove the validation. Also calls `setSectionPrefix` which returns whether section prefix is updated. This is the 3rd patch as a split of llvm#155337
1 parent 9bf88d0 commit 13e563e

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

llvm/lib/CodeGen/StaticDataAnnotator.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,8 @@ 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-
9081
StringRef SectionPrefix = SDPI->getConstantSectionPrefix(&GV, PSI);
91-
if (SectionPrefix.empty())
92-
continue;
93-
82+
// setSectionPrefix returns true if the section prefix is updated.
9483
Changed |= GV.setSectionPrefix(SectionPrefix);
9584
}
9685

llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
22
target triple = "x86_64-unknown-linux-gnu"
33

4-
;; A minimal test case. llc will crash if global variables already has a section
5-
;; prefix. Subsequent PRs will expand on this test case to test the hotness
6-
;; reconciliation implementation.
7-
8-
; RUN: not llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
4+
;; A minimal test case. Subsequent PRs will expand on this test case
5+
;; (e.g., with more functions, variables and profiles) and test the hotness
6+
;; reconcillation implementation.
7+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
98
; RUN: -partition-static-data-sections=true \
109
; RUN: -data-sections=true -unique-section-names=false \
11-
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefix=ERR
10+
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefix=IR
1211

13-
; ERR: Global variable hot_bss already has a section prefix hot
12+
; IR: .section .bss.hot.,"aw"
1413

1514
@hot_bss = internal global i32 0, !section_prefix !17
1615

0 commit comments

Comments
 (0)