From: Nikita Popov Date: Fri, 9 Dec 2022 15:17:45 +0000 (+0100) Subject: [BasicAA] Handle phi with itself as incoming value X-Git-Tag: upstream/17.0.6~24499 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc1e2bb4d44c6a47705faff52fc62e83917998d0;p=platform%2Fupstream%2Fllvm.git [BasicAA] Handle phi with itself as incoming value We can skip such incoming values. This was already done by PhiValues if present, but we can also do this without the additional analysis. --- diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 2b552bf..6aad258 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -1360,6 +1360,10 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize, SmallPtrSet UniqueSrc; Value *OnePhi = nullptr; for (Value *PV1 : PN->incoming_values()) { + // Skip the phi itself being the incoming value. + if (PV1 == PN) + continue; + if (isa(PV1)) { if (OnePhi && OnePhi != PV1) { // To control potential compile time explosion, we choose to be diff --git a/llvm/test/Analysis/BasicAA/recphi.ll b/llvm/test/Analysis/BasicAA/recphi.ll index 4d2fa39..3bf621f 100644 --- a/llvm/test/Analysis/BasicAA/recphi.ll +++ b/llvm/test/Analysis/BasicAA/recphi.ll @@ -413,8 +413,7 @@ exit: ret void } -; NO-PHI-VALUES: MayAlias: i8* %a, i8* %phi -; PHI-VALUES: MustAlias: i8* %a, i8* %phi +; CHECK: MustAlias: i8* %a, i8* %phi define void @phi_contains_self() { entry: %a = alloca i32