[CPU/A64] Avoid static init order in A64 sequences
The A64 sequence table is populated by registration statics spread across multiple translation units. Keeping the backing map as a global object makes registration depend on cross-TU initialization order and can hit the table before it has been constructed. Move the sequence table behind a function-local static so sequence registration is safe regardless of which unit initializes first.
This commit is contained in:
@@ -22,11 +22,11 @@ namespace a64 {
|
||||
class A64Emitter;
|
||||
|
||||
typedef bool (*SequenceSelectFn)(A64Emitter&, const hir::Instr*, uint32_t ikey);
|
||||
extern std::unordered_map<uint32_t, SequenceSelectFn> sequence_table;
|
||||
std::unordered_map<uint32_t, SequenceSelectFn>& SequenceTable();
|
||||
|
||||
template <typename T>
|
||||
bool Register() {
|
||||
sequence_table.insert({T::head_key(), T::Select});
|
||||
SequenceTable().insert({T::head_key(), T::Select});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user