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 @@ -2277,18 +2277,24 @@ bool LoopAccessInfo::canAnalyzeLoop() {
2277
2277
return true ;
2278
2278
}
2279
2279
2280
- // / Returns whether \p I is a known math library call that has memory write-only
2281
- // / attribute set.
2280
+ // / Returns whether \p I is a known math library call that has attribute
2281
+ // / 'memory(argmem: write)' set.
2282
2282
static bool isMathLibCallMemWriteOnly (const TargetLibraryInfo *TLI,
2283
2283
const Instruction &I) {
2284
2284
auto *Call = dyn_cast<CallInst>(&I);
2285
2285
if (!Call)
2286
2286
return false ;
2287
2287
2288
+ Function *F = Call->getCalledFunction ();
2289
+ if (!F->hasFnAttribute (Attribute::AttrKind::Memory))
2290
+ return false ;
2291
+
2292
+ auto ME = F->getFnAttribute (Attribute::AttrKind::Memory).getMemoryEffects ();
2288
2293
LibFunc Func;
2289
2294
TLI->getLibFunc (*Call, Func);
2290
- return Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2291
- Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf;
2295
+ return ME.onlyWritesMemory () && ME.onlyAccessesArgPointees () &&
2296
+ (Func == LibFunc::LibFunc_modf || Func == LibFunc::LibFunc_modff ||
2297
+ Func == LibFunc::LibFunc_frexp || Func == LibFunc::LibFunc_frexpf);
2292
2298
}
2293
2299
2294
2300
void LoopAccessInfo::analyzeLoop (AAResults *AA, LoopInfo *LI,
You can’t perform that action at this time.
0 commit comments