[llvm] a2f9ca8 - Utils: Use StringRef and rename variable for clarity

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 12:25:51 PST 2022


Author: Matt Arsenault
Date: 2022-11-28T15:25:45-05:00
New Revision: a2f9ca88758b3d6af268a692aa0cce274f19fd00

URL: https://github.com/llvm/llvm-project/commit/a2f9ca88758b3d6af268a692aa0cce274f19fd00
DIFF: https://github.com/llvm/llvm-project/commit/a2f9ca88758b3d6af268a692aa0cce274f19fd00.diff

LOG: Utils: Use StringRef and rename variable for clarity

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/ModuleUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 9e1492b97a864..da588b3445e77 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
 
 #define DEBUG_TYPE "moduleutils"
 
-static void appendToGlobalArray(const char *Array, Module &M, Function *F,
+static void appendToGlobalArray(StringRef ArrayName, Module &M, Function *F,
                                 int Priority, Constant *Data) {
   IRBuilder<> IRB(M.getContext());
   FunctionType *FnTy = FunctionType::get(IRB.getVoidTy(), false);
@@ -31,7 +31,7 @@ static void appendToGlobalArray(const char *Array, Module &M, Function *F,
   SmallVector<Constant *, 16> CurrentCtors;
   StructType *EltTy = StructType::get(
       IRB.getInt32Ty(), PointerType::getUnqual(FnTy), IRB.getInt8PtrTy());
-  if (GlobalVariable *GVCtor = M.getNamedGlobal(Array)) {
+  if (GlobalVariable *GVCtor = M.getNamedGlobal(ArrayName)) {
     if (Constant *Init = GVCtor->getInitializer()) {
       unsigned n = Init->getNumOperands();
       CurrentCtors.reserve(n + 1);
@@ -59,7 +59,7 @@ static void appendToGlobalArray(const char *Array, Module &M, Function *F,
   // Create the new global variable and replace all uses of
   // the old global variable with the new one.
   (void)new GlobalVariable(M, NewInit->getType(), false,
-                           GlobalValue::AppendingLinkage, NewInit, Array);
+                           GlobalValue::AppendingLinkage, NewInit, ArrayName);
 }
 
 void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data) {


        


More information about the llvm-commits mailing list