Skip to content

Commit

Permalink
Merge pull request #309 from Xilinx/bump_to_267de854
Browse files Browse the repository at this point in the history
[AutoBump] Merge with 267de85 (May 22) (50)
  • Loading branch information
mgehre-amd authored Sep 4, 2024
2 parents 88c094e + 1815baa commit efc7b5a
Show file tree
Hide file tree
Showing 2,195 changed files with 74,045 additions and 48,599 deletions.
2 changes: 1 addition & 1 deletion .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function compute-projects-to-test() {
done
;;
clang)
for p in clang-tools-extra compiler-rt flang lldb cross-project-tests; do
for p in clang-tools-extra compiler-rt lldb cross-project-tests; do
echo $p
done
;;
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Setup Environment
run: |
pip install -r ./llvm/utils/git/requirements.txt
pip install --require-hashes -r ./llvm/utils/git/requirements.txt
./llvm/utils/git/github-automation.py --token ${{ github.token }} setup-llvmbot-git
- name: Backport Commits
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-subscriber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Automation Script
working-directory: ./llvm/utils/git/
run: |
pip install -r requirements.txt
pip install --require-hashes -r requirements.txt
- name: Update watchers
working-directory: ./llvm/utils/git/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/llvm-bugs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'llvm/llvm-project'
steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merged-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Automation Script
working-directory: ./llvm/utils/git/
run: |
pip install -r requirements.txt
pip install --require-hashes -r requirements.txt
- name: Add Buildbot information comment
working-directory: ./llvm/utils/git/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/new-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Setup Automation Script
working-directory: ./llvm/utils/git/
run: |
pip install -r requirements.txt
pip install --require-hashes -r requirements.txt
- name: Greet Author
working-directory: ./llvm/utils/git/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-request-release-note.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Install Dependencies
run: |
pip install -r llvm/utils/git/requirements.txt
pip install --require-hashes -r llvm/utils/git/requirements.txt
- name: Request Release Note
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-subscriber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Automation Script
working-directory: ./llvm/utils/git/
run: |
pip install -r requirements.txt
pip install --require-hashes -r requirements.txt
- name: Update watchers
working-directory: ./llvm/utils/git/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Install Dependencies
run: |
pip install -r ./llvm/utils/git/requirements.txt
pip install --require-hashes -r ./llvm/utils/git/requirements.txt
- name: Check Permissions
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Install dependencies
run: |
pip install -r ./llvm/utils/git/requirements.txt
pip install --require-hashes -r ./llvm/utils/git/requirements.txt
- name: Version Check
run: |
Expand Down
3 changes: 3 additions & 0 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,9 @@ class BinaryContext {
/// have an origin file name available.
bool HasSymbolsWithFileName{false};

/// Does the binary have BAT section.
bool HasBATSection{false};

/// Sum of execution count of all functions
uint64_t SumExecutionCount{0};

Expand Down
4 changes: 2 additions & 2 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ class MCPlusBuilder {
return false;
}

/// Check whether we support inverting this branch
virtual bool isUnsupportedBranch(const MCInst &Inst) const { return false; }
/// Check whether this conditional branch can be reversed
virtual bool isReversibleBranch(const MCInst &Inst) const { return true; }

/// Return true of the instruction is of pseudo kind.
virtual bool isPseudo(const MCInst &Inst) const {
Expand Down
6 changes: 5 additions & 1 deletion bolt/include/bolt/Passes/BinaryPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "bolt/Core/BinaryContext.h"
#include "bolt/Core/BinaryFunction.h"
#include "bolt/Core/DynoStats.h"
#include "bolt/Profile/BoltAddressTranslation.h"
#include "llvm/Support/CommandLine.h"
#include <atomic>
#include <set>
Expand Down Expand Up @@ -399,8 +400,11 @@ class PrintProfileStats : public BinaryFunctionPass {
/// Prints a list of the top 100 functions sorted by a set of
/// dyno stats categories.
class PrintProgramStats : public BinaryFunctionPass {
BoltAddressTranslation *BAT = nullptr;

public:
explicit PrintProgramStats() : BinaryFunctionPass(false) {}
explicit PrintProgramStats(BoltAddressTranslation *BAT = nullptr)
: BinaryFunctionPass(false), BAT(BAT) {}

const char *getName() const override { return "print-stats"; }
bool shouldPrint(const BinaryFunction &) const override { return false; }
Expand Down
4 changes: 2 additions & 2 deletions bolt/include/bolt/Passes/StokeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ struct StokeFuncInfo {
<< "," << NumBlocks << "," << IsLoopFree << "," << NumLoops << ","
<< MaxLoopDepth << "," << HotSize << "," << TotalSize << ","
<< Score << "," << HasCall << ",\"{ ";
for (std::string S : DefIn)
for (const std::string &S : DefIn)
Outfile << "%" << S << " ";
Outfile << "}\",\"{ ";
for (std::string S : LiveOut)
for (const std::string &S : LiveOut)
Outfile << "%" << S << " ";
Outfile << "}\"," << HeapOut << "," << StackOut << "," << HasRipAddr
<< "," << Omitted << "\n";
Expand Down
9 changes: 6 additions & 3 deletions bolt/include/bolt/Profile/DataAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define BOLT_PROFILE_DATA_AGGREGATOR_H

#include "bolt/Profile/DataReader.h"
#include "bolt/Profile/YAMLProfileWriter.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Program.h"
Expand Down Expand Up @@ -122,14 +123,14 @@ class DataAggregator : public DataReader {
uint64_t ExternCount{0};
};

struct BranchInfo {
struct TakenBranchInfo {
uint64_t TakenCount{0};
uint64_t MispredCount{0};
};

/// Intermediate storage for profile data. We save the results of parsing
/// and use them later for processing and assigning profile.
std::unordered_map<Trace, BranchInfo, TraceHash> BranchLBRs;
std::unordered_map<Trace, TakenBranchInfo, TraceHash> BranchLBRs;
std::unordered_map<Trace, FTInfo, TraceHash> FallthroughLBRs;
std::vector<AggregatedLBREntry> AggregatedLBRs;
std::unordered_map<uint64_t, uint64_t> BasicSamples;
Expand Down Expand Up @@ -248,7 +249,7 @@ class DataAggregator : public DataReader {
BinaryFunction *getBATParentFunction(const BinaryFunction &Func) const;

/// Retrieve the location name to be used for samples recorded in \p Func.
StringRef getLocationName(const BinaryFunction &Func) const;
static StringRef getLocationName(const BinaryFunction &Func, bool BAT);

/// Semantic actions - parser hooks to interpret parsed perf samples
/// Register a sample (non-LBR mode), i.e. a new hit at \p Address
Expand Down Expand Up @@ -490,6 +491,8 @@ class DataAggregator : public DataReader {
/// Parse the output generated by "perf buildid-list" to extract build-ids
/// and return a file name matching a given \p FileBuildID.
std::optional<StringRef> getFileNameForBuildID(StringRef FileBuildID);

friend class YAMLProfileWriter;
};
} // namespace bolt
} // namespace llvm
Expand Down
4 changes: 3 additions & 1 deletion bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,9 @@ void BinaryContext::processInterproceduralReferences() {
InterproceduralReferences) {
BinaryFunction &Function = *It.first;
uint64_t Address = It.second;
if (!Address || Function.isIgnored())
// Process interprocedural references from ignored functions in BAT mode
// (non-simple in non-relocation mode) to properly register entry points
if (!Address || (Function.isIgnored() && !HasBATSection))
continue;

BinaryFunction *TargetFunction =
Expand Down
7 changes: 4 additions & 3 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ Error BinaryFunction::disassemble() {
const bool IsCondBranch = MIB->isConditionalBranch(Instruction);
MCSymbol *TargetSymbol = nullptr;

if (BC.MIB->isUnsupportedBranch(Instruction)) {
if (!BC.MIB->isReversibleBranch(Instruction)) {
setIgnored();
if (BinaryFunction *TargetFunc =
BC.getBinaryFunctionContainingAddress(TargetAddress))
Expand Down Expand Up @@ -1666,7 +1666,8 @@ void BinaryFunction::postProcessEntryPoints() {
// In non-relocation mode there's potentially an external undetectable
// reference to the entry point and hence we cannot move this entry
// point. Optimizing without moving could be difficult.
if (!BC.HasRelocations)
// In BAT mode, register any known entry points for CFG construction.
if (!BC.HasRelocations && !BC.HasBATSection)
setSimple(false);

const uint32_t Offset = KV.first;
Expand Down Expand Up @@ -3381,7 +3382,7 @@ void BinaryFunction::fixBranches() {

// Reverse branch condition and swap successors.
auto swapSuccessors = [&]() {
if (MIB->isUnsupportedBranch(*CondBranch)) {
if (!MIB->isReversibleBranch(*CondBranch)) {
if (opts::Verbosity) {
BC.outs() << "BOLT-INFO: unable to swap successors in " << *this
<< '\n';
Expand Down
26 changes: 20 additions & 6 deletions bolt/lib/Passes/BinaryPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@ static uint64_t fixDoubleJumps(BinaryFunction &Function, bool MarkInvalid) {
MCPlusBuilder *MIB = Function.getBinaryContext().MIB.get();
for (BinaryBasicBlock &BB : Function) {
auto checkAndPatch = [&](BinaryBasicBlock *Pred, BinaryBasicBlock *Succ,
const MCSymbol *SuccSym) {
const MCSymbol *SuccSym,
std::optional<uint32_t> Offset) {
// Ignore infinite loop jumps or fallthrough tail jumps.
if (Pred == Succ || Succ == &BB)
return false;
Expand Down Expand Up @@ -715,9 +716,11 @@ static uint64_t fixDoubleJumps(BinaryFunction &Function, bool MarkInvalid) {
Pred->removeSuccessor(&BB);
Pred->eraseInstruction(Pred->findInstruction(Branch));
Pred->addTailCallInstruction(SuccSym);
MCInst *TailCall = Pred->getLastNonPseudoInstr();
assert(TailCall);
MIB->setOffset(*TailCall, BB.getOffset());
if (Offset) {
MCInst *TailCall = Pred->getLastNonPseudoInstr();
assert(TailCall);
MIB->setOffset(*TailCall, *Offset);
}
} else {
return false;
}
Expand Down Expand Up @@ -760,7 +763,8 @@ static uint64_t fixDoubleJumps(BinaryFunction &Function, bool MarkInvalid) {
if (Pred->getSuccessor() == &BB ||
(Pred->getConditionalSuccessor(true) == &BB && !IsTailCall) ||
Pred->getConditionalSuccessor(false) == &BB)
if (checkAndPatch(Pred, Succ, SuccSym) && MarkInvalid)
if (checkAndPatch(Pred, Succ, SuccSym, MIB->getOffset(*Inst)) &&
MarkInvalid)
BB.markValid(BB.pred_size() != 0 || BB.isLandingPad() ||
BB.isEntryPoint());
}
Expand Down Expand Up @@ -1386,9 +1390,19 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
if (Function.isPLTFunction())
continue;

// Adjustment for BAT mode: the profile for BOLT split fragments is combined
// so only count the hot fragment.
const uint64_t Address = Function.getAddress();
bool IsHotParentOfBOLTSplitFunction = !Function.getFragments().empty() &&
BAT && BAT->isBATFunction(Address) &&
!BAT->fetchParentAddress(Address);

++NumRegularFunctions;

if (!Function.isSimple()) {
// In BOLTed binaries split functions are non-simple (due to non-relocation
// mode), but the original function is known to be simple and we have a
// valid profile for it.
if (!Function.isSimple() && !IsHotParentOfBOLTSplitFunction) {
if (Function.hasProfile())
++NumNonSimpleProfiledFunctions;
continue;
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Passes/Instrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void Instrumentation::instrumentFunction(BinaryFunction &Function,
else if (BC.MIB->isUnconditionalBranch(Inst))
HasUnconditionalBranch = true;
else if ((!BC.MIB->isCall(Inst) && !BC.MIB->isConditionalBranch(Inst)) ||
BC.MIB->isUnsupportedBranch(Inst))
!BC.MIB->isReversibleBranch(Inst))
continue;

const uint32_t FromOffset = *BC.MIB->getOffset(Inst);
Expand Down
Loading

0 comments on commit efc7b5a

Please sign in to comment.