mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 06:00:28 +00:00
0060160bcf
This restores commit r260408, along with a fix for a bot failure. The bot failure was caused by dereferencing a unique_ptr in the same call instruction parameter list where it was passed via std::move. Apparently due to luck this was not exposed when I built the compiler with clang, only with gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260442 91177308-0d34-0410-b5e6-96231b3b80d8
58 lines
2.2 KiB
C++
58 lines
2.2 KiB
C++
//===-- FunctionInfo.cpp - Function Info Index ----------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the function info index and summary classes for the
|
|
// IR library.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/IR/FunctionInfo.h"
|
|
#include "llvm/ADT/StringMap.h"
|
|
using namespace llvm;
|
|
|
|
// Create the combined function index/summary from multiple
|
|
// per-module instances.
|
|
void FunctionInfoIndex::mergeFrom(std::unique_ptr<FunctionInfoIndex> Other,
|
|
uint64_t NextModuleId) {
|
|
|
|
StringRef ModPath;
|
|
for (auto &OtherFuncInfoLists : *Other) {
|
|
uint64_t FuncGUID = OtherFuncInfoLists.first;
|
|
FunctionInfoList &List = OtherFuncInfoLists.second;
|
|
|
|
// Assert that the func info list only has one entry, since we shouldn't
|
|
// have duplicate names within a single per-module index.
|
|
assert(List.size() == 1);
|
|
std::unique_ptr<FunctionInfo> Info = std::move(List.front());
|
|
|
|
// Skip if there was no function summary section.
|
|
if (!Info->functionSummary())
|
|
continue;
|
|
|
|
// Add the module path string ref for this module if we haven't already
|
|
// saved a reference to it.
|
|
if (ModPath.empty())
|
|
ModPath =
|
|
addModulePath(Info->functionSummary()->modulePath(), NextModuleId);
|
|
else
|
|
assert(ModPath == Info->functionSummary()->modulePath() &&
|
|
"Each module in the combined map should have a unique ID");
|
|
|
|
// Note the module path string ref was copied above and is still owned by
|
|
// the original per-module index. Reset it to the new module path
|
|
// string reference owned by the combined index.
|
|
Info->functionSummary()->setModulePath(ModPath);
|
|
|
|
// Add new function info to existing list. There may be duplicates when
|
|
// combining FunctionMap entries, due to COMDAT functions. Any local
|
|
// functions were given unique global IDs.
|
|
addFunctionInfo(FuncGUID, std::move(Info));
|
|
}
|
|
}
|