@@ -823,36 +823,6 @@ static inline bool shouldRecordFunctionAddr(Function *F) {
823823 return F->hasAddressTaken () || F->hasLinkOnceLinkage ();
824824}
825825
826- static inline Constant *getFuncAddrForProfData (Function *Fn) {
827- auto *Int8PtrTy = Type::getInt8PtrTy (Fn->getContext ());
828- // Store a nullptr in __llvm_profd, if we shouldn't use a real address
829- if (!shouldRecordFunctionAddr (Fn))
830- return ConstantPointerNull::get (Int8PtrTy);
831-
832- // If we can't use an alias, we must use the public symbol, even though this
833- // may require a symbolic relocation. When the function has local linkage, we
834- // can use the symbol directly without introducing relocations.
835- if (Fn->isDeclarationForLinker () || Fn->hasLocalLinkage ())
836- return ConstantExpr::getBitCast (Fn, Int8PtrTy);
837-
838- // When possible use a private alias to avoid symbolic relocations.
839- auto *GA = GlobalAlias::create (GlobalValue::LinkageTypes::PrivateLinkage,
840- Fn->getName (), Fn);
841-
842- // When the instrumented function is a COMDAT function, we cannot use a
843- // private alias. If we did, we would create reference to a local label in
844- // this function's section. If this version of the function isn't selected by
845- // the linker, then the metadata would introduce a reference to a discarded
846- // section. So, for COMDAT functions, we need to adjust the linkage of the
847- // alias. Using hidden visibility avoids a dynamic relocation and an entry in
848- // the dynamic symbol table.
849- if (Fn->hasComdat ()) {
850- GA->setLinkage (Fn->getLinkage ());
851- GA->setVisibility (GlobalValue::VisibilityTypes::HiddenVisibility);
852- }
853- return ConstantExpr::getBitCast (GA, Int8PtrTy);
854- }
855-
856826static bool needsRuntimeRegistrationOfSectionRange (const Triple &TT) {
857827 // Don't do this for Darwin. compiler-rt uses linker magic.
858828 if (TT.isOSDarwin ())
@@ -1044,7 +1014,9 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfInstBase *Inc) {
10441014 };
10451015 auto *DataTy = StructType::get (Ctx, makeArrayRef (DataTypes));
10461016
1047- Constant *FunctionAddr = getFuncAddrForProfData (Fn);
1017+ Constant *FunctionAddr = shouldRecordFunctionAddr (Fn)
1018+ ? ConstantExpr::getBitCast (Fn, Int8PtrTy)
1019+ : ConstantPointerNull::get (Int8PtrTy);
10481020
10491021 Constant *Int16ArrayVals[IPVK_Last + 1 ];
10501022 for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
0 commit comments