@@ -106,6 +106,10 @@ static cl::opt<bool> PreserveAssemblyUseListOrder(
106106 " preserve-ll-uselistorder" , cl::Hidden, cl::init(false ),
107107 cl::desc(" Preserve use-list order when writing LLVM assembly." ));
108108
109+ static cl::opt<bool > PrintFPMemoryEffects (
110+ " print-fp-memory-effects" , cl::Hidden,
111+ cl::desc (" Pretty print floating-point memory effects when dumping" ));
112+
109113// Make virtual table appear in this compilation unit.
110114AssemblyAnnotationWriter::~AssemblyAnnotationWriter () = default ;
111115
@@ -4321,6 +4325,25 @@ void AssemblyWriter::printGCRelocateComment(const GCRelocateInst &Relocate) {
43214325 Out << " )" ;
43224326}
43234327
4328+ static void printFPMemoryEffects (raw_ostream &Out, MemoryEffects ME) {
4329+ ModRefInfo MR = ME.getModRef (IRMemLocation::InaccessibleMem);
4330+ Out << " ; fpe=[" ;
4331+ switch (MR) {
4332+ case ModRefInfo::NoModRef:
4333+ break ;
4334+ case ModRefInfo::Ref:
4335+ Out << " r" ;
4336+ break ;
4337+ case ModRefInfo::Mod:
4338+ Out << " w" ;
4339+ break ;
4340+ case ModRefInfo::ModRef:
4341+ Out << " rw" ;
4342+ break ;
4343+ }
4344+ Out << " ]" ;
4345+ }
4346+
43244347// / printInfoComment - Print a little comment after the instruction indicating
43254348// / which slot it occupies.
43264349void AssemblyWriter::printInfoComment (const Value &V) {
@@ -4351,30 +4374,14 @@ void AssemblyWriter::printInfoComment(const Value &V) {
43514374 if (PrintInstAddrs)
43524375 Out << " ; " << &V;
43534376
4354- if (auto *CI = dyn_cast<CallInst>(&V))
4355- if (Intrinsic::ID IID = CI->getIntrinsicID ())
4356- if (IntrinsicInst::isFloatingPointOperation (IID))
4357- if (const BasicBlock *BB = CI->getParent ())
4358- if (const Function *F = BB->getParent ())
4359- if (F->hasFnAttribute (Attribute::StrictFP)) {
4360- MemoryEffects ME = CI->getMemoryEffects ();
4361- ModRefInfo MR = ME.getModRef (IRMemLocation::InaccessibleMem);
4362- Out << " ; fpe=[" ;
4363- switch (MR) {
4364- case ModRefInfo::NoModRef:
4365- break ;
4366- case ModRefInfo::Ref:
4367- Out << " r" ;
4368- break ;
4369- case ModRefInfo::Mod:
4370- Out << " w" ;
4371- break ;
4372- case ModRefInfo::ModRef:
4373- Out << " rw" ;
4374- break ;
4375- }
4376- Out << " ]" ;
4377- }
4377+ if (PrintFPMemoryEffects) {
4378+ if (auto *CI = dyn_cast<CallInst>(&V))
4379+ if (Intrinsic::ID IID = CI->getIntrinsicID ())
4380+ if (const Function *F = CI->getFunction ())
4381+ if (IntrinsicInst::isFloatingPointOperation (IID) &&
4382+ F->hasFnAttribute (Attribute::StrictFP))
4383+ printFPMemoryEffects (Out, CI->getMemoryEffects ());
4384+ }
43784385}
43794386
43804387static void maybePrintCallAddrSpace (const Value *Operand, const Instruction *I,
0 commit comments