File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -2381,18 +2381,24 @@ bool LoopAccessInfo::canAnalyzeLoop() {
2381
2381
return true ;
2382
2382
}
2383
2383
2384
- // / Returns whether \p I is a known math library call that has memory write-only
2385
- // / attribute set.
2384
+ // / Returns whether \p I is a known math library call that has attribute
2385
+ // / 'memory(argmem: write)' set.
2386
2386
static bool isMathLibCallMemWriteOnly (const TargetLibraryInfo *TLI,
2387
2387
const Instruction &I) {
2388
2388
auto *Call = dyn_cast<CallInst>(&I);
2389
2389
if (!Call)
2390
2390
return false ;
2391
2391
2392
+ Function *F = Call->getCalledFunction ();
2393
+ if (!F->hasFnAttribute (Attribute::AttrKind::Memory))
2394
+ return false ;
2395
+
2396
+ auto ME = F->getFnAttribute (Attribute::AttrKind::Memory).getMemoryEffects ();
2392
2397
LibFunc Func;
2393
2398
TLI->getLibFunc (*Call, Func);
2394
- return Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2395
- Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf;
2399
+ return ME.onlyWritesMemory () && ME.onlyAccessesArgPointees () &&
2400
+ (Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2401
+ Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf);
2396
2402
}
2397
2403
2398
2404
void LoopAccessInfo::analyzeLoop (AAResults *AA, LoopInfo *LI,
You can’t perform that action at this time.
0 commit comments