[llvm] fa5fdfb - [CodeGen] Remove extraneous ArrayRef (NFC) (#88601)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 11:06:38 PDT 2024


Author: Kazu Hirata
Date: 2024-04-15T11:06:35-07:00
New Revision: fa5fdfb126f9beeaa2f719930ef951d339f41e36

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

LOG: [CodeGen] Remove extraneous ArrayRef (NFC) (#88601)

We don't need to create these instances of ArrayRef because
StructType::create and ConstantStruct::get take ArrayRef, and ArrayRef
can be implicitly constructed from C arrays.

Added: 
    

Modified: 
    llvm/lib/CodeGen/LowerEmuTLS.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LowerEmuTLS.cpp b/llvm/lib/CodeGen/LowerEmuTLS.cpp
index af0b0a20c85669..ec36b669ac018a 100644
--- a/llvm/lib/CodeGen/LowerEmuTLS.cpp
+++ b/llvm/lib/CodeGen/LowerEmuTLS.cpp
@@ -139,8 +139,7 @@ bool addEmuTlsVar(Module &M, const GlobalVariable *GV) {
   IntegerType *WordType = DL.getIntPtrType(C);
   PointerType *InitPtrType = PointerType::getUnqual(C);
   Type *ElementTypes[4] = {WordType, WordType, VoidPtrType, InitPtrType};
-  ArrayRef<Type*> ElementTypeArray(ElementTypes, 4);
-  StructType *EmuTlsVarType = StructType::create(ElementTypeArray);
+  StructType *EmuTlsVarType = StructType::create(ElementTypes);
   EmuTlsVar = cast<GlobalVariable>(
       M.getOrInsertGlobal(EmuTlsVarName, EmuTlsVarType));
   copyLinkageVisibility(M, GV, EmuTlsVar);
@@ -170,9 +169,7 @@ bool addEmuTlsVar(Module &M, const GlobalVariable *GV) {
       ConstantInt::get(WordType, DL.getTypeStoreSize(GVType)),
       ConstantInt::get(WordType, GVAlignment.value()), NullPtr,
       EmuTlsTmplVar ? EmuTlsTmplVar : NullPtr};
-  ArrayRef<Constant*> ElementValueArray(ElementValues, 4);
-  EmuTlsVar->setInitializer(
-      ConstantStruct::get(EmuTlsVarType, ElementValueArray));
+  EmuTlsVar->setInitializer(ConstantStruct::get(EmuTlsVarType, ElementValues));
   Align MaxAlignment =
       std::max(DL.getABITypeAlign(WordType), DL.getABITypeAlign(VoidPtrType));
   EmuTlsVar->setAlignment(MaxAlignment);


        


More information about the llvm-commits mailing list