From: Davide Italiano Date: Tue, 27 Jun 2017 00:33:37 +0000 (+0000) Subject: [CFLAA] Use raw pointers instead of Optional. NFC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ba26728be6739110bf1873226883567d66a3483;p=llvm [CFLAA] Use raw pointers instead of Optional. NFC. Using Optional<> here doesn't seem to be terribly valuable, but this is not the main point of this change. The change enables us to merge the (now) two identical copies of parentFunctionOfValue() that Steensgaard's and Andersens' provide. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306351 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFLSteensAliasAnalysis.cpp b/lib/Analysis/CFLSteensAliasAnalysis.cpp index 0825111501a..33154ee9588 100644 --- a/lib/Analysis/CFLSteensAliasAnalysis.cpp +++ b/lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -90,7 +90,7 @@ const StratifiedIndex StratifiedLink::SetSentinel = /// Determines whether it would be pointless to add the given Value to our sets. static bool canSkipAddingToSets(Value *Val); -static Optional parentFunctionOfValue(Value *Val) { +static Function *parentFunctionOfValue(Value *Val) { if (auto *Inst = dyn_cast(Val)) { auto *Bb = Inst->getParent(); return Bb->getParent(); @@ -98,7 +98,7 @@ static Optional parentFunctionOfValue(Value *Val) { if (auto *Arg = dyn_cast(Val)) return Arg->getParent(); - return None; + return nullptr; } static bool canSkipAddingToSets(Value *Val) { @@ -281,9 +281,9 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA, return NoAlias; Function *Fn = nullptr; - auto MaybeFnA = parentFunctionOfValue(ValA); - auto MaybeFnB = parentFunctionOfValue(ValB); - if (!MaybeFnA.hasValue() && !MaybeFnB.hasValue()) { + Function *MaybeFnA = parentFunctionOfValue(ValA); + Function *MaybeFnB = parentFunctionOfValue(ValB); + if (!MaybeFnA && !MaybeFnB) { // The only times this is known to happen are when globals + InlineAsm are // involved DEBUG(dbgs() @@ -291,12 +291,12 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA, return MayAlias; } - if (MaybeFnA.hasValue()) { - Fn = *MaybeFnA; - assert((!MaybeFnB.hasValue() || *MaybeFnB == *MaybeFnA) && + if (MaybeFnA) { + Fn = MaybeFnA; + assert((!MaybeFnB || MaybeFnB == MaybeFnA) && "Interprocedural queries not supported"); } else { - Fn = *MaybeFnB; + Fn = MaybeFnB; } assert(Fn != nullptr);