@@ -758,18 +758,14 @@ void InstrProfiling::lowerCoverageData(GlobalVariable *CoverageNamesVar) {
758
758
}
759
759
760
760
// / Get the name of a profiling variable for a particular function.
761
- static std::string getVarName (InstrProfIncrementInst *Inc, StringRef Prefix,
762
- bool &Renamed) {
761
+ static std::string getVarName (InstrProfIncrementInst *Inc, StringRef Prefix) {
763
762
StringRef NamePrefix = getInstrProfNameVarPrefix ();
764
763
StringRef Name = Inc->getName ()->getName ().substr (NamePrefix.size ());
765
764
Function *F = Inc->getParent ()->getParent ();
766
765
Module *M = F->getParent ();
767
766
if (!DoHashBasedCounterSplit || !isIRPGOFlagSet (M) ||
768
- !canRenameComdatFunc (*F)) {
769
- Renamed = false ;
767
+ !canRenameComdatFunc (*F))
770
768
return (Prefix + Name).str ();
771
- }
772
- Renamed = true ;
773
769
uint64_t FuncHash = Inc->getHash ()->getZExtValue ();
774
770
SmallVector<char , 24 > HashPostfix;
775
771
if (Name.endswith ((Twine (" ." ) + Twine (FuncHash)).toStringRef (HashPostfix)))
@@ -882,11 +878,8 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
882
878
// discarded.
883
879
bool DataReferencedByCode = profDataReferencedByCode (*M);
884
880
bool NeedComdat = needsComdatForCounter (*Fn, *M);
885
- bool Renamed;
886
- std::string CntsVarName =
887
- getVarName (Inc, getInstrProfCountersVarPrefix (), Renamed);
888
- std::string DataVarName =
889
- getVarName (Inc, getInstrProfDataVarPrefix (), Renamed);
881
+ std::string CntsVarName = getVarName (Inc, getInstrProfCountersVarPrefix ());
882
+ std::string DataVarName = getVarName (Inc, getInstrProfDataVarPrefix ());
890
883
auto MaybeSetComdat = [&](GlobalVariable *GV) {
891
884
bool UseComdat = (NeedComdat || TT.isOSBinFormatELF ());
892
885
if (UseComdat) {
@@ -927,7 +920,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
927
920
ArrayType *ValuesTy = ArrayType::get (Type::getInt64Ty (Ctx), NS);
928
921
auto *ValuesVar = new GlobalVariable (
929
922
*M, ValuesTy, false , Linkage, Constant::getNullValue (ValuesTy),
930
- getVarName (Inc, getInstrProfValuesVarPrefix (), Renamed ));
923
+ getVarName (Inc, getInstrProfValuesVarPrefix ()));
931
924
ValuesVar->setVisibility (Visibility);
932
925
ValuesVar->setSection (
933
926
getInstrProfSectionName (IPSK_vals, TT.getObjectFormat ()));
@@ -962,13 +955,8 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
962
955
//
963
956
// On COFF, a comdat leader cannot be local so we require DataReferencedByCode
964
957
// to be false.
965
- //
966
- // If profd is in a deduplicate comdat, NS==0 with a hash suffix guarantees
967
- // that other copies must have the same CFG and cannot have value profiling.
968
- // If no hash suffix, other profd copies may be referenced by code.
969
- if (NS == 0 && !(NeedComdat && !Renamed) &&
970
- (TT.isOSBinFormatELF () ||
971
- (!DataReferencedByCode && TT.isOSBinFormatCOFF ()))) {
958
+ if (NS == 0 && (TT.isOSBinFormatELF () ||
959
+ (!DataReferencedByCode && TT.isOSBinFormatCOFF ()))) {
972
960
Linkage = GlobalValue::PrivateLinkage;
973
961
Visibility = GlobalValue::DefaultVisibility;
974
962
}
0 commit comments