On Thu, Mar 12, 2026 at 5:51 PM Vineet Gupta <[email protected]> wrote:
>
>
> On 3/12/26 5:44 PM, H.J. Lu wrote:
> >>> Please try this enclosed patch.
> >> Awesome, it does work perfectly for the tripping tests before. I'll give
> >> it more extensive testing but this looks promising already.
> > If it works, please update the comment to explain that it is done for
> > compatibility
> > reasons.
>
> Sorry care to elaborate, comment for which part ?
> Compatibilty between gcc and llvm ? That's just the trigger,
> conceptually it is for implementing a certain ABI.
diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 4773d789d8e..6f41a9e843c 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -299,13 +299,14 @@ bpf_file_end (void)
static rtx
bpf_function_value (const_tree ret_type,
const_tree fntype_or_decl,
- bool outgoing ATTRIBUTE_UNUSED)
+ bool outgoing)
{
enum machine_mode mode;
int unsignedp;
mode = TYPE_MODE (ret_type);
- if (INTEGRAL_TYPE_P (ret_type))
+ /* NB: Treat the callee's return value as unpromoted. */
+ if (outgoing && INTEGRAL_TYPE_P (ret_type))
mode = promote_function_mode (ret_type, mode, &unsignedp,
fntype_or_decl, 1);
is needed only if callee doesn't always extend the return value. I assume
that GCC will be changed to always extend the return value in callee. If
it is incorrect, you need to avoid extending the callee return value in
TARGET_PROMOTE_FUNCTION_MODE.
> Thx,
> -Vineet
>
> >
> >> FWIW, the newly wired up default_promote_function_mode_sign_extend ()
> >> has the same semantics as updated PROMOTE_MODE so in theory we could get
> >> away with keeping bpf tgt hook to
> >> default_promote_function_mode_always_promote () but former conveys the
> >> semantics better.
> >>
> >> Thx,
> >> -Vineet
> >
> >
>
--
H.J.