r242698 - Fixed style issues pointed out by Justin Bogner.

Artem Belevich tra at google.com
Mon Jul 20 13:02:54 PDT 2015


Author: tra
Date: Mon Jul 20 15:02:54 2015
New Revision: 242698

URL: http://llvm.org/viewvc/llvm-project?rev=242698&view=rev
Log:
Fixed style issues pointed out by Justin Bogner.

Differential Revision: http://reviews.llvm.org/D11273

Modified:
    cfe/trunk/lib/Driver/Action.cpp
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=242698&r1=242697&r2=242698&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Mon Jul 20 15:02:54 2015
@@ -65,13 +65,12 @@ CudaDeviceAction::CudaDeviceAction(std::
 void CudaHostAction::anchor() {}
 
 CudaHostAction::CudaHostAction(std::unique_ptr<Action> Input,
-                               const ActionList &_DeviceActions)
-    : Action(CudaHostClass, std::move(Input)), DeviceActions(_DeviceActions) {}
+                               const ActionList &DeviceActions)
+    : Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions) {}
 
 CudaHostAction::~CudaHostAction() {
-  for (iterator it = DeviceActions.begin(), ie = DeviceActions.end(); it != ie;
-       ++it)
-    delete *it;
+  for (auto &DA : DeviceActions)
+    delete DA;
 }
 
 void JobAction::anchor() {}

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=242698&r1=242697&r2=242698&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jul 20 15:02:54 2015
@@ -1262,7 +1262,7 @@ buildCudaActions(const Driver &D, const
 
   // Replicate inputs for each GPU architecture.
   Driver::InputList CudaDeviceInputs;
-  for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i)
+  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
     CudaDeviceInputs.push_back(std::make_pair(types::TY_CUDA_DEVICE, InputArg));
 
   // Build actions for all device inputs.
@@ -1273,9 +1273,8 @@ buildCudaActions(const Driver &D, const
 
   // Check whether any of device actions stopped before they could generate PTX.
   bool PartialCompilation = false;
-  bool DeviceOnlyCompilation = Args.hasArg(options::OPT_cuda_device_only);
-  for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i) {
-    if (CudaDeviceActions[i]->getKind() != Action::BackendJobClass) {
+  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
+    if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
       PartialCompilation = true;
       break;
     }
@@ -1283,6 +1282,7 @@ buildCudaActions(const Driver &D, const
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
+  bool DeviceOnlyCompilation = Args.hasArg(options::OPT_cuda_device_only);
   if (PartialCompilation || DeviceOnlyCompilation) {
     // In case of partial or device-only compilation results of device actions
     // are not consumed by the host action device actions have to be added to
@@ -1295,27 +1295,27 @@ buildCudaActions(const Driver &D, const
       return nullptr;
     }
 
-    for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i)
+    for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
       Actions.push_back(
-          new CudaDeviceAction(std::unique_ptr<Action>(CudaDeviceActions[i]),
-                               GpuArchList[i], /* AtTopLevel */ true));
+          new CudaDeviceAction(std::unique_ptr<Action>(CudaDeviceActions[I]),
+                               GpuArchList[I], /* AtTopLevel */ true));
     // Kill host action in case of device-only compilation.
     if (DeviceOnlyCompilation)
       Current.reset(nullptr);
     return Current;
-  } else {
-    // Outputs of device actions during complete CUDA compilation get created
-    // with AtTopLevel=false and become inputs for the host action.
-    ActionList DeviceActions;
-    for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i)
-      DeviceActions.push_back(
-          new CudaDeviceAction(std::unique_ptr<Action>(CudaDeviceActions[i]),
-                               GpuArchList[i], /* AtTopLevel */ false));
-    // Return a new host action that incorporates original host action and all
-    // device actions.
-    return std::unique_ptr<Action>(
-        new CudaHostAction(std::move(Current), DeviceActions));
   }
+
+  // Outputs of device actions during complete CUDA compilation get created
+  // with AtTopLevel=false and become inputs for the host action.
+  ActionList DeviceActions;
+  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
+    DeviceActions.push_back(
+        new CudaDeviceAction(std::unique_ptr<Action>(CudaDeviceActions[I]),
+                             GpuArchList[I], /* AtTopLevel */ false));
+  // Return a new host action that incorporates original host action and all
+  // device actions.
+  return std::unique_ptr<Action>(
+      new CudaHostAction(std::move(Current), DeviceActions));
 }
 
 void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
@@ -1376,9 +1376,9 @@ void Driver::BuildActions(const ToolChai
   ActionList LinkerInputs;
 
   llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PL;
-  for (unsigned i = 0, e = Inputs.size(); i != e; ++i) {
-    types::ID InputType = Inputs[i].first;
-    const Arg *InputArg = Inputs[i].second;
+  for (auto &I : Inputs) {
+    types::ID InputType = I.first;
+    const Arg *InputArg = I.second;
 
     PL.clear();
     types::getCompilationPhases(InputType, PL);
@@ -1424,14 +1424,13 @@ void Driver::BuildActions(const ToolChai
       // Assumes that clang does everything up until linking phase, so we inject
       // cuda device actions at the last step before linking. Otherwise CUDA
       // host action forces preprocessor into a separate invocation.
-      if (FinalPhase == phases::Link) {
-        for (auto i = PL.begin(), e = PL.end(); i != e; ++i) {
-          auto next = i + 1;
-          if (next != e && *next == phases::Link)
-            CudaInjectionPhase = *i;
+      CudaInjectionPhase = FinalPhase;
+      if (FinalPhase == phases::Link)
+        for (auto PI = PL.begin(), PE = PL.end(); PI != PE; ++PI) {
+          auto next = PI + 1;
+          if (next != PE && *next == phases::Link)
+            CudaInjectionPhase = *PI;
         }
-      } else
-        CudaInjectionPhase = FinalPhase;
     }
 
     // Build the pipeline for this file.
@@ -1794,7 +1793,7 @@ void Driver::BuildJobsForAction(Compilat
   if (const CudaDeviceAction *CDA = dyn_cast<CudaDeviceAction>(A)) {
     // Figure out which NVPTX triple to use for device-side compilation based on
     // whether host is 64-bit.
-    llvm::Triple DeviceTriple(C.getDefaultToolChain().getTriple().isArch64Bit()
+    llvm::Triple DeviceTriple(TC->getTriple().isArch64Bit()
                                   ? "nvptx64-nvidia-cuda"
                                   : "nvptx-nvidia-cuda");
     BuildJobsForAction(C, *CDA->begin(),

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=242698&r1=242697&r2=242698&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jul 20 15:02:54 2015
@@ -4873,11 +4873,9 @@ void Clang::ConstructJob(Compilation &C,
   // Host-side cuda compilation receives device-side outputs as Inputs[1...].
   // Include them with -fcuda-include-gpubinary.
   if (IsCuda && Inputs.size() > 1)
-    for (InputInfoList::const_iterator it = std::next(Inputs.begin()),
-                                       ie = Inputs.end();
-         it != ie; ++it) {
+    for (auto I = std::next(Inputs.begin()), E = Inputs.end(); I != E; ++I) {
       CmdArgs.push_back("-fcuda-include-gpubinary");
-      CmdArgs.push_back(it->getFilename());
+      CmdArgs.push_back(I->getFilename());
     }
 
   // Finally add the compile command to the compilation.





More information about the cfe-commits mailing list