Skip to content

Revert "[CGData][MachineOutliner] Global Outlining (#90074)" #108033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions llvm/include/llvm/ADT/StableHashing.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ inline stable_hash stable_hash_combine(stable_hash A, stable_hash B,
// Removes suffixes introduced by LLVM from the name to enhance stability and
// maintain closeness to the original name across different builds.
inline StringRef get_stable_name(StringRef Name) {
// Return the part after ".content." that represents contents.
auto [P0, S0] = Name.rsplit(".content.");
if (!S0.empty())
return S0;

Comment on lines -56 to -60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a drive-by comment: It would be nice to have changes to core llvm headers like this in a separate PR, so that reverting doesn't cause everyone to rebuild a large portion of the build tree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will follow this up!

// Ignore these suffixes.
auto [P1, S1] = Name.rsplit(".llvm.");
auto [P2, S2] = P1.rsplit(".__uniq.");
return P2;
Expand Down
40 changes: 2 additions & 38 deletions llvm/include/llvm/CodeGen/MachineOutliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "llvm/CodeGen/LiveRegUnits.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineStableHash.h"
#include <initializer_list>

namespace llvm {
Expand Down Expand Up @@ -235,11 +234,11 @@ struct OutlinedFunction {
unsigned FrameConstructionID = 0;

/// Return the number of candidates for this \p OutlinedFunction.
virtual unsigned getOccurrenceCount() const { return Candidates.size(); }
unsigned getOccurrenceCount() const { return Candidates.size(); }

/// Return the number of bytes it would take to outline this
/// function.
virtual unsigned getOutliningCost() const {
unsigned getOutliningCost() const {
unsigned CallOverhead = 0;
for (const Candidate &C : Candidates)
CallOverhead += C.getCallOverhead();
Expand Down Expand Up @@ -273,42 +272,7 @@ struct OutlinedFunction {
}

OutlinedFunction() = delete;
virtual ~OutlinedFunction() = default;
};

/// The information necessary to create an outlined function that is matched
/// globally.
struct GlobalOutlinedFunction : public OutlinedFunction {
explicit GlobalOutlinedFunction(std::unique_ptr<OutlinedFunction> OF,
unsigned GlobalOccurrenceCount)
: OutlinedFunction(*OF), GlobalOccurrenceCount(GlobalOccurrenceCount) {}

unsigned GlobalOccurrenceCount;

/// Return the number of times that appear globally.
/// Global outlining candidate is uniquely created per each match, but this
/// might be erased out when it's overlapped with the previous outlining
/// instance.
unsigned getOccurrenceCount() const override {
assert(Candidates.size() <= 1);
return Candidates.empty() ? 0 : GlobalOccurrenceCount;
}

/// Return the outlining cost using the global occurrence count
/// with the same cost as the first (unique) candidate.
unsigned getOutliningCost() const override {
assert(Candidates.size() <= 1);
unsigned CallOverhead =
Candidates.empty()
? 0
: Candidates[0].getCallOverhead() * getOccurrenceCount();
return CallOverhead + SequenceSize + FrameOverhead;
}

GlobalOutlinedFunction() = delete;
~GlobalOutlinedFunction() = default;
};

} // namespace outliner
} // namespace llvm

Expand Down
26 changes: 1 addition & 25 deletions llvm/lib/CGData/CodeGenData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@
using namespace llvm;
using namespace cgdata;

cl::opt<bool>
CodeGenDataGenerate("codegen-data-generate", cl::init(false), cl::Hidden,
cl::desc("Emit CodeGen Data into custom sections"));
cl::opt<std::string>
CodeGenDataUsePath("codegen-data-use-path", cl::init(""), cl::Hidden,
cl::desc("File path to where .cgdata file is read"));

static std::string getCGDataErrString(cgdata_error Err,
const std::string &ErrMsg = "") {
std::string Msg;
Expand Down Expand Up @@ -139,24 +132,7 @@ CodeGenData &CodeGenData::getInstance() {
std::call_once(CodeGenData::OnceFlag, []() {
Instance = std::unique_ptr<CodeGenData>(new CodeGenData());

if (CodeGenDataGenerate)
Instance->EmitCGData = true;
else if (!CodeGenDataUsePath.empty()) {
// Initialize the global CGData if the input file name is given.
// We do not error-out when failing to parse the input file.
// Instead, just emit an warning message and fall back as if no CGData
// were available.
auto FS = vfs::getRealFileSystem();
auto ReaderOrErr = CodeGenDataReader::create(CodeGenDataUsePath, *FS);
if (Error E = ReaderOrErr.takeError()) {
warn(std::move(E), CodeGenDataUsePath);
return;
}
// Publish each CGData based on the data type in the header.
auto Reader = ReaderOrErr->get();
if (Reader->hasOutlinedHashTree())
Instance->publishOutlinedHashTree(Reader->releaseOutlinedHashTree());
}
// TODO: Initialize writer or reader mode for the client optimization.
});
return *(Instance.get());
}
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ add_llvm_component_library(LLVMCodeGen
Analysis
BitReader
BitWriter
CGData
CodeGenTypes
Core
MC
Expand Down
Loading
Loading