diff options
author | Lang Hames <lhames@gmail.com> | 2024-06-26 12:49:33 +1000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2024-06-26 13:00:41 +1000 |
commit | 896dd322afcc1cf5dc4fa7375dedd55b59001eb4 (patch) | |
tree | 37011ea623362d9e0de737c3aee23ade0aebc9e1 /llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp | |
parent | 96b1f8859df3c82b6362b1dd07ee485f48cb1816 (diff) | |
download | llvm-896dd322afcc1cf5dc4fa7375dedd55b59001eb4.zip llvm-896dd322afcc1cf5dc4fa7375dedd55b59001eb4.tar.gz llvm-896dd322afcc1cf5dc4fa7375dedd55b59001eb4.tar.bz2 |
[ORC] Fix block dependence calculation in ObjectLinkingLayer.
This fixes a bug in ObjectLinkingLayer::computeBlockNonLocalDeps: The worklist
needs to be built *after* all immediate dependencies / dependants are recorded,
rather than trying to populate it as part of the same loop. (Trying to do the
latter causes us to miss some blocks that should have been included in the
worklist).
This fixes a bug discovered by @Sahil123 on discord during work on
out-of-process execution support in the clang-repl.
No testcase yet. This *might* be testable with a unit test and a custom
JITLinkContext but I believe some aspects of the algorithm depend on memory
layout. I'll need to investigate that. Alternatively we could add llvm-jitlink
testcases that exercise concurrent linking (and should probably do that anyway).
Either option will require some investment and I don't want to hold this fix up
in the mean time.
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp index 57ade94..a66c40d 100644 --- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp @@ -626,9 +626,11 @@ private: } } } + } - // If this node has both dependants and dependencies then add it to the - // worklist to propagate the dependencies to the dependants. + // Add blocks with both dependants and dependencies to the worklist to + // propagate dependencies to dependants. + for (auto &[B, BI] : BlockInfos) { if (!BI.Dependants.empty() && !BI.Dependencies.empty()) WorkList.push_back(B); } |