[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)
Amy Kwan via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 21 10:55:44 PDT 2024
================
@@ -3369,6 +3369,48 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddressAIX(SDValue Op,
bool Is64Bit = Subtarget.isPPC64();
bool HasAIXSmallLocalExecTLS = Subtarget.hasAIXSmallLocalExecTLS();
TLSModel::Model Model = getTargetMachine().getTLSModel(GV);
+ // Initialize heuristic setting lazily:
+ // (1) Use initial-exec for single TLS var reference within current function.
+ // (2) Use local-dynamic for multiple TLS var references within current func.
+ PPCFunctionInfo *FuncInfo =
+ DAG.getMachineFunction().getInfo<PPCFunctionInfo>();
+ if (Subtarget.hasAIXShLibTLSModelHeuristic() &&
+ !FuncInfo->isAIXFuncUseInitDone()) {
+ std::set<const GlobalValue *> TLSGV;
+ for (SDNode &Node : DAG.allnodes()) {
+ SDNode *N = &Node;
+ if (N->getOpcode() == ISD::GlobalTLSAddress) {
+ if (GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N)) {
+ const GlobalValue *GV = GA->getGlobal();
+ TLSModel::Model Model = getTargetMachine().getTLSModel(GV);
+ if (Model == TLSModel::InitialExec ||
+ Model == TLSModel::LocalDynamic) {
+ TLSGV.insert(GV);
+ }
+ }
+ }
+ }
+ LLVM_DEBUG(dbgs() << format("TLSGV count:%d\n", TLSGV.size()));
----------------
amy-kwan wrote:
`TLSGV.size()` is used more than once and can be pulled out.
https://github.com/llvm/llvm-project/pull/84132
More information about the cfe-commits
mailing list