summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-26 19:26:05 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-26 19:26:05 +0000
commit1b67cfd40f426ed7730009df444646020a4a8ecf (patch)
tree802cd8158a7e5d6015291d1ab9de40f694a0de6f /clang/lib/CodeGen/CodeGenPGO.cpp
parent3586be721697cf7dbad82d45fffa80506d84a3e1 (diff)
downloadbcm5719-llvm-1b67cfd40f426ed7730009df444646020a4a8ecf.tar.gz
bcm5719-llvm-1b67cfd40f426ed7730009df444646020a4a8ecf.zip
InstrProf: Use unique_ptr
llvm-svn: 204846
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 34dca7c7248..7b45650572a 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -162,7 +162,7 @@ void CodeGenPGO::setFuncName(llvm::Function *Fn) {
RawFuncName = RawFuncName.substr(1);
if (!Fn->hasLocalLinkage()) {
- PrefixedFuncName = new std::string(RawFuncName);
+ PrefixedFuncName.reset(new std::string(RawFuncName));
return;
}
@@ -170,7 +170,7 @@ void CodeGenPGO::setFuncName(llvm::Function *Fn) {
// Do not include the full path in the file name since there's no guarantee
// that it will stay the same, e.g., if the files are checked out from
// version control in different locations.
- PrefixedFuncName = new std::string(CGM.getCodeGenOpts().MainFileName);
+ PrefixedFuncName.reset(new std::string(CGM.getCodeGenOpts().MainFileName));
if (PrefixedFuncName->empty())
PrefixedFuncName->assign("<unknown>");
PrefixedFuncName->append(":");
@@ -849,7 +849,7 @@ void CodeGenPGO::assignRegionCounters(const Decl *D, llvm::Function *Fn) {
}
void CodeGenPGO::mapRegionCounters(const Decl *D) {
- RegionCounterMap = new llvm::DenseMap<const Stmt*, unsigned>();
+ RegionCounterMap.reset(new llvm::DenseMap<const Stmt *, unsigned>);
MapRegionCounters Walker(*RegionCounterMap);
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
Walker.VisitFunctionDecl(FD);
@@ -863,7 +863,7 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) {
}
void CodeGenPGO::computeRegionCounts(const Decl *D) {
- StmtCountMap = new llvm::DenseMap<const Stmt*, uint64_t>();
+ StmtCountMap.reset(new llvm::DenseMap<const Stmt *, uint64_t>);
ComputeRegionCounts Walker(*StmtCountMap, *this);
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
Walker.VisitFunctionDecl(FD);
@@ -917,22 +917,17 @@ void CodeGenPGO::loadRegionCounts(PGOProfileData *PGOData) {
// counters does not match. This could be tightened down in the future to
// ignore counts when the input changes in various ways, e.g., by comparing a
// hash value based on some characteristics of the input.
- RegionCounts = new std::vector<uint64_t>();
+ RegionCounts.reset(new std::vector<uint64_t>);
uint64_t Hash;
if (PGOData->getFunctionCounts(getFuncName(), Hash, *RegionCounts) ||
- Hash != FunctionHash || RegionCounts->size() != NumRegionCounters) {
- delete RegionCounts;
- RegionCounts = 0;
- }
+ Hash != FunctionHash || RegionCounts->size() != NumRegionCounters)
+ RegionCounts.reset();
}
void CodeGenPGO::destroyRegionCounters() {
- if (RegionCounterMap != 0)
- delete RegionCounterMap;
- if (StmtCountMap != 0)
- delete StmtCountMap;
- if (RegionCounts != 0)
- delete RegionCounts;
+ RegionCounterMap.reset();
+ StmtCountMap.reset();
+ RegionCounts.reset();
}
/// \brief Calculate what to divide by to scale weights.
OpenPOWER on IntegriCloud