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