[llvm] [DataFlowSanitizer] Properly add ext attributes on arguments as needed. (PR #225443)
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 05:26:43 PDT 2026
================
@@ -3164,10 +3213,18 @@ bool DFSanVisitor::visitWrappedCallBase(Function &F, CallBase &CB) {
// Adds variable arguments.
append_range(Args, drop_begin(CB.args(), FT->getNumParams()));
+ // Combine CallSite attributes with Function declaration attributes.
+ AttributeList CombinedAttrs = CI->getAttributes();
----------------
JonPsson1 wrote:
Trying without this now, it seems that only one file of the Instrumentation/DataFlowSanitizer tests is affected: shadow-args-zext.ll, like:
```
declare zeroext i16 @dfsan_get_label(i64 signext)
; CHECK-LABEL: @"dfsw$dfsan_get_label"
-; CHECK: %{{.*}} = call i16 @__dfsw_dfsan_get_label(i64 %0, i8 zeroext %1, ptr %{{.*}})
+; CHECK: %{{.*}} = call i16 @__dfsw_dfsan_get_label(i64 signext %0, i8 zeroext %1, ptr %{{.*}})
declare zeroext i16 @k2(i64 signext, i64 signext)
; CHECK-LABEL: @"dfsw$k2"
-; CHECK: %{{.*}} = call i16 @__dfsw_k2(i64 %{{.*}}, i64 %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, ptr %{{.*}})
+; CHECK: %{{.*}} = call i16 @__dfsw_k2(i64 signext %{{.*}}, i64 signext %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, ptr %{{.*}})
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 %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, ptr %{{.*}})
+; CHECK: %{{.*}} = call i16 @__dfsw_k4(i64 signext %{{.*}}, i64 signext %{{.*}}, i64 signext %{{.*}}, i64 signext %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, i8 zeroext %{{.*}}, ptr %{{.*}})
-; CHECK: declare zeroext i16 @__dfsw_dfsan_get_label(i64 signext, i8, ptr)
-; CHECK: declare zeroext i16 @__dfsw_k2(i64 signext, i64 signext, i8, i8, ptr)
-; CHECK: declare zeroext i16 @__dfsw_k4(i64 signext, i64 signext, i64 signext, i64 signext, i8, i8, i8, i8, ptr)
+; CHECK: declare zeroext i16 @__dfsw_dfsan_get_label(i64 signext, i8 zeroext, ptr)
+; CHECK: declare zeroext i16 @__dfsw_k2(i64 signext, i64 signext, i8 zeroext, i8 zeroext, ptr)
+; CHECK: declare zeroext i16 @__dfsw_k4(i64 signext, i64 signext, i64 signext, i64 signext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, ptr)
```
The i64 signext attributes were part of the declaration in the input file.
I also get an error with compiler-rt / DataFlowSanitizer-s390x :: trace-cmp.c:
```
./build/./bin/clang -fsanitize=dataflow -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -mbackchain -fsanitize-coverage=trace-pc-guard,pc-table,func,trace-cmp ./compiler-rt/test/dfsan/trace-cmp.c -o ./build/runtimes/runtimes-bins/compiler-rt/test/dfsan/S390XConfig/Output/trace-cmp.c.tmp
# | ERROR: Missing extension attribute of passed value in call to function:
# | Callee: void @__dfsw___sanitizer_cov_trace_const_cmp4(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
# | Caller: signext i32 @main(i32 signext, ptr)
```
It seems here that the callee is declared with zeroext attributes that the CustomCI did not get without this.
https://github.com/llvm/llvm-project/pull/225443
More information about the llvm-commits
mailing list