File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -2309,18 +2309,24 @@ bool LoopAccessInfo::canAnalyzeLoop() {
23092309 return true ;
23102310}
23112311
2312- // / Returns whether \p I is a known math library call that has memory write-only
2313- // / attribute set.
2312+ // / Returns whether \p I is a known math library call that has attribute
2313+ // / 'memory(argmem: write)' set.
23142314static bool isMathLibCallMemWriteOnly (const TargetLibraryInfo *TLI,
23152315 const Instruction &I) {
23162316 auto *Call = dyn_cast<CallInst>(&I);
23172317 if (!Call)
23182318 return false ;
23192319
2320+ Function *F = Call->getCalledFunction ();
2321+ if (!F->hasFnAttribute (Attribute::AttrKind::Memory))
2322+ return false ;
2323+
2324+ auto ME = F->getFnAttribute (Attribute::AttrKind::Memory).getMemoryEffects ();
23202325 LibFunc Func;
23212326 TLI->getLibFunc (*Call, Func);
2322- return Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2323- Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf;
2327+ return ME.onlyWritesMemory () && ME.onlyAccessesArgPointees () &&
2328+ (Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2329+ Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf);
23242330}
23252331
23262332void LoopAccessInfo::analyzeLoop (AAResults *AA, LoopInfo *LI,
You can’t perform that action at this time.
0 commit comments