[llvm] [llubi] Add support for byval pointer arguments (PR #201852)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 03:19:38 PDT 2026


================
@@ -1826,10 +1830,61 @@ class InstExecutor : public InstVisitor<InstExecutor, void>,
     for (auto [I, Arg] : enumerate(CB.args())) {
       Type *ArgTy = Arg->getType();
       AnyValue &ArgVal = CalleeArgs[I];
+
       // CallBase::paramHasAttr also checks parameter attributes at known
       // callee. We do it explicitly to avoid duplication.
       AttributeSet AttrsAtCallSite = CB.getParamAttributes(I);
       AttributeSet AttrsAtCallee = Callee->getAttributes().getParamAttrs(I);
+
+      if (ArgTy->isPointerTy()) {
+        auto *ByValTy = AttrsAtCallSite.getByValType();
+        auto *ByValTyFromCallee = AttrsAtCallee.getByValType();
+        if (ByValTy != ByValTyFromCallee) {
+          reportImmediateUB()
+              << "Mismatched byval attribute between callee and callsite.";
+          return;
+        }
+        if (ByValTy) {
+          if (ArgVal.isPoison()) {
----------------
antoniofrighetto wrote:

There are some tests passing `null` byval in test/Transforms. Would this be UB at call-site?

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


More information about the llvm-commits mailing list