llvm.org GIT mirror llvm / a399781
undo 80 column trespassing I caused git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109092 91177308-0d34-0410-b5e6-96231b3b80d8 Gabor Greif 10 years ago
9 changed file(s) with 39 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
259259 bool LowerRd = !S.customReadBarrier();
260260 bool InitRoots = S.initializeRoots();
261261
262 SmallVector32> Roots;
262 SmallVector 32> Roots;
263263
264264 bool MadeChange = false;
265265 for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
270270 case Intrinsic::gcwrite:
271271 if (LowerWr) {
272272 // Replace a write barrier with a simple store.
273 Value *St = new StoreInst(CI->getArgOperand(0), CI->getArgOperand(2), CI);
273 Value *St = new StoreInst(CI->getArgOperand(0),
274 CI->getArgOperand(2), CI);
274275 CI->replaceAllUsesWith(St);
275276 CI->eraseFromParent();
276277 }
480480 Value *Ops[3];
481481 Ops[0] = CI->getArgOperand(0);
482482 // Extend the amount to i32.
483 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1), Type::getInt32Ty(Context),
483 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1),
484 Type::getInt32Ty(Context),
484485 /* isSigned */ false);
485486 Ops[2] = Size;
486487 ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
14111411 nl(Out);
14121412 }
14131413 Out << "CallInst* " << iName << " = CallInst::Create("
1414 << opNames[call->getNumArgOperands()] << ", " << iName << "_params.begin(), "
1414 << opNames[call->getNumArgOperands()] << ", "
1415 << iName << "_params.begin(), "
14151416 << iName << "_params.end(), \"";
14161417 } else if (call->getNumArgOperands() == 1) {
14171418 Out << "CallInst* " << iName << " = CallInst::Create("
23022302 if (isa(CI->getCalledValue())) return false;
23032303
23042304 // Resolve function pointers.
2305 Function *Callee = dyn_cast(getVal(Values, CI->getCalledValue()));
2305 Function *Callee = dyn_cast(getVal(Values,
2306 CI->getCalledValue()));
23062307 if (!Callee) return false; // Cannot resolve.
23072308
23082309 SmallVector Formals;
629629 cast(II->getArgOperand(0)->getType())->getNumElements();
630630 APInt DemandedElts(VWidth, 1);
631631 APInt UndefElts(VWidth, 0);
632 if (Value *V = SimplifyDemandedVectorElts(II->getArgOperand(0), DemandedElts,
633 UndefElts)) {
632 if (Value *V = SimplifyDemandedVectorElts(II->getArgOperand(0),
633 DemandedElts, UndefElts)) {
634634 II->setArgOperand(0, V);
635635 return II;
636636 }
654654
655655 if (AllEltsOk) {
656656 // Cast the input vectors to byte vectors.
657 Value *Op0 = Builder->CreateBitCast(II->getArgOperand(0), Mask->getType());
658 Value *Op1 = Builder->CreateBitCast(II->getArgOperand(1), Mask->getType());
657 Value *Op0 = Builder->CreateBitCast(II->getArgOperand(0),
658 Mask->getType());
659 Value *Op1 = Builder->CreateBitCast(II->getArgOperand(1),
660 Mask->getType());
659661 Value *Result = UndefValue::get(Op0->getType());
660662
661663 // Only extract each element once.
771773 NewInstruction = IC->ReplaceInstUsesWith(*CI, With);
772774 }
773775 bool isFoldable(unsigned SizeCIOp, unsigned SizeArgOp, bool isString) const {
774 if (ConstantInt *SizeCI = dyn_cast(CI->getArgOperand(SizeCIOp))) {
776 if (ConstantInt *SizeCI =
777 dyn_cast(CI->getArgOperand(SizeCIOp))) {
775778 if (SizeCI->isAllOnesValue())
776779 return true;
777780 if (isString)
778781 return SizeCI->getZExtValue() >=
779782 GetStringLength(CI->getArgOperand(SizeArgOp));
780 if (ConstantInt *Arg = dyn_cast(CI->getArgOperand(SizeArgOp)))
783 if (ConstantInt *Arg = dyn_cast(
784 CI->getArgOperand(SizeArgOp)))
781785 return SizeCI->getZExtValue() >= Arg->getZExtValue();
782786 }
783787 return false;
11391143 IntrinsicInst *Tramp =
11401144 cast(cast(Callee)->getOperand(0));
11411145
1142 Function *NestF = cast(Tramp->getArgOperand(1)->stripPointerCasts());
1146 Function *NestF =cast(Tramp->getArgOperand(1)->stripPointerCasts());
11431147 const PointerType *NestFPTy = cast(NestF->getType());
11441148 const FunctionType *NestFTy = cast(NestFPTy->getElementType());
11451149
742742 const Type *ArgTys[3] = { M->getRawDest()->getType(),
743743 M->getRawSource()->getType(),
744744 M->getLength()->getType() };
745 M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3));
745 M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy,
746 ArgTys, 3));
746747
747748 // MemDep may have over conservative information about this instruction, just
748749 // conservatively flush it from the cache.
565565
566566 // fold strstr(x, "y") -> strchr(x, 'y').
567567 if (HasStr2 && ToFindStr.size() == 1)
568 return B.CreateBitCast(EmitStrChr(CI->getArgOperand(0), ToFindStr[0], B, TD),
569 CI->getType());
568 return B.CreateBitCast(EmitStrChr(CI->getArgOperand(0),
569 ToFindStr[0], B, TD), CI->getType());
570570 return 0;
571571 }
572572 };
680680 return 0;
681681
682682 // memset(p, v, n) -> llvm.memset(p, v, n, 1)
683 Value *Val = B.CreateIntCast(CI->getArgOperand(1), Type::getInt8Ty(*Context),
684 false);
683 Value *Val = B.CreateIntCast(CI->getArgOperand(1),
684 Type::getInt8Ty(*Context), false);
685685 EmitMemSet(CI->getArgOperand(0), Val, CI->getArgOperand(2), false, B, TD);
686686 return CI->getArgOperand(0);
687687 }
10411041 if (!TD) return 0;
10421042
10431043 // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1)
1044 EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(1), // Copy the nul byte.
1045 ConstantInt::get(TD->getIntPtrType(*Context),
1046 FormatStr.size()+1), 1, false, B, TD);
1044 EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(1), // Copy the
1045 ConstantInt::get(TD->getIntPtrType(*Context), // nul byte.
1046 FormatStr.size() + 1), 1, false, B, TD);
10471047 return ConstantInt::get(CI->getType(), FormatStr.size());
10481048 }
10491049
10791079 Value *IncLen = B.CreateAdd(Len,
10801080 ConstantInt::get(Len->getType(), 1),
10811081 "leninc");
1082 EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(2), IncLen, 1, false, B, TD);
1082 EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(2),
1083 IncLen, 1, false, B, TD);
10831084
10841085 // The sprintf result is the unincremented number of bytes in the string.
10851086 return B.CreateIntCast(Len, CI->getType(), false);
421421 return false;
422422
423423 if (isFoldable(3, 2, false)) {
424 EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
425 1, false, B, TD);
424 EmitMemCpy(CI->getArgOperand(0), CI->getArgOperand(1),
425 CI->getArgOperand(2), 1, false, B, TD);
426426 replaceCall(CI->getArgOperand(0));
427427 return true;
428428 }
444444 return false;
445445
446446 if (isFoldable(3, 2, false)) {
447 EmitMemMove(CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
448 1, false, B, TD);
447 EmitMemMove(CI->getArgOperand(0), CI->getArgOperand(1),
448 CI->getArgOperand(2), 1, false, B, TD);
449449 replaceCall(CI->getArgOperand(0));
450450 return true;
451451 }
464464 if (isFoldable(3, 2, false)) {
465465 Value *Val = B.CreateIntCast(CI->getArgOperand(1), B.getInt8Ty(),
466466 false);
467 EmitMemSet(CI->getArgOperand(0), Val, CI->getArgOperand(2), false, B, TD);
467 EmitMemSet(CI->getArgOperand(0), Val, CI->getArgOperand(2),
468 false, B, TD);
468469 replaceCall(CI->getArgOperand(0));
469470 return true;
470471 }
397397 SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
398398 } else if (isShufPD) {
399399 Value *Op1 = CI->getArgOperand(1);
400 unsigned MaskVal = cast(CI->getArgOperand(2))->getZExtValue();
400 unsigned MaskVal =
401 cast(CI->getArgOperand(2))->getZExtValue();
401402 Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), MaskVal & 1));
402403 Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C),
403404 ((MaskVal >> 1) & 1)+2));