[llvm] d44cd1b - Revert "[FunctionAttrs] Make location classification more precise"
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 03:11:17 PDT 2022
Author: Nikita Popov
Date: 2022-10-13T12:11:04+02:00
New Revision: d44cd1bbeb7542eba06401279e5f2c117247019b
URL: https://github.com/llvm/llvm-project/commit/d44cd1bbeb7542eba06401279e5f2c117247019b
DIFF: https://github.com/llvm/llvm-project/commit/d44cd1bbeb7542eba06401279e5f2c117247019b.diff
LOG: Revert "[FunctionAttrs] Make location classification more precise"
This reverts commit b05f5b90a12098660a4fc16da0b4d421ddfe14e2.
There are thread sanitizer buildbot failures in simple_stack.c.
I think that's because this ended up affecting the handling of
volatile accesses to allocas. Reverting for now.
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 a5bf7543472c..007d84a702fa 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -139,19 +139,10 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
F.getAttributes().hasAttrSomewhere(Attribute::Preallocated))
MRB |= FunctionModRefBehavior::argMemOnly(ModRefInfo::ModRef);
- auto AddPtrAccess = [&](const Value *Ptr, ModRefInfo MR) {
+ // Returns true if Ptr is not based on a function argument.
+ auto IsArgumentOrAlloca = [](const Value *Ptr) {
const Value *UO = getUnderlyingObject(Ptr);
- if (isa<AllocaInst>(UO))
- return;
- if (isa<Argument>(UO)) {
- MRB |= FunctionModRefBehavior::argMemOnly(MR);
- return;
- }
- // If it's not an identified object, it might be an argument.
- if (!isIdentifiedObject(UO))
- MRB |= FunctionModRefBehavior::argMemOnly(MR);
- MRB |= FunctionModRefBehavior(FunctionModRefBehavior::Other, MR);
- return;
+ return isa<Argument>(UO) || isa<AllocaInst>(UO);
};
// Scan the function body for instructions that may read or write memory.
for (Instruction &I : instructions(F)) {
@@ -202,7 +193,9 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true))
continue;
- AddPtrAccess(Loc.Ptr, ArgMR);
+ MRB |= FunctionModRefBehavior::argMemOnly(ArgMR);
+ if (!IsArgumentOrAlloca(Loc.Ptr))
+ MRB |= FunctionModRefBehavior(FunctionModRefBehavior::Other, ArgMR);
}
}
continue;
@@ -228,7 +221,11 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
if (!I.isVolatile() && AAR.pointsToConstantMemory(*Loc, /*OrLocal=*/true))
continue;
- AddPtrAccess(Loc->Ptr, MR);
+ // The accessed location can be either only argument memory, or
+ // argument & other memory, but never inaccessible memory.
+ MRB |= FunctionModRefBehavior::argMemOnly(MR);
+ if (!IsArgumentOrAlloca(Loc->Ptr))
+ MRB |= FunctionModRefBehavior(FunctionModRefBehavior::Other, MR);
}
return OrigMRB & MRB;
More information about the llvm-commits
mailing list