Should we add the byval parameter attribute to struct parameters?
Pros:
- Improves optimizations;
- Used by MSan instrumentation pass (without it a test will fail).
Cons:
- ?
An example of an optimization without byval and with byval:
$ cat test.c struct S { char c[32]; }; void foo(struct S s) { s.c[0] = 42; } $ clang --target=riscv64-linux -O2 -S -o- test.c
Without byval:
foo: addi a1, zero, 42 sb a1, 0(a0) ret
With byval:
foo: ret
I'm not sure what the impact would be of also adding the attribute to vector parameters, so this patch doesn't do so.