[ModuleSummaryAnalysis] Use helper methods to check readnone/readonly (NFC)
authorNikita Popov <npopov@redhat.com>
Fri, 21 Oct 2022 10:16:57 +0000 (12:16 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 21 Oct 2022 10:18:57 +0000 (12:18 +0200)
This makes sure that this code continue working when switching to
the memory attribute.

A caveat here is that onlyReadsMemory() will also true for readnone.
To be conservative, I'm explicitly excluding that case here.

llvm/lib/Analysis/ModuleSummaryAnalysis.cpp

index efe6058..52827c2 100644 (file)
@@ -492,8 +492,7 @@ static void computeFunctionSummary(
       F.getLinkage(), F.getVisibility(), NotEligibleForImport,
       /* Live = */ false, F.isDSOLocal(), F.canBeOmittedFromSymbolTable());
   FunctionSummary::FFlags FunFlags{
-      F.hasFnAttribute(Attribute::ReadNone),
-      F.hasFnAttribute(Attribute::ReadOnly),
+      F.doesNotAccessMemory(), F.onlyReadsMemory() && !F.doesNotAccessMemory(),
       F.hasFnAttribute(Attribute::NoRecurse), F.returnDoesNotAlias(),
       // FIXME: refactor this to use the same code that inliner is using.
       // Don't try to import functions with noinline attribute.