diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -1630,12 +1630,12 @@ SDValue fqneg = DAG.getNode(ISD::FNEG, DL, FltVT, fq); MachineFunction &MF = DAG.getMachineFunction(); - const AMDGPUMachineFunction *MFI = MF.getInfo(); + const SIMachineFunctionInfo *MFI = MF.getInfo(); // float fr = mad(fqneg, fb, fa); unsigned OpCode = !Subtarget->hasMadMacF32Insts() ? (unsigned)ISD::FMA : - !MFI->getMode().allFP32Denormals() ? + (!MFI || !MFI->getMode().allFP32Denormals()) ? (unsigned)ISD::FMAD : (unsigned)AMDGPUISD::FMAD_FTZ; SDValue fr = DAG.getNode(OpCode, DL, FltVT, fqneg, fb, fa); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h --- a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h @@ -45,9 +45,6 @@ /// stages. Align DynLDSAlign; - // State of MODE register, assumed FP mode. - AMDGPU::SIModeRegisterDefaults Mode; - // Kernels + shaders. i.e. functions called by the hardware and not called // by other functions. bool IsEntryFunction = false; @@ -80,10 +77,6 @@ return GDSSize; } - AMDGPU::SIModeRegisterDefaults getMode() const { - return Mode; - } - bool isEntryFunction() const { return IsEntryFunction; } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp @@ -17,7 +17,7 @@ using namespace llvm; AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) - : Mode(MF.getFunction()), IsEntryFunction(AMDGPU::isEntryFunctionCC( + : IsEntryFunction(AMDGPU::isEntryFunctionCC( MF.getFunction().getCallingConv())), IsModuleEntryFunction( AMDGPU::isModuleEntryFunctionCC(MF.getFunction().getCallingConv())), diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h @@ -351,6 +351,9 @@ class SIMachineFunctionInfo final : public AMDGPUMachineFunction { friend class GCNTargetMachine; + // State of MODE register, assumed FP mode. + AMDGPU::SIModeRegisterDefaults Mode; + // Registers that may be reserved for spilling purposes. These may be the same // as the input registers. Register ScratchRSrcReg = AMDGPU::PRIVATE_RSRC_REG; @@ -552,6 +555,10 @@ WWMReservedRegs.insert(Reg); } + AMDGPU::SIModeRegisterDefaults getMode() const { + return Mode; + } + ArrayRef getSGPRToVGPRSpills(int FrameIndex) const { auto I = SGPRToVGPRSpills.find(FrameIndex); diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp @@ -31,6 +31,7 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF) : AMDGPUMachineFunction(MF), + Mode(MF.getFunction()), BufferPSV(static_cast(MF.getTarget())), ImagePSV(static_cast(MF.getTarget())), GWSResourcePSV(static_cast(MF.getTarget())),