Mark a couple arrays as static and const. Use array_lengthof instead of sizeof/sizeof.
authorCraig Topper <craig.topper@gmail.com>
Thu, 24 May 2012 04:22:05 +0000 (04:22 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 24 May 2012 04:22:05 +0000 (04:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157369 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/NVPTX/NVPTXAsmPrinter.cpp
lib/Target/NVPTX/NVPTXISelLowering.cpp

index f268b4aae401a41faf93346a322f2d214759e78f..c2eb894f032637455af707c50b6cba01e4e9409b 100644 (file)
@@ -490,7 +490,7 @@ NVPTXAsmPrinter::emitVirtualRegister(unsigned int vr, bool isVec,
 void NVPTXAsmPrinter::printVecModifiedImmediate(const MachineOperand &MO,
                                                 const char *Modifier,
                                                 raw_ostream &O) {
-char vecelem[] = {'0', '1', '2', '3', '0', '1', '2', '3'};
+  static const char vecelem[] = {'0', '1', '2', '3', '0', '1', '2', '3'};
   int Imm = (int)MO.getImm();
   if(0 == strcmp(Modifier, "vecelem"))
     O << "_" << vecelem[Imm];
index d326805b22cf40eba2cd6725ed587b2ff82a864b..d517e8117b790cdc6fb754745a58c17314af60da 100644 (file)
@@ -887,10 +887,10 @@ NVPTXTargetLowering::getParamHelpSymbol(SelectionDAG &DAG, int idx) {
 // Check to see if the kernel argument is image*_t or sampler_t
 
 bool llvm::isImageOrSamplerVal(const Value *arg, const Module *context) {
-  const char *specialTypes[] = {
-                                "struct._image2d_t",
-                                "struct._image3d_t",
-                                "struct._sampler_t"
+  static const char *const specialTypes[] = {
+                                             "struct._image2d_t",
+                                             "struct._image3d_t",
+                                             "struct._sampler_t"
   };
 
   const Type *Ty = arg->getType();
@@ -905,7 +905,7 @@ bool llvm::isImageOrSamplerVal(const Value *arg, const Module *context) {
   const StructType *STy = dyn_cast<StructType>(PTy->getElementType());
   const std::string TypeName = STy ? STy->getName() : "";
 
-  for (int i=0, e=sizeof(specialTypes)/sizeof(specialTypes[0]); i!=e; ++i)
+  for (int i = 0, e = array_lengthof(specialTypes); i != e; ++i)
     if (TypeName == specialTypes[i])
       return true;