forked from OSchip/llvm-project
[NFC] Return correct PreservedAnalysis for CoroEarly
This is a fix for previous typo. It makes no sense to return PreservedAnalyses::all() if anything is change. This change simplify codes further.
This commit is contained in:
parent
bd0d126302
commit
5b6742a6bd
|
@ -151,8 +151,11 @@ bool Lowerer::lowerEarlyIntrinsics(Function &F) {
|
||||||
SmallVector<CoroFreeInst *, 4> CoroFrees;
|
SmallVector<CoroFreeInst *, 4> CoroFrees;
|
||||||
bool HasCoroSuspend = false;
|
bool HasCoroSuspend = false;
|
||||||
for (Instruction &I : llvm::make_early_inc_range(instructions(F))) {
|
for (Instruction &I : llvm::make_early_inc_range(instructions(F))) {
|
||||||
if (auto *CB = dyn_cast<CallBase>(&I)) {
|
auto *CB = dyn_cast<CallBase>(&I);
|
||||||
switch (CB->getIntrinsicID()) {
|
if (!CB)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (CB->getIntrinsicID()) {
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
case Intrinsic::coro_free:
|
case Intrinsic::coro_free:
|
||||||
|
@ -209,16 +212,18 @@ bool Lowerer::lowerEarlyIntrinsics(Function &F) {
|
||||||
case Intrinsic::coro_done:
|
case Intrinsic::coro_done:
|
||||||
lowerCoroDone(cast<IntrinsicInst>(&I));
|
lowerCoroDone(cast<IntrinsicInst>(&I));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
Changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that all CoroFree reference the coro.id intrinsic.
|
// Make sure that all CoroFree reference the coro.id intrinsic.
|
||||||
// Token type is not exposed through coroutine C/C++ builtins to plain C, so
|
// Token type is not exposed through coroutine C/C++ builtins to plain C, so
|
||||||
// we allow specifying none and fixing it up here.
|
// we allow specifying none and fixing it up here.
|
||||||
if (CoroId)
|
if (CoroId)
|
||||||
for (CoroFreeInst *CF : CoroFrees)
|
for (CoroFreeInst *CF : CoroFrees)
|
||||||
CF->setArgOperand(0, CoroId);
|
CF->setArgOperand(0, CoroId);
|
||||||
|
|
||||||
// Coroutine suspention could potentially lead to any argument modified
|
// Coroutine suspention could potentially lead to any argument modified
|
||||||
// outside of the function, hence arguments should not have noalias
|
// outside of the function, hence arguments should not have noalias
|
||||||
// attributes.
|
// attributes.
|
||||||
|
@ -226,6 +231,7 @@ bool Lowerer::lowerEarlyIntrinsics(Function &F) {
|
||||||
for (Argument &A : F.args())
|
for (Argument &A : F.args())
|
||||||
if (A.hasNoAliasAttr())
|
if (A.hasNoAliasAttr())
|
||||||
A.removeAttr(Attribute::NoAlias);
|
A.removeAttr(Attribute::NoAlias);
|
||||||
|
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,11 +249,8 @@ PreservedAnalyses CoroEarlyPass::run(Module &M, ModuleAnalysisManager &) {
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
|
|
||||||
Lowerer L(M);
|
Lowerer L(M);
|
||||||
bool Changed = false;
|
|
||||||
for (auto &F : M)
|
for (auto &F : M)
|
||||||
Changed |= L.lowerEarlyIntrinsics(F);
|
L.lowerEarlyIntrinsics(F);
|
||||||
if (Changed)
|
|
||||||
return PreservedAnalyses::all();
|
|
||||||
|
|
||||||
PreservedAnalyses PA;
|
PreservedAnalyses PA;
|
||||||
PA.preserveSet<CFGAnalyses>();
|
PA.preserveSet<CFGAnalyses>();
|
||||||
|
|
Loading…
Reference in New Issue