mlir: Avoid SmallVector::set_size in SerializeToHsacoPass::loadLibraries

Spotted this in a final grep of projects I don't usually build before
pushing https://reviews.llvm.org/D115380, which makes
`SmallVector::set_size()` private.

Update to `truncate()`, a new-ish variant of `resize()` that asserts the
new size is not bigger and that avoids pulling in the allocation and
initialization code for growing. Doesn't really look like the perf
impact of that would matter here, but since `dirLength` is known to be a
smaller size then we might as well.

Differential Revision: https://reviews.llvm.org/D117073
This commit is contained in:
Duncan P. N. Exon Smith 2022-01-11 18:11:15 -08:00
parent 529f098789
commit b77d4d54f9
1 changed files with 1 additions and 1 deletions

View File

@ -160,7 +160,7 @@ SerializeToHsacoPass::loadLibraries(SmallVectorImpl<char> &path,
llvm::StringRef pathRef(path.data(), path.size());
std::unique_ptr<llvm::Module> library =
llvm::getLazyIRFileModule(pathRef, error, context);
path.set_size(dirLength);
path.truncate(dirLength);
if (!library) {
getOperation().emitError() << "Failed to load library " << file
<< " from " << path << error.getMessage();