From 513ac6e9b045dd2d5e0d1a5e221380cfb999676a Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sun, 10 May 2020 16:53:07 -0500 Subject: [PATCH] [Attributor] Ignore illegal accesses to `null` When we categorize a pointer value we bailed at `null` before. If we know `null` is not a valid memory location we can ignore it as there won't be an access at all. --- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index b3f656d..26196f0 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -6229,9 +6229,13 @@ void AAMemoryLocationImpl::categorizePtrValue( MLK = NO_GLOBAL_INTERNAL_MEM; else MLK = NO_GLOBAL_EXTERNAL_MEM; - } else if (isa(V)) + } else if (isa(V) && + !NullPointerIsDefined(getAssociatedFunction(), + V.getType()->getPointerAddressSpace())) { + return true; + } else if (isa(V)) { MLK = NO_LOCAL_MEM; - else if (const auto *CB = dyn_cast(&V)) { + } else if (const auto *CB = dyn_cast(&V)) { const auto &NoAliasAA = A.getAAFor(*this, IRPosition::callsite_returned(*CB)); if (NoAliasAA.isAssumedNoAlias()) -- 2.7.4