================ @@ -3362,6 +3362,64 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op, return LowerGlobalTLSAddressLinux(Op, DAG); } +/// updateForAIXShLibTLSModelOpt - Helper to initialize TLS model opt settings, +/// and then apply the update. +static void updateForAIXShLibTLSModelOpt(TLSModel::Model &Model, + SelectionDAG &DAG, + const TargetMachine &TM) { + // Initialize TLS model opt setting lazily: + // (1) Use initial-exec for single TLS var references within current function. + // (2) Use local-dynamic for multiple TLS var references within current + // function. + PPCFunctionInfo *FuncInfo = + DAG.getMachineFunction().getInfo<PPCFunctionInfo>(); + if (!FuncInfo->isAIXFuncUseInitDone()) { + SmallPtrSet<const GlobalValue *, 8> TLSGV; + // Iterate over all instructions within current function, collect all TLS + // global variables (global variables taken as the first parameter to + // Intrinsic::threadlocal_address). + const Function &Func = DAG.getMachineFunction().getFunction(); + for (Function::const_iterator BI = Func.begin(), BE = Func.end(); BI != BE; + ++BI) + for (BasicBlock::const_iterator II = BI->begin(), IE = BI->end(); + II != IE; ++II) + if (II->getOpcode() == Instruction::Call) + if (const CallInst *CI = dyn_cast<const CallInst>(&*II)) + if (Function *CF = CI->getCalledFunction()) + if (CF->isDeclaration() && + CF->getIntrinsicID() == Intrinsic::threadlocal_address) + if (const GlobalValue *GV = + dyn_cast<GlobalValue>(II->getOperand(0))) { + TLSModel::Model GVModel = TM.getTLSModel(GV); + if (GVModel == TLSModel::InitialExec || ---------------- orcguru wrote:
Thank you for the guidance. I have limited the transformation. https://github.com/llvm/llvm-project/pull/84132 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits