[llvm] r331418 - [gcov] Switch to an explicit if clunky array to satisfy some compilers

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Wed May 2 17:11:03 PDT 2018


Author: chandlerc
Date: Wed May  2 17:11:03 2018
New Revision: 331418

URL: http://llvm.org/viewvc/llvm-project?rev=331418&view=rev
Log:
[gcov] Switch to an explicit if clunky array to satisfy some compilers
on various build bots that are unhappy with using makeArrayRef with an
initializer list.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=331418&r1=331417&r2=331418&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Wed May  2 17:11:03 2018
@@ -908,6 +908,8 @@ Function *GCOVProfiler::insertCounterWri
                           EmitArcsCallArgsTy->getPointerTo()});
 
   Constant *Zero32 = Builder.getInt32(0);
+  // Build an explicit array of two zeros for use in ConstantExpr GEP building.
+  Constant *TwoZero32s[] = {Zero32, Zero32};
 
   SmallVector<Constant *, 8> FileInfos;
   for (int i : llvm::seq<int>(0, CUNodes->getNumOperands())) {
@@ -943,10 +945,8 @@ Function *GCOVProfiler::insertCounterWri
       unsigned Arcs = cast<ArrayType>(GV->getValueType())->getNumElements();
       EmitArcsCallArgsArray.push_back(ConstantStruct::get(
           EmitArcsCallArgsTy,
-          {Builder.getInt32(Arcs),
-           ConstantExpr::getInBoundsGetElementPtr(
-               GV->getValueType(), GV,
-               makeArrayRef<Constant *>({Zero32, Zero32}))}));
+          {Builder.getInt32(Arcs), ConstantExpr::getInBoundsGetElementPtr(
+                                       GV->getValueType(), GV, TwoZero32s)}));
     }
     // Create global arrays for the two emit calls.
     int CountersSize = CountersBySP.size();
@@ -976,12 +976,11 @@ Function *GCOVProfiler::insertCounterWri
     FileInfos.push_back(ConstantStruct::get(
         FileInfoTy,
         {StartFileCallArgs, Builder.getInt32(CountersSize),
+         ConstantExpr::getInBoundsGetElementPtr(EmitFunctionCallArgsArrayTy,
+                                                EmitFunctionCallArgsArrayGV,
+                                                TwoZero32s),
          ConstantExpr::getInBoundsGetElementPtr(
-             EmitFunctionCallArgsArrayTy, EmitFunctionCallArgsArrayGV,
-             makeArrayRef<Constant *>({Zero32, Zero32})),
-         ConstantExpr::getInBoundsGetElementPtr(
-             EmitArcsCallArgsArrayTy, EmitArcsCallArgsArrayGV,
-             makeArrayRef<Constant *>({Zero32, Zero32}))}));
+             EmitArcsCallArgsArrayTy, EmitArcsCallArgsArrayGV, TwoZero32s)}));
   }
 
   // If we didn't find anything to actually emit, bail on out.




More information about the llvm-commits mailing list