aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/PredicateInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils/PredicateInfo.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PredicateInfo.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index d4b2bcf..4c87bab 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -728,16 +728,12 @@ void PredicateInfoBuilder::renameUses(SmallVectorImpl<Value *> &OpsToRename) {
PredicateInfoBuilder::ValueInfo &
PredicateInfoBuilder::getOrCreateValueInfo(Value *Operand) {
- auto OIN = ValueInfoNums.find(Operand);
- if (OIN == ValueInfoNums.end()) {
- // This will grow it
+ auto Res = ValueInfoNums.try_emplace(Operand, ValueInfos.size());
+ if (Res.second) {
+ // Allocate space for new ValueInfo.
ValueInfos.resize(ValueInfos.size() + 1);
- // This will use the new size and give us a 0 based number of the info
- auto InsertResult = ValueInfoNums.insert({Operand, ValueInfos.size() - 1});
- assert(InsertResult.second && "Value info number already existed?");
- return ValueInfos[InsertResult.first->second];
}
- return ValueInfos[OIN->second];
+ return ValueInfos[Res.first->second];
}
const PredicateInfoBuilder::ValueInfo &