forked from OSchip/llvm-project
[RS4GC] Rename stripDereferenceabilityInfo into stripNonValidAttributes.
llvm-svn: 251157
This commit is contained in:
parent
c73d8b0e18
commit
dde0029a25
|
@ -92,10 +92,10 @@ struct RewriteStatepointsForGC : public ModulePass {
|
||||||
Changed |= runOnFunction(F);
|
Changed |= runOnFunction(F);
|
||||||
|
|
||||||
if (Changed) {
|
if (Changed) {
|
||||||
// stripDereferenceabilityInfo asserts that shouldRewriteStatepointsIn
|
// stripNonValidAttributes asserts that shouldRewriteStatepointsIn
|
||||||
// returns true for at least one function in the module. Since at least
|
// returns true for at least one function in the module. Since at least
|
||||||
// one function changed, we know that the precondition is satisfied.
|
// one function changed, we know that the precondition is satisfied.
|
||||||
stripDereferenceabilityInfo(M);
|
stripNonValidAttributes(M);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Changed;
|
return Changed;
|
||||||
|
@ -112,15 +112,15 @@ struct RewriteStatepointsForGC : public ModulePass {
|
||||||
/// dereferenceability that are no longer valid/correct after
|
/// dereferenceability that are no longer valid/correct after
|
||||||
/// RewriteStatepointsForGC has run. This is because semantically, after
|
/// RewriteStatepointsForGC has run. This is because semantically, after
|
||||||
/// RewriteStatepointsForGC runs, all calls to gc.statepoint "free" the entire
|
/// RewriteStatepointsForGC runs, all calls to gc.statepoint "free" the entire
|
||||||
/// heap. stripDereferenceabilityInfo (conservatively) restores correctness
|
/// heap. stripNonValidAttributes (conservatively) restores correctness
|
||||||
/// by erasing all attributes in the module that externally imply
|
/// by erasing all attributes in the module that externally imply
|
||||||
/// dereferenceability.
|
/// dereferenceability.
|
||||||
///
|
///
|
||||||
void stripDereferenceabilityInfo(Module &M);
|
void stripNonValidAttributes(Module &M);
|
||||||
|
|
||||||
// Helpers for stripDereferenceabilityInfo
|
// Helpers for stripNonValidAttributes
|
||||||
void stripDereferenceabilityInfoFromBody(Function &F);
|
void stripNonValidAttributesFromBody(Function &F);
|
||||||
void stripDereferenceabilityInfoFromPrototype(Function &F);
|
void stripNonValidAttributesFromPrototype(Function &F);
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -2492,8 +2492,8 @@ static bool insertParsePoints(Function &F, DominatorTree &DT, Pass *P,
|
||||||
|
|
||||||
// Handles both return values and arguments for Functions and CallSites.
|
// Handles both return values and arguments for Functions and CallSites.
|
||||||
template <typename AttrHolder>
|
template <typename AttrHolder>
|
||||||
static void RemoveDerefAttrAtIndex(LLVMContext &Ctx, AttrHolder &AH,
|
static void RemoveNonValidAttrAtIndex(LLVMContext &Ctx, AttrHolder &AH,
|
||||||
unsigned Index) {
|
unsigned Index) {
|
||||||
AttrBuilder R;
|
AttrBuilder R;
|
||||||
if (AH.getDereferenceableBytes(Index))
|
if (AH.getDereferenceableBytes(Index))
|
||||||
R.addAttribute(Attribute::get(Ctx, Attribute::Dereferenceable,
|
R.addAttribute(Attribute::get(Ctx, Attribute::Dereferenceable,
|
||||||
|
@ -2508,18 +2508,18 @@ static void RemoveDerefAttrAtIndex(LLVMContext &Ctx, AttrHolder &AH,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RewriteStatepointsForGC::stripDereferenceabilityInfoFromPrototype(Function &F) {
|
RewriteStatepointsForGC::stripNonValidAttributesFromPrototype(Function &F) {
|
||||||
LLVMContext &Ctx = F.getContext();
|
LLVMContext &Ctx = F.getContext();
|
||||||
|
|
||||||
for (Argument &A : F.args())
|
for (Argument &A : F.args())
|
||||||
if (isa<PointerType>(A.getType()))
|
if (isa<PointerType>(A.getType()))
|
||||||
RemoveDerefAttrAtIndex(Ctx, F, A.getArgNo() + 1);
|
RemoveNonValidAttrAtIndex(Ctx, F, A.getArgNo() + 1);
|
||||||
|
|
||||||
if (isa<PointerType>(F.getReturnType()))
|
if (isa<PointerType>(F.getReturnType()))
|
||||||
RemoveDerefAttrAtIndex(Ctx, F, AttributeSet::ReturnIndex);
|
RemoveNonValidAttrAtIndex(Ctx, F, AttributeSet::ReturnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RewriteStatepointsForGC::stripDereferenceabilityInfoFromBody(Function &F) {
|
void RewriteStatepointsForGC::stripNonValidAttributesFromBody(Function &F) {
|
||||||
if (F.empty())
|
if (F.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2549,9 +2549,9 @@ void RewriteStatepointsForGC::stripDereferenceabilityInfoFromBody(Function &F) {
|
||||||
if (CallSite CS = CallSite(&I)) {
|
if (CallSite CS = CallSite(&I)) {
|
||||||
for (int i = 0, e = CS.arg_size(); i != e; i++)
|
for (int i = 0, e = CS.arg_size(); i != e; i++)
|
||||||
if (isa<PointerType>(CS.getArgument(i)->getType()))
|
if (isa<PointerType>(CS.getArgument(i)->getType()))
|
||||||
RemoveDerefAttrAtIndex(Ctx, CS, i + 1);
|
RemoveNonValidAttrAtIndex(Ctx, CS, i + 1);
|
||||||
if (isa<PointerType>(CS.getType()))
|
if (isa<PointerType>(CS.getType()))
|
||||||
RemoveDerefAttrAtIndex(Ctx, CS, AttributeSet::ReturnIndex);
|
RemoveNonValidAttrAtIndex(Ctx, CS, AttributeSet::ReturnIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2570,17 +2570,17 @@ static bool shouldRewriteStatepointsIn(Function &F) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RewriteStatepointsForGC::stripDereferenceabilityInfo(Module &M) {
|
void RewriteStatepointsForGC::stripNonValidAttributes(Module &M) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert(std::any_of(M.begin(), M.end(), shouldRewriteStatepointsIn) &&
|
assert(std::any_of(M.begin(), M.end(), shouldRewriteStatepointsIn) &&
|
||||||
"precondition!");
|
"precondition!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (Function &F : M)
|
for (Function &F : M)
|
||||||
stripDereferenceabilityInfoFromPrototype(F);
|
stripNonValidAttributesFromPrototype(F);
|
||||||
|
|
||||||
for (Function &F : M)
|
for (Function &F : M)
|
||||||
stripDereferenceabilityInfoFromBody(F);
|
stripNonValidAttributesFromBody(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RewriteStatepointsForGC::runOnFunction(Function &F) {
|
bool RewriteStatepointsForGC::runOnFunction(Function &F) {
|
||||||
|
|
Loading…
Reference in New Issue