@@ -139,12 +139,13 @@ CallInst *IRBuilderBase::CreateCall(FunctionType *FTy, Value *Callee,
139139 // If the builder is in strictfp mode and has non-default options (like
140140 // non-dynamic rounding), add corresponding operand bundle. If such bundle is
141141 // already present, assume it overwrites defaults.
142- bool doesTheCallAccessFPEnv = false ;
142+ bool NeedUpdateMemoryEffects = false ;
143143 if (IsFPConstrained) {
144144 if (const auto *Func = dyn_cast<Function>(Callee)) {
145145 if (Intrinsic::ID ID = Func->getIntrinsicID ()) {
146146 if (IntrinsicInst::isFloatingPointOperation (ID)) {
147- doesTheCallAccessFPEnv = true ;
147+ MemoryEffects FME = Func->getMemoryEffects ();
148+ NeedUpdateMemoryEffects = !FME.doesAccessInaccessibleMem ();
148149 bool NeedRound = DefaultConstrainedRounding != RoundingMode::Dynamic;
149150 bool NeedExcept = DefaultConstrainedExcept != fp::ebStrict;
150151 for (const auto &Item : OpBundles) {
@@ -166,10 +167,8 @@ CallInst *IRBuilderBase::CreateCall(FunctionType *FTy, Value *Callee,
166167
167168 // If the call accesses FPE, update memory effects accordingly.
168169 CallInst *CI = CallInst::Create (FTy, Callee, Args, OpBundles);
169- if (doesTheCallAccessFPEnv ) {
170+ if (NeedUpdateMemoryEffects ) {
170171 MemoryEffects ME = MemoryEffects::inaccessibleMemOnly ();
171- if (CI->getAttributes ().hasFnAttr (Attribute::Memory))
172- ME |= CI->getAttributes ().getMemoryEffects ();
173172 auto A = Attribute::getWithMemoryEffects (getContext (), ME);
174173 CI->addFnAttr (A);
175174 }
0 commit comments