|
24 | 24 | // loads from __spirv_BuiltIn GVs) |
25 | 25 | // – Unknown : any other mayReadOrWriteMemory() (intrinsics, calls, |
26 | 26 | // generic addrspace) |
27 | | -// * At the same time, build a per-basic block summary of memory accesses: |
28 | | -// - None : only private/constant or no accesses |
29 | | -// - Local : at least one addrspace(3) access |
30 | | -// - Global : at least one addrspace(1/5/6) access (except loads from |
31 | | -// __spirv_BuiltIn globals) |
32 | 27 | // - Unknown: any other mayReadOrWriteMemory() instruction |
33 | 28 | // |
34 | 29 | // 2) **At Entry and At Exit Elimination** |
|
45 | 40 | // – Find the single barrier with the *widest* (ExecScope, MemScope) |
46 | 41 | // (ignore Unknown). |
47 | 42 | // – Erase all other barriers (they synchronize nothing). |
48 | | -// If BB summary == None (no local, global or unknown accesses): |
49 | | -// - Find the single barrier with the widest (ExecScope, MemScope) |
50 | | -// ignoring Unknown scopes. |
51 | | -// - Erase all other barriers since they synchronize nothing. |
52 | 43 | // b) *General Redundancy Check* |
53 | 44 | // Otherwise we walk the barriers in source order and compare each new |
54 | 45 | // barrier to the most recent one that is still alive: |
@@ -1000,6 +991,11 @@ PreservedAnalyses SYCLOptimizeBarriersPass::run(Function &F, |
1000 | 991 | Changed |= eliminateBackToBackInBB(BarrierBBPair.first, |
1001 | 992 | BarrierBBPair.second, BBMemInfo); |
1002 | 993 |
|
| 994 | + // Refresh the list of barriers after back-to-back elimination. |
| 995 | + BarrierPtrs.clear(); |
| 996 | + for (auto &Pair : BarriersByBB) |
| 997 | + for (auto &BD : Pair.second) |
| 998 | + BarrierPtrs.push_back(&BD); |
1003 | 999 | // TODO: hoist 2 barriers with the same predecessor BBs. |
1004 | 1000 |
|
1005 | 1001 | // In the end eliminate or narrow barriers depending on DT and PDT analyses. |
|
0 commit comments