diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -1240,6 +1240,7 @@ std::vector Args(ArgIt, ArgIt + FT->getNumParams()); CallInst *CI = CallInst::Create(F, Args, "", BB); + CI->setAttributes(F->getAttributes()); if (FT->getReturnType()->isVoidTy()) ReturnInst::Create(*Ctx, BB); else @@ -2479,13 +2480,17 @@ Value *DFSanFunction::updateOriginIfTainted(Value *Shadow, Value *Origin, IRBuilder<> &IRB) { assert(DFS.shouldTrackOrigins()); - return IRB.CreateCall(DFS.DFSanChainOriginIfTaintedFn, {Shadow, Origin}); + auto *CB = IRB.CreateCall(DFS.DFSanChainOriginIfTaintedFn, {Shadow, Origin}); + CB->setAttributes(CB->getCalledFunction()->getAttributes()); + return CB; } Value *DFSanFunction::updateOrigin(Value *V, IRBuilder<> &IRB) { if (!DFS.shouldTrackOrigins()) return V; - return IRB.CreateCall(DFS.DFSanChainOriginFn, V); + auto *CB = IRB.CreateCall(DFS.DFSanChainOriginFn, V); + CB->setAttributes(CB->getCalledFunction()->getAttributes()); + return CB; } Value *DFSanFunction::originToIntptr(IRBuilder<> &IRB, Value *Origin) { @@ -2560,10 +2565,11 @@ } if (shouldInstrumentWithCall()) { - IRB.CreateCall(DFS.DFSanMaybeStoreOriginFn, - {CollapsedShadow, - IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()), - ConstantInt::get(DFS.IntptrTy, Size), Origin}); + auto *CB = IRB.CreateCall(DFS.DFSanMaybeStoreOriginFn, + {CollapsedShadow, + IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()), + ConstantInt::get(DFS.IntptrTy, Size), Origin}); + CB->setAttributes(CB->getCalledFunction()->getAttributes()); } else { Value *Cmp = convertToBool(CollapsedShadow, IRB, "_dfscmp"); Instruction *CheckTerm = SplitBlockAndInsertIfThen( @@ -2923,11 +2929,12 @@ Value *ValOrigin = DFSF.DFS.shouldTrackOrigins() ? DFSF.getOrigin(I.getValue()) : DFSF.DFS.ZeroOrigin; - IRB.CreateCall( + auto *CB = IRB.CreateCall( DFSF.DFS.DFSanSetLabelFn, {ValShadow, ValOrigin, IRB.CreateBitCast(I.getDest(), Type::getInt8PtrTy(*DFSF.DFS.Ctx)), IRB.CreateZExtOrTrunc(I.getLength(), DFSF.DFS.IntptrTy)}); + CB->setAttributes(CB->getCalledFunction()->getAttributes()); } void DFSanVisitor::visitMemTransferInst(MemTransferInst &I) { diff --git a/llvm/test/Instrumentation/DataFlowSanitizer/memset.ll b/llvm/test/Instrumentation/DataFlowSanitizer/memset.ll --- a/llvm/test/Instrumentation/DataFlowSanitizer/memset.ll +++ b/llvm/test/Instrumentation/DataFlowSanitizer/memset.ll @@ -10,7 +10,7 @@ define void @ms(i8* %p, i8 %v) { ; CHECK-LABEL: @"dfs$ms" ; CHECK-SAME: (i8* %0, i8 %1, i[[#SBITS]] %2, i[[#SBITS]] %3) - ; CHECK: call void @__dfsan_set_label(i[[#SBITS]] %3, i32 0, i8* %0, i64 1) + ; CHECK: call void @__dfsan_set_label(i[[#SBITS]] zeroext %3, i32 zeroext 0, i8* %0, i64 1) call void @llvm.memset.p0i8.i64(i8* %p, i8 %v, i64 1, i1 1) ret void } diff --git a/llvm/test/Instrumentation/DataFlowSanitizer/origin_mem_intrinsic.ll b/llvm/test/Instrumentation/DataFlowSanitizer/origin_mem_intrinsic.ll --- a/llvm/test/Instrumentation/DataFlowSanitizer/origin_mem_intrinsic.ll +++ b/llvm/test/Instrumentation/DataFlowSanitizer/origin_mem_intrinsic.ll @@ -36,7 +36,7 @@ ; CHECK: @"dfs$memset" ; CHECK: [[O:%.*]] = load i32, i32* getelementptr inbounds ([200 x i32], [200 x i32]* @__dfsan_arg_origin_tls, i64 0, i64 1), align 4 ; CHECK: [[S:%.*]] = load i[[#SBITS]], i[[#SBITS]]* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__dfsan_arg_tls to i64), i64 2) to i[[#SBITS]]*), align [[ALIGN:2]] - ; CHECK: call void @__dfsan_set_label(i[[#SBITS]] [[S]], i32 [[O]], i8* %p, i64 1) + ; CHECK: call void @__dfsan_set_label(i[[#SBITS]] zeroext [[S]], i32 zeroext [[O]], i8* %p, i64 1) call void @llvm.memset.p0i8.i64(i8* %p, i8 %v, i64 1, i1 1) ret void -} \ No newline at end of file +} diff --git a/llvm/test/Instrumentation/DataFlowSanitizer/origin_store.ll b/llvm/test/Instrumentation/DataFlowSanitizer/origin_store.ll --- a/llvm/test/Instrumentation/DataFlowSanitizer/origin_store.ll +++ b/llvm/test/Instrumentation/DataFlowSanitizer/origin_store.ll @@ -63,7 +63,7 @@ ; CHECK: %_dfscmp = icmp ne i[[#SBITS]] %[[#AS]], 0 ; CHECK-NEXT: br i1 %_dfscmp, label %[[L1:.*]], label %[[L2:.*]], ; CHECK: [[L1]]: - ; CHECK-NEXT: %[[#NO:]] = call i32 @__dfsan_chain_origin(i32 %[[#AO]]) + ; CHECK-NEXT: %[[#NO:]] = call zeroext i32 @__dfsan_chain_origin(i32 zeroext %[[#AO]]) ; CHECK-NEXT: store i32 %[[#NO]], i32* %[[#ORIGIN_PTR]], align 4 ; CHECK-NEXT: br label %[[L2]] ; CHECK: [[L2]]: @@ -91,7 +91,7 @@ ; CHECK: %_dfscmp = icmp ne i[[#SBITS]] %[[#AS]], 0 ; CHECK-NEXT: br i1 %_dfscmp, label %[[L1:.*]], label %[[L2:.*]], ; CHECK: [[L1]]: - ; CHECK-NEXT: %[[#NO:]] = call i32 @__dfsan_chain_origin(i32 %[[#AO]]) + ; CHECK-NEXT: %[[#NO:]] = call zeroext i32 @__dfsan_chain_origin(i32 zeroext %[[#AO]]) ; CHECK-NEXT: %[[#NO_ZEXT:]] = zext i32 %[[#NO]] to i64 ; CHECK-NEXT: %[[#NO_SHL:]] = shl i64 %[[#NO_ZEXT]], 32 ; CHECK-NEXT: %[[#NO2:]] = or i64 %[[#NO_ZEXT]], %[[#NO_SHL]] @@ -121,7 +121,7 @@ ; CHECK: %_dfscmp = icmp ne i[[#SBITS]] %[[#AS]], 0 ; CHECK-NEXT: br i1 %_dfscmp, label %[[L1:.*]], label %[[L2:.*]], ; CHECK: [[L1]]: - ; CHECK-NEXT: %[[#NO:]] = call i32 @__dfsan_chain_origin(i32 %[[#AO]]) + ; CHECK-NEXT: %[[#NO:]] = call zeroext i32 @__dfsan_chain_origin(i32 zeroext %[[#AO]]) ; CHECK-NEXT: store i32 %[[#NO]], i32* %[[#O_PTR0:]], align 4 ; CHECK-NEXT: %[[#O_PTR1:]] = getelementptr i32, i32* %[[#O_PTR0]], i32 1 ; CHECK-NEXT: store i32 %[[#NO]], i32* %[[#O_PTR1]], align 4 @@ -148,7 +148,7 @@ ; CHECK: %_dfscmp = icmp ne i[[#SBITS]] %[[#AS]], 0 ; CHECK-NEXT: br i1 %_dfscmp, label %[[L1:.*]], label %[[L2:.*]], ; CHECK: [[L1]]: - ; CHECK-NEXT: %[[#NO:]] = call i32 @__dfsan_chain_origin(i32 %[[#AO]]) + ; CHECK-NEXT: %[[#NO:]] = call zeroext i32 @__dfsan_chain_origin(i32 zeroext %[[#AO]]) ; CHECK-NEXT: %[[#NO_ZEXT:]] = zext i32 %[[#NO]] to i64 ; CHECK-NEXT: %[[#NO_SHL:]] = shl i64 %[[#NO_ZEXT]], 32 ; CHECK-NEXT: %[[#NO2:]] = or i64 %[[#NO_ZEXT]], %[[#NO_SHL]] diff --git a/llvm/test/Instrumentation/DataFlowSanitizer/origin_store_threshold.ll b/llvm/test/Instrumentation/DataFlowSanitizer/origin_store_threshold.ll --- a/llvm/test/Instrumentation/DataFlowSanitizer/origin_store_threshold.ll +++ b/llvm/test/Instrumentation/DataFlowSanitizer/origin_store_threshold.ll @@ -14,7 +14,7 @@ ; CHECK: [[AS1:%.*]] = extractvalue [2 x i[[#SBITS]]] [[AS]], 1 ; CHECK: [[AS01:%.*]] = or i[[#SBITS]] [[AS0]], [[AS1]] ; CHECK: [[ADDR:%.*]] = bitcast [2 x i64]* %p to i8* - ; CHECK: call void @__dfsan_maybe_store_origin(i[[#SBITS]] [[AS01]], i8* [[ADDR]], i64 16, i32 [[AO]]) + ; CHECK: call void @__dfsan_maybe_store_origin(i[[#SBITS]] zeroext [[AS01]], i8* [[ADDR]], i64 16, i32 zeroext [[AO]]) ; CHECK: store [2 x i64] %a, [2 x i64]* %p, align 8 store [2 x i64] %a, [2 x i64]* %p diff --git a/llvm/test/Instrumentation/DataFlowSanitizer/origin_track_load.ll b/llvm/test/Instrumentation/DataFlowSanitizer/origin_track_load.ll --- a/llvm/test/Instrumentation/DataFlowSanitizer/origin_track_load.ll +++ b/llvm/test/Instrumentation/DataFlowSanitizer/origin_track_load.ll @@ -17,7 +17,7 @@ ; CHECK-NEXT: %[[#LABEL_ORIGIN_H32:]] = lshr i64 %[[#LABEL_ORIGIN]], 32 ; CHECK-NEXT: %[[#LABEL:]] = trunc i64 %[[#LABEL_ORIGIN_H32]] to i[[#SBITS]] ; CHECK-NEXT: %[[#ORIGIN:]] = trunc i64 %[[#LABEL_ORIGIN]] to i32 - ; CHECK-NEXT: %[[#ORIGIN_CHAINED:]] = call i32 @__dfsan_chain_origin_if_tainted(i[[#SBITS]] %[[#LABEL]], i32 %[[#ORIGIN]]) + ; CHECK-NEXT: %[[#ORIGIN_CHAINED:]] = call zeroext i32 @__dfsan_chain_origin_if_tainted(i[[#SBITS]] zeroext %[[#LABEL]], i32 zeroext %[[#ORIGIN]]) ; CHECK-NEXT: %[[#LABEL:]] = or i[[#SBITS]] %[[#LABEL]], %[[#PS]] ; CHECK-NEXT: %[[#NZ:]] = icmp ne i[[#SBITS]] %[[#PS]], 0 diff --git a/llvm/test/Instrumentation/DataFlowSanitizer/shadow-args-zext.ll b/llvm/test/Instrumentation/DataFlowSanitizer/shadow-args-zext.ll --- a/llvm/test/Instrumentation/DataFlowSanitizer/shadow-args-zext.ll +++ b/llvm/test/Instrumentation/DataFlowSanitizer/shadow-args-zext.ll @@ -41,15 +41,15 @@ declare zeroext i16 @dfsan_get_label(i64 signext) ; CHECK-LABEL: @"dfsw$dfsan_get_label" -; CHECK: %{{.*}} = call i16 @__dfsw_dfsan_get_label(i64 %0, i[[#SBITS]] zeroext %1, i[[#SBITS]]* %{{.*}}) +; CHECK: %{{.*}} = call zeroext i16 @__dfsw_dfsan_get_label(i64 signext %0, i[[#SBITS]] zeroext %1, i[[#SBITS]]* %{{.*}}) declare zeroext i16 @k2(i64 signext, i64 signext) ; CHECK-LABEL: @"dfsw$k2" -; CHECK: %{{.*}} = call i16 @__dfsw_k2(i64 %{{.*}}, i64 %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]]* %{{.*}}) +; CHECK: %{{.*}} = call zeroext i16 @__dfsw_k2(i64 signext %{{.*}}, i64 signext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]]* %{{.*}}) declare zeroext i16 @k4(i64 signext, i64 signext, i64 signext, i64 signext) ; CHECK-LABEL: @"dfsw$k4" -; CHECK: %{{.*}} = call i16 @__dfsw_k4(i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]]* %{{.*}}) +; CHECK: %{{.*}} = call zeroext i16 @__dfsw_k4(i64 signext %{{.*}}, i64 signext %{{.*}}, i64 signext %{{.*}}, i64 signext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]] zeroext %{{.*}}, i[[#SBITS]]* %{{.*}}) ; CHECK: declare zeroext i16 @__dfsw_dfsan_get_label(i64 signext, i[[#SBITS]], i[[#SBITS]]*)