[llvm] 7c32c7e - Reapply [FunctionAttrs] Make location classification more precise
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 06:13:27 PDT 2022
Author: Nikita Popov
Date: 2022-10-20T15:13:20+02:00
New Revision: 7c32c7e77744f549743d5c5f970d60c8539da982
URL: https://github.com/llvm/llvm-project/commit/7c32c7e77744f549743d5c5f970d60c8539da982
DIFF: https://github.com/llvm/llvm-project/commit/7c32c7e77744f549743d5c5f970d60c8539da982.diff
LOG: Reapply [FunctionAttrs] Make location classification more precise
Reapplying after the fix for volatile modelling in D135863.
-----
Don't add argmem if the pointer is clearly not an argument (e.g.
a global). I don't think this makes a difference right now, but
gives more obvious results with D135780.
Added:
Modified:
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 7ca76adb3d68..932feea044b3 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -145,11 +145,17 @@ static MemoryEffects checkFunctionMemoryAccess(Function &F, bool ThisBody,
return;
const Value *UO = getUnderlyingObject(Loc.Ptr);
- // The accessed location can be either only argument memory, or
- // argument & other memory, but never inaccessible memory.
- ME |= MemoryEffects::argMemOnly(MR);
- if (!isa<Argument>(UO) && !isa<AllocaInst>(UO))
- ME |= MemoryEffects(MemoryEffects::Other, MR);
+ assert(!isa<AllocaInst>(UO) &&
+ "Should have been handled by pointsToConstantMemory()");
+ if (isa<Argument>(UO)) {
+ ME |= MemoryEffects::argMemOnly(MR);
+ return;
+ }
+
+ // If it's not an identified object, it might be an argument.
+ if (!isIdentifiedObject(UO))
+ ME |= MemoryEffects::argMemOnly(MR);
+ ME |= MemoryEffects(MemoryEffects::Other, MR);
};
// Scan the function body for instructions that may read or write memory.
for (Instruction &I : instructions(F)) {
More information about the llvm-commits
mailing list