<div dir="ltr">Oh, neat! Not sure I would've thought of that!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 26, 2021 at 10:35 AM Benjamin Kramer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Benjamin Kramer<br>
Date: 2021-07-26T16:33:38+02:00<br>
New Revision: 404f0d4f7cc7b7497c9725c6c6f20b21df8611bb<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/404f0d4f7cc7b7497c9725c6c6f20b21df8611bb" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/404f0d4f7cc7b7497c9725c6c6f20b21df8611bb</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/404f0d4f7cc7b7497c9725c6c6f20b21df8611bb.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/404f0d4f7cc7b7497c9725c6c6f20b21df8611bb.diff</a><br>
<br>
LOG: Simplify away some SmallVector copies. NFCI.<br>
<br>
The lifetime of the initializer list is the full expression, so we can<br>
skip storing it in a temporary vector.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    llvm/include/llvm/IR/Constants.h<br>
    llvm/include/llvm/IR/DerivedTypes.h<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h<br>
index 142dc2187450..1f716a45b70f 100644<br>
--- a/llvm/include/llvm/IR/Constants.h<br>
+++ b/llvm/include/llvm/IR/Constants.h<br>
@@ -454,8 +454,7 @@ class ConstantStruct final : public ConstantAggregate {<br>
   template <typename... Csts><br>
   static std::enable_if_t<are_base_of<Constant, Csts...>::value, Constant *><br>
   get(StructType *T, Csts *...Vs) {<br>
-    SmallVector<Constant *, 8> Values({Vs...});<br>
-    return get(T, Values);<br>
+    return get(T, ArrayRef<Constant *>({Vs...}));<br>
   }<br>
<br>
   /// Return an anonymous struct that has the specified elements.<br>
<br>
diff  --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h<br>
index 7354aa0525b1..b68a912b5f70 100644<br>
--- a/llvm/include/llvm/IR/DerivedTypes.h<br>
+++ b/llvm/include/llvm/IR/DerivedTypes.h<br>
@@ -244,8 +244,7 @@ class StructType : public Type {<br>
   static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *><br>
   create(StringRef Name, Type *elt1, Tys *... elts) {<br>
     assert(elt1 && "Cannot create a struct type with no elements with this");<br>
-    SmallVector<llvm::Type *, 8> StructFields({elt1, elts...});<br>
-    return create(StructFields, Name);<br>
+    return create(ArrayRef<Type *>({elt1, elts...}), Name);<br>
   }<br>
<br>
   /// This static method is the primary way to create a literal StructType.<br>
@@ -263,8 +262,7 @@ class StructType : public Type {<br>
   get(Type *elt1, Tys *... elts) {<br>
     assert(elt1 && "Cannot create a struct type with no elements with this");<br>
     LLVMContext &Ctx = elt1->getContext();<br>
-    SmallVector<llvm::Type *, 8> StructFields({elt1, elts...});<br>
-    return llvm::StructType::get(Ctx, StructFields);<br>
+    return StructType::get(Ctx, ArrayRef<Type *>({elt1, elts...}));<br>
   }<br>
<br>
   /// Return the type with the specified name, or null if there is none by that<br>
@@ -306,8 +304,7 @@ class StructType : public Type {<br>
   std::enable_if_t<are_base_of<Type, Tys...>::value, void><br>
   setBody(Type *elt1, Tys *... elts) {<br>
     assert(elt1 && "Cannot create a struct type with no elements with this");<br>
-    SmallVector<llvm::Type *, 8> StructFields({elt1, elts...});<br>
-    setBody(StructFields);<br>
+    setBody(ArrayRef<Type *>({elt1, elts...}));<br>
   }<br>
<br>
   /// Return true if the specified type is valid as a element type.<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>