aboutsummaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
Diffstat (limited to 'bolt')
-rw-r--r--bolt/include/bolt/Profile/DataAggregator.h3
-rw-r--r--bolt/lib/Passes/FrameOptimizer.cpp5
-rw-r--r--bolt/lib/Profile/DataAggregator.cpp39
-rw-r--r--bolt/test/AArch64/unsupported-passes.test8
4 files changed, 31 insertions, 24 deletions
diff --git a/bolt/include/bolt/Profile/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h
index cb1b87f..db0f690 100644
--- a/bolt/include/bolt/Profile/DataAggregator.h
+++ b/bolt/include/bolt/Profile/DataAggregator.h
@@ -502,9 +502,6 @@ private:
/// entries).
void imputeFallThroughs();
- /// Register profiled functions for lite mode.
- void registerProfiledFunctions();
-
/// Debugging dump methods
void dump() const;
void dump(const PerfBranchSample &Sample) const;
diff --git a/bolt/lib/Passes/FrameOptimizer.cpp b/bolt/lib/Passes/FrameOptimizer.cpp
index 81d4d93..b0b7207f 100644
--- a/bolt/lib/Passes/FrameOptimizer.cpp
+++ b/bolt/lib/Passes/FrameOptimizer.cpp
@@ -224,6 +224,11 @@ Error FrameOptimizerPass::runOnFunctions(BinaryContext &BC) {
if (opts::FrameOptimization == FOP_NONE)
return Error::success();
+ if (!BC.isX86()) {
+ BC.errs() << "BOLT-ERROR: " << getName() << " is supported only on X86\n";
+ exit(1);
+ }
+
std::unique_ptr<BinaryFunctionCallGraph> CG;
std::unique_ptr<FrameAnalysis> FA;
std::unique_ptr<RegAnalysis> RA;
diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index c13fa6d..3604fdd 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -581,26 +581,6 @@ void DataAggregator::imputeFallThroughs() {
outs() << "BOLT-INFO: imputed " << InferredTraces << " traces\n";
}
-void DataAggregator::registerProfiledFunctions() {
- DenseSet<uint64_t> Addrs;
- for (const auto &Trace : llvm::make_first_range(Traces)) {
- if (Trace.Branch != Trace::FT_ONLY &&
- Trace.Branch != Trace::FT_EXTERNAL_ORIGIN)
- Addrs.insert(Trace.Branch);
- Addrs.insert(Trace.From);
- }
-
- for (const auto [PC, _] : BasicSamples)
- Addrs.insert(PC);
-
- for (const PerfMemSample &MemSample : MemSamples)
- Addrs.insert(MemSample.PC);
-
- for (const uint64_t Addr : Addrs)
- if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr))
- Func->setHasProfileAvailable();
-}
-
Error DataAggregator::preprocessProfile(BinaryContext &BC) {
this->BC = &BC;
@@ -623,7 +603,6 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
exit(0);
}
- registerProfiledFunctions();
return Error::success();
}
@@ -1368,6 +1347,10 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
}
const uint64_t FromOffset = Addr[0]->Offset;
+ BinaryFunction *FromFunc = getBinaryFunctionContainingAddress(FromOffset);
+ if (FromFunc)
+ FromFunc->setHasProfileAvailable();
+
int64_t Count = Counters[0];
int64_t Mispreds = Counters[1];
@@ -1378,6 +1361,11 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
return std::error_code();
}
+ const uint64_t ToOffset = Addr[1]->Offset;
+ BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(ToOffset);
+ if (ToFunc)
+ ToFunc->setHasProfileAvailable();
+
/// For fall-through types, adjust locations to match Trace container.
if (Type == FT || Type == FT_EXTERNAL_ORIGIN || Type == FT_EXTERNAL_RETURN) {
Addr[2] = Location(Addr[1]->Offset); // Trace To
@@ -1625,6 +1613,9 @@ std::error_code DataAggregator::parseBranchEvents() {
Traces.reserve(TraceMap.size());
for (const auto &[Trace, Info] : TraceMap) {
Traces.emplace_back(Trace, Info);
+ for (const uint64_t Addr : {Trace.Branch, Trace.From})
+ if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Addr))
+ BF->setHasProfileAvailable();
}
clear(TraceMap);
@@ -1685,6 +1676,9 @@ std::error_code DataAggregator::parseBasicEvents() {
continue;
++NumTotalSamples;
+ if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Sample->PC))
+ BF->setHasProfileAvailable();
+
++BasicSamples[Sample->PC];
EventNames.insert(Sample->EventName);
}
@@ -1722,6 +1716,9 @@ std::error_code DataAggregator::parseMemEvents() {
if (std::error_code EC = Sample.getError())
return EC;
+ if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Sample->PC))
+ BF->setHasProfileAvailable();
+
MemSamples.emplace_back(std::move(Sample.get()));
}
diff --git a/bolt/test/AArch64/unsupported-passes.test b/bolt/test/AArch64/unsupported-passes.test
new file mode 100644
index 0000000..886fc1c
--- /dev/null
+++ b/bolt/test/AArch64/unsupported-passes.test
@@ -0,0 +1,8 @@
+// Checks that non-fully supported passes on AArch64 are handled appropriately.
+
+// REQUIRES: system-linux,asserts,target=aarch64{{.*}}
+
+RUN: %clang %cflags %p/../Inputs/hello.c -o %t -Wl,-q
+RUN: not llvm-bolt %t -o %t.bolt --frame-opt=all 2>&1 | FileCheck %s
+
+CHECK: BOLT-ERROR: frame-optimizer is supported only on X86