tv: avoid memory allocation when construction a new TLI object
MODIFY
tv/tv.cpp
tv/tv.cpp
@@ -726,13 +726,12 @@ llvmGetPassPluginInfo() {
tv.print_pass_name = true;
llvm::TargetLibraryInfoImpl TLIImpl;
- unique_ptr<llvm::TargetLibraryInfo> TLI_holder;
+ optional<llvm::TargetLibraryInfo> TLI_holder;
auto get_TLI = [&](llvm::Function &F) {
TLIImpl = llvm::TargetLibraryInfoImpl(
llvm::Triple(F.getParent()->getTargetTriple()));
- TLI_holder = make_unique<llvm::TargetLibraryInfo>(TLIImpl, &F);
- return TLI_holder.get();
+ return &TLI_holder.emplace(TLIImpl, &F);
};
tv.run(*const_cast<llvm::Module *>(unwrapModule(IR)), get_TLI);

tv: avoid memory allocation when construction a new TLI object