llvm.org GIT mirror llvm / b5e9bf0
Don't create a MemoryBuffer just to get the MemoryBufferRef. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216608 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
268268 static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
269269 int *claimed) {
270270 LLVMContext Context;
271 std::unique_ptr buffer;
271 MemoryBufferRef BufferRef;
272 std::unique_ptr Buffer;
272273 if (get_view) {
273274 const void *view;
274275 if (get_view(file->handle, &view) != LDPS_OK) {
275276 message(LDPL_ERROR, "Failed to get a view of %s", file->name);
276277 return LDPS_ERR;
277278 }
278 buffer = MemoryBuffer::getMemBuffer(StringRef((char *)view, file->filesize),
279 "", false);
279 BufferRef = MemoryBufferRef(StringRef((char *)view, file->filesize), "");
280280 } else {
281281 int64_t offset = 0;
282282 // Gold has found what might be IR part-way inside of a file, such as
291291 message(LDPL_ERROR, EC.message().c_str());
292292 return LDPS_ERR;
293293 }
294 buffer = std::move(BufferOrErr.get());
294 Buffer = std::move(BufferOrErr.get());
295 BufferRef = Buffer->getMemBufferRef();
295296 }
296297
297298 ErrorOr ObjOrErr =
298 object::IRObjectFile::createIRObjectFile(buffer->getMemBufferRef(),
299 Context);
299 object::IRObjectFile::createIRObjectFile(BufferRef, Context);
300300 std::error_code EC = ObjOrErr.getError();
301301 if (EC == BitcodeError::InvalidBitcodeSignature)
302302 return LDPS_OK;