@@ -823,36 +823,6 @@ static inline bool shouldRecordFunctionAddr(Function *F) {
823
823
return F->hasAddressTaken () || F->hasLinkOnceLinkage ();
824
824
}
825
825
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
-
856
826
static bool needsRuntimeRegistrationOfSectionRange (const Triple &TT) {
857
827
// Don't do this for Darwin. compiler-rt uses linker magic.
858
828
if (TT.isOSDarwin ())
@@ -1044,7 +1014,9 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfInstBase *Inc) {
1044
1014
};
1045
1015
auto *DataTy = StructType::get (Ctx, makeArrayRef (DataTypes));
1046
1016
1047
- Constant *FunctionAddr = getFuncAddrForProfData (Fn);
1017
+ Constant *FunctionAddr = shouldRecordFunctionAddr (Fn)
1018
+ ? ConstantExpr::getBitCast (Fn, Int8PtrTy)
1019
+ : ConstantPointerNull::get (Int8PtrTy);
1048
1020
1049
1021
Constant *Int16ArrayVals[IPVK_Last + 1 ];
1050
1022
for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
0 commit comments