Skip to content

Commit 96a5135

Browse files
committed
Revert "[InstrProf][X86] Mark non-directly accessed globals as large (#74778)"
This reverts commit 5507f70. Breaks bots, e.g. https://lab.llvm.org/buildbot/#/builders/232/builds/16374
1 parent bbb8a0d commit 96a5135

File tree

5 files changed

+8
-46
lines changed

5 files changed

+8
-46
lines changed

llvm/include/llvm/Transforms/Instrumentation.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ GlobalVariable *createPrivateGlobalForString(Module &M, StringRef Str,
4949
// Returns nullptr on failure.
5050
Comdat *getOrCreateFunctionComdat(Function &F, Triple &T);
5151

52-
// Place global in a large section for x86-64 ELF binaries to mitigate
53-
// relocation overflow pressure. This can be be used for metadata globals that
54-
// aren't directly accessed by code, which has no performance impact.
55-
void setGlobalVariableLargeSection(Triple &TargetTriple, GlobalVariable &GV);
56-
5752
// Insert GCOV profiling instrumentation
5853
struct GCOVOptions {
5954
static GCOVOptions getDefault();

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,9 @@ ModuleAddressSanitizer::CreateMetadataGlobal(Module &M, Constant *Initializer,
21462146
Metadata->setSection(getGlobalMetadataSection());
21472147
// Place metadata in a large section for x86-64 ELF binaries to mitigate
21482148
// relocation pressure.
2149-
setGlobalVariableLargeSection(TargetTriple, *Metadata);
2149+
if (TargetTriple.getArch() == Triple::x86_64 &&
2150+
TargetTriple.getObjectFormat() == Triple::ELF)
2151+
Metadata->setCodeModel(CodeModel::Large);
21502152
return Metadata;
21512153
}
21522154

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include "llvm/Support/Error.h"
5050
#include "llvm/Support/ErrorHandling.h"
5151
#include "llvm/TargetParser/Triple.h"
52-
#include "llvm/Transforms/Instrumentation.h"
5352
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
5453
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
5554
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -1295,7 +1294,6 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc) {
12951294
*M, ValuesTy, false, Linkage, Constant::getNullValue(ValuesTy),
12961295
getVarName(Inc, getInstrProfValuesVarPrefix(), Renamed));
12971296
ValuesVar->setVisibility(Visibility);
1298-
setGlobalVariableLargeSection(TT, *ValuesVar);
12991297
ValuesVar->setSection(
13001298
getInstrProfSectionName(IPSK_vals, TT.getObjectFormat()));
13011299
ValuesVar->setAlignment(Align(8));
@@ -1424,7 +1422,6 @@ void InstrProfiling::emitVNodes() {
14241422
auto *VNodesVar = new GlobalVariable(
14251423
*M, VNodesTy, false, GlobalValue::PrivateLinkage,
14261424
Constant::getNullValue(VNodesTy), getInstrProfVNodesVarName());
1427-
setGlobalVariableLargeSection(TT, *VNodesVar);
14281425
VNodesVar->setSection(
14291426
getInstrProfSectionName(IPSK_vnodes, TT.getObjectFormat()));
14301427
VNodesVar->setAlignment(M->getDataLayout().getABITypeAlign(VNodesTy));
@@ -1452,7 +1449,6 @@ void InstrProfiling::emitNameData() {
14521449
GlobalValue::PrivateLinkage, NamesVal,
14531450
getInstrProfNamesVarName());
14541451
NamesSize = CompressedNameStr.size();
1455-
setGlobalVariableLargeSection(TT, *NamesVar);
14561452
NamesVar->setSection(
14571453
getInstrProfSectionName(IPSK_name, TT.getObjectFormat()));
14581454
// On COFF, it's important to reduce the alignment down to 1 to prevent the

llvm/lib/Transforms/Instrumentation/Instrumentation.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,3 @@ Comdat *llvm::getOrCreateFunctionComdat(Function &F, Triple &T) {
8585
return C;
8686
}
8787

88-
void llvm::setGlobalVariableLargeSection(Triple &TargetTriple,
89-
GlobalVariable &GV) {
90-
if (TargetTriple.getArch() == Triple::x86_64 &&
91-
TargetTriple.getObjectFormat() == Triple::ELF) {
92-
GV.setCodeModel(CodeModel::Large);
93-
}
94-
}

llvm/test/Instrumentation/InstrProfiling/icall-comdat.ll

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
;; Check that static counters are allocated for value profiler
2+
23
; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC
34
; RUN: opt < %s -mtriple=powerpc-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC
45
; RUN: opt < %s -mtriple=sparc-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC
@@ -15,10 +16,6 @@
1516
; RUN: opt %s -mtriple=powerpc64-ibm-aix -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN
1617
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN
1718

18-
;; Check that globals have the proper code model.
19-
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-X8664
20-
; RUN: opt %s -mtriple=powerpc-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-PPC
21-
2219
@__profn_foo = private constant [3 x i8] c"foo"
2320
@__profn_bar = private constant [3 x i8] c"bar"
2421

@@ -49,8 +46,8 @@ declare void @llvm.instrprof.value.profile(ptr, i64, i64, i32, i32) #0
4946

5047
attributes #0 = { nounwind }
5148

52-
; STATIC: @__profvp_foo = private global [1 x i64] zeroinitializer, section "{{[^"]+}}",{{.*}} comdat($__profc_foo)
53-
; STATIC: @__profvp_bar = private global [1 x i64] zeroinitializer, section "{{[^"]+}}",{{.*}} comdat($__profc_bar)
49+
; STATIC: @__profvp_foo = private global [1 x i64] zeroinitializer, section "{{[^"]+}}", comdat($__profc_foo)
50+
; STATIC: @__profvp_bar = private global [1 x i64] zeroinitializer, section "{{[^"]+}}", comdat($__profc_bar)
5451
; STATIC: @__llvm_prf_vnodes
5552

5653
; DYN-NOT: @__profvp_foo
@@ -76,26 +73,5 @@ attributes #0 = { nounwind }
7673
; ALIGN: @__profc_bar = private global {{.*}} section "__llvm_prf_cnts",{{.*}} align 8
7774
; ALIGN: @__profvp_bar = private global {{.*}} section "__llvm_prf_vals",{{.*}} align 8
7875
; ALIGN: @__profd_bar = private global {{.*}} section "__llvm_prf_data",{{.*}} align 8
79-
; ALIGN: @__llvm_prf_vnodes = private global {{.*}} section "__llvm_prf_vnds",{{.*}} align 8
80-
; ALIGN: @__llvm_prf_nm = private constant {{.*}} section "__llvm_prf_names",{{.*}} align 1
81-
82-
; CODEMODEL: @__profc_foo =
83-
; CODEMODEL-NOT: code_model "large"
84-
; CODEMODEL: @__profvp_foo =
85-
; CODEMODEL-X8664-SAME: code_model "large"
86-
; CODEMODEL-PPC-NOT: code_model
87-
; CODEMODEL: @__profd_foo =
88-
; CODEMODEL-NOT: code_model "large"
89-
; CODEMODEL: @__profc_bar =
90-
; CODEMODEL-NOT: code_model "large"
91-
; CODEMODEL: @__profvp_bar =
92-
; CODEMODEL-X8664-SAME: code_model "large"
93-
; CODEMODEL-PPC-NOT: code_model
94-
; CODEMODEL: @__profd_bar =
95-
; CODEMODEL-NOT: code_model "large"
96-
; CODEMODEL: @__llvm_prf_vnodes =
97-
; CODEMODEL-X8664-SAME: code_model "large"
98-
; CODEMODEL-PPC-NOT: code_model
99-
; CODEMODEL: @__llvm_prf_nm =
100-
; CODEMODEL-X8664-SAME: code_model "large"
101-
; CODEMODEL-PPC-NOT: code_model
76+
; ALIGN: @__llvm_prf_vnodes = private global {{.*}} section "__llvm_prf_vnds", align 8
77+
; ALIGN: @__llvm_prf_nm = private constant {{.*}} section "__llvm_prf_names", align 1

0 commit comments

Comments
 (0)