diff options
| author | Sergey Dmitriev <serguei.n.dmitriev@intel.com> | 2019-08-27 21:47:52 +0000 |
|---|---|---|
| committer | Sergey Dmitriev <serguei.n.dmitriev@intel.com> | 2019-08-27 21:47:52 +0000 |
| commit | 4368971b05cc81d35c18086cef2165a974ceb631 (patch) | |
| tree | 4f64c56224a9233c87f77379862f6dc461c6a3ef /clang/tools | |
| parent | 5bbb604bb5b32ce20122dbf0f2f4041616db2700 (diff) | |
| download | bcm5719-llvm-4368971b05cc81d35c18086cef2165a974ceb631.tar.gz bcm5719-llvm-4368971b05cc81d35c18086cef2165a974ceb631.zip | |
[Clang][Bundler] Fix for a hang when unbundling fat binary
clang-offload-bundler tool may hang under certain conditions when it extracts a subset of all available device bundles from the fat binary that is handled by the BinaryFileHandler. This patch fixes this problem.
Differential Revision: https://reviews.llvm.org/D66598
llvm-svn: 370115
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp index 9f52790d55c..a1c7418e26a 100644 --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -215,6 +215,7 @@ class BinaryFileHandler final : public FileHandler { /// Iterator for the bundle information that is being read. StringMap<BundleInfo>::iterator CurBundleInfo; + StringMap<BundleInfo>::iterator NextBundleInfo; public: BinaryFileHandler() : FileHandler() {} @@ -284,19 +285,19 @@ public: BundlesInfo[Triple] = BundleInfo(Size, Offset); } // Set the iterator to where we will start to read. - CurBundleInfo = BundlesInfo.begin(); + CurBundleInfo = BundlesInfo.end(); + NextBundleInfo = BundlesInfo.begin(); } StringRef ReadBundleStart(MemoryBuffer &Input) final { - if (CurBundleInfo == BundlesInfo.end()) + if (NextBundleInfo == BundlesInfo.end()) return StringRef(); - + CurBundleInfo = NextBundleInfo++; return CurBundleInfo->first(); } void ReadBundleEnd(MemoryBuffer &Input) final { assert(CurBundleInfo != BundlesInfo.end() && "Invalid reader info!"); - ++CurBundleInfo; } void ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final { |

