mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Avoid redundant allocations in the linker optimisation hint
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210747 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -96,6 +96,19 @@ static inline int MCLOHIdToNbArgs(MCLOHType Kind) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class raw_counting_ostream : public raw_ostream {
|
||||||
|
uint64_t Count = 0;
|
||||||
|
|
||||||
|
void write_impl(const char *, size_t size) override { Count += size; }
|
||||||
|
|
||||||
|
uint64_t current_pos() const override { return Count; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
~raw_counting_ostream() { flush(); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Store Linker Optimization Hint information (LOH).
|
/// Store Linker Optimization Hint information (LOH).
|
||||||
class MCLOHDirective {
|
class MCLOHDirective {
|
||||||
MCLOHType Kind;
|
MCLOHType Kind;
|
||||||
@@ -132,8 +145,7 @@ public:
|
|||||||
/// the given @p Layout.
|
/// the given @p Layout.
|
||||||
uint64_t getEmitSize(const MachObjectWriter &ObjWriter,
|
uint64_t getEmitSize(const MachObjectWriter &ObjWriter,
|
||||||
const MCAsmLayout &Layout) const {
|
const MCAsmLayout &Layout) const {
|
||||||
std::string Buffer;
|
raw_counting_ostream OutStream;
|
||||||
raw_string_ostream OutStream(Buffer);
|
|
||||||
Emit_impl(OutStream, ObjWriter, Layout);
|
Emit_impl(OutStream, ObjWriter, Layout);
|
||||||
return OutStream.tell();
|
return OutStream.tell();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user