bondhugula created this revision. bondhugula added a reviewer: tra. Herald added subscribers: carlosgalvezp, Groverkss, bollu, yaxunl. bondhugula requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Update an instance of dyn_cast -> cast in Clang CUDA codegen. While on this, other clang-tidy updates. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112284 Files: clang/lib/CodeGen/CGCUDANV.cpp Index: clang/lib/CodeGen/CGCUDANV.cpp =================================================================== --- clang/lib/CodeGen/CGCUDANV.cpp +++ clang/lib/CodeGen/CGCUDANV.cpp @@ -177,7 +177,7 @@ llvm::Function *finalizeModule() override; }; -} +} // end anonymous namespace std::string CGNVCUDARuntime::addPrefixToName(StringRef FuncName) const { if (CGM.getLangOpts().HIP) @@ -237,11 +237,10 @@ // hipError_t hipLaunchByPtr(char *); return CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, CharPtrTy, false), "hipLaunchByPtr"); - } else { - // cudaError_t cudaLaunch(char *); - return CGM.CreateRuntimeFunction( - llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); } + // cudaError_t cudaLaunch(char *); + return CGM.CreateRuntimeFunction( + llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); } llvm::FunctionType *CGNVCUDARuntime::getRegisterGlobalsFnTy() const { @@ -253,8 +252,8 @@ } llvm::FunctionType *CGNVCUDARuntime::getRegisterLinkedBinaryFnTy() const { - auto CallbackFnTy = getCallbackFnTy(); - auto RegisterGlobalsFnTy = getRegisterGlobalsFnTy(); + auto *CallbackFnTy = getCallbackFnTy(); + auto *RegisterGlobalsFnTy = getRegisterGlobalsFnTy(); llvm::Type *Params[] = {RegisterGlobalsFnTy->getPointerTo(), VoidPtrTy, VoidPtrTy, CallbackFnTy->getPointerTo()}; return llvm::FunctionType::get(VoidTy, Params, false); @@ -396,8 +395,8 @@ QualType QT = cudaLaunchKernelFD->getType(); QualType CQT = QT.getCanonicalType(); - llvm::Type *Ty = CGM.getTypes().ConvertType(CQT); - llvm::FunctionType *FTy = dyn_cast<llvm::FunctionType>(Ty); + llvm::Type *Ty = cast<llvm::FunctionType>(CGM.getTypes().ConvertType(CQT)); + llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty); const CGFunctionInfo &FI = CGM.getTypes().arrangeFunctionDeclaration(cudaLaunchKernelFD); @@ -590,7 +589,7 @@ uint64_t VarSize = CGM.getDataLayout().getTypeAllocSize(Var->getValueType()); if (Info.Flags.isManaged()) { - auto ManagedVar = new llvm::GlobalVariable( + auto *ManagedVar = new llvm::GlobalVariable( CGM.getModule(), Var->getType(), /*isConstant=*/false, Var->getLinkage(), /*Init=*/Var->isDeclaration() @@ -823,7 +822,7 @@ GpuBinaryHandle, CharUnits::fromQuantity(GpuBinaryHandle->getAlignment())); { - auto HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); + auto *HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); llvm::Constant *Zero = llvm::Constant::getNullValue(HandleValue->getType()); llvm::Value *EQZero = CtorBuilder.CreateICmpEQ(HandleValue, Zero); @@ -842,7 +841,7 @@ CtorBuilder.SetInsertPoint(ExitBlock); // Call __hip_register_globals(GpuBinaryHandle); if (RegisterGlobalsFunc) { - auto HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); + auto *HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); CtorBuilder.CreateCall(RegisterGlobalsFunc, HandleValue); } } @@ -958,7 +957,7 @@ Address GpuBinaryAddr(GpuBinaryHandle, CharUnits::fromQuantity( GpuBinaryHandle->getAlignment())); - auto HandleValue = DtorBuilder.CreateLoad(GpuBinaryAddr); + auto *HandleValue = DtorBuilder.CreateLoad(GpuBinaryAddr); // There is only one HIP fat binary per linked module, however there are // multiple destructor functions. Make sure the fat binary is unregistered // only once. @@ -1071,7 +1070,7 @@ llvm::GlobalVariable *Var = Info.Var; if (Info.Flags.getKind() == DeviceVarFlags::Variable && Info.Flags.isManaged()) { - auto ManagedVar = new llvm::GlobalVariable( + auto *ManagedVar = new llvm::GlobalVariable( CGM.getModule(), Var->getType(), /*isConstant=*/false, Var->getLinkage(), /*Init=*/Var->isDeclaration()
Index: clang/lib/CodeGen/CGCUDANV.cpp =================================================================== --- clang/lib/CodeGen/CGCUDANV.cpp +++ clang/lib/CodeGen/CGCUDANV.cpp @@ -177,7 +177,7 @@ llvm::Function *finalizeModule() override; }; -} +} // end anonymous namespace std::string CGNVCUDARuntime::addPrefixToName(StringRef FuncName) const { if (CGM.getLangOpts().HIP) @@ -237,11 +237,10 @@ // hipError_t hipLaunchByPtr(char *); return CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, CharPtrTy, false), "hipLaunchByPtr"); - } else { - // cudaError_t cudaLaunch(char *); - return CGM.CreateRuntimeFunction( - llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); } + // cudaError_t cudaLaunch(char *); + return CGM.CreateRuntimeFunction( + llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); } llvm::FunctionType *CGNVCUDARuntime::getRegisterGlobalsFnTy() const { @@ -253,8 +252,8 @@ } llvm::FunctionType *CGNVCUDARuntime::getRegisterLinkedBinaryFnTy() const { - auto CallbackFnTy = getCallbackFnTy(); - auto RegisterGlobalsFnTy = getRegisterGlobalsFnTy(); + auto *CallbackFnTy = getCallbackFnTy(); + auto *RegisterGlobalsFnTy = getRegisterGlobalsFnTy(); llvm::Type *Params[] = {RegisterGlobalsFnTy->getPointerTo(), VoidPtrTy, VoidPtrTy, CallbackFnTy->getPointerTo()}; return llvm::FunctionType::get(VoidTy, Params, false); @@ -396,8 +395,8 @@ QualType QT = cudaLaunchKernelFD->getType(); QualType CQT = QT.getCanonicalType(); - llvm::Type *Ty = CGM.getTypes().ConvertType(CQT); - llvm::FunctionType *FTy = dyn_cast<llvm::FunctionType>(Ty); + llvm::Type *Ty = cast<llvm::FunctionType>(CGM.getTypes().ConvertType(CQT)); + llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty); const CGFunctionInfo &FI = CGM.getTypes().arrangeFunctionDeclaration(cudaLaunchKernelFD); @@ -590,7 +589,7 @@ uint64_t VarSize = CGM.getDataLayout().getTypeAllocSize(Var->getValueType()); if (Info.Flags.isManaged()) { - auto ManagedVar = new llvm::GlobalVariable( + auto *ManagedVar = new llvm::GlobalVariable( CGM.getModule(), Var->getType(), /*isConstant=*/false, Var->getLinkage(), /*Init=*/Var->isDeclaration() @@ -823,7 +822,7 @@ GpuBinaryHandle, CharUnits::fromQuantity(GpuBinaryHandle->getAlignment())); { - auto HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); + auto *HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); llvm::Constant *Zero = llvm::Constant::getNullValue(HandleValue->getType()); llvm::Value *EQZero = CtorBuilder.CreateICmpEQ(HandleValue, Zero); @@ -842,7 +841,7 @@ CtorBuilder.SetInsertPoint(ExitBlock); // Call __hip_register_globals(GpuBinaryHandle); if (RegisterGlobalsFunc) { - auto HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); + auto *HandleValue = CtorBuilder.CreateLoad(GpuBinaryAddr); CtorBuilder.CreateCall(RegisterGlobalsFunc, HandleValue); } } @@ -958,7 +957,7 @@ Address GpuBinaryAddr(GpuBinaryHandle, CharUnits::fromQuantity( GpuBinaryHandle->getAlignment())); - auto HandleValue = DtorBuilder.CreateLoad(GpuBinaryAddr); + auto *HandleValue = DtorBuilder.CreateLoad(GpuBinaryAddr); // There is only one HIP fat binary per linked module, however there are // multiple destructor functions. Make sure the fat binary is unregistered // only once. @@ -1071,7 +1070,7 @@ llvm::GlobalVariable *Var = Info.Var; if (Info.Flags.getKind() == DeviceVarFlags::Variable && Info.Flags.isManaged()) { - auto ManagedVar = new llvm::GlobalVariable( + auto *ManagedVar = new llvm::GlobalVariable( CGM.getModule(), Var->getType(), /*isConstant=*/false, Var->getLinkage(), /*Init=*/Var->isDeclaration()
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits