Index: lib/Target/NVPTX/CMakeLists.txt =================================================================== --- lib/Target/NVPTX/CMakeLists.txt +++ lib/Target/NVPTX/CMakeLists.txt @@ -21,7 +21,7 @@ NVPTXInferAddressSpaces.cpp NVPTXInstrInfo.cpp NVPTXLowerAggrCopies.cpp - NVPTXLowerKernelArgs.cpp + NVPTXLowerArgs.cpp NVPTXLowerAlloca.cpp NVPTXPeephole.cpp NVPTXMCExpr.cpp Index: lib/Target/NVPTX/NVPTX.h =================================================================== --- lib/Target/NVPTX/NVPTX.h +++ lib/Target/NVPTX/NVPTX.h @@ -53,7 +53,7 @@ MachineFunctionPass *createNVPTXPrologEpilogPass(); MachineFunctionPass *createNVPTXReplaceImageHandlesPass(); FunctionPass *createNVPTXImageOptimizerPass(); -FunctionPass *createNVPTXLowerKernelArgsPass(const NVPTXTargetMachine *TM); +FunctionPass *createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM); BasicBlockPass *createNVPTXLowerAllocaPass(); MachineFunctionPass *createNVPTXPeephole(); Index: lib/Target/NVPTX/NVPTXLowerArgs.cpp =================================================================== --- lib/Target/NVPTX/NVPTXLowerArgs.cpp +++ lib/Target/NVPTX/NVPTXLowerArgs.cpp @@ -1,4 +1,4 @@ -//===-- NVPTXLowerKernelArgs.cpp - Lower kernel arguments -----------------===// +//===-- NVPTXLowerArgs.cpp - Lower kernel arguments -----------------===// // // The LLVM Compiler Infrastructure // @@ -102,11 +102,11 @@ using namespace llvm; namespace llvm { -void initializeNVPTXLowerKernelArgsPass(PassRegistry &); +void initializeNVPTXLowerArgsPass(PassRegistry &); } namespace { -class NVPTXLowerKernelArgs : public FunctionPass { +class NVPTXLowerArgs : public FunctionPass { bool runOnFunction(Function &F) override; bool runOnKernelFunction(Function &F); @@ -122,7 +122,7 @@ public: static char ID; // Pass identification, replacement for typeid - NVPTXLowerKernelArgs(const NVPTXTargetMachine *TM = nullptr) + NVPTXLowerArgs(const NVPTXTargetMachine *TM = nullptr) : FunctionPass(ID), TM(TM) {} const char *getPassName() const override { return "Lower pointer arguments of CUDA kernels"; @@ -133,10 +133,10 @@ }; } // namespace -char NVPTXLowerKernelArgs::ID = 1; +char NVPTXLowerArgs::ID = 1; -INITIALIZE_PASS(NVPTXLowerKernelArgs, "nvptx-lower-kernel-args", - "Lower kernel arguments (NVPTX)", false, false) +INITIALIZE_PASS(NVPTXLowerArgs, "nvptx-lower-args", + "Lower arguments (NVPTX)", false, false) // ============================================================================= // If the function had a byval struct ptr arg, say foo(%struct.x* byval %d), @@ -151,7 +151,7 @@ // struct from param space to local space. // Then replace all occurrences of %d by %temp. // ============================================================================= -void NVPTXLowerKernelArgs::handleByValParam(Argument *Arg) { +void NVPTXLowerArgs::handleByValParam(Argument *Arg) { Function *Func = Arg->getParent(); Instruction *FirstInst = &(Func->getEntryBlock().front()); PointerType *PType = dyn_cast(Arg->getType()); @@ -173,7 +173,7 @@ new StoreInst(LI, AllocA, FirstInst); } -void NVPTXLowerKernelArgs::markPointerAsGlobal(Value *Ptr) { +void NVPTXLowerArgs::markPointerAsGlobal(Value *Ptr) { if (Ptr->getType()->getPointerAddressSpace() == ADDRESS_SPACE_GLOBAL) return; @@ -203,7 +203,7 @@ // ============================================================================= // Main function for this pass. // ============================================================================= -bool NVPTXLowerKernelArgs::runOnKernelFunction(Function &F) { +bool NVPTXLowerArgs::runOnKernelFunction(Function &F) { if (TM && TM->getDrvInterface() == NVPTX::CUDA) { // Mark pointers in byval structs as global. for (auto &B : F) { @@ -236,18 +236,18 @@ } // Device functions only need to copy byval args into local memory. -bool NVPTXLowerKernelArgs::runOnDeviceFunction(Function &F) { +bool NVPTXLowerArgs::runOnDeviceFunction(Function &F) { for (Argument &Arg : F.args()) if (Arg.getType()->isPointerTy() && Arg.hasByValAttr()) handleByValParam(&Arg); return true; } -bool NVPTXLowerKernelArgs::runOnFunction(Function &F) { +bool NVPTXLowerArgs::runOnFunction(Function &F) { return isKernelFunction(F) ? runOnKernelFunction(F) : runOnDeviceFunction(F); } FunctionPass * -llvm::createNVPTXLowerKernelArgsPass(const NVPTXTargetMachine *TM) { - return new NVPTXLowerKernelArgs(TM); +llvm::createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM) { + return new NVPTXLowerArgs(TM); } Index: lib/Target/NVPTX/NVPTXTargetMachine.cpp =================================================================== --- lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -63,7 +63,7 @@ void initializeNVPTXFavorNonGenericAddrSpacesPass(PassRegistry &); void initializeNVPTXInferAddressSpacesPass(PassRegistry &); void initializeNVPTXLowerAggrCopiesPass(PassRegistry &); -void initializeNVPTXLowerKernelArgsPass(PassRegistry &); +void initializeNVPTXLowerArgsPass(PassRegistry &); void initializeNVPTXLowerAllocaPass(PassRegistry &); } @@ -82,7 +82,7 @@ initializeNVPTXAssignValidGlobalNamesPass(PR); initializeNVPTXFavorNonGenericAddrSpacesPass(PR); initializeNVPTXInferAddressSpacesPass(PR); - initializeNVPTXLowerKernelArgsPass(PR); + initializeNVPTXLowerArgsPass(PR); initializeNVPTXLowerAllocaPass(PR); initializeNVPTXLowerAggrCopiesPass(PR); } @@ -195,7 +195,7 @@ } void NVPTXPassConfig::addAddressSpaceInferencePasses() { - // NVPTXLowerKernelArgs emits alloca for byval parameters which can often + // NVPTXLowerArgs emits alloca for byval parameters which can often // be eliminated by SROA. addPass(createSROAPass()); addPass(createNVPTXLowerAllocaPass()); @@ -253,9 +253,9 @@ addPass(createNVPTXAssignValidGlobalNamesPass()); addPass(createGenericToNVVMPass()); - // NVPTXLowerKernelArgs is required for correctness and should be run right + // NVPTXLowerArgs is required for correctness and should be run right // before the address space inference passes. - addPass(createNVPTXLowerKernelArgsPass(&getNVPTXTargetMachine())); + addPass(createNVPTXLowerArgsPass(&getNVPTXTargetMachine())); if (getOptLevel() != CodeGenOpt::None) { addAddressSpaceInferencePasses(); addStraightLineScalarOptimizationPasses(); Index: test/CodeGen/NVPTX/bug21465.ll =================================================================== --- test/CodeGen/NVPTX/bug21465.ll +++ test/CodeGen/NVPTX/bug21465.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -nvptx-lower-kernel-args -S | FileCheck %s +; RUN: opt < %s -nvptx-lower-args -S | FileCheck %s ; RUN: llc < %s -march=nvptx64 -mcpu=sm_35 | FileCheck %s --check-prefix PTX target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"