[llvm] [DataFlowSanitizer] Properly add ext attributes on arguments as needed. (PR #225443)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 10:46:20 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()?).
----------------
efriedma-quic wrote:

Spent a bit more time reading the code.

I guess setting attributes like this actually makes sense, sort of.  getCustomFunctionType adds arguments to the function, and those arguments need attributes.

Probably getCustomFunctionType itself should be computing the attributes, instead of trying to figure out the attributes later.  It's really hard to follow what parameters are supposed to have which attributes.  If we do it at the point where we know what each parameter means, it should be simpler: we know we're adding a PrimitiveShadowTy argument, so we can add the corresponding attribute.

https://github.com/llvm/llvm-project/pull/225443


More information about the llvm-commits mailing list