Skip to content

Commit 53b4a14

Browse files
committed
Merge branch 'main' into users/kparzysz/spr/d02-flang-doacross-sema
2 parents 2a94fd7 + f87737f commit 53b4a14

File tree

1,484 files changed

+151893
-143172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,484 files changed

+151893
-143172
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @MaheshRavishankar @nicolasvasilache
6969
/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp @hanhanW @nicolasvasilache
7070
/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @dcaballe @hanhanW @nicolasvasilache
71-
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @banach-space @dcaballe @hanhanW @nicolasvasilache
71+
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @banach-space @dcaballe @hanhanW @nicolasvasilache @Groverkss
7272

7373
# MemRef Dialect in MLIR.
7474
/mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp @MaheshRavishankar @nicolasvasilache
@@ -82,9 +82,9 @@
8282
/mlir/**/*VectorToSCF* @banach-space @dcaballe @matthias-springer @nicolasvasilache
8383
/mlir/**/*VectorToLLVM* @banach-space @dcaballe @nicolasvasilache
8484
/mlir/**/*X86Vector* @aartbik @dcaballe @nicolasvasilache
85-
/mlir/include/mlir/Dialect/Vector @banach-space @dcaballe @nicolasvasilache
85+
/mlir/include/mlir/Dialect/Vector @banach-space @dcaballe @nicolasvasilache @Groverkss
8686
/mlir/include/mlir/Dialect/Vector/IR @kuhar
87-
/mlir/lib/Dialect/Vector @banach-space @dcaballe @nicolasvasilache
87+
/mlir/lib/Dialect/Vector @banach-space @dcaballe @nicolasvasilache @Groverkss
8888
/mlir/lib/Dialect/Vector/Transforms/* @banach-space @dcaballe @hanhanW @nicolasvasilache
8989
/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @banach-space @dcaballe @MaheshRavishankar @nicolasvasilache
9090
/mlir/**/*EmulateNarrowType* @dcaballe @hanhanW
@@ -141,7 +141,7 @@
141141
/clang/tools/clang-installapi/ @cyndyishida
142142

143143
# ExtractAPI
144-
/clang/**/ExtractAPI @daniel-grumberg
144+
/clang/**/ExtractAPI @daniel-grumberg @QuietMisdreavus
145145

146146
# DWARFLinker, dwarfutil, dsymutil
147147
/llvm/**/DWARFLinker/ @JDevlieghere

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,10 @@ class BinaryFunction {
908908
return BB && BB->getOffset() == Offset ? BB : nullptr;
909909
}
910910

911+
const BinaryBasicBlock *getBasicBlockAtOffset(uint64_t Offset) const {
912+
return const_cast<BinaryFunction *>(this)->getBasicBlockAtOffset(Offset);
913+
}
914+
911915
/// Retrieve the landing pad BB associated with invoke instruction \p Invoke
912916
/// that is in \p BB. Return nullptr if none exists
913917
BinaryBasicBlock *getLandingPadBBFor(const BinaryBasicBlock &BB,

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ class DataAggregator : public DataReader {
266266
uint64_t Mispreds);
267267

268268
/// Register a \p Branch.
269-
bool doBranch(uint64_t From, uint64_t To, uint64_t Count, uint64_t Mispreds);
269+
bool doBranch(uint64_t From, uint64_t To, uint64_t Count, uint64_t Mispreds,
270+
bool IsPreagg);
270271

271272
/// Register a trace between two LBR entries supplied in execution order.
272273
bool doTrace(const LBREntry &First, const LBREntry &Second,

bolt/include/bolt/Profile/YAMLProfileReader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class YAMLProfileReader : public ProfileReaderBase {
105105
yaml::bolt::BinaryProfile YamlBP;
106106

107107
/// Map a function ID from a YAML profile to a BinaryFunction object.
108-
std::vector<BinaryFunction *> YamlProfileToFunction;
108+
DenseMap<uint32_t, BinaryFunction *> YamlProfileToFunction;
109109

110110
using FunctionSet = std::unordered_set<const BinaryFunction *>;
111111
/// To keep track of functions that have a matched profile before the profile
@@ -162,8 +162,6 @@ class YAMLProfileReader : public ProfileReaderBase {
162162
/// Update matched YAML -> BinaryFunction pair.
163163
void matchProfileToFunction(yaml::bolt::BinaryFunctionProfile &YamlBF,
164164
BinaryFunction &BF) {
165-
if (YamlBF.Id >= YamlProfileToFunction.size())
166-
YamlProfileToFunction.resize(YamlBF.Id + 1);
167165
YamlProfileToFunction[YamlBF.Id] = &BF;
168166
YamlBF.Used = true;
169167

bolt/lib/Passes/LongJmp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ void LongJmpPass::relaxLocalBranches(BinaryFunction &BF) {
877877
<< " of " << BF << " in " << NumIterations << " iterations\n";
878878
}
879879
});
880+
(void)NumIterations;
880881
}
881882

882883
// Add trampoline blocks from all fragments to the layout.

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -778,42 +778,75 @@ bool DataAggregator::doInterBranch(BinaryFunction *FromFunc,
778778
}
779779

780780
bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
781-
uint64_t Mispreds) {
782-
bool IsReturn = false;
783-
auto handleAddress = [&](uint64_t &Addr, bool IsFrom) -> BinaryFunction * {
784-
if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr)) {
785-
Addr -= Func->getAddress();
786-
if (IsFrom) {
787-
auto checkReturn = [&](auto MaybeInst) {
788-
IsReturn = MaybeInst && BC->MIB->isReturn(*MaybeInst);
789-
};
790-
if (Func->hasInstructions())
791-
checkReturn(Func->getInstructionAtOffset(Addr));
792-
else
793-
checkReturn(Func->disassembleInstructionAtOffset(Addr));
794-
}
781+
uint64_t Mispreds, bool IsPreagg) {
782+
// Returns whether \p Offset in \p Func contains a return instruction.
783+
auto checkReturn = [&](const BinaryFunction &Func, const uint64_t Offset) {
784+
auto isReturn = [&](auto MI) { return MI && BC->MIB->isReturn(*MI); };
785+
return Func.hasInstructions()
786+
? isReturn(Func.getInstructionAtOffset(Offset))
787+
: isReturn(Func.disassembleInstructionAtOffset(Offset));
788+
};
795789

796-
if (BAT)
797-
Addr = BAT->translate(Func->getAddress(), Addr, IsFrom);
790+
// Returns whether \p Offset in \p Func may be a call continuation excluding
791+
// entry points and landing pads.
792+
auto checkCallCont = [&](const BinaryFunction &Func, const uint64_t Offset) {
793+
// No call continuation at a function start.
794+
if (!Offset)
795+
return false;
796+
797+
// FIXME: support BAT case where the function might be in empty state
798+
// (split fragments declared non-simple).
799+
if (!Func.hasCFG())
800+
return false;
801+
802+
// The offset should not be an entry point or a landing pad.
803+
const BinaryBasicBlock *ContBB = Func.getBasicBlockAtOffset(Offset);
804+
return ContBB && !ContBB->isEntryPoint() && !ContBB->isLandingPad();
805+
};
798806

799-
if (BinaryFunction *ParentFunc = getBATParentFunction(*Func)) {
800-
Func = ParentFunc;
801-
if (IsFrom)
802-
NumColdSamples += Count;
803-
}
807+
// Mutates \p Addr to an offset into the containing function, performing BAT
808+
// offset translation and parent lookup.
809+
//
810+
// Returns the containing function (or BAT parent) and whether the address
811+
// corresponds to a return (if \p IsFrom) or a call continuation (otherwise).
812+
auto handleAddress = [&](uint64_t &Addr, bool IsFrom) {
813+
BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr);
814+
if (!Func)
815+
return std::pair{Func, false};
804816

805-
return Func;
806-
}
807-
return nullptr;
817+
Addr -= Func->getAddress();
818+
819+
bool IsRetOrCallCont =
820+
IsFrom ? checkReturn(*Func, Addr) : checkCallCont(*Func, Addr);
821+
822+
if (BAT)
823+
Addr = BAT->translate(Func->getAddress(), Addr, IsFrom);
824+
825+
BinaryFunction *ParentFunc = getBATParentFunction(*Func);
826+
if (!ParentFunc)
827+
return std::pair{Func, IsRetOrCallCont};
828+
829+
if (IsFrom)
830+
NumColdSamples += Count;
831+
832+
return std::pair{ParentFunc, IsRetOrCallCont};
808833
};
809834

810-
BinaryFunction *FromFunc = handleAddress(From, /*IsFrom=*/true);
835+
uint64_t ToOrig = To;
836+
auto [FromFunc, IsReturn] = handleAddress(From, /*IsFrom*/ true);
837+
auto [ToFunc, IsCallCont] = handleAddress(To, /*IsFrom*/ false);
838+
if (!FromFunc && !ToFunc)
839+
return false;
840+
841+
// Record call to continuation trace.
842+
if (IsPreagg && FromFunc != ToFunc && (IsReturn || IsCallCont)) {
843+
LBREntry First{ToOrig - 1, ToOrig - 1, false};
844+
LBREntry Second{ToOrig, ToOrig, false};
845+
return doTrace(First, Second, Count);
846+
}
811847
// Ignore returns.
812848
if (IsReturn)
813849
return true;
814-
BinaryFunction *ToFunc = handleAddress(To, /*IsFrom=*/false);
815-
if (!FromFunc && !ToFunc)
816-
return false;
817850

818851
// Treat recursive control transfers as inter-branches.
819852
if (FromFunc == ToFunc && To != 0) {
@@ -830,10 +863,19 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
830863
BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(Second.From);
831864
if (!FromFunc || !ToFunc) {
832865
LLVM_DEBUG({
833-
dbgs() << "Out of range trace starting in " << FromFunc->getPrintName()
834-
<< formatv(" @ {0:x}", First.To - FromFunc->getAddress())
835-
<< " and ending in " << ToFunc->getPrintName()
836-
<< formatv(" @ {0:x}\n", Second.From - ToFunc->getAddress());
866+
dbgs() << "Out of range trace starting in ";
867+
if (FromFunc)
868+
dbgs() << formatv("{0} @ {1:x}", *FromFunc,
869+
First.To - FromFunc->getAddress());
870+
else
871+
dbgs() << Twine::utohexstr(First.To);
872+
dbgs() << " and ending in ";
873+
if (ToFunc)
874+
dbgs() << formatv("{0} @ {1:x}", *ToFunc,
875+
Second.From - ToFunc->getAddress());
876+
else
877+
dbgs() << Twine::utohexstr(Second.From);
878+
dbgs() << '\n';
837879
});
838880
NumLongRangeTraces += Count;
839881
return false;
@@ -1620,7 +1662,8 @@ void DataAggregator::processBranchEvents() {
16201662
for (const auto &AggrLBR : BranchLBRs) {
16211663
const Trace &Loc = AggrLBR.first;
16221664
const TakenBranchInfo &Info = AggrLBR.second;
1623-
doBranch(Loc.From, Loc.To, Info.TakenCount, Info.MispredCount);
1665+
doBranch(Loc.From, Loc.To, Info.TakenCount, Info.MispredCount,
1666+
/*IsPreagg*/ false);
16241667
}
16251668
}
16261669

@@ -1781,7 +1824,7 @@ void DataAggregator::processPreAggregated() {
17811824
switch (AggrEntry.EntryType) {
17821825
case AggregatedLBREntry::BRANCH:
17831826
doBranch(AggrEntry.From.Offset, AggrEntry.To.Offset, AggrEntry.Count,
1784-
AggrEntry.Mispreds);
1827+
AggrEntry.Mispreds, /*IsPreagg*/ true);
17851828
break;
17861829
case AggregatedLBREntry::FT:
17871830
case AggregatedLBREntry::FT_EXTERNAL_ORIGIN: {

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ bool YAMLProfileReader::parseFunctionProfile(
238238
BB.setExecutionCount(YamlBB.ExecCount);
239239

240240
for (const yaml::bolt::CallSiteInfo &YamlCSI : YamlBB.CallSites) {
241-
BinaryFunction *Callee = YamlCSI.DestId < YamlProfileToFunction.size()
242-
? YamlProfileToFunction[YamlCSI.DestId]
243-
: nullptr;
241+
BinaryFunction *Callee = YamlProfileToFunction.lookup(YamlCSI.DestId);
244242
bool IsFunction = Callee ? true : false;
245243
MCSymbol *CalleeSymbol = nullptr;
246244
if (IsFunction)
@@ -703,7 +701,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
703701
break;
704702
}
705703
}
706-
YamlProfileToFunction.resize(YamlBP.Functions.size() + 1);
704+
YamlProfileToFunction.reserve(YamlBP.Functions.size());
707705

708706
// Computes hash for binary functions.
709707
if (opts::MatchProfileWithFunctionHash) {
@@ -756,12 +754,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
756754
NormalizeByCalls = usesEvent("branches");
757755
uint64_t NumUnused = 0;
758756
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
759-
if (YamlBF.Id >= YamlProfileToFunction.size()) {
760-
// Such profile was ignored.
761-
++NumUnused;
762-
continue;
763-
}
764-
if (BinaryFunction *BF = YamlProfileToFunction[YamlBF.Id])
757+
if (BinaryFunction *BF = YamlProfileToFunction.lookup(YamlBF.Id))
765758
parseFunctionProfile(*BF, YamlBF);
766759
else
767760
++NumUnused;

bolt/lib/Rewrite/PseudoProbeRewriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
127127

128128
StringRef Contents = PseudoProbeDescSection->getContents();
129129
if (!ProbeDecoder.buildGUID2FuncDescMap(
130-
reinterpret_cast<const uint8_t *>(Contents.data()),
131-
Contents.size())) {
130+
reinterpret_cast<const uint8_t *>(Contents.data()), Contents.size(),
131+
/*IsMMapped*/ true)) {
132132
errs() << "BOLT-WARNING: fail in building GUID2FuncDescMap\n";
133133
return;
134134
}

0 commit comments

Comments
 (0)