Commit graph

29 commits

Author SHA1 Message Date
Pirama Arumuga Nainar
950e8c97fe [cc:riscv64] Do not pass -mno-strict-align while linking
Bug: http://b/327307773

Newer clang rejects this flag as unsupported.  It is not necessary while linking because the flag is passed as an IR feature.

Change-Id: I781afd913be7c07612196e736c3ae58773791071
2024-03-20 17:25:20 +00:00
Elliott Hughes
b48fb83936 Defer to clang for --hash-style.
We fixed the clang driver to "do the right thing" based on target api level years ago, but these manual workarounds predate that (or were copy & pasted from places that predated that). We don't need them any more.

See https://github.com/android/ndk/issues/2005 for more detail.

Change-Id: I995741b8606e389e8de8272f1cc532624516245a
2024-03-20 14:50:26 +00:00
Pirama Arumuga Nainar
0593537f58 [cc:riscv64] change -munaligned-access to -mno-strict-align
Bug: http://b/327307773

cd071253c7 removed -munaligned-access

Change-Id: I7a102fa1cdc49564cb0b724e6f177d33b3636f55
Test: presubmit
2024-03-19 16:28:31 +00:00
Elliott Hughes
c2600464c7 Fully document all the riscv64 flags.
In particular, make it clearer when/how we can remove each of them.

Change-Id: Ic3156e53ea56479324781fea737390588bc086b5
2024-03-18 19:37:13 +00:00
AdityaK
2c90a92d77 Update unaligned-vector-mem to -munaligned-access
Latest compiler has merged both unaligned access flags into one.

TODO:  This is needed until we change clang driver to enable -munaligned access by default.for Android b/327307773

Bug: 326790418
Change-Id: Ia8c29dc56104d2cffb8ac41aae6eeacccae68e61
2024-02-28 06:14:57 +00:00
Elliott Hughes
6c93f6953f Really disable auto-vectorization.
The previous patch was insufficient. Craig Topper explains:

  -fno-vectorize only disables the loop vectorizer

  -fno-slp-vectorize only disables the SLP vectorizer

  The backend can also use vector instructions for memcpy/memset or
  combining multiple scalar loads and/or stores. That is independent
  of -fno-vectorize.

  -mllvm -vector-bits-min=0 will disable any use of fixed vectors. And
  will make attribute(vector_size) get scalarized.

  -mno-implicit-float will disable both vectorizers and
  prevent the backend for using vectors for memcpy/memset
  oor multiple scalar loads/stores. It will not affect
  attribute(vector_size). -mno-implicit-float also prevents scalar
  floating point instructions from being used for anything that didn’t
  use float/double/_Float16/etc. type in source, but I don’t think that
  happens on RISC-V today. 32-bit X86 can use a 64-bit x87 FP load as an
  atomic load for uint64_t, for example. Basically -mno-implicit-float
  is supposed to prevent the compiler from using FP or vectors when the
  source doesn’t explicitly use FP or vectors.

So -mno-implicit-float was what we were actually looking for here. I've
done a clean build with this change, and see only the expected
(hand-written assembler) vector code in bionic, and the ART
ClassLinker::LoadClass() issue is gone too. As far as I can tell, the
remaining vector code is all deliberate in that sense.

We may still end up back here again, to change "gcv" to "gc", but that
still requires some code changes just to build, and still makes it less
obvious that this is just a temporary workaround for a qemu bug
(specifically https://gitlab.com/qemu-project/qemu/-/issues/1976).

Bug: http://b/320416684
Test: objdump
Change-Id: Ibd104e4289d6d1aaf441efa0440fedc90e3da29a
2024-01-22 15:00:21 -08:00
Pirama Arumuga Nainar
5376892762 [riscv64] disable vectorizer during LTO
With LTO, vectorization needs to be disabled separately in the linker flags as well.

Change-Id: I71d813974a9b7a40954d3dab5b1704baed610fd0
2024-01-19 23:02:01 +00:00
AdityaK
431c0b9c8e Pass jump-is-expensive flag both to compiler and linker
Change-Id: I89e30f98188aed4c5076a34f150e80386fc63f48
2024-01-19 07:32:59 -08:00
Elliott Hughes
c0ea850bfb Disable auto-vectorization.
Until https://gitlab.com/qemu-project/qemu/-/issues/1976 is fixed, this
is just causing too much confusion and wasted time.

Removing V from the architecture string has the same effect, but
requires some code changes (to be able to compile code that's
_explicitly_ using V), and makes it less obvious that this is just a
temporary workaround for a qemu bug.

Bug: http://b/320416684
Test: objdump
Change-Id: Iec7d63ab227b31f82f530dabbdc4f3aa54277f04
2024-01-17 14:24:53 -08:00
Elliott Hughes
bee01f7d62 riscv64: disable a weird option.
By default clang assumes that on riscv64 jumps are really expensive.
That's probably not true for the kind of SoCs we're dealing with, but
more importantly (see the bug) it causes clang to do loads from the
right hand side of a `&&` before the left hand side has been evaluated.
This found one latent bug in libcore, and it doesn't seem like the best
use of anyone's time to have to chase similar issues if they're going
to be similarly latent for riscv64 when we get clang's default fixed.

Bug: https://github.com/google/android-riscv64/issues/124
Test: treehugger
Change-Id: I640f1b43ea3d2452366ab86e97a9189fa9f5326c
2023-12-01 17:39:20 -08:00
Elliott Hughes
74780e61dc riscv64: stop explicitly disabling emutls.
riscv64 has always had ELF TLS (and the emutls bugs have been fixed now
too).

Test: treehugger
Change-Id: I8dd1d28d4f28a442130e4cf536166ea733f16a96
2023-12-01 02:08:05 +00:00
Elliott Hughes
4b350985eb riscv64: assume fast unaligned access.
We have a CTS test for this, so we may as well let the compiler take
advantage!

Test: treehugger
Change-Id: Icb6dc73be5e6da1155f39ca03245ae6b9d24dfb5
2023-10-04 14:50:03 -07:00
Elliott Hughes
726b001ae1 Revert "Revert "riscv64: enable V.""
This reverts commit 2583523144.

Change-Id: I5b05d546e17dee497dce1bfeb9290445e1c071c2
2023-09-15 16:36:59 +00:00
Jeremy DeHaan
2583523144 Revert "riscv64: enable V."
This reverts commit aa204ec49c.

Reason for revert: b/300158981

Change-Id: I4e969c7fccade0f8e1b29cb6267c27355ddca866
2023-09-14 00:46:21 +00:00
Elliott Hughes
aa204ec49c riscv64: enable V.
Test: treehugger
Change-Id: I5bbbb22074632366c7ffa38bc437d80da692685b
2023-07-27 15:17:34 -07:00
Prashanth Swaminathan
0498912c9f Revert "Enable sext.w removal for riscv targets"
This reverts commit bce5507c02.

The update of LLVM to clang-r498229 resolved the error with sext.w as
resolved in D143594.

Bug: 275574215
Test: Verified boot of riscv64 phone target.
Change-Id: Ie31b7db03004c5aafb6067713ef5f819e0706b64
2023-07-13 17:33:12 -07:00
Elliott Hughes
121483bbbc riscv64: enable Zbs.
Cuttlefish still boots to homescreen, all instructions in the extension
are actually seen to be in use, and the bionic tests still pass.

Test: see above
Change-Id: I429729a722cdd7b3bdf257cb7329ee151ec998a0
2023-06-14 08:33:38 -07:00
Elliott Hughes
1d1d90b552 riscv64: enable Zba.
Cuttlefish still boots to homescreen, all instructions in the extension
are actually seen to be in use, and the bionic tests still pass.

Test: see above
Change-Id: I6373fa6245115b9b6c845db03ee73b321c07e02a
2023-06-13 07:27:12 -07:00
Aditya Kumar
55ceae9e61 [RISC-V] rv64gc_zbb for Android
This reverts commit cc75089229.

Reason for revert: Retry

Change-Id: I957ef442a4988046eeb9771b7ce1acaf4cb6ef8d
2023-06-07 11:19:24 -07:00
Elliott Hughes
2aff6c1132 riscv64: stop reserving x18 for shadow call stack.
We're switching from x18 to gp, in stages. This change frees up x18
again now bionic and ART have switched to gp. There's no need for a
corresponding "reserve gp" change because gp is automatically reserved.
That's what makes it the perfect choice for shadow call stack (at
least until we get Zsslpcfi and an actual hardware shadow stack pointer
special-purpose register).

Bug: https://github.com/google/android-riscv64/issues/72
Bug: http://b/277909695
Test: treehugger
Change-Id: Iaee1d44cba8daf5d4a27a3791fe3cc28ed1a5d9a
2023-04-12 14:24:44 -07:00
Prashanth Swaminathan
bce5507c02 Enable sext.w removal for riscv targets
Bug: 275574215
Test: Verified boot complete on aosp_cf_riscv64_phone target.
Change-Id: I771dbc492075eec18919b66dc74ae524e3f4b3cd
2023-03-30 20:06:50 +00:00
Alistair Delva
cc75089229 Revert "[RISC-V] rv64gc_zbb for Android"
This reverts commit 9838acffdd.

Reason for revert: b/274947458

Broke CI.
Will reland with QEMU options once the host image is fixed.

Change-Id: I6ad847cde2a291b3dd5b92314b2011744de50883
2023-03-28 20:59:36 +00:00
AdityaK
9838acffdd [RISC-V] rv64gc_zbb for Android
Change-Id: Ia6ee7899f8643e5a81a3a8125319bed11a0795da
2023-03-23 16:54:50 -07:00
Elliott Hughes
c214e1ab8a Merge "Allow SCS for riscv64 too." 2023-03-21 22:10:56 +00:00
AdityaK
f7c0afdb6e Disable emulated tls for RISCV
Bug: b/267688421

Change-Id: I885bcf966db2e9a0a3edc1fee865b3cf9c6ff90a
2023-02-13 21:31:36 +00:00
Elliott Hughes
e4793bc73f Allow SCS for riscv64 too.
Bug: https://github.com/google/android-riscv64/issues/55
Test: treehugger
Change-Id: I319fc662c1dd6083757f78b8d91ec2775ef94a46
2023-02-10 01:53:17 +00:00
Elliott Hughes
9f0c951862 Remove a flag from riscv64 that was copied from arm64.
This causes us to align the text section to 4KiB, not just the data
section. From the bug that added this for arm64, there was an admission
that it costs 17MiB across the tree, and a not entirely convincing claim
of a performance improvement (undermined by the fact that "some stuff
was faster, some stuff was slower"). See http://b/150506341 for that.

Anyway, let's assume we don't want this for riscv64 for now.

Test: `mm -j` in bionic and readelf on the resulting libtest_empty.so
Change-Id: I0ed592a97ef705175191d9c66271a599af4eb18f
2022-11-15 00:56:04 +00:00
Colin Cross
2c435a00ff Set -fno-emulated-tls for riscv64
Building for riscv64 fails with link errors on __thread variables.
Set -fno-emulated-tls to fix it.

Bug: 254713216
Test: lunch aosp_riscv64-userdebug && m ALLOW_MISSING_DEPENDENCIES=true ndk_sysroot
Change-Id: I3dca81dfd277d681b6c868a5e8385e3a37335a5f
2022-10-20 14:31:24 -07:00
Colin Cross
f05b0d35d2 Add riscv64-linux-android support
Add barebones riscv64-linux-android support.  This should be enough
to add riscv64-specific entries to Android.bp files, but can't
actually compile anything until there are riscv64 toolchains.

Test: arch_test.go
Change-Id: I0dcc7e797d9352dd38243be908a7f19004ff3db1
2022-10-03 08:43:13 -07:00