[PATCH] D97896: [Clang][RISCV][RFC] Add byval parameter attribute?

Luís Marques via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 3 17:24:06 PST 2021


luismarques created this revision.
luismarques added reviewers: asb, mundaym.
Herald added subscribers: vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
luismarques requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97896

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97896.327961.patch
Type: text/x-patch
Size: 14025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210304/29fd6118/attachment-0001.bin>


More information about the cfe-commits mailing list