================ @@ -170,20 +173,49 @@ static Value *appendString(IRBuilder<> &Builder, Value *Desc, Value *Arg, return callAppendStringN(Builder, Desc, Arg, Length, IsLast); } +static Value *appendVectorArg(IRBuilder<> &Builder, Value *Desc, Value *Arg, + bool IsLast, bool IsBuffered) { + assert(Arg->getType()->isVectorTy() && "incorrent append* function"); + auto VectorTy = dyn_cast<FixedVectorType>(Arg->getType()); + auto Zero = Builder.getInt64(0); + if (VectorTy) { + for (unsigned int i = 0; i < VectorTy->getNumElements() - 1; i++) { + auto Val = Builder.CreateExtractElement(Arg, i); + Desc = callAppendArgs(Builder, Desc, 1, + fitArgInto64Bits(Builder, Val, IsBuffered), Zero, + Zero, Zero, Zero, Zero, Zero, false); + } + + Value* Val = + Builder.CreateExtractElement(Arg, VectorTy->getNumElements() - 1); + return callAppendArgs(Builder, Desc, 1, + fitArgInto64Bits(Builder, Val, IsBuffered), Zero, + Zero, Zero, Zero, Zero, Zero, IsLast); + } + return nullptr; +} + static Value *processArg(IRBuilder<> &Builder, Value *Desc, Value *Arg, - bool SpecIsCString, bool IsLast) { + bool SpecIsCString, bool IsVector, bool IsLast, + bool IsBuffered) { if (SpecIsCString && isa<PointerType>(Arg->getType())) { return appendString(Builder, Desc, Arg, IsLast); } - // If the format specifies a string but the argument is not, the frontend will - // have printed a warning. We just rely on undefined behaviour and send the - // argument anyway. - return appendArg(Builder, Desc, Arg, IsLast); + + if (IsVector) { + return appendVectorArg(Builder, Desc, Arg, IsLast, IsBuffered); + } + + // If the format specifies a string but the argument is not, the frontend + // will have printed a warning. We just rely on undefined behaviour and send + // the argument anyway. + return appendArg(Builder, Desc, Arg, IsLast, IsBuffered); } // Scan the format string to locate all specifiers, and mark the ones that // specify a string, i.e, the "%s" specifier with optional '*' characters. -static void locateCStrings(SparseBitVector<8> &BV, StringRef Str) { +static void locateCStringsAndVectors(SparseBitVector<8> &BV, ---------------- ssahasra wrote:
update the comment above the function https://github.com/llvm/llvm-project/pull/72556 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits