Skip to content

Commit

Permalink
[CodeGen] Remove extraneous ArrayRef (NFC) (#88601)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kazutakahirata authored Apr 15, 2024
1 parent b570eb5 commit fa5fdfb
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions llvm/lib/CodeGen/LowerEmuTLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fa5fdfb

Please sign in to comment.