[llvm] [CodeGen] Remove extraneous ArrayRef (NFC) (PR #88601)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 13 00:04:29 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/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.
>From 49621c0e6225a9414805a44bfc9d787ed63782b2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 12 Apr 2024 23:38:21 -0700
Subject: [PATCH] [CodeGen] Remove extraneous ArrayRef (NFC)
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.
---
llvm/lib/CodeGen/LowerEmuTLS.cpp | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
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