tidy up, remove dependence on order of evaluation of function args from EmitMemCpy.
llvm-svn: 90297
This commit is contained in:
		
							parent
							
								
									af35329f71
								
							
						
					
					
						commit
						eea42c7b51
					
				| 
						 | 
					@ -128,8 +128,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
 | 
					/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
 | 
				
			||||||
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
 | 
					Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
 | 
				
			||||||
  return
 | 
					  return B.CreateBitCast(V, Type::getInt8PtrTy(*Context), "cstr");
 | 
				
			||||||
        B.CreateBitCast(V, Type::getInt8PtrTy(*Context), "cstr");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
 | 
					/// EmitStrLen - Emit a call to the strlen function to the builder, for the
 | 
				
			||||||
| 
						 | 
					@ -157,27 +156,25 @@ Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder<> &B) {
 | 
				
			||||||
Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
 | 
					Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
 | 
				
			||||||
                                       unsigned Align, IRBuilder<> &B) {
 | 
					                                       unsigned Align, IRBuilder<> &B) {
 | 
				
			||||||
  Module *M = Caller->getParent();
 | 
					  Module *M = Caller->getParent();
 | 
				
			||||||
  Intrinsic::ID IID = Intrinsic::memcpy;
 | 
					  const Type *Ty = Len->getType();
 | 
				
			||||||
  const Type *Tys[1];
 | 
					  Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1);
 | 
				
			||||||
  Tys[0] = Len->getType();
 | 
					  Dst = CastToCStr(Dst, B);
 | 
				
			||||||
  Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1);
 | 
					  Src = CastToCStr(Src, B);
 | 
				
			||||||
  return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len,
 | 
					  return B.CreateCall4(MemCpy, Dst, Src, Len,
 | 
				
			||||||
                       ConstantInt::get(Type::getInt32Ty(*Context), Align));
 | 
					                       ConstantInt::get(Type::getInt32Ty(*Context), Align));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// EmitMemMOve - Emit a call to the memmove function to the builder.  This
 | 
					/// EmitMemMove - Emit a call to the memmove function to the builder.  This
 | 
				
			||||||
/// always expects that the size has type 'intptr_t' and Dst/Src are pointers.
 | 
					/// always expects that the size has type 'intptr_t' and Dst/Src are pointers.
 | 
				
			||||||
Value *LibCallOptimization::EmitMemMove(Value *Dst, Value *Src, Value *Len,
 | 
					Value *LibCallOptimization::EmitMemMove(Value *Dst, Value *Src, Value *Len,
 | 
				
			||||||
					unsigned Align, IRBuilder<> &B) {
 | 
										unsigned Align, IRBuilder<> &B) {
 | 
				
			||||||
  Module *M = Caller->getParent();
 | 
					  Module *M = Caller->getParent();
 | 
				
			||||||
  Intrinsic::ID IID = Intrinsic::memmove;
 | 
					  const Type *Ty = TD->getIntPtrType(*Context);
 | 
				
			||||||
  const Type *Tys[1];
 | 
					  Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1);
 | 
				
			||||||
  Tys[0] = TD->getIntPtrType(*Context);
 | 
					  Dst = CastToCStr(Dst, B);
 | 
				
			||||||
  Value *MemMove = Intrinsic::getDeclaration(M, IID, Tys, 1);
 | 
					  Src = CastToCStr(Src, B);
 | 
				
			||||||
  Value *D = CastToCStr(Dst, B);
 | 
					 | 
				
			||||||
  Value *S = CastToCStr(Src, B);
 | 
					 | 
				
			||||||
  Value *A = ConstantInt::get(Type::getInt32Ty(*Context), Align);
 | 
					  Value *A = ConstantInt::get(Type::getInt32Ty(*Context), Align);
 | 
				
			||||||
  return B.CreateCall4(MemMove, D, S, Len, A);
 | 
					  return B.CreateCall4(MemMove, Dst, Src, Len, A);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// EmitMemChr - Emit a call to the memchr function.  This assumes that Ptr is
 | 
					/// EmitMemChr - Emit a call to the memchr function.  This assumes that Ptr is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue