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