@@ -277,8 +277,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
277
277
Type *tys[] = {dbuf->getType (), len_arg->getType ()};
278
278
279
279
auto memset = cast<CallInst>(Builder2.CreateCall (
280
- Intrinsic::getDeclaration (called->getParent (), Intrinsic::memset ,
281
- tys),
280
+ getIntrinsicDeclaration (called->getParent (), Intrinsic::memset ,
281
+ tys),
282
282
nargs, BufferDefs));
283
283
memset ->addParamAttr (0 , Attribute::NonNull);
284
284
} else if (funcName == " MPI_Isend" || funcName == " PMPI_Isend" ) {
@@ -887,8 +887,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
887
887
ValueType::None, ValueType::None, ValueType::None},
888
888
Builder2, /* lookup*/ true );
889
889
auto memset = cast<CallInst>(Builder2.CreateCall (
890
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
891
- Intrinsic::memset , tys),
890
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
891
+ Intrinsic::memset , tys),
892
892
nargs));
893
893
memset ->addParamAttr (0 , Attribute::NonNull);
894
894
}
@@ -1057,8 +1057,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1057
1057
1058
1058
Type *tys[] = {shadow ->getType (), buf->getType (), len_arg->getType ()};
1059
1059
1060
- auto memcpyF = Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1061
- Intrinsic::memcpy , tys);
1060
+ auto memcpyF = getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1061
+ Intrinsic::memcpy , tys);
1062
1062
1063
1063
auto mem =
1064
1064
cast<CallInst>(Builder2.CreateCall (memcpyF, nargs, BufferDefs));
@@ -1080,8 +1080,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1080
1080
Value *args[] = {shadow , val_arg, len_arg, volatile_arg};
1081
1081
Type *tys[] = {args[0 ]->getType (), args[2 ]->getType ()};
1082
1082
auto memset = cast<CallInst>(Builder2.CreateCall (
1083
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1084
- Intrinsic::memset , tys),
1083
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1084
+ Intrinsic::memset , tys),
1085
1085
args, BufferDefs));
1086
1086
memset ->addParamAttr (0 , Attribute::NonNull);
1087
1087
Builder2.CreateBr (mergeBlock);
@@ -1262,8 +1262,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1262
1262
Type *tys[] = {nargs[0 ]->getType (), nargs[1 ]->getType (),
1263
1263
len_arg->getType ()};
1264
1264
1265
- auto memcpyF = Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1266
- Intrinsic::memcpy , tys);
1265
+ auto memcpyF = getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1266
+ Intrinsic::memcpy , tys);
1267
1267
1268
1268
auto mem =
1269
1269
cast<CallInst>(Builder2.CreateCall (memcpyF, nargs, BufferDefs));
@@ -1314,8 +1314,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1314
1314
Value *args[] = {shadow_recvbuf, val_arg, len_arg, volatile_arg};
1315
1315
Type *tys[] = {args[0 ]->getType (), args[2 ]->getType ()};
1316
1316
auto memset = cast<CallInst>(Builder2.CreateCall (
1317
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1318
- Intrinsic::memset , tys),
1317
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1318
+ Intrinsic::memset , tys),
1319
1319
args, BufferDefs));
1320
1320
memset ->addParamAttr (0 , Attribute::NonNull);
1321
1321
@@ -1496,8 +1496,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1496
1496
Value *args[] = {shadow_recvbuf, val_arg, len_arg, volatile_arg};
1497
1497
Type *tys[] = {args[0 ]->getType (), args[2 ]->getType ()};
1498
1498
auto memset = cast<CallInst>(Builder2.CreateCall (
1499
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1500
- Intrinsic::memset , tys),
1499
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1500
+ Intrinsic::memset , tys),
1501
1501
args, BufferDefs));
1502
1502
memset ->addParamAttr (0 , Attribute::NonNull);
1503
1503
@@ -1696,8 +1696,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1696
1696
Value *args[] = {shadow_recvbuf, val_arg, recvlen_arg, volatile_arg};
1697
1697
Type *tys[] = {args[0 ]->getType (), args[2 ]->getType ()};
1698
1698
auto memset = cast<CallInst>(Builder2.CreateCall (
1699
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1700
- Intrinsic::memset , tys),
1699
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1700
+ Intrinsic::memset , tys),
1701
1701
args, BufferDefs));
1702
1702
memset ->addParamAttr (0 , Attribute::NonNull);
1703
1703
@@ -1917,8 +1917,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
1917
1917
Value *args[] = {shadow_recvbuf, val_arg, recvlen_arg, volatile_arg};
1918
1918
Type *tys[] = {args[0 ]->getType (), args[2 ]->getType ()};
1919
1919
auto memset = cast<CallInst>(Builder2.CreateCall (
1920
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
1921
- Intrinsic::memset , tys),
1920
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
1921
+ Intrinsic::memset , tys),
1922
1922
args, BufferDefs));
1923
1923
memset ->addParamAttr (0 , Attribute::NonNull);
1924
1924
}
@@ -2129,8 +2129,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
2129
2129
Value *args[] = {shadow_recvbuf, val_arg, recvlen_arg, volatile_arg};
2130
2130
Type *tys[] = {args[0 ]->getType (), args[2 ]->getType ()};
2131
2131
auto memset = cast<CallInst>(Builder2.CreateCall (
2132
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
2133
- Intrinsic::memset , tys),
2132
+ getIntrinsicDeclaration (gutils->newFunc ->getParent (),
2133
+ Intrinsic::memset , tys),
2134
2134
args, BufferDefs));
2135
2135
memset ->addParamAttr (0 , Attribute::NonNull);
2136
2136
}
@@ -3822,20 +3822,7 @@ bool AdjointGenerator::handleKnownCallDerivatives(
3822
3822
3823
3823
if (funcName == " posix_memalign" ||
3824
3824
funcName == " cudaMallocHost" ) {
3825
- auto volatile_arg = ConstantInt::getFalse (call.getContext ());
3826
-
3827
- Value *nargs[] = {dst_arg, val_arg, len_arg, volatile_arg};
3828
-
3829
- Type *tys[] = {dst_arg->getType (), len_arg->getType ()};
3830
-
3831
- auto memset = cast<CallInst>(BuilderZ.CreateCall (
3832
- Intrinsic::getDeclaration (gutils->newFunc ->getParent (),
3833
- Intrinsic::memset , tys),
3834
- nargs));
3835
- // memset->addParamAttr(0,
3836
- // Attribute::getWithAlignment(Context,
3837
- // inst->getAlignment()));
3838
- memset ->addParamAttr (0 , Attribute::NonNull);
3825
+ BuilderZ.CreateMemSet (dst_arg, val_arg, len_arg, MaybeAlign ());
3839
3826
} else if (funcName == " cudaMalloc" ) {
3840
3827
Type *tys[] = {PT, val_arg->getType (), len_arg->getType ()};
3841
3828
auto F = M->getOrInsertFunction (
0 commit comments