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 @@ -2309,18 +2309,24 @@ bool LoopAccessInfo::canAnalyzeLoop() {
2309
2309
return true ;
2310
2310
}
2311
2311
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.
2314
2314
static bool isMathLibCallMemWriteOnly (const TargetLibraryInfo *TLI,
2315
2315
const Instruction &I) {
2316
2316
auto *Call = dyn_cast<CallInst>(&I);
2317
2317
if (!Call)
2318
2318
return false ;
2319
2319
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 ();
2320
2325
LibFunc Func;
2321
2326
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);
2324
2330
}
2325
2331
2326
2332
void LoopAccessInfo::analyzeLoop (AAResults *AA, LoopInfo *LI,
You can’t perform that action at this time.
0 commit comments