mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-25 03:30:37 +00:00
uselistorder: Thread bit through ValueEnumerator
Canonicalize access to whether to preserve use-list order in bitcode on a `bool` stored in `ValueEnumerator`. Next step, expose this as a `bool` through `WriteBitcodeToFile()`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234956 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
83ed6b7814
commit
d01ee74ffa
@ -2047,6 +2047,9 @@ static void WriteUseList(ValueEnumerator &VE, UseListOrder &&Order,
|
|||||||
|
|
||||||
static void WriteUseListBlock(const Function *F, ValueEnumerator &VE,
|
static void WriteUseListBlock(const Function *F, ValueEnumerator &VE,
|
||||||
BitstreamWriter &Stream) {
|
BitstreamWriter &Stream) {
|
||||||
|
assert(VE.shouldPreserveUseListOrder() &&
|
||||||
|
"Expected to be preserving use-list order");
|
||||||
|
|
||||||
auto hasMore = [&]() {
|
auto hasMore = [&]() {
|
||||||
return !VE.UseListOrders.empty() && VE.UseListOrders.back().F == F;
|
return !VE.UseListOrders.empty() && VE.UseListOrders.back().F == F;
|
||||||
};
|
};
|
||||||
@ -2127,7 +2130,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
|
|||||||
|
|
||||||
if (NeedsMetadataAttachment)
|
if (NeedsMetadataAttachment)
|
||||||
WriteMetadataAttachment(F, VE, Stream);
|
WriteMetadataAttachment(F, VE, Stream);
|
||||||
if (shouldPreserveBitcodeUseListOrder())
|
if (VE.shouldPreserveUseListOrder())
|
||||||
WriteUseListBlock(&F, VE, Stream);
|
WriteUseListBlock(&F, VE, Stream);
|
||||||
VE.purgeFunction();
|
VE.purgeFunction();
|
||||||
Stream.ExitBlock();
|
Stream.ExitBlock();
|
||||||
@ -2318,7 +2321,7 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) {
|
|||||||
Stream.EmitRecord(bitc::MODULE_CODE_VERSION, Vals);
|
Stream.EmitRecord(bitc::MODULE_CODE_VERSION, Vals);
|
||||||
|
|
||||||
// Analyze the module, enumerating globals, functions, etc.
|
// Analyze the module, enumerating globals, functions, etc.
|
||||||
ValueEnumerator VE(*M);
|
ValueEnumerator VE(*M, shouldPreserveBitcodeUseListOrder());
|
||||||
|
|
||||||
// Emit blockinfo, which defines the standard abbreviations etc.
|
// Emit blockinfo, which defines the standard abbreviations etc.
|
||||||
WriteBlockInfo(VE, Stream);
|
WriteBlockInfo(VE, Stream);
|
||||||
@ -2351,7 +2354,7 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) {
|
|||||||
WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream);
|
WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream);
|
||||||
|
|
||||||
// Emit module-level use-lists.
|
// Emit module-level use-lists.
|
||||||
if (shouldPreserveBitcodeUseListOrder())
|
if (VE.shouldPreserveUseListOrder())
|
||||||
WriteUseListBlock(nullptr, VE, Stream);
|
WriteUseListBlock(nullptr, VE, Stream);
|
||||||
|
|
||||||
// Emit function bodies.
|
// Emit function bodies.
|
||||||
|
@ -283,9 +283,11 @@ static bool isIntOrIntVectorValue(const std::pair<const Value*, unsigned> &V) {
|
|||||||
return V.first->getType()->isIntOrIntVectorTy();
|
return V.first->getType()->isIntOrIntVectorTy();
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueEnumerator::ValueEnumerator(const Module &M)
|
ValueEnumerator::ValueEnumerator(const Module &M,
|
||||||
: HasMDString(false), HasMDLocation(false), HasGenericDebugNode(false) {
|
bool ShouldPreserveUseListOrder)
|
||||||
if (shouldPreserveBitcodeUseListOrder())
|
: HasMDString(false), HasMDLocation(false), HasGenericDebugNode(false),
|
||||||
|
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
|
||||||
|
if (ShouldPreserveUseListOrder)
|
||||||
UseListOrders = predictUseListOrder(M);
|
UseListOrders = predictUseListOrder(M);
|
||||||
|
|
||||||
// Enumerate the global variables.
|
// Enumerate the global variables.
|
||||||
@ -461,7 +463,7 @@ void ValueEnumerator::print(raw_ostream &OS, const MetadataMapType &Map,
|
|||||||
void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
|
void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
|
||||||
if (CstStart == CstEnd || CstStart+1 == CstEnd) return;
|
if (CstStart == CstEnd || CstStart+1 == CstEnd) return;
|
||||||
|
|
||||||
if (shouldPreserveBitcodeUseListOrder())
|
if (ShouldPreserveUseListOrder)
|
||||||
// Optimizing constants makes the use-list order difficult to predict.
|
// Optimizing constants makes the use-list order difficult to predict.
|
||||||
// Disable it for now when trying to preserve the order.
|
// Disable it for now when trying to preserve the order.
|
||||||
return;
|
return;
|
||||||
|
@ -67,6 +67,7 @@ private:
|
|||||||
bool HasMDString;
|
bool HasMDString;
|
||||||
bool HasMDLocation;
|
bool HasMDLocation;
|
||||||
bool HasGenericDebugNode;
|
bool HasGenericDebugNode;
|
||||||
|
bool ShouldPreserveUseListOrder;
|
||||||
|
|
||||||
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
|
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
|
||||||
AttributeGroupMapType AttributeGroupMap;
|
AttributeGroupMapType AttributeGroupMap;
|
||||||
@ -102,7 +103,7 @@ private:
|
|||||||
ValueEnumerator(const ValueEnumerator &) = delete;
|
ValueEnumerator(const ValueEnumerator &) = delete;
|
||||||
void operator=(const ValueEnumerator &) = delete;
|
void operator=(const ValueEnumerator &) = delete;
|
||||||
public:
|
public:
|
||||||
ValueEnumerator(const Module &M);
|
ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder);
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const;
|
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const;
|
||||||
@ -123,6 +124,8 @@ public:
|
|||||||
bool hasMDLocation() const { return HasMDLocation; }
|
bool hasMDLocation() const { return HasMDLocation; }
|
||||||
bool hasGenericDebugNode() const { return HasGenericDebugNode; }
|
bool hasGenericDebugNode() const { return HasGenericDebugNode; }
|
||||||
|
|
||||||
|
bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; }
|
||||||
|
|
||||||
unsigned getTypeID(Type *T) const {
|
unsigned getTypeID(Type *T) const {
|
||||||
TypeMapType::const_iterator I = TypeMap.find(T);
|
TypeMapType::const_iterator I = TypeMap.find(T);
|
||||||
assert(I != TypeMap.end() && "Type not in ValueEnumerator!");
|
assert(I != TypeMap.end() && "Type not in ValueEnumerator!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user