[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:03:10 PDT 2026
================
@@ -3138,6 +3167,26 @@ bool DFSanVisitor::visitWrappedCallBase(Function &F, CallBase &CB) {
if (Function *CustomFn = dyn_cast<Function>(CustomF.getCallee())) {
CustomFn->copyAttributesFrom(&F);
+ // Ensure all narrow integer arguments (both original and added
+ // shadow/origin) have an extension attribute on the function
+ // declaration. If none is present, add the right attribute for zero
+ // extend as all DFSan args are unsigned. TODO: Avoid getting here with
+ // missing attributes in the first place (use TLI/emitLibFunc()?).
----------------
JonPsson1 wrote:
This affects four of the Instrumentation/DataFlowSanitzer tests, for instance shadow-args-zext.ll:
```
< declare zeroext i16 @__dfsw_dfsan_get_label(i64 signext, i8, ptr)
---
> declare zeroext i16 @__dfsw_dfsan_get_label(i64 signext, i8 zeroext, ptr)
128c128
< declare zeroext i16 @__dfsw_k2(i64 signext, i64 signext, i8, i8, ptr)
---
> declare zeroext i16 @__dfsw_k2(i64 signext, i64 signext, i8 zeroext, i8 zeroext, ptr)
130c130
< declare zeroext i16 @__dfsw_k4(i64 signext, i64 signext, i64 signext, i64 signext, i8, i8, i8, i8, ptr)
---
> declare zeroext i16 @__dfsw_k4(i64 signext, i64 signext, i64 signext, i64 signext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, ptr)
```
Not sure exactly how to improve on this - one idea is to try what @nikic suggested previously and try to model these calls in a better way with emitLimFunc() / tablegen, but not familiar at all with the details here. I am not sure why the instrumented functions are first declared and then modified, for instance. Nevertheless, my aim at this point is to at get the verification step of args extensions enabled for clang by default, so I would think a major refactoring would have to wait a while.
https://github.com/llvm/llvm-project/pull/225443
More information about the llvm-commits
mailing list