From 7e9c9a65826ea05709f1768902c6dde9daf9d390 Mon Sep 17 00:00:00 2001 From: Artem Belevich Date: Wed, 20 Jul 2016 21:44:07 +0000 Subject: [PATCH] [NVPTX] Renamed NVPTXLowerKernelArgs -> NVPTXLowerArgs. NFC. After r276153 the pass applies to both kernels and regular functions. Differential Revision: https://reviews.llvm.org/D22583 llvm-svn: 276189 --- llvm/lib/Target/NVPTX/CMakeLists.txt | 2 +- llvm/lib/Target/NVPTX/NVPTX.h | 2 +- ...LowerKernelArgs.cpp => NVPTXLowerArgs.cpp} | 28 +++++++++---------- llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp | 10 +++---- llvm/test/CodeGen/NVPTX/bug21465.ll | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) rename llvm/lib/Target/NVPTX/{NVPTXLowerKernelArgs.cpp => NVPTXLowerArgs.cpp} (91%) diff --git a/llvm/lib/Target/NVPTX/CMakeLists.txt b/llvm/lib/Target/NVPTX/CMakeLists.txt index b67c40500861..2cb060a18f92 100644 --- a/llvm/lib/Target/NVPTX/CMakeLists.txt +++ b/llvm/lib/Target/NVPTX/CMakeLists.txt @@ -21,7 +21,7 @@ set(NVPTXCodeGen_sources NVPTXInferAddressSpaces.cpp NVPTXInstrInfo.cpp NVPTXLowerAggrCopies.cpp - NVPTXLowerKernelArgs.cpp + NVPTXLowerArgs.cpp NVPTXLowerAlloca.cpp NVPTXPeephole.cpp NVPTXMCExpr.cpp diff --git a/llvm/lib/Target/NVPTX/NVPTX.h b/llvm/lib/Target/NVPTX/NVPTX.h index e91385ac13f2..a882441275de 100644 --- a/llvm/lib/Target/NVPTX/NVPTX.h +++ b/llvm/lib/Target/NVPTX/NVPTX.h @@ -53,7 +53,7 @@ FunctionPass *createNVVMReflectPass(const StringMap &Mapping); MachineFunctionPass *createNVPTXPrologEpilogPass(); MachineFunctionPass *createNVPTXReplaceImageHandlesPass(); FunctionPass *createNVPTXImageOptimizerPass(); -FunctionPass *createNVPTXLowerKernelArgsPass(const NVPTXTargetMachine *TM); +FunctionPass *createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM); BasicBlockPass *createNVPTXLowerAllocaPass(); MachineFunctionPass *createNVPTXPeephole(); diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp similarity index 91% rename from llvm/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp rename to llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp index daba8270c917..eaf45c8c9ff1 100644 --- a/llvm/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp @@ -1,4 +1,4 @@ -//===-- NVPTXLowerKernelArgs.cpp - Lower kernel arguments -----------------===// +//===-- NVPTXLowerArgs.cpp - Lower 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 @@ class NVPTXLowerKernelArgs : public FunctionPass { 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 @@ private: }; } // 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 @@ INITIALIZE_PASS(NVPTXLowerKernelArgs, "nvptx-lower-kernel-args", // 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 @@ void NVPTXLowerKernelArgs::handleByValParam(Argument *Arg) { 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 @@ void NVPTXLowerKernelArgs::markPointerAsGlobal(Value *Ptr) { // ============================================================================= // 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 @@ bool NVPTXLowerKernelArgs::runOnKernelFunction(Function &F) { } // 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); } diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp index b9f5919964c7..3dffc22b48d9 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -63,7 +63,7 @@ void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry&); void initializeNVPTXFavorNonGenericAddrSpacesPass(PassRegistry &); void initializeNVPTXInferAddressSpacesPass(PassRegistry &); void initializeNVPTXLowerAggrCopiesPass(PassRegistry &); -void initializeNVPTXLowerKernelArgsPass(PassRegistry &); +void initializeNVPTXLowerArgsPass(PassRegistry &); void initializeNVPTXLowerAllocaPass(PassRegistry &); } @@ -82,7 +82,7 @@ extern "C" void LLVMInitializeNVPTXTarget() { initializeNVPTXAssignValidGlobalNamesPass(PR); initializeNVPTXFavorNonGenericAddrSpacesPass(PR); initializeNVPTXInferAddressSpacesPass(PR); - initializeNVPTXLowerKernelArgsPass(PR); + initializeNVPTXLowerArgsPass(PR); initializeNVPTXLowerAllocaPass(PR); initializeNVPTXLowerAggrCopiesPass(PR); } @@ -195,7 +195,7 @@ void NVPTXPassConfig::addEarlyCSEOrGVNPass() { } 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 @@ void NVPTXPassConfig::addIRPasses() { 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(); diff --git a/llvm/test/CodeGen/NVPTX/bug21465.ll b/llvm/test/CodeGen/NVPTX/bug21465.ll index acd3cee9848e..7a0909225d43 100644 --- a/llvm/test/CodeGen/NVPTX/bug21465.ll +++ b/llvm/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"