@@ -1288,7 +1288,7 @@ void DataFlowSanitizer::buildExternWeakCheckIfNeeded(IRBuilder<> &IRB,
1288
1288
// for a extern weak function, add a check here to help identify the issue.
1289
1289
if (GlobalValue::isExternalWeakLinkage (F->getLinkage ())) {
1290
1290
std::vector<Value *> Args;
1291
- Args.push_back (IRB. CreatePointerCast (F, IRB. getInt8PtrTy ()) );
1291
+ Args.push_back (F );
1292
1292
Args.push_back (IRB.CreateGlobalStringPtr (F->getName ()));
1293
1293
IRB.CreateCall (DFSanWrapperExternWeakNullFn, Args);
1294
1294
}
@@ -2270,8 +2270,7 @@ std::pair<Value *, Value *> DFSanFunction::loadShadowOriginSansLoadTracking(
2270
2270
IRBuilder<> IRB (Pos);
2271
2271
CallInst *Call =
2272
2272
IRB.CreateCall (DFS.DFSanLoadLabelAndOriginFn ,
2273
- {IRB.CreatePointerCast (Addr, IRB.getInt8PtrTy ()),
2274
- ConstantInt::get (DFS.IntptrTy , Size)});
2273
+ {Addr, ConstantInt::get (DFS.IntptrTy , Size)});
2275
2274
Call->addRetAttr (Attribute::ZExt);
2276
2275
return {IRB.CreateTrunc (IRB.CreateLShr (Call, DFS.OriginWidthBits ),
2277
2276
DFS.PrimitiveShadowTy ),
@@ -2527,10 +2526,9 @@ void DFSanFunction::storeOrigin(Instruction *Pos, Value *Addr, uint64_t Size,
2527
2526
}
2528
2527
2529
2528
if (shouldInstrumentWithCall ()) {
2530
- IRB.CreateCall (DFS.DFSanMaybeStoreOriginFn ,
2531
- {CollapsedShadow,
2532
- IRB.CreatePointerCast (Addr, IRB.getInt8PtrTy ()),
2533
- ConstantInt::get (DFS.IntptrTy , Size), Origin});
2529
+ IRB.CreateCall (
2530
+ DFS.DFSanMaybeStoreOriginFn ,
2531
+ {CollapsedShadow, Addr, ConstantInt::get (DFS.IntptrTy , Size), Origin});
2534
2532
} else {
2535
2533
Value *Cmp = convertToBool (CollapsedShadow, IRB, " _dfscmp" );
2536
2534
DomTreeUpdater DTU (DT, DomTreeUpdater::UpdateStrategy::Lazy);
@@ -2924,8 +2922,7 @@ void DFSanVisitor::visitMemTransferInst(MemTransferInst &I) {
2924
2922
if (DFSF.DFS .shouldTrackOrigins ()) {
2925
2923
IRB.CreateCall (
2926
2924
DFSF.DFS .DFSanMemOriginTransferFn ,
2927
- {IRB.CreatePointerCast (I.getArgOperand (0 ), IRB.getInt8PtrTy ()),
2928
- IRB.CreatePointerCast (I.getArgOperand (1 ), IRB.getInt8PtrTy ()),
2925
+ {I.getArgOperand (0 ), I.getArgOperand (1 ),
2929
2926
IRB.CreateIntCast (I.getArgOperand (2 ), DFSF.DFS .IntptrTy , false )});
2930
2927
}
2931
2928
@@ -3213,10 +3210,9 @@ void DFSanVisitor::visitLibAtomicLoad(CallBase &CB) {
3213
3210
// TODO: Support ClCombinePointerLabelsOnLoad
3214
3211
// TODO: Support ClEventCallbacks
3215
3212
3216
- NextIRB.CreateCall (DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3217
- {NextIRB.CreatePointerCast (DstPtr, NextIRB.getInt8PtrTy ()),
3218
- NextIRB.CreatePointerCast (SrcPtr, NextIRB.getInt8PtrTy ()),
3219
- NextIRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3213
+ NextIRB.CreateCall (
3214
+ DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3215
+ {DstPtr, SrcPtr, NextIRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3220
3216
}
3221
3217
3222
3218
Value *DFSanVisitor::makeAddReleaseOrderingTable (IRBuilder<> &IRB) {
@@ -3252,10 +3248,9 @@ void DFSanVisitor::visitLibAtomicStore(CallBase &CB) {
3252
3248
// TODO: Support ClCombinePointerLabelsOnStore
3253
3249
// TODO: Support ClEventCallbacks
3254
3250
3255
- IRB.CreateCall (DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3256
- {IRB.CreatePointerCast (DstPtr, IRB.getInt8PtrTy ()),
3257
- IRB.CreatePointerCast (SrcPtr, IRB.getInt8PtrTy ()),
3258
- IRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3251
+ IRB.CreateCall (
3252
+ DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3253
+ {DstPtr, SrcPtr, IRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3259
3254
}
3260
3255
3261
3256
void DFSanVisitor::visitLibAtomicExchange (CallBase &CB) {
@@ -3273,16 +3268,14 @@ void DFSanVisitor::visitLibAtomicExchange(CallBase &CB) {
3273
3268
// the additional complexity to address this is not warrented.
3274
3269
3275
3270
// Current Target to Dest
3276
- IRB.CreateCall (DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3277
- {IRB.CreatePointerCast (DstPtr, IRB.getInt8PtrTy ()),
3278
- IRB.CreatePointerCast (TargetPtr, IRB.getInt8PtrTy ()),
3279
- IRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3271
+ IRB.CreateCall (
3272
+ DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3273
+ {DstPtr, TargetPtr, IRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3280
3274
3281
3275
// Current Src to Target (overriding)
3282
- IRB.CreateCall (DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3283
- {IRB.CreatePointerCast (TargetPtr, IRB.getInt8PtrTy ()),
3284
- IRB.CreatePointerCast (SrcPtr, IRB.getInt8PtrTy ()),
3285
- IRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3276
+ IRB.CreateCall (
3277
+ DFSF.DFS .DFSanMemShadowOriginTransferFn ,
3278
+ {TargetPtr, SrcPtr, IRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3286
3279
}
3287
3280
3288
3281
void DFSanVisitor::visitLibAtomicCompareExchange (CallBase &CB) {
@@ -3305,13 +3298,10 @@ void DFSanVisitor::visitLibAtomicCompareExchange(CallBase &CB) {
3305
3298
3306
3299
// If original call returned true, copy Desired to Target.
3307
3300
// If original call returned false, copy Target to Expected.
3308
- NextIRB.CreateCall (
3309
- DFSF.DFS .DFSanMemShadowOriginConditionalExchangeFn ,
3310
- {NextIRB.CreateIntCast (&CB, NextIRB.getInt8Ty (), false ),
3311
- NextIRB.CreatePointerCast (TargetPtr, NextIRB.getInt8PtrTy ()),
3312
- NextIRB.CreatePointerCast (ExpectedPtr, NextIRB.getInt8PtrTy ()),
3313
- NextIRB.CreatePointerCast (DesiredPtr, NextIRB.getInt8PtrTy ()),
3314
- NextIRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3301
+ NextIRB.CreateCall (DFSF.DFS .DFSanMemShadowOriginConditionalExchangeFn ,
3302
+ {NextIRB.CreateIntCast (&CB, NextIRB.getInt8Ty (), false ),
3303
+ TargetPtr, ExpectedPtr, DesiredPtr,
3304
+ NextIRB.CreateIntCast (Size, DFSF.DFS .IntptrTy , false )});
3315
3305
}
3316
3306
3317
3307
void DFSanVisitor::visitCallBase (CallBase &CB) {
0 commit comments