<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117701>117701</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] __builtin_readcyclecounter generated privileged rdcycle instruction
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
grooverdan
</td>
</tr>
</table>
<pre>
__builtin_readcyclecounter was a great abstraction. But then ARM made it privileged #43652, and RISCV made I privileged in Linux 6.6.
In a clang compiled project that isn't kernel or privileged level we are calving out exceptions on not using like `__builtin_readcyclecounter` and going back to assembly like:
* https://github.com/MariaDB/server/pull/1620
* https://github.com/MariaDB/server/pull/2980
* https://github.com/MariaDB/server/pull/1635
There's a documentation bug #39723 to improve this.
FEATURE REQUEST: Create a "--{no-,}privileged" compile option for those developers doing normal userspace things that doesn't generate the instructions that are prevented in kernels.
Or am I going to be adding another MIPS exception when #106318 gets merged?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklEtvpDgQxz-NuZS6ZZsGug8cOg-kljba3SSz18jYFfDG2MgPMvn2K0NHyWXnMieEXO_fv0qEoAeL2JLqhlR3hUhxdL4dvHMLeiVs0Tv10b689EmbqO2LR6HkhzQoXbIRPbyLAAIGjyKC6EP0Qkbt7B5uUoQ4ooXz4wNMQiHoCLPXizY4oALCy0NZV5zwWxBWwePl6fafzfDy3U5b-EPb9BPqfb0n9Ezo-WJBgDTCDiDdNGuDCmbv_kWZU4oIOljCmwhv6C0acP57QIMLGnhHEB5BCrNoO4BLEfCnxDkXH8BZsC5CCvkNjH5DIDX9_zGQmq5NDC479EK-QXQgQsCpNx9rAFLm0gk_wxjjHPIv7wjvBh3H1O-lmwjvHoTX4u6G8C6gX9AT3s3JGMI7VnP6O_78dPwtf1aX1Tb95xE9Et5k7srJNKGNIo8N-jRkrOWp4WXuX0-zdwtCHHW4ouvuz88_Hu_h8f7vH_dPz6Q8A9xm8SAIIJzvdqS5sW5H-C1p7r6oEc4_WYNbIcGr8xBHFxBUJupm9AHUCsA6PwkDKaAPs5BrBXYImziUw6s8BrToc-o4Imgbok9y478aZn3MHhe0cdPhJqfPVv70ICa4XJlHBz2CUCr_COviiB4eLn89fckK3vM6EF4yWpfsCAPGABP63F7ZFaot1ak8iQJb1pS8ZqfqdCjGlh972hwlraumpIr1VDB5PNJjXVWvqqFNoVtO-YExXjPGSnbYn7B6LY-NFAcq6WulyIHiJLTZG7NMe-eHQoeQsGWsaSgrjOjRhPUEcG7xHdZXwnm-CL7NTrs-DYEcqNEhhq8wUUez3o51eUl1B7-4FJ_TVt-X0W8236dfJG_aX2g0Z79-dtetJ7xbaw5ZqFtTS8v_CwAA__8uEZz3">