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 @@ -2326,18 +2326,24 @@ bool LoopAccessInfo::canAnalyzeLoop() {
2326
2326
return true ;
2327
2327
}
2328
2328
2329
- // / Returns whether \p I is a known math library call that has memory write-only
2330
- // / attribute set.
2329
+ // / Returns whether \p I is a known math library call that has attribute
2330
+ // / 'memory(argmem: write)' set.
2331
2331
static bool isMathLibCallMemWriteOnly (const TargetLibraryInfo *TLI,
2332
2332
const Instruction &I) {
2333
2333
auto *Call = dyn_cast<CallInst>(&I);
2334
2334
if (!Call)
2335
2335
return false ;
2336
2336
2337
+ Function *F = Call->getCalledFunction ();
2338
+ if (!F->hasFnAttribute (Attribute::AttrKind::Memory))
2339
+ return false ;
2340
+
2341
+ auto ME = F->getFnAttribute (Attribute::AttrKind::Memory).getMemoryEffects ();
2337
2342
LibFunc Func;
2338
2343
TLI->getLibFunc (*Call, Func);
2339
- return Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2340
- Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf;
2344
+ return ME.onlyWritesMemory () && ME.onlyAccessesArgPointees () &&
2345
+ (Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2346
+ Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf);
2341
2347
}
2342
2348
2343
2349
void LoopAccessInfo::analyzeLoop (AAResults *AA, LoopInfo *LI,
You can’t perform that action at this time.
0 commit comments