This revision was automatically updated to reflect the committed changes. Closed by commit rL370115: [Clang][Bundler] Fix for a hang when unbundling fat binary (authored by sdmitriev, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D66598?vs=217485&id=217501#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66598/new/ https://reviews.llvm.org/D66598 Files: cfe/trunk/test/Driver/clang-offload-bundler.c cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Index: cfe/trunk/test/Driver/clang-offload-bundler.c =================================================================== --- cfe/trunk/test/Driver/clang-offload-bundler.c +++ cfe/trunk/test/Driver/clang-offload-bundler.c @@ -221,6 +221,11 @@ // RUN: diff %t.empty %t.res.tgt1 // RUN: diff %t.empty %t.res.tgt2 +// Check that we do not have to unbundle all available bundles from the fat binary. +// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.unordered.ast -unbundle +// RUN: diff %t.ast %t.res.ast +// RUN: diff %t.tgt2 %t.res.tgt2 + // // Check object bundle/unbundle. The content should be bundled into an ELF // section (we are using a PowerPC little-endian host which uses ELF). We Index: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp =================================================================== --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -215,6 +215,7 @@ /// Iterator for the bundle information that is being read. StringMap<BundleInfo>::iterator CurBundleInfo; + StringMap<BundleInfo>::iterator NextBundleInfo; public: BinaryFileHandler() : FileHandler() {} @@ -284,19 +285,19 @@ 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 {
Index: cfe/trunk/test/Driver/clang-offload-bundler.c =================================================================== --- cfe/trunk/test/Driver/clang-offload-bundler.c +++ cfe/trunk/test/Driver/clang-offload-bundler.c @@ -221,6 +221,11 @@ // RUN: diff %t.empty %t.res.tgt1 // RUN: diff %t.empty %t.res.tgt2 +// Check that we do not have to unbundle all available bundles from the fat binary. +// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.unordered.ast -unbundle +// RUN: diff %t.ast %t.res.ast +// RUN: diff %t.tgt2 %t.res.tgt2 + // // Check object bundle/unbundle. The content should be bundled into an ELF // section (we are using a PowerPC little-endian host which uses ELF). We Index: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp =================================================================== --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -215,6 +215,7 @@ /// Iterator for the bundle information that is being read. StringMap<BundleInfo>::iterator CurBundleInfo; + StringMap<BundleInfo>::iterator NextBundleInfo; public: BinaryFileHandler() : FileHandler() {} @@ -284,19 +285,19 @@ 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 {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits