Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions llvm/lib/Object/OffloadBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ Error extractOffloadBundle(MemoryBufferRef Contents, uint64_t SectionOffset,
StringRef FileName,
SmallVectorImpl<OffloadBundleFatBin> &Bundles) {

uint64_t Offset = 0;
int64_t NextbundleStart = 0;
size_t Offset = 0;
size_t NextbundleStart = 0;

// There could be multiple offloading bundles stored at this section.
while (NextbundleStart >= 0) {

while (NextbundleStart != StringRef::npos) {
std::unique_ptr<MemoryBuffer> Buffer =
MemoryBuffer::getMemBuffer(Contents.getBuffer().drop_front(Offset), "",
/*RequiresNullTerminator=*/false);
Expand All @@ -60,10 +59,9 @@ Error extractOffloadBundle(MemoryBufferRef Contents, uint64_t SectionOffset,

// Find the next bundle by searching for the magic string
StringRef Str = Buffer->getBuffer();
NextbundleStart =
(int64_t)Str.find(StringRef("__CLANG_OFFLOAD_BUNDLE__"), 24);
NextbundleStart = Str.find(StringRef("__CLANG_OFFLOAD_BUNDLE__"), 24);

if (NextbundleStart >= 0)
if (NextbundleStart != StringRef::npos)
Offset += NextbundleStart;
}

Expand Down