llvm.org GIT mirror llvm / 3512034
Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216525 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
40 changed file(s) with 102 addition(s) and 131 deletion(s). Raw diff Collapse all Expand all
9898 // implicit conversion operator to ArrayRef.
9999 operator ArrayRef() const {
100100 if (Val.isNull())
101 return ArrayRef();
101 return None;
102102 if (Val.template is())
103103 return *Val.getAddrOfPtr1();
104104 return *Val.template get();
104104 ResultT (*Func)(ArrayRef)>
105105 struct VariadicFunction {
106106 ResultT operator()() const {
107 return Func(ArrayRef());
107 return Func(None);
108108 }
109109
110110 #define LLVM_DEFINE_OVERLOAD(N) \
151151 ResultT (*Func)(Param0T, ArrayRef)>
152152 struct VariadicFunction1 {
153153 ResultT operator()(Param0T P0) const {
154 return Func(P0, ArrayRef());
154 return Func(P0, None);
155155 }
156156
157157 #define LLVM_DEFINE_OVERLOAD(N) \
198198 ResultT (*Func)(Param0T, Param1T, ArrayRef)>
199199 struct VariadicFunction2 {
200200 ResultT operator()(Param0T P0, Param1T P1) const {
201 return Func(P0, P1, ArrayRef());
201 return Func(P0, P1, None);
202202 }
203203
204204 #define LLVM_DEFINE_OVERLOAD(N) \
247247 ResultT (*Func)(Param0T, Param1T, Param2T, ArrayRef)>
248248 struct VariadicFunction3 {
249249 ResultT operator()(Param0T P0, Param1T P1, Param2T P2) const {
250 return Func(P0, P1, P2, ArrayRef());
250 return Func(P0, P1, P2, None);
251251 }
252252
253253 #define LLVM_DEFINE_OVERLOAD(N) \
586586
587587 InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
588588 BasicBlock *UnwindDest, const Twine &Name = "") {
589 return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
590 ArrayRef()),
589 return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, None),
591590 Name);
592591 }
593592 InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
184184 /// convenience method for passes to do so.
185185 void dropUnknownMetadata(ArrayRef KnownIDs);
186186 void dropUnknownMetadata() {
187 return dropUnknownMetadata(ArrayRef());
187 return dropUnknownMetadata(None);
188188 }
189189 void dropUnknownMetadata(unsigned ID1) {
190190 return dropUnknownMetadata(makeArrayRef(ID1));
539539 if (Sec->sh_offset + Sec->sh_size > Buf.size())
540540 return object_error::parse_failed;
541541 const uint8_t *Start = base() + Sec->sh_offset;
542 return ArrayRef(Start, Sec->sh_size);
542 return makeArrayRef(Start, Sec->sh_size);
543543 }
544544
545545 template
349349 ArrayRef EpilogueScopes() const {
350350 assert(E() == 0 && "epilogue scopes are only present when the E bit is 0");
351351 size_t Offset = HeaderWords(*this);
352 return ArrayRef(&Data[Offset], EpilogueCount());
352 return makeArrayRef(&Data[Offset], EpilogueCount());
353353 }
354354
355355 ArrayRef UnwindByteCode() const {
357357 + (E() ? 0 : EpilogueCount());
358358 const support::ulittle8_t *ByteCode =
359359 reinterpret_cast(&Data[Offset]);
360 return ArrayRef(ByteCode,
361 CodeWords() * sizeof(uint32_t));
360 return makeArrayRef(ByteCode, CodeWords() * sizeof(uint32_t));
362361 }
363362
364363 uint32_t ExceptionHandlerRVA() const {
134134 "getResources() must be called before getProcResourceCycles()");
135135 unsigned PRKinds = SchedModel.getNumProcResourceKinds();
136136 assert((MBBNum+1) * PRKinds <= ProcResourceCycles.size());
137 return ArrayRef(ProcResourceCycles.data() + MBBNum * PRKinds,
138 PRKinds);
137 return makeArrayRef(ProcResourceCycles.data() + MBBNum * PRKinds, PRKinds);
139138 }
140139
141140
255254 getProcResourceDepths(unsigned MBBNum) const {
256255 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
257256 assert((MBBNum+1) * PRKinds <= ProcResourceDepths.size());
258 return ArrayRef(ProcResourceDepths.data() + MBBNum * PRKinds,
259 PRKinds);
257 return makeArrayRef(ProcResourceDepths.data() + MBBNum * PRKinds, PRKinds);
260258 }
261259
262260 /// Get an array of processor resource heights for MBB. Indexed by processor
269267 getProcResourceHeights(unsigned MBBNum) const {
270268 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
271269 assert((MBBNum+1) * PRKinds <= ProcResourceHeights.size());
272 return ArrayRef(ProcResourceHeights.data() + MBBNum * PRKinds,
273 PRKinds);
270 return makeArrayRef(ProcResourceHeights.data() + MBBNum * PRKinds, PRKinds);
274271 }
275272
276273 //===----------------------------------------------------------------------===//
966966 BCS[B].Exit = SpillPlacement::PrefSpill;
967967
968968 if (++B == GroupSize) {
969 ArrayRef Array(BCS, B);
970 SpillPlacer->addConstraints(Array);
969 SpillPlacer->addConstraints(makeArrayRef(BCS, B));
971970 B = 0;
972971 }
973972 }
974973
975 ArrayRef Array(BCS, B);
976 SpillPlacer->addConstraints(Array);
974 SpillPlacer->addConstraints(makeArrayRef(BCS, B));
977975 SpillPlacer->addLinks(makeArrayRef(TBS, T));
978976 }
979977
10121010
10131011 // Compute through constraints from the interference, or assume that all
10141012 // through blocks prefer spilling when forming compact regions.
1015 ArrayRef NewBlocks = makeArrayRef(ActiveBlocks).slice(AddedTo);
1013 auto NewBlocks = makeArrayRef(ActiveBlocks).slice(AddedTo);
10161014 if (Cand.PhysReg)
10171015 addThroughConstraints(Cand.Intf, NewBlocks);
10181016 else
23672367 if (!HiExists &&
23682368 (!LegalOperations ||
23692369 TLI.isOperationLegalOrCustom(LoOp, N->getValueType(0)))) {
2370 SDValue Res = DAG.getNode(LoOp, SDLoc(N), N->getValueType(0),
2371 ArrayRef(N->op_begin(), N->op_end()));
2370 SDValue Res = DAG.getNode(LoOp, SDLoc(N), N->getValueType(0), N->ops());
23722371 return CombineTo(N, Res, Res);
23732372 }
23742373
23772376 if (!LoExists &&
23782377 (!LegalOperations ||
23792378 TLI.isOperationLegal(HiOp, N->getValueType(1)))) {
2380 SDValue Res = DAG.getNode(HiOp, SDLoc(N), N->getValueType(1),
2381 ArrayRef(N->op_begin(), N->op_end()));
2379 SDValue Res = DAG.getNode(HiOp, SDLoc(N), N->getValueType(1), N->ops());
23822380 return CombineTo(N, Res, Res);
23832381 }
23842382
23882386
23892387 // If the two computed results can be simplified separately, separate them.
23902388 if (LoExists) {
2391 SDValue Lo = DAG.getNode(LoOp, SDLoc(N), N->getValueType(0),
2392 ArrayRef(N->op_begin(), N->op_end()));
2389 SDValue Lo = DAG.getNode(LoOp, SDLoc(N), N->getValueType(0), N->ops());
23932390 AddToWorklist(Lo.getNode());
23942391 SDValue LoOpt = combine(Lo.getNode());
23952392 if (LoOpt.getNode() && LoOpt.getNode() != Lo.getNode() &&
23992396 }
24002397
24012398 if (HiExists) {
2402 SDValue Hi = DAG.getNode(HiOp, SDLoc(N), N->getValueType(1),
2403 ArrayRef(N->op_begin(), N->op_end()));
2399 SDValue Hi = DAG.getNode(HiOp, SDLoc(N), N->getValueType(1), N->ops());
24042400 AddToWorklist(Hi.getNode());
24052401 SDValue HiOpt = combine(Hi.getNode());
24062402 if (HiOpt.getNode() && HiOpt != Hi &&
51015101 }
51025102
51035103 SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, SDVTList VTList) {
5104 return getNode(Opcode, DL, VTList, ArrayRef());
5104 return getNode(Opcode, DL, VTList, None);
51055105 }
51065106
51075107 SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, SDVTList VTList,
25402540 StringRef Str, bool AddNull) {
25412541 if (!AddNull) {
25422542 const uint8_t *Data = reinterpret_cast(Str.data());
2543 return get(Context, ArrayRef(const_cast(Data),
2543 return get(Context, makeArrayRef(const_cast(Data),
25442544 Str.size()));
25452545 }
25462546
691691 assert(D.Struct_NumElements <= 5 && "Can't handle this yet");
692692 for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
693693 Elts[i] = DecodeFixedType(Infos, Tys, Context);
694 return StructType::get(Context, ArrayRef(Elts,D.Struct_NumElements));
694 return StructType::get(Context, makeArrayRef(Elts,D.Struct_NumElements));
695695 }
696696
697697 case IITDescriptor::Argument:
149149 ReturnType(R), Params(P), isVarArg(V) {}
150150 KeyTy(const FunctionType* FT) :
151151 ReturnType(FT->getReturnType()),
152 Params(ArrayRef(FT->param_begin(), FT->param_end())),
152 Params(makeArrayRef(FT->param_begin(), FT->param_end())),
153153 isVarArg(FT->isVarArg()) {}
154154 bool operator==(const KeyTy& that) const {
155155 if (ReturnType != that.ReturnType)
6161
6262 MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) {
6363 // To ensure uniqueness the root node is self-referential.
64 MDNode *Dummy = MDNode::getTemporary(Context, ArrayRef());
64 MDNode *Dummy = MDNode::getTemporary(Context, None);
6565
6666 SmallVector Args(1, Dummy);
6767 if (Extra)
5151 }
5252
5353 ArrayRef MCObjectDisassembler::getStaticInitFunctions() {
54 return ArrayRef();
54 return None;
5555 }
5656
5757 ArrayRef MCObjectDisassembler::getStaticExitFunctions() {
58 return ArrayRef();
58 return None;
5959 }
6060
6161 MemoryObject *MCObjectDisassembler::getRegionFor(uint64_t Addr) {
558558
559559 size_t EntrySize = 8;
560560 size_t EntryCount = ModInitContents.size() / EntrySize;
561 return ArrayRef(
561 return makeArrayRef(
562562 reinterpret_cast(ModInitContents.data()), EntryCount);
563563 }
564564
568568
569569 size_t EntrySize = 8;
570570 size_t EntryCount = ModExitContents.size() / EntrySize;
571 return ArrayRef(
571 return makeArrayRef(
572572 reinterpret_cast(ModExitContents.data()), EntryCount);
573573 }
782782 == 0 && "Aux Symbol data did not point to the beginning of a symbol");
783783 # endif
784784 }
785 return ArrayRef(Aux,
786 Symbol->NumberOfAuxSymbols * sizeof(coff_symbol));
785 return makeArrayRef(Aux, Symbol->NumberOfAuxSymbols * sizeof(coff_symbol));
787786 }
788787
789788 std::error_code COFFObjectFile::getSectionName(const coff_section *Sec,
824823 uintptr_t ConEnd = ConStart + Sec->SizeOfRawData;
825824 if (ConEnd > uintptr_t(Data.getBufferEnd()))
826825 return object_error::parse_failed;
827 Res = ArrayRef(reinterpret_cast(ConStart),
828 Sec->SizeOfRawData);
826 Res = makeArrayRef(reinterpret_cast(ConStart),
827 Sec->SizeOfRawData);
829828 return object_error::success;
830829 }
831830
15141514 MachOObjectFile::getSectionRawName(DataRefImpl Sec) const {
15151515 const section_base *Base =
15161516 reinterpret_cast(Sections[Sec.d.a]);
1517 return ArrayRef(Base->sectname);
1517 return makeArrayRef(Base->sectname);
15181518 }
15191519
15201520 ArrayRef
15211521 MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {
15221522 const section_base *Base =
15231523 reinterpret_cast(Sections[Sec.d.a]);
1524 return ArrayRef(Base->segname);
1524 return makeArrayRef(Base->segname);
15251525 }
15261526
15271527 bool
207207 memcpy(&buffer[used], Ptr, free);
208208 Ptr = Ptr + free;
209209 Size -= free;
210 body(ArrayRef(buffer, 64));
210 body(makeArrayRef(buffer, 64));
211211 }
212212
213213 if (Size >= 64) {
214 Ptr = body(ArrayRef(Ptr, Size & ~(unsigned long) 0x3f));
214 Ptr = body(makeArrayRef(Ptr, Size & ~(unsigned long) 0x3f));
215215 Size &= 0x3f;
216216 }
217217
239239
240240 if (free < 8) {
241241 memset(&buffer[used], 0, free);
242 body(ArrayRef(buffer, 64));
242 body(makeArrayRef(buffer, 64));
243243 used = 0;
244244 free = 64;
245245 }
256256 buffer[62] = hi >> 16;
257257 buffer[63] = hi >> 24;
258258
259 body(ArrayRef(buffer, 64));
259 body(makeArrayRef(buffer, 64));
260260
261261 result[0] = a;
262262 result[1] = a >> 8;
104104 bool AllowReplacements,
105105 unsigned MaxEditDistance) const {
106106 return llvm::ComputeEditDistance(
107 llvm::ArrayRef(data(), size()),
108 llvm::ArrayRef(Other.data(), Other.size()),
107 makeArrayRef(data(), size()),
108 makeArrayRef(Other.data(), Other.size()),
109109 AllowReplacements, MaxEditDistance);
110110 }
111111
76257625 Ops.push_back(Inc);
76267626
76277627 EVT Tys[3] = { VT, MVT::i64, MVT::Other };
7628 SDVTList SDTys = DAG.getVTList(ArrayRef(Tys, 3));
7628 SDVTList SDTys = DAG.getVTList(Tys);
76297629 unsigned NewOp = IsLaneOp ? AArch64ISD::LD1LANEpost : AArch64ISD::LD1DUPpost;
76307630 SDValue UpdN = DAG.getMemIntrinsicNode(NewOp, SDLoc(N), SDTys, Ops,
76317631 MemVT,
77557755 Tys[n] = VecTy;
77567756 Tys[n++] = MVT::i64; // Type of write back register
77577757 Tys[n] = MVT::Other; // Type of the chain
7758 SDVTList SDTys = DAG.getVTList(ArrayRef(Tys, NumResultVecs + 2));
7758 SDVTList SDTys = DAG.getVTList(makeArrayRef(Tys, NumResultVecs + 2));
77597759
77607760 MemIntrinsicSDNode *MemInt = cast(N);
77617761 SDValue UpdN = DAG.getMemIntrinsicNode(NewOpc, SDLoc(N), SDTys, Ops,
8484
8585 // If a subtarget does not define resources for STPQi, bail here.
8686 if (SCDesc->isValid() && !SCDesc->isVariant()) {
87 unsigned ResLenWithSTP = BBTrace.getResourceLength(
88 ArrayRef(), SCDesc);
87 unsigned ResLenWithSTP = BBTrace.getResourceLength(None, SCDesc);
8988 if (ResLenWithSTP > ResLength) {
9089 DEBUG(dbgs() << " Suppress STP in BB: " << BB->getNumber()
9190 << " resources " << ResLength << " -> " << ResLenWithSTP
90999099 Tys[n] = VecTy;
91009100 Tys[n++] = MVT::i32;
91019101 Tys[n] = MVT::Other;
9102 SDVTList SDTys = DAG.getVTList(ArrayRef(Tys, NumResultVecs+2));
9102 SDVTList SDTys = DAG.getVTList(makeArrayRef(Tys, NumResultVecs+2));
91039103 SmallVector Ops;
91049104 Ops.push_back(N->getOperand(0)); // incoming chain
91059105 Ops.push_back(N->getOperand(AddrOpIdx));
91789178 for (n = 0; n < NumVecs; ++n)
91799179 Tys[n] = VT;
91809180 Tys[n] = MVT::Other;
9181 SDVTList SDTys = DAG.getVTList(ArrayRef(Tys, NumVecs+1));
9181 SDVTList SDTys = DAG.getVTList(makeArrayRef(Tys, NumVecs+1));
91829182 SDValue Ops[] = { VLD->getOperand(0), VLD->getOperand(2) };
91839183 MemIntrinsicSDNode *VLDMemInt = cast(VLD);
91849184 SDValue VLDDup = DAG.getMemIntrinsicNode(NewOpc, SDLoc(VLD), SDTys,
12991299 Value *Result = UndefValue::get(DestTy);
13001300 for (unsigned int I = 0, E = SrcTy->getStructNumElements(); I < E; ++I) {
13011301 Value *Element = createCast(
1302 Builder, Builder.CreateExtractValue(V, ArrayRef(I)),
1302 Builder, Builder.CreateExtractValue(V, makeArrayRef(I)),
13031303 DestTy->getStructElementType(I));
13041304
13051305 Result =
1306 Builder.CreateInsertValue(Result, Element, ArrayRef(I));
1306 Builder.CreateInsertValue(Result, Element, makeArrayRef(I));
13071307 }
13081308 return Result;
13091309 }
679679 CI,
680680 Builder->CreateShuffleVector(
681681 Vec, Undef, ConstantDataVector::get(
682 II->getContext(), ArrayRef(Mask))));
682 II->getContext(), makeArrayRef(Mask))));
683683
684684 } else if (auto Source =
685685 dyn_cast(II->getArgOperand(0))) {
434434 DFSanSetLabelFnTy = FunctionType::get(Type::getVoidTy(*Ctx),
435435 DFSanSetLabelArgs, /*isVarArg=*/false);
436436 DFSanNonzeroLabelFnTy = FunctionType::get(
437 Type::getVoidTy(*Ctx), ArrayRef(), /*isVarArg=*/false);
437 Type::getVoidTy(*Ctx), None, /*isVarArg=*/false);
438438
439439 if (GetArgTLSPtr) {
440440 Type *ArgTLSTy = ArrayType::get(ShadowTy, 64);
736736 Edge += Successors;
737737 }
738738
739 ArrayRef V(&EdgeTable[0], TableSize);
740739 GlobalVariable *EdgeTableGV =
741740 new GlobalVariable(
742741 *M, EdgeTableTy, true, GlobalValue::InternalLinkage,
743 ConstantArray::get(EdgeTableTy, V),
742 ConstantArray::get(EdgeTableTy,
743 makeArrayRef(&EdgeTable[0],TableSize)),
744744 "__llvm_gcda_edge_table");
745745 EdgeTableGV->setUnnamedAddr(true);
746746 return EdgeTableGV;
18691869 Value *Op = I.getArgOperand(0);
18701870 Type *OpType = Op->getType();
18711871 Function *BswapFunc = Intrinsic::getDeclaration(
1872 F.getParent(), Intrinsic::bswap, ArrayRef(&OpType, 1));
1872 F.getParent(), Intrinsic::bswap, makeArrayRef(&OpType, 1));
18731873 setShadow(&I, IRB.CreateCall(BswapFunc, getShadow(Op)));
18741874 setOrigin(&I, getOrigin(Op));
18751875 }
480480 Type *PtrTy = Ty->getPointerTo();
481481 Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
482482 createOrdering(&IRB, LI->getOrdering())};
483 CallInst *C = CallInst::Create(TsanAtomicLoad[Idx],
484 ArrayRef(Args));
483 CallInst *C = CallInst::Create(TsanAtomicLoad[Idx], Args);
485484 ReplaceInstWithInst(I, C);
486485
487486 } else if (StoreInst *SI = dyn_cast(I)) {
496495 Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
497496 IRB.CreateIntCast(SI->getValueOperand(), Ty, false),
498497 createOrdering(&IRB, SI->getOrdering())};
499 CallInst *C = CallInst::Create(TsanAtomicStore[Idx],
500 ArrayRef(Args));
498 CallInst *C = CallInst::Create(TsanAtomicStore[Idx], Args);
501499 ReplaceInstWithInst(I, C);
502500 } else if (AtomicRMWInst *RMWI = dyn_cast(I)) {
503501 Value *Addr = RMWI->getPointerOperand();
514512 Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
515513 IRB.CreateIntCast(RMWI->getValOperand(), Ty, false),
516514 createOrdering(&IRB, RMWI->getOrdering())};
517 CallInst *C = CallInst::Create(F, ArrayRef(Args));
515 CallInst *C = CallInst::Create(F, Args);
518516 ReplaceInstWithInst(I, C);
519517 } else if (AtomicCmpXchgInst *CASI = dyn_cast(I)) {
520518 Value *Addr = CASI->getPointerOperand();
542540 Value *Args[] = {createOrdering(&IRB, FI->getOrdering())};
543541 Function *F = FI->getSynchScope() == SingleThread ?
544542 TsanAtomicSignalFence : TsanAtomicThreadFence;
545 CallInst *C = CallInst::Create(F, ArrayRef(Args));
543 CallInst *C = CallInst::Create(F, Args);
546544 ReplaceInstWithInst(I, C);
547545 }
548546 return true;
884884 OldSeq),
885885 SequenceToMDString(Inst->getContext(),
886886 NewSeq)};
887 Node = MDNode::get(Inst->getContext(),
888 ArrayRef(tmp, 3));
887 Node = MDNode::get(Inst->getContext(), tmp);
889888
890889 Inst->setMetadata(NodeId, Node);
891890 }
905904 Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
906905 Type *I8XX = PointerType::getUnqual(I8X);
907906 Type *Params[] = {I8XX, I8XX};
908 FunctionType *FTy = FunctionType::get(Type::getVoidTy(C),
909 ArrayRef(Params, 2),
907 FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), Params,
910908 /*isVarArg=*/false);
911909 Constant *Callee = M->getOrInsertFunction(Name, FTy);
912910
948946 Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
949947 Type *I8XX = PointerType::getUnqual(I8X);
950948 Type *Params[] = {I8XX, I8XX};
951 FunctionType *FTy = FunctionType::get(Type::getVoidTy(C),
952 ArrayRef(Params, 2),
949 FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), Params,
953950 /*isVarArg=*/false);
954951 Constant *Callee = M->getOrInsertFunction(Name, FTy);
955952
10091009 }
10101010
10111011 Constant *Ptr = Operands[0];
1012 ArrayRef Indices(Operands.begin() + 1, Operands.end());
1012 auto Indices = makeArrayRef(Operands.begin() + 1, Operands.end());
10131013 markConstant(&I, ConstantExpr::getGetElementPtr(Ptr, Indices));
10141014 }
10151015
4141 AttributeSet AS[2];
4242 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
4343 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
44 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
45 ArrayRef(AVs, 2));
44 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex, AVs);
4645
4746 LLVMContext &Context = B.GetInsertBlock()->getContext();
4847 Constant *StrLen = M->getOrInsertFunction("strlen",
7069 AttributeSet AS[2];
7170 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
7271 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
73 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
74 ArrayRef(AVs, 2));
72 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex, AVs);
7573
7674 LLVMContext &Context = B.GetInsertBlock()->getContext();
7775 Constant *StrNLen = M->getOrInsertFunction("strnlen",
9997 Module *M = B.GetInsertBlock()->getParent()->getParent();
10098 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
10199 AttributeSet AS =
102 AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
103 ArrayRef(AVs, 2));
100 AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex, AVs);
104101
105102 Type *I8Ptr = B.getInt8PtrTy();
106103 Type *I32Ty = B.getInt32Ty();
127124 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
128125 AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
129126 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
130 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
131 ArrayRef(AVs, 2));
127 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex, AVs);
132128
133129 LLVMContext &Context = B.GetInsertBlock()->getContext();
134130 Value *StrNCmp = M->getOrInsertFunction("strncmp",
237233 Module *M = B.GetInsertBlock()->getParent()->getParent();
238234 AttributeSet AS;
239235 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
240 AS = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
241 ArrayRef(AVs, 2));
236 AS = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex, AVs);
242237 LLVMContext &Context = B.GetInsertBlock()->getContext();
243238 Value *MemChr = M->getOrInsertFunction("memchr",
244239 AttributeSet::get(M->getContext(), AS),
267262 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
268263 AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
269264 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
270 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
271 ArrayRef(AVs, 2));
265 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex, AVs);
272266
273267 LLVMContext &Context = B.GetInsertBlock()->getContext();
274268 Value *MemCmp = M->getOrInsertFunction("memcmp",
316316 DenseMap > MDMap;
317317 for (SetVector::iterator I = MD.begin(), IE = MD.end();
318318 I != IE; ++I) {
319 MDNode *Dummy = MDNode::getTemporary(CalledFunc->getContext(),
320 ArrayRef());
319 MDNode *Dummy = MDNode::getTemporary(CalledFunc->getContext(), None);
321320 DummyNodes.push_back(Dummy);
322321 MDMap[*I] = Dummy;
323322 }
172172
173173 if (Exit->isLandingPad()) {
174174 SmallVector NewBBs;
175 SplitLandingPadPredecessors(Exit, ArrayRef(&LoopBlocks[0],
176 LoopBlocks.size()),
175 SplitLandingPadPredecessors(Exit, LoopBlocks,
177176 ".loopexit", ".nonloopexit",
178177 PP, NewBBs);
179178 NewExitBB = NewBBs[0];
32243224 unsigned i = 0;
32253225
32263226 for (; i < NumReducedVals - ReduxWidth + 1; i += ReduxWidth) {
3227 ArrayRef ValsToReduce(&ReducedVals[i], ReduxWidth);
3228 V.buildTree(ValsToReduce, ReductionOps);
3227 V.buildTree(makeArrayRef(&ReducedVals[i], ReduxWidth), ReductionOps);
32293228
32303229 // Estimate cost.
32313230 int Cost = V.getTreeCost() + getReductionCost(TTI, ReducedVals[i]);
34173416 // Try to vectorize them.
34183417 unsigned NumElts = (SameTypeIt - IncIt);
34193418 DEBUG(errs() << "SLP: Trying to vectorize starting at PHIs (" << NumElts << ")\n");
3420 if (NumElts > 1 &&
3421 tryToVectorizeList(ArrayRef(IncIt, NumElts), R)) {
3419 if (NumElts > 1 && tryToVectorizeList(makeArrayRef(IncIt, NumElts), R)) {
34223420 // Success start over because instructions might have been changed.
34233421 HaveVectorizedPhiNodes = true;
34243422 Changed = true;
35603558 // Process the stores in chunks of 16.
35613559 for (unsigned CI = 0, CE = it->second.size(); CI < CE; CI+=16) {
35623560 unsigned Len = std::min(CE - CI, 16);
3563 ArrayRef Chunk(&it->second[CI], Len);
3564 Changed |= vectorizeStores(Chunk, -SLPCostThreshold, R);
3561 Changed |= vectorizeStores(makeArrayRef(&it->second[CI], Len),
3562 -SLPCostThreshold, R);
35653563 }
35663564 }
35673565 return Changed;
8787 "TOTAL", RegionCoverageInfo(CoveredRegions, NumRegions),
8888 LineCoverageInfo(CoveredLines, NonCodeLines, NumLines),
8989 FunctionCoverageInfo(NumFunctionsCovered, NumFunctions),
90 ArrayRef());
90 None);
9191 }
213213 }
214214
215215 void printBinary(StringRef Label, StringRef Str, ArrayRef Value) {
216 ArrayRef V(reinterpret_cast(Value.data()),
217 Value.size());
216 auto V = makeArrayRef(reinterpret_cast(Value.data()),
217 Value.size());
218218 printBinaryImpl(Label, Str, V, false);
219219 }
220220
223223 }
224224
225225 void printBinary(StringRef Label, ArrayRef Value) {
226 ArrayRef V(reinterpret_cast(Value.data()),
227 Value.size());
226 auto V = makeArrayRef(reinterpret_cast(Value.data()),
227 Value.size());
228228 printBinaryImpl(Label, StringRef(), V, false);
229229 }
230230
231231 void printBinary(StringRef Label, StringRef Value) {
232 ArrayRef V(reinterpret_cast(Value.data()),
233 Value.size());
232 auto V = makeArrayRef(reinterpret_cast(Value.data()),
233 Value.size());
234234 printBinaryImpl(Label, StringRef(), V, false);
235235 }
236236
237237 void printBinaryBlock(StringRef Label, StringRef Value) {
238 ArrayRef V(reinterpret_cast(Value.data()),
239 Value.size());
238 auto V = makeArrayRef(reinterpret_cast(Value.data()),
239 Value.size());
240240 printBinaryImpl(Label, StringRef(), V, true);
241241 }
242242
613613 0x7E7FFA5EADD8846ULL,
614614 0x305F341CA00B613DULL
615615 };
616 APInt A2(integerPartWidth*4, ArrayRef(E2, 4));
616 APInt A2(integerPartWidth*4, E2);
617617 for (unsigned i = 0; i < 4; ++i) {
618618 for (unsigned j = 0; j < integerPartWidth; ++j) {
619619 EXPECT_EQ(bool(E2[i] & (1ULL << j)),
652652
653653 // Test round up.
654654 integerPart I4[4] = {0x0, 0xF, 0x18, 0x0};
655 APInt A4(integerPartWidth*4, ArrayRef(I4, 4));
655 APInt A4(integerPartWidth*4, I4);
656656 EXPECT_EQ(A4.nearestLogBase2(), A4.ceilLogBase2());
657657
658658 // Test round down.
659659 integerPart I5[4] = {0x0, 0xF, 0x10, 0x0};
660 APInt A5(integerPartWidth*4, ArrayRef(I5, 4));
660 APInt A5(integerPartWidth*4, I5);
661661 EXPECT_EQ(A5.nearestLogBase2(), A5.logBase2());
662662
663663 // Test ties round up.
664664 uint64_t I6[4] = {0x0, 0x0, 0x0, 0x18};
665 APInt A6(integerPartWidth*4, ArrayRef(I6, 4));
665 APInt A6(integerPartWidth*4, I6);
666666 EXPECT_EQ(A6.nearestLogBase2(), A6.ceilLogBase2());
667667
668668 // Test BitWidth == 1 special cases.
3838
3939 TEST(ConvertUTFTest, OddLengthInput) {
4040 std::string Result;
41 bool Success = convertUTF16ToUTF8String(ArrayRef("xxxxx", 5), Result);
41 bool Success = convertUTF16ToUTF8String(makeArrayRef("xxxxx", 5), Result);
4242 EXPECT_FALSE(Success);
4343 }
4444
4545 TEST(ConvertUTFTest, Empty) {
4646 std::string Result;
47 bool Success = convertUTF16ToUTF8String(ArrayRef(), Result);
47 bool Success = convertUTF16ToUTF8String(None, Result);
4848 EXPECT_TRUE(Success);
4949 EXPECT_TRUE(Result.empty());
5050 }
5151
5252 TEST(ConvertUTFTest, HasUTF16BOM) {
53 bool HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xff\xfe", 2));
53 bool HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xff\xfe", 2));
5454 EXPECT_TRUE(HasBOM);
55 HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff", 2));
55 HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff", 2));
5656 EXPECT_TRUE(HasBOM);
57 HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff ", 3));
57 HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff ", 3));
5858 EXPECT_TRUE(HasBOM); // Don't care about odd lengths.
59 HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff\x00asdf", 6));
59 HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff\x00asdf", 6));
6060 EXPECT_TRUE(HasBOM);
6161
62 HasBOM = hasUTF16ByteOrderMark(ArrayRef());
62 HasBOM = hasUTF16ByteOrderMark(None);
6363 EXPECT_FALSE(HasBOM);
64 HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe", 1));
64 HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe", 1));
6565 EXPECT_FALSE(HasBOM);
6666 }
6767
4040 }
4141
4242 TEST(MD5Test, MD5) {
43 TestMD5Sum(ArrayRef((const uint8_t *)"", (size_t) 0),
43 TestMD5Sum(makeArrayRef((const uint8_t *)"", (size_t) 0),
4444 "d41d8cd98f00b204e9800998ecf8427e");
45 TestMD5Sum(ArrayRef((const uint8_t *)"a", (size_t) 1),
45 TestMD5Sum(makeArrayRef((const uint8_t *)"a", (size_t) 1),
4646 "0cc175b9c0f1b6a831c399e269772661");
47 TestMD5Sum(ArrayRef((const uint8_t *)"abcdefghijklmnopqrstuvwxyz",
48 (size_t) 26),
47 TestMD5Sum(makeArrayRef((const uint8_t *)"abcdefghijklmnopqrstuvwxyz",
48 (size_t) 26),
4949 "c3fcd3d76192e4007dfb496cca67e13b");
50 TestMD5Sum(ArrayRef((const uint8_t *)"\0", (size_t) 1),
50 TestMD5Sum(makeArrayRef((const uint8_t *)"\0", (size_t) 1),
5151 "93b885adfe0da089cdf634904fd59f71");
52 TestMD5Sum(ArrayRef((const uint8_t *)"a\0", (size_t) 2),
52 TestMD5Sum(makeArrayRef((const uint8_t *)"a\0", (size_t) 2),
5353 "4144e195f46de78a3623da7364d04f11");
54 TestMD5Sum(ArrayRef((const uint8_t *)"abcdefghijklmnopqrstuvwxyz\0",
55 (size_t) 27),
54 TestMD5Sum(makeArrayRef((const uint8_t *)"abcdefghijklmnopqrstuvwxyz\0",
55 (size_t) 27),
5656 "81948d1f1554f58cd1a56ebb01f808cb");
5757 TestMD5Sum("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b");
5858 }
679679
680680 OS << " }\n";
681681 OS << " }\n";
682 OS << " return AttributeSet::get(C, ArrayRef(AS, "
683 "NumAttrs));\n";
682 OS << " return AttributeSet::get(C, makeArrayRef(AS, NumAttrs));\n";
684683 OS << "}\n";
685684 OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
686685 }