[llvm] ee17ca7 - [llvm] Construct SmallVector with ArrayRef (NFC) (#136063)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 19:29:34 PDT 2025


Author: Kazu Hirata
Date: 2025-04-16T19:29:30-07:00
New Revision: ee17ca77e50a2170dd79f31e109f6751235e098e

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

LOG: [llvm] Construct SmallVector with ArrayRef (NFC) (#136063)

Added: 
    

Modified: 
    llvm/lib/IR/IRBuilder.cpp
    llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
    llvm/tools/lto/lto.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index e5a2f08c393c9..b448c0372eb0e 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -747,21 +747,13 @@ getStatepointBundles(std::optional<ArrayRef<T1>> TransitionArgs,
                      std::optional<ArrayRef<T2>> DeoptArgs,
                      ArrayRef<T3> GCArgs) {
   std::vector<OperandBundleDef> Rval;
-  if (DeoptArgs) {
-    SmallVector<Value*, 16> DeoptValues;
-    llvm::append_range(DeoptValues, *DeoptArgs);
-    Rval.emplace_back("deopt", DeoptValues);
-  }
-  if (TransitionArgs) {
-    SmallVector<Value*, 16> TransitionValues;
-    llvm::append_range(TransitionValues, *TransitionArgs);
-    Rval.emplace_back("gc-transition", TransitionValues);
-  }
-  if (GCArgs.size()) {
-    SmallVector<Value*, 16> LiveValues;
-    llvm::append_range(LiveValues, GCArgs);
-    Rval.emplace_back("gc-live", LiveValues);
-  }
+  if (DeoptArgs)
+    Rval.emplace_back("deopt", SmallVector<Value *, 16>(*DeoptArgs));
+  if (TransitionArgs)
+    Rval.emplace_back("gc-transition",
+                      SmallVector<Value *, 16>(*TransitionArgs));
+  if (GCArgs.size())
+    Rval.emplace_back("gc-live", SmallVector<Value *, 16>(GCArgs));
   return Rval;
 }
 
@@ -1091,9 +1083,7 @@ CallInst *IRBuilderBase::CreateConstrainedFPCall(
     Function *Callee, ArrayRef<Value *> Args, const Twine &Name,
     std::optional<RoundingMode> Rounding,
     std::optional<fp::ExceptionBehavior> Except) {
-  llvm::SmallVector<Value *, 6> UseArgs;
-
-  append_range(UseArgs, Args);
+  llvm::SmallVector<Value *, 6> UseArgs(Args);
 
   if (Intrinsic::hasConstrainedFPRoundingModeOperand(Callee->getIntrinsicID()))
     UseArgs.push_back(getConstrainedFPRounding(Rounding));

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index 3f877b525549f..cb27d5473fd73 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -129,8 +129,7 @@ static void substituteOperandWithArgument(Function *OldF,
     UniqueValues.insert(Op->get());
 
   // Determine the new function's signature.
-  SmallVector<Type *> NewArgTypes;
-  llvm::append_range(NewArgTypes, OldF->getFunctionType()->params());
+  SmallVector<Type *> NewArgTypes(OldF->getFunctionType()->params());
   size_t ArgOffset = NewArgTypes.size();
   for (Value *V : UniqueValues)
     NewArgTypes.push_back(V->getType());

diff  --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 29219c9114522..bb64d42ccced1 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -496,8 +496,7 @@ void lto_codegen_debug_options_array(lto_code_gen_t cg,
                                      const char *const *options, int number) {
   assert(optionParsingState != OptParsingState::Early &&
          "early option processing already happened");
-  SmallVector<StringRef, 4> Options;
-  llvm::append_range(Options, ArrayRef(options, number));
+  SmallVector<StringRef, 4> Options(ArrayRef(options, number));
   unwrap(cg)->setCodeGenDebugOptions(ArrayRef(Options));
 }
 


        


More information about the llvm-commits mailing list