[llvm] r336448 - AMDGPU: Fix UBSan error caused by r335942
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 6 10:16:17 PDT 2018
Author: tstellar
Date: Fri Jul 6 10:16:17 2018
New Revision: 336448
URL: http://llvm.org/viewvc/llvm-project?rev=336448&view=rev
Log:
AMDGPU: Fix UBSan error caused by r335942
Summary: Fixes PR38071.
Reviewers: arsenm, dstenb
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D48979
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp?rev=336448&r1=336447&r2=336448&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUISelLowering.cpp Fri Jul 6 10:16:17 2018
@@ -3939,7 +3939,8 @@ SDValue AMDGPUTargetLowering::loadInputV
uint32_t AMDGPUTargetLowering::getImplicitParameterOffset(
const MachineFunction &MF, const ImplicitParameter Param) const {
const AMDGPUMachineFunction *MFI = MF.getInfo<AMDGPUMachineFunction>();
- const AMDGPUSubtarget &ST = MF.getSubtarget<AMDGPUSubtarget>();
+ const AMDGPUCommonSubtarget &ST =
+ AMDGPUCommonSubtarget::get(getTargetMachine(), MF.getFunction());
unsigned ExplicitArgOffset = ST.getExplicitKernelArgOffset(MF.getFunction());
unsigned Alignment = ST.getAlignmentForImplicitArgPtr();
uint64_t ArgOffset = alignTo(MFI->getExplicitKernArgSize(), Alignment) +
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h?rev=336448&r1=336447&r2=336448&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h Fri Jul 6 10:16:17 2018
@@ -114,6 +114,18 @@ public:
return TargetTriple.getOS() == Triple::AMDPAL;
}
+ bool isMesa3DOS() const {
+ return TargetTriple.getOS() == Triple::Mesa3D;
+ }
+
+ bool isMesaKernel(const Function &F) const {
+ return isMesa3DOS() && !AMDGPU::isShader(F.getCallingConv());
+ }
+
+ bool isAmdCodeObjectV2(const Function &F) const {
+ return isAmdHsaOS() || isMesaKernel(F);
+ }
+
bool has16BitInsts() const {
return Has16BitInsts;
}
@@ -166,6 +178,12 @@ public:
return isAmdHsaOS() ? 8 : 4;
}
+ /// Returns the offset in bytes from the start of the input buffer
+ /// of the first explicit kernel argument.
+ unsigned getExplicitKernelArgOffset(const Function &F) const {
+ return isAmdCodeObjectV2(F) ? 0 : 36;
+ }
+
/// \returns Maximum number of work groups per compute unit supported by the
/// subtarget and limited by given \p FlatWorkGroupSize.
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
@@ -384,10 +402,6 @@ public:
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
- bool isMesa3DOS() const {
- return TargetTriple.getOS() == Triple::Mesa3D;
- }
-
Generation getGeneration() const {
return (Generation)Gen;
}
@@ -603,19 +617,11 @@ public:
return HasUnpackedD16VMem;
}
- bool isMesaKernel(const Function &F) const {
- return isMesa3DOS() && !AMDGPU::isShader(F.getCallingConv());
- }
-
// Covers VS/PS/CS graphics shaders
bool isMesaGfxShader(const Function &F) const {
return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
}
- bool isAmdCodeObjectV2(const Function &F) const {
- return isAmdHsaOS() || isMesaKernel(F);
- }
-
bool hasMad64_32() const {
return getGeneration() >= SEA_ISLANDS;
}
@@ -652,12 +658,6 @@ public:
return D16PreservesUnusedBits;
}
- /// Returns the offset in bytes from the start of the input buffer
- /// of the first explicit kernel argument.
- unsigned getExplicitKernelArgOffset(const Function &F) const {
- return isAmdCodeObjectV2(F) ? 0 : 36;
- }
-
/// \returns Number of bytes of arguments that are passed to a shader or
/// kernel in addition to the explicit ones declared for the function.
unsigned getImplicitArgNumBytes(const Function &F) const {
@@ -1088,10 +1088,6 @@ public:
bool hasFMA() const { return FMA; }
- unsigned getExplicitKernelArgOffset(const MachineFunction &MF) const {
- return 36;
- }
-
bool hasCFAluBug() const { return CFALUBug; }
bool hasVertexCache() const { return HasVertexCache; }
Modified: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp?rev=336448&r1=336447&r2=336448&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp Fri Jul 6 10:16:17 2018
@@ -1658,7 +1658,7 @@ SDValue R600TargetLowering::LowerFormalA
unsigned ValBase = ArgLocs[In.getOrigArgIndex()].getLocMemOffset();
unsigned PartOffset = VA.getLocMemOffset();
- unsigned Offset = Subtarget->getExplicitKernelArgOffset(MF) +
+ unsigned Offset = Subtarget->getExplicitKernelArgOffset(MF.getFunction()) +
VA.getLocMemOffset();
MachinePointerInfo PtrInfo(UndefValue::get(PtrTy), PartOffset - ValBase);
More information about the llvm-commits
mailing list