@@ -875,7 +875,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
875875
876876 // Try to find a value of each element of an aggregate.
877877 // FIXME: deal with more complex, not one-dimensional, aggregate types
878- SmallVector<Optional <Instruction *>, 2 > AggElts (NumAggElts, NotFound);
878+ SmallVector<std::optional <Instruction *>, 2 > AggElts (NumAggElts, NotFound);
879879
880880 // Do we know values for each element of the aggregate?
881881 auto KnowAllElts = [&AggElts]() {
@@ -908,7 +908,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
908908 // Now, we may have already previously recorded the value for this element
909909 // of an aggregate. If we did, that means the CurrIVI will later be
910910 // overwritten with the already-recorded value. But if not, let's record it!
911- Optional <Instruction *> &Elt = AggElts[Indices.front ()];
911+ std::optional <Instruction *> &Elt = AggElts[Indices.front ()];
912912 Elt = Elt.value_or (InsertedValue);
913913
914914 // FIXME: should we handle chain-terminating undef base operand?
@@ -938,7 +938,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
938938 // / or different elements had different source aggregates.
939939 FoundMismatch
940940 };
941- auto Describe = [](Optional <Value *> SourceAggregate) {
941+ auto Describe = [](std::optional <Value *> SourceAggregate) {
942942 if (SourceAggregate == NotFound)
943943 return AggregateDescription::NotFound;
944944 if (*SourceAggregate == FoundMismatch)
@@ -952,8 +952,8 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
952952 // If found, return the source aggregate from which the extraction was.
953953 // If \p PredBB is provided, does PHI translation of an \p Elt first.
954954 auto FindSourceAggregate =
955- [&](Instruction *Elt, unsigned EltIdx, Optional <BasicBlock *> UseBB,
956- Optional <BasicBlock *> PredBB) -> Optional <Value *> {
955+ [&](Instruction *Elt, unsigned EltIdx, std::optional <BasicBlock *> UseBB,
956+ std::optional <BasicBlock *> PredBB) -> std::optional <Value *> {
957957 // For now(?), only deal with, at most, a single level of PHI indirection.
958958 if (UseBB && PredBB)
959959 Elt = dyn_cast<Instruction>(Elt->DoPHITranslation (*UseBB, *PredBB));
@@ -980,9 +980,9 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
980980 // see if we can find appropriate source aggregate for each of the elements,
981981 // and see it's the same aggregate for each element. If so, return it.
982982 auto FindCommonSourceAggregate =
983- [&](Optional <BasicBlock *> UseBB,
984- Optional <BasicBlock *> PredBB) -> Optional <Value *> {
985- Optional <Value *> SourceAggregate;
983+ [&](std::optional <BasicBlock *> UseBB,
984+ std::optional <BasicBlock *> PredBB) -> std::optional <Value *> {
985+ std::optional <Value *> SourceAggregate;
986986
987987 for (auto I : enumerate(AggElts)) {
988988 assert (Describe (SourceAggregate) != AggregateDescription::FoundMismatch &&
@@ -994,7 +994,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
994994 // For this element, is there a plausible source aggregate?
995995 // FIXME: we could special-case undef element, IFF we know that in the
996996 // source aggregate said element isn't poison.
997- Optional <Value *> SourceAggregateForElement =
997+ std::optional <Value *> SourceAggregateForElement =
998998 FindSourceAggregate (*I.value (), I.index (), UseBB, PredBB);
999999
10001000 // Okay, what have we found? Does that correlate with previous findings?
@@ -1028,7 +1028,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
10281028 return *SourceAggregate;
10291029 };
10301030
1031- Optional <Value *> SourceAggregate;
1031+ std::optional <Value *> SourceAggregate;
10321032
10331033 // Can we find the source aggregate without looking at predecessors?
10341034 SourceAggregate = FindCommonSourceAggregate (/* UseBB=*/ std::nullopt ,
@@ -1049,7 +1049,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
10491049 // they all should be defined in the same basic block.
10501050 BasicBlock *UseBB = nullptr ;
10511051
1052- for (const Optional <Instruction *> &I : AggElts) {
1052+ for (const std::optional <Instruction *> &I : AggElts) {
10531053 BasicBlock *BB = (*I)->getParent ();
10541054 // If it's the first instruction we've encountered, record the basic block.
10551055 if (!UseBB) {
0 commit comments