8000 make alias group zero universal by can-lehmann · Pull Request #167 · can-lehmann/metajit.cpp · GitHub
[go: up one dir, main page]

Skip to content

make alias group zero universal - #167

Merged
can-lehmann merged 7 commits into
mainfrom
can-universal-alias-group
Nov 22, 2026
Merged

can-lehmann merged 7 commits into
mainfrom
can-universal-alias-group

Conversation

@can-lehmann
Copy link
Copy Markdown
Owner

No description provided.

@github-actions
Copy link
Copy Markdown

Coverage

File Lines Functions Branches
bitprovenance.hpp 🟢 100.00% 🟢 100.00% 🟡 82.13%
codeheap.hpp 🔴 65.38% 🟢 100.00% 🔴 62.50%
genext.hpp 🟡 73.94% 🟡 87.50% 🟡 75.99%
jitir.hpp 🟡 72.29% 🟡 79.38% 🟡 72.25%
jitir_llvmapi.hpp 🔴 54.65% 🟡 80.00% 🔴 50.00%
llvmgen.hpp 🟢 90.74% 🟢 91.67% 🟡 79.75%
lowerllvm.hpp 🟡 70.72% 🟡 87.50% 🔴 51.42%
x86gen.hpp 🟡 88.59% 🟡 85.23% 🟡 83.06%
x86insts.inc.hpp 🟡 80.87% - -
TOTAL 🟡 75.68% 🟡 81.41% 🟡 76.86%
Diff Coverage

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • jitir.hpp (66.7%): Missing lines 4687,5745-5746,5750,5798,5813,5865-5869,5890,7903-7904,9102-9106
  • llvmgen.hpp (100%)
  • x86gen.hpp (75.0%): Missing lines 669-673,689

Summary

  • Total: 84 lines
  • Missing: 25 lines
  • Coverage: 70%

jitir.hpp

Lines 4683-4691

  4683       _guard_success = nullptr;
  4684     }
  4685 
  4686     void init_store(Value* ptr, Value* value, AliasingGroup aliasing, uint64_t offset) {
! 4687       invalidate_memory_for_store(aliasing);
  4688       if (aliasing < 0) {
  4689         _exact_memory[-aliasing] = value;
  4690       } else {
  4691         _memory[aliasing].store(ptr, offset, value);

Lines 5741-5754

  5741     }
  5742   };
  5743 
  5744   inline bool could_alias(LoadInst* load, StoreInst* store) {
! 5745     if (load->aliasing() != store->aliasing() &&
! 5746         load->aliasing() != 0 && store->aliasing() != 0) {
  5747       return false;
  5748     }
  5749 
! 5750     if (load->aliasing() == store->aliasing() && load->aliasing() < 0) {
  5751       return true; // Exact aliasing
  5752     }
  5753 
  5754     if (load->ptr() != store->ptr()) {

Lines 5794-5802

  5794     std::unordered_map<Key, AliasingGroup, KeyHash> _exact_groups;
  5795     Value* _only_base;
  5796 
  5797     void access(AliasingGroup aliasing, Value* ptr, uint64_t offset, Type type) {
! 5798       assert(aliasing > 0);
  5799       GroupInfo& group = _groups[aliasing];
  5800       if (!group.is_invalid) {
  5801         if (group.base == nullptr) {
  5802           group.base = ptr;

Lines 5809-5817

  5809       }
  5810     }
  5811 
  5812     AliasingGroup apply(AliasingGroup aliasing, uint64_t offset) {
! 5813       assert(aliasing > 0);
  5814       GroupInfo& group = _groups[aliasing];
  5815       if (group.is_invalid) {
  5816         return aliasing;
  5817       }

Lines 5861-5873

  5861       NameMap<bool> unused(section);
  5862       ExpandingVector<StoreInst*> last_store;
  5863       auto mark_stores_live = [&]() {
  5864         for (StoreInst*& store : last_store) {
! 5865           if (store) {
! 5866             unused[store] = false;
! 5867             store = nullptr;
! 5868           }
! 5869         }
  5870       };
  5871 
  5872       for (Block* block : *section) {
  5873         for (Inst* inst : *block) {

Lines 5886-5894

  5886             } else if (load->aliasing() == 0) {
  5887               mark_stores_live();
  5888             }
  5889           } else if (dynamic_cast<CallInst*>(inst)) {
! 5890             mark_stores_live();
  5891           }
  5892         }
  5893 
  5894         mark_stores_live();

Lines 7899-7908

  7899         for (Inst* inst : *block) {
  7900           if (dynmatch(StoreInst, store, inst)) {
  7901             if (store->aliasing() < 0) {
  7902               stores[-store->aliasing()] = 1;
! 7903             } else if (store->aliasing() == 0) {
! 7904               has_unknown_memory_write = true;
  7905             }
  7906           } else if (dynamic_cast<CallInst*>(inst)) {
  7907             has_unknown_memory_write = true;
  7908           }

Lines 9098-9110

  9098           } else if (store) {
  9099             last_stores.erase(0);
  9100             last_stores[store->aliasing()] = store;
  9101             if (auto group = valid_loads.find(0); group != valid_loads.end()) {
! 9102               for (LoadInst* load : group->second) {
! 9103                 canon_erase(Lookup(load));
! 9104               }
! 9105               valid_loads.erase(group);
! 9106             }
  9107             std::vector<LoadInst*>& loads = valid_loads[store->aliasing()];
  9108             std::vector<LoadInst*> remaining_loads;
  9109             for (LoadInst* load : loads) {
  9110               if (could_alias(load, store)) {

x86gen.hpp

Lines 665-677

  665         auto dependency = [&](AliasingGroup aliasing) -> void* {
  666           if (aliasing == 0) {
  667             return last_write;
  668           }
! 669           if (auto store = last_store.find(aliasing); store != last_store.end()) {
! 670             return store->second;
! 671           }
! 672           return last_clobber;
! 673         };
  674         for (Inst* inst : *block) {
  675           for (Value* arg : inst->args()) {
  676             if (arg->is_named()) {
  677               _use_counts[(NamedValue*) arg]++;

Lines 685-693

  685             if (store->aliasing() == 0) {
  686               last_clobber = store;
  687               last_store.clear();
  688             } else {
! 689               last_store[store->aliasing()] = store;
  690             }
  691           } else if (dynamic_cast<CallInst*>(inst)) {
  692             _memory_deps[inst] = block;
  693             last_clobber = inst;

@github-actions
Copy link
Copy Markdown

Coverage

File Lines Functions Branches
bitprovenance.hpp 🟢 100.00% 🟢 100.00% 🟡 82.13%
codeheap.hpp 🔴 65.38% 🟢 100.00% 🔴 62.50%
genext.hpp 🟡 73.94% 🟡 87.50% 🟡 75.99%
jitir.hpp 🟡 72.28% 🟡 79.38% 🟡 72.25%
jitir_llvmapi.hpp 🔴 54.65% 🟡 80.00% 🔴 50.00%
llvmgen.hpp 🟢 90.74% 🟢 91.67% 🟡 79.75%
lowerllvm.hpp 🟡 70.72% 🟡 87.50% 🔴 51.42%
x86gen.hpp 🟡 88.59% 🟡 85.23% 🟡 83.06%
x86insts.inc.hpp 🟡 80.87% - -
TOTAL 🟡 75.68% 🟡 81.41% 🟡 76.86%
Diff Coverage

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • jitir.hpp (63.5%): Missing lines 4687,5745-5746,5750,5798,5813,5865-5869,5878-5879,5883,5885,5891,7904-7905,9103-9107
  • llvmgen.hpp (100%)
  • x86gen.hpp (75.0%): Missing lines 669-673,689

Summary

  • Total: 90 lines
  • Missing: 29 lines
  • Coverage: 67%

jitir.hpp

Lines 4683-4691

  4683       _guard_success = nullptr;
  4684     }
  4685 
  4686     void init_store(Value* ptr, Value* value, AliasingGroup aliasing, uint64_t offset) {
! 4687       invalidate_memory_for_store(aliasing);
  4688       if (aliasing < 0) {
  4689         _exact_memory[-aliasing] = value;
  4690       } else {
  4691         _memory[aliasing].store(ptr, offset, value);

Lines 5741-5754

  5741     }
  5742   };
  5743 
  5744   inline bool could_alias(LoadInst* load, StoreInst* store) {
! 5745     if (load->aliasing() != store->aliasing() &&
! 5746         load->aliasing() != 0 && store->aliasing() != 0) {
  5747       return false;
  5748     }
  5749 
! 5750     if (load->aliasing() == store->aliasing() && load->aliasing() < 0) {
  5751       return true; // Exact aliasing
  5752     }
  5753 
  5754     if (load->ptr() != store->ptr()) {

Lines 5794-5802

  5794     std::unordered_map<Key, AliasingGroup, KeyHash> _exact_groups;
  5795     Value* _only_base;
  5796 
  5797     void access(AliasingGroup aliasing, Value* ptr, uint64_t offset, Type type) {
! 5798       assert(aliasing > 0);
  5799       GroupInfo& group = _groups[aliasing];
  5800       if (!group.is_invalid) {
  5801         if (group.base == nullptr) {
  5802           group.base = ptr;

Lines 5809-5817

  5809       }
  5810     }
  5811 
  5812     AliasingGroup apply(AliasingGroup aliasing, uint64_t offset) {
! 5813       assert(aliasing > 0);
  5814       GroupInfo& group = _groups[aliasing];
  5815       if (group.is_invalid) {
  5816         return aliasing;
  5817       }

Lines 5861-5873

  5861     ExpandingVector<StoreInst*> _last_store;
  5862 
  5863     void mark_stores_live() {
  5864       for (StoreInst*& store : _last_store) {
! 5865         if (store) {
! 5866           _unused[store] = false;
! 5867           store = nullptr;
! 5868         }
! 5869       }
  5870     }
  5871   public:
  5872     DeadStoreElim(Section* section): Pass(section), _unused(section) {
  5873       for (Block* block : *section) {

Lines 5874-5889

  5874         for (Inst* inst : *block) {
  5875           if (dynmatch(StoreInst, store, inst)) {
  5876             Pointer pointer(store->ptr(), store->offset());
  5877             if (store->aliasing() < 0) {
! 5878               _last_store[-store->aliasing()] = store;
! 5879               _unused[store] = true;
  5880             }
  5881           } else if (dynmatch(LoadInst, load, inst)) {
  5882             if (load->aliasing() < 0) {
! 5883               StoreInst* store = _last_store[-load->aliasing()];
  5884               if (store) {
! 5885                 _unused[store] = false;
  5886               }
  5887             } else if (load->aliasing() == 0) {
  5888               mark_stores_live();
  5889             }

Lines 5887-5895

  5887             } else if (load->aliasing() == 0) {
  5888               mark_stores_live();
  5889             }
  5890           } else if (dynamic_cast<CallInst*>(inst)) {
! 5891             mark_stores_live();
  5892           }
  5893         }
  5894 
  5895         mark_stores_live();

Lines 7900-7909

  7900         for (Inst* inst : *block) {
  7901           if (dynmatch(StoreInst, store, inst)) {
  7902             if (store->aliasing() < 0) {
  7903               stores[-store->aliasing()] = 1;
! 7904             } else if (store->aliasing() == 0) {
! 7905               has_unknown_memory_write = true;
  7906             }
  7907           } else if (dynamic_cast<CallInst*>(inst)) {
  7908             has_unknown_memory_write = true;
  7909           }

Lines 9099-9111

  9099           } else if (store) {
  9100             last_stores.erase(0);
  9101             last_stores[store->aliasing()] = store;
  9102             if (auto group = valid_loads.find(0); group != valid_loads.end()) {
! 9103               for (LoadInst* load : group->second) {
! 9104                 canon_erase(Lookup(load));
! 9105               }
! 9106               valid_loads.erase(group);
! 9107             }
  9108             std::vector<LoadInst*>& loads = valid_loads[store->aliasing()];
  9109             std::vector<LoadInst*> remaining_loads;
  9110             for (LoadInst* load : loads) {
  9111               if (could_alias(load, store)) {

x86gen.hpp

Lines 665-677

  665         auto dependency = [&](AliasingGroup aliasing) -> void* {
  666           if (aliasing == 0) {
  667             return last_write;
  668           }
! 669           if (auto store = last_store.find(aliasing); store != last_store.end()) {
! 670             return store->second;
! 671           }
! 672           return last_clobber;
! 673         };
  674         for (Inst* inst : *block) {
  675           for (Value* arg : inst->args()) {
  676             if (arg->is_named()) {
  677               _use_counts[(NamedValue*) arg]++;

Lines 685-693

  685             if (store->aliasing() == 0) {
  686               last_clobber = store;
  687               last_store.clear();
  688             } else {
! 689               last_store[store->aliasing()] = store;
  690             }
  691           } else if (dynamic_cast<CallInst*>(inst)) {
  692             _memory_deps[inst] = block;
  693             last_clobber = inst;

@github-actions
Copy link
Copy Markdown

Coverage

File Lines Functions Branches
bitprovenance.hpp 🟢 100.00% 🟢 100.00% 🟡 82.13%
codeheap.hpp 🔴 65.38% 🟢 100.00% 🔴 62.50%
genext.hpp 🟡 73.94% 🟡 87.50% 🟡 75.99%
jitir.hpp 🟡 72.27% 🟡 79.38% 🟡 72.55%
jitir_llvmapi.hpp 🔴 54.65% 🟡 80.00% 🔴 50.00%
llvmgen.hpp 🟢 90.74% 🟢 91.67% 🟡 79.75%
lowerllvm.hpp 🟡 70.72% 🟡 87.50% 🔴 51.42%
x86gen.hpp 🟡 88.59% 🟡 85.23% 🟡 83.06%
x86insts.inc.hpp 🟡 80.87% - -
TOTAL 🟡 75.67% 🟡 81.41% 🟡 77.00%
Diff Coverage

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • jitir.hpp (63.5%): Missing lines 4687,5745-5747,5801,5816,5868-5872,5881-5882,5886,5888,5894,7907-7908,9106-9110
  • llvmgen.hpp (100%)
  • x86gen.hpp (75.0%): Missing lines 669-673,689

Summary

  • Total: 90 lines
  • Missing: 29 lines
  • Coverage: 67%

jitir.hpp

Lines 4683-4691

  4683       _guard_success = nullptr;
  4684     }
  4685 
  4686     void init_store(Value* ptr, Value* value, AliasingGroup aliasing, uint64_t offset) {
! 4687       invalidate_memory_for_store(aliasing);
  4688       if (aliasing < 0) {
  4689         _exact_memory[-aliasing] = value;
  4690       } else {
  4691         _memory[aliasing].store(ptr, offset, value);

Lines 5741-5751

  5741     }
  5742   };
  5743 
  5744   inline bool could_alias(LoadInst* load, StoreInst* store) {
! 5745     if (load->aliasing() == 0 || store->aliasing() == 0) {
! 5746       return true;
! 5747     }
  5748 
  5749     if (load->aliasing() != store->aliasing()) {
  5750       return false;
  5751     }

Lines 5797-5805

  5797     std::unordered_map<Key, AliasingGroup, KeyHash> _exact_groups;
  5798     Value* _only_base;
  5799 
  5800     void access(AliasingGroup aliasing, Value* ptr, uint64_t offset, Type type) {
! 5801       assert(aliasing > 0);
  5802       GroupInfo& group = _groups[aliasing];
  5803       if (!group.is_invalid) {
  5804         if (group.base == nullptr) {
  5805           group.base = ptr;

Lines 5812-5820

  5812       }
  5813     }
  5814 
  5815     AliasingGroup apply(AliasingGroup aliasing, uint64_t offset) {
! 5816       assert(aliasing > 0);
  5817       GroupInfo& group = _groups[aliasing];
  5818       if (group.is_invalid) {
  5819         return aliasing;
  5820       }

Lines 5864-5876

  5864     ExpandingVector<StoreInst*> _last_store;
  5865 
  5866     void mark_stores_live() {
  5867       for (StoreInst*& store : _last_store) {
! 5868         if (store) {
! 5869           _unused[store] = false;
! 5870           store = nullptr;
! 5871         }
! 5872       }
  5873     }
  5874   public:
  5875     DeadStoreElim(Section* section): Pass(section), _unused(section) {
  5876       for (Block* block : *section) {

Lines 5877-5892

  5877         for (Inst* inst : *block) {
  5878           if (dynmatch(StoreInst, store, inst)) {
  5879             Pointer pointer(store->ptr(), store->offset());
  5880             if (store->aliasing() < 0) {
! 5881               _last_store[-store->aliasing()] = store;
! 5882               _unused[store] = true;
  5883             }
  5884           } else if (dynmatch(LoadInst, load, inst)) {
  5885             if (load->aliasing() < 0) {
! 5886               StoreInst* store = _last_store[-
8000
load->aliasing()];
  5887               if (store) {
! 5888                 _unused[store] = false;
  5889               }
  5890             } else if (load->aliasing() == 0) {
  5891               mark_stores_live();
  5892             }

Lines 5890-5898

  5890             } else if (load->aliasing() == 0) {
  5891               mark_stores_live();
  5892             }
  5893           } else if (dynamic_cast<CallInst*>(inst)) {
! 5894             mark_stores_live();
  5895           }
  5896         }
  5897 
  5898         mark_stores_live();

Lines 7903-7912

  7903         for (Inst* inst : *block) {
  7904           if (dynmatch(StoreInst, store, inst)) {
  7905             if (store->aliasing() < 0) {
  7906               stores[-store->aliasing()] = 1;
! 7907             } else if (store->aliasing() == 0) {
! 7908               has_unknown_memory_write = true;
  7909             }
  7910           } else if (dynamic_cast<CallInst*>(inst)) {
  7911             has_unknown_memory_write = true;
  7912           }

Lines 9102-9114

  9102           } else if (store) {
  9103             last_stores.erase(0);
  9104             last_stores[store->aliasing()] = store;
  9105             if (auto group = valid_loads.find(0); group != valid_loads.end()) {
! 9106               for (LoadInst* load : group->second) {
! 9107                 canon_erase(Lookup(load));
! 9108               }
! 9109               valid_loads.erase(group);
! 9110             }
  9111             std::vector<LoadInst*>& loads = valid_loads[store->aliasing()];
  9112             std::vector<LoadInst*> remaining_loads;
  9113             for (LoadInst* load : loads) {
  9114               if (could_alias(load, store)) {

x86gen.hpp

Lines 665-677

  665         auto dependency = [&](AliasingGroup aliasing) -> void* {
  666           if (aliasing == 0) {
  667             return last_write;
  668           }
! 669           if (auto store = last_store.find(aliasing); store != last_store.end()) {
! 670             return store->second;
! 671           }
! 672           return last_clobber;
! 673         };
  674         for (Inst* inst : *block) {
  675           for (Value* arg : inst->args()) {
  676             if (arg->is_named()) {
  677               _use_counts[(NamedValue*) arg]++;

Lines 685-693

  685             if (store->aliasing() == 0) {
  686               last_clobber = store;
  687               last_store.clear();
  688             } else {
! 689               last_store[store->aliasing()] = store;
  690             }
  691           } else if (dynamic_cast<CallInst*>(inst)) {
  692             _memory_deps[inst] = block;
  693             last_clobber = inst;

@github-actions
Copy link
Copy Markdown

Coverage

File Lines Functions Branches
bitprovenance.hpp 🟢 100.00% 🟢 100.00% 🟡 82.13%
codeheap.hpp 🔴 65.38% 🟢 100.00% 🔴 62.50%
genext.hpp 🟡 73.94% 🟡 87.50% 🟡 75.99%
jitir.hpp 🟡 72.25% 🟡 79.38% 🟡 72.43%
jitir_llvmapi.hpp 🔴 54.65% 🟡 80.00% 🔴 50.00%
llvmgen.hpp 🟢 90.74% 🟢 91.67% 🟡 79.75%
lowerllvm.hpp 🟡 70.72% 🟡 87.50% 🔴 51.42%
x86gen.hpp 🟡 88.71% 🟡 85.19% 🟡 82.90%
x86insts.inc.hpp 🟡 80.87% - -
TOTAL 🟡 75.68% 🟡 81.40% 🟡 76.88%
Diff Coverage

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • jitir.hpp (62.7%): Missing lines 4687,5745-5747,5801,5816,5853-5854,5873-5877,5886-5887,5891,5893,5899,7913-7914,9112-9116
  • llvmgen.hpp (100%)
  • x86gen.hpp (82.4%): Missing lines 676,689-690

Summary

  • Total: 87 lines
  • Missing: 28 lines
  • Coverage: 67%

jitir.hpp

Lines 4683-4691

  4683       _guard_success = nullptr;
  4684     }
  4685 
  4686     void init_store(Value* ptr, Value* value, AliasingGroup aliasing, uint64_t offset) {
! 4687       invalidate_memory_for_store(aliasing);
  4688       if (aliasing < 0) {
  4689         _exact_memory[-aliasing] = value;
  4690       } else {
  4691         _memory[aliasing].store(ptr, offset, value);

Lines 5741-5751

  5741     }
  5742   };
  5743 
  5744   inline bool could_alias(LoadInst* load, StoreInst* store) {
! 5745     if (load->aliasing() == 0 || store->aliasing() == 0) {
! 5746       return true;
! 5747     }
  5748 
  5749     if (load->aliasing() != store->aliasing()) {
  5750       return false;
  5751     }

Lines 5797-5805

  5797     std::unordered_map<Key, AliasingGroup, KeyHash> _exact_groups;
  5798     Value* _only_base;
  5799 
  5800     void access(AliasingGroup aliasing, Value* ptr, uint64_t offset, Type type) {
! 5801       assert(aliasing > 0);
  5802       GroupInfo& group = _groups[aliasing];
  5803       if (!group.is_invalid) {
  5804         if (group.base == nullptr) {
  5805           group.base = ptr;

Lines 5812-5820

  5812       }
  5813     }
  5814 
  5815     AliasingGroup apply(AliasingGroup aliasing, uint64_t offset) {
! 5816       assert(aliasing > 0);
  5817       GroupInfo& group = _groups[aliasing];
  5818       if (group.is_invalid) {
  5819         return aliasing;
  5820       }

Lines 5849-5858

  5849       }
  5850 
  5851       if (static_cast<int64_t>(_min_exact_group) + INT32_MAX <
  5852           static_cast<int64_t>(_loads.size() + _stores.size())) {
! 5853         return;
! 5854       }
  5855 
  5856       for (LoadInst* load : _loads) {
  5857         load->set_aliasing(apply(load->aliasing(), load->offset()));
  5858       }

Lines 5869-5881

  5869     ExpandingVector<StoreInst*> _last_store;
  5870 
  5871     void mark_stores_live() {
  5872       for (StoreInst*& store : _last_store) {
! 5873         if (store) {
! 5874           _unused[store] = false;
! 5875           store = nullptr;
! 5876         }
! 5877       }
  5878     }
  5879   public:
  5880     DeadStoreElim(Section* section): Pass(section), _unused(section) {
  5881       for (Block* block : *section) {

Lines 5882-5897

  5882         for (Inst* inst : *block) {
  5883           if (dynmatch(StoreInst, store, inst)) {
  5884             Pointer pointer(store->ptr(), store->offset());
  5885             if (store->aliasing() < 0) {
! 5886               _last_store[-store->aliasing()] = store;
! 5887               _unused[store] = true;
  5888             }
  5889           } else if (dynmatch(LoadInst, load, inst)) {
  5890             if (load->aliasing() < 0) {
! 5891               StoreInst* store = _last_store[-load->aliasing()];
  5892               if (store) {
! 5893                 _unused[store] = false;
  5894               }
  5895             } else if (load->aliasing() == 0) {
  5896               mark_stores_live();
  5897             }

Lines 5895-5903

  5895             } else if (load->aliasing() == 0) {
  5896               mark_stores_live();
  5897             }
  5898           } else if (dynamic_cast<CallInst*>(inst)) {
! 5899             mark_stores_live();
  5900           }
  5901         }
  5902 
  5903         mark_stores_live();

Lines 7909-7918

  7909         for (Inst* inst : *block) {
  7910           if (dynmatch(StoreInst, store, inst)) {
  7911             if (store->aliasing() < 0) {
  7912               stores[-store->aliasing()] = 1;
! 7913             } else if (store->aliasing() == 0) {
! 7914               has_unknown_memory_write = true;
  7915             }
  7916           } else if (dynamic_cast<CallInst*>(inst)) {
  7917             has_unknown_memory_write = true;
  7918           }

Lines 9108-9120

  9108           } else if (store) {
  9109             last_stores.erase(0);
  9110             last_stores[store->aliasing()] = store;
  9111             if (auto group = valid_loads.find(0); group != valid_loads.end()) {
! 9112               for (LoadInst* load : group->second) {
! 9113                 canon_erase(Lookup(load));
! 9114               }
! 9115               valid_loads.erase(group);
! 9116             }
  9117             std::vector<LoadInst*>& loads = valid_loads[store->aliasing()];
  9118             std::vector<LoadInst*> remaining_loads;
  9119             for (LoadInst* load : loads) {
  9120               if (could_alias(load, store)) {

x86gen.hpp

Lines 672-680

  672             void* dep = last_clobber; \
  673             if (inst->aliasing() == 0) { \
  674               dep = last_write; \
  675             } else if (auto previous = last_store.find(inst->aliasing()); previous != last_store.end()) { \
! 676               dep = previous->second; \
  677             } \
  678             _memory_deps[inst] = dep;
  679 
  680           if (dynmatch(LoadInst, load, inst)) {

Lines 685-694

  685             if (store->aliasing() == 0) {
  686               last_clobber = store;
  687               last_store.clear();
  688             } else {
! 689               last_store[store->aliasing()] = store;
! 690             }
  691           } else if (dynamic_cast<CallInst*>(inst)) {
  692             _memory_deps[inst] = (void*) block;
  693             last_clobber = inst;
  694             last_write = inst;

@github-actions
Copy link
Copy Markdown

Coverage

File Lines Functions Branches
bitprovenance.hpp 🟢 100.00% 🟢 100.00% 🟡 82.13%
codeheap.hpp 🔴 65.38% 🟢 100.00% 🔴 62.50%
genext.hpp 🟡 73.94% 🟡 87.50% 🟡 75.99%
jitir.hpp 🟡 71.51% 🟡 78.84% 🟡 72.43%
jitir_llvmapi.hpp 🔴 54.65% 🟡 80.00% 🔴 50.00%
llvmgen.hpp 🟢 90.74% 🟢 91.67% 🟡 79.75%
lowerllvm.hpp 🟡 70.72% 🟡 87.50% 🔴 51.42%
x86gen.hpp 🟡 88.71% 🟡 85.19% 🟡 82.90%
x86insts.inc.hpp 🟡 80.87% - -
TOTAL 🟡 75.23% 🟡 80.99% 🟡 76.88%
Diff Coverage

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • jitir.hpp (60.9%): Missing lines 4687,5745-5747,5859-5860,5911,5926,5963-5964,5983-5987,5996-5997,6001,6003,6009,8023-8024,9222-9226
  • llvmgen.hpp (100%)
  • x86gen.hpp (82.4%): Missing lines 676,689-690

Summary

  • Total: 89 lines
  • Missing: 30 lines
  • Coverage: 66%

jitir.hpp

Lines 4683-4691

  4683       _guard_success = nullptr;
  4684     }
  4685 
  4686     void init_store(Value* ptr, Value* value, AliasingGroup aliasing, uint64_t offset) {
! 4687       invalidate_memory_for_store(aliasing);
  4688       if (aliasing < 0) {
  4689         _exact_memory[-aliasing] = value;
  4690       } else {
  4691         _memory[aliasing].store(ptr, offset, value);

Lines 5741-5751

  5741     }
  5742   };
  5743 
  5744   inline bool could_alias(LoadInst* load, StoreInst* store) {
! 5745     if (load->aliasing() == 0 || store->aliasing() == 0) {
! 5746       return true;
! 5747     }
  5748 
  5749     if (load->aliasing() != store->aliasing()) {
  5750       return false;
  5751     }

Lines 5855-5864

  5855         }
  5856       }
  5857 
  5858       for (auto& [alloca, info] : _alloca_info) {
! 5859         if (info.eligible && info.existing_group &&
! 5860             (*info.existing_group == 0 || !_confined.at(*info.existing_group))) {
  5861           if (_max_group == INT32_MAX) {
  5862             break;
  5863           }
  5864           AliasingGroup group = ++_max_group;

Lines 5907-5915

  5907     std::unordered_map<Key, AliasingGroup, KeyHash> _exact_groups;
  5908     Value* _only_base;
  5909 
  5910     void access(AliasingGroup aliasing, Value* ptr, uint64_t offset, Type type) {
! 5911       assert(aliasing > 0);
  5912       GroupInfo& group = _groups[aliasing];
  5913       if (!group.is_invalid) {
  5914         if (group.base == nullptr) {
  5915           group.base = ptr;

Lines 5922-5930

  5922       }
  5923     }
  5924 
  5925     AliasingGroup apply(AliasingGroup aliasing, uint64_t offset) {
! 5926       assert(aliasing > 0);
  5927       GroupInfo& group = _groups[aliasing];
  5928       if (group.is_invalid) {
  5929         return aliasing;
  5930       }

Lines 5959-5968

  5959       }
  5960 
  5961       if (static_cast<int64_t>(_min_exact_group) + INT32_MAX <
  5962           static_cast<int64_t>(_loads.size() + _stores.size())) {
! 5963         return;
! 5964       }
  5965 
  5966       for (LoadInst* load : _loads) {
  5967         load->set_aliasing(apply(load->aliasing(), load->offset()));
  5968       }

Lines 5979-5991

  5979     ExpandingVector<StoreInst*> _last_store;
  5980 
  5981     void mark_stores_live() {
  5982       for (StoreInst*& store : _last_store) {
! 5983         if (store) {
! 5984           _unused[store] = false;
! 5985           store = nullptr;
! 5986         }
! 5987       }
  5988     }
  5989   public:
  5990     DeadStoreElim(Section* section): Pass(section), _unused(section) {
  5991       for (Block* block : *section) {

Lines 5992-6007

  5992         for (Inst* inst : *block) {
  5993           if (dynmatch(StoreInst, store, inst)) {
  5994             Pointer pointer(store->ptr(), store->offset());
  5995             if (store->aliasing() < 0) {
! 5996               _last_store[-store->aliasing()] = store;
! 5997               _unused[store] = true;
  5998             }
  5999           } else if (dynmatch(LoadInst, load, inst)) {
  6000             if (load->aliasing() < 0) {
! 6001               StoreInst* store = _last_store[-load->aliasing()];
  6002               if (store) {
! 6003                 _unused[store] = false;
  6004               }
  6005             } else if (load->aliasing() == 0) {
  6006               mark_stores_live();
  6007             }

Lines 6005 8BD0 -6013

  6005             } else if (load->aliasing() == 0) {
  6006               mark_stores_live();
  6007             }
  6008           } else if (dynamic_cast<CallInst*>(inst)) {
! 6009             mark_stores_live();
  6010           }
  6011         }
  6012 
  6013         mark_stores_live();

Lines 8019-8028

  8019         for (Inst* inst : *block) {
  8020           if (dynmatch(StoreInst, store, inst)) {
  8021             if (store->aliasing() < 0) {
  8022               stores[-store->aliasing()] = 1;
! 8023             } else if (store->aliasing() == 0) {
! 8024               has_unknown_memory_write = true;
  8025             }
  8026           } else if (dynamic_cast<CallInst*>(inst)) {
  8027             has_unknown_memory_write = true;
  8028           }

Lines 9218-9230

  9218           } else if (store) {
  9219             last_stores.erase(0);
  9220             last_stores[store->aliasing()] = store;
  9221             if (auto group = valid_loads.find(0); group != valid_loads.end()) {
! 9222               for (LoadInst* load : group->second) {
! 9223                 canon_erase(Lookup(load));
! 9224               }
! 9225               valid_loads.erase(group);
! 9226             }
  9227             std::vector<LoadInst*>& loads = valid_loads[store->aliasing()];
  9228             std::vector<LoadInst*> remaining_loads;
  9229             for (LoadInst* load : loads) {
  9230               if (could_alias(load, store)) {

x86gen.hpp

Lines 672-680

  672             void* dep = last_clobber; \
  673             if (inst->aliasing() == 0) { \
  674               dep = last_write; \
  675             } else if (auto previous = last_store.find(inst->aliasing()); previous != last_store.end()) { \
! 676               dep = previous->second; \
  677             } \
  678             _memory_deps[inst] = dep;
  679 
  680           if (dynmatch(LoadInst, load, inst)) {

Lines 685-694

  685             if (store->aliasing() == 0) {
  686               last_clobber = store;
  687               last_store.clear();
  688             } else {
! 689               last_store[store->aliasing()] = store;
! 690             }
  691           } else if (dynamic_cast<CallInst*>(inst)) {
  692             _memory_deps[inst] = (void*) block;
  693             last_clobber = inst;
  694             last_write = inst;

@can-lehmann
can-lehmann merged commit 20fea35 into main Nov 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0