Fangrui Song
bb03cdcb44
RISCV: Remove shouldForceRelocation and unneeded relocations
...
Follow-up to #140494
`shouldForceRelocation` is conservative and produces redundant
relocations.
For example, RISCVAsmBackend::ForceRelocs (introduced to support mixed
relax/norelax code) leads to redundant relocations in the following
example adapted from #77436
```
.option norelax
j label
// For assembly input, RISCVAsmParser::ParseInstruction sets ForceRelocs (https://reviews.llvm.org/D46423 ).
// For direct object emission, RISCVELFStreamer sets ForceRelocs (#77436 )
.option relax
call foo // linker-relaxable
.option norelax
j label // redundant relocation due to ForceRelocs
.option relax
label:
```
Root problem: The `isSymbolRefDifferenceFullyResolvedImpl` condition in
MCAssembler::evaluateFixup does not check whether two locations are
separated by a fragment whose size can be indeterminate due to linker
instruction (e.g. MCDataFragment with relaxation, or MCAlignFragment
due to indeterminate start offst).
This patch
* Updates the fragment walk code in
`attemptToFoldSymbolOffsetDifference` to treat MCRelaxableFragment
(for --riscv-asm-relax-branches) as fixed size after finishLayout.
* Adds a condition in `addReloc` to complement
`isSymbolRefDifferenceFullyResolvedImpl`.
* Removes the no longer needed `shouldForceRelocation`.
This fragment walk code path handles nicely handles
mixed relax/norelax case from
https://discourse.llvm.org/t/possible-problem-related-to-subtarget-usage/75283
and allows us to remove `MCSubtargetInfo` argument (#73721 ) as a follow-up.
This fragment walk code should be avoided in the absence of
linker-relaxable fragments within the current section.
Adjust two bolt/test/RISCV tests (#141310 )
Pull Request: https://github.com/llvm/llvm-project/pull/140692
2025-05-23 18:44:15 -07:00
..
2025-05-19 15:49:41 -07:00
2025-05-23 13:56:49 -07:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2025-01-07 13:33:22 -03:00
2025-01-06 19:23:21 +08:00
2025-04-08 19:42:43 -07:00
2025-05-13 09:12:24 +02:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2024-11-06 00:20:21 +03:00
2024-11-25 18:59:31 -08:00
2025-02-13 09:57:33 -08:00
2024-03-31 22:19:33 -07:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2024-02-05 14:30:10 -08:00
2024-12-12 07:58:36 +01:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2024-07-09 10:45:56 -07:00
2024-12-17 00:19:45 -08:00
2025-04-28 08:35:51 -07:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2024-06-21 11:11:10 +08:00
2025-05-21 08:26:35 -07:00
2025-05-23 00:27:04 +08:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2025-03-27 19:31:38 -03:00
2025-03-07 09:23:50 +08:00
2024-11-15 17:53:14 +08:00
2024-07-09 14:34:03 +08:00
2024-07-09 14:34:03 +08:00
2024-07-09 14:34:03 +08:00
2025-02-13 09:57:33 -08:00
2024-09-03 16:04:51 -07:00
2024-09-03 16:04:51 -07:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-05-06 11:13:05 +01:00
2025-02-13 09:57:33 -08:00
2025-03-27 19:31:38 -03:00
2025-02-13 09:57:33 -08:00
2024-02-15 16:34:40 -08:00
2024-11-12 09:35:16 -08:00
2025-05-09 08:41:14 -07:00
2024-11-12 09:35:16 -08:00
2024-11-15 17:53:14 +08:00
2025-03-06 13:02:17 +08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-04-23 17:36:00 -07:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2024-10-11 20:25:53 +01:00
2025-02-13 09:57:33 -08:00
2024-06-20 07:27:07 +02:00
2024-02-23 15:44:57 -08:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2024-04-05 12:39:39 -07:00
2025-04-08 19:34:03 -07:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-11-28 15:01:49 +08:00
2024-02-05 14:07:09 +01:00
2024-02-05 14:07:09 +01:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-05-16 09:40:11 +08:00
2025-05-16 09:40:11 +08:00
2025-01-28 21:03:12 +05:30
2025-04-22 17:14:25 +01:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2024-03-20 08:44:24 -07:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2025-03-27 19:31:38 -03:00
2025-05-15 08:35:43 -07:00
2024-10-11 20:25:53 +01:00
2025-05-15 08:35:43 -07:00
2025-02-13 09:57:33 -08:00
2024-03-20 08:44:24 -07:00
2025-05-15 08:35:43 -07:00
2024-11-27 10:24:34 -08:00
2025-03-06 13:01:58 +08:00
2024-03-20 08:44:24 -07:00
2025-03-17 16:39:51 +08:00
2025-05-15 08:35:43 -07:00
2025-05-15 08:35:43 -07:00
2025-05-15 08:35:43 -07:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-03-20 08:44:24 -07:00
2025-02-13 09:57:33 -08:00
2024-12-04 13:52:20 -08:00
2025-04-08 10:11:20 -07:00
2025-03-28 07:06:17 -07:00
2024-11-06 00:20:21 +03:00
2025-04-14 14:48:47 +08:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-10-11 20:25:53 +01:00
2025-02-13 09:57:33 -08:00
2025-05-21 08:26:35 -07:00
2024-12-06 14:07:27 -05:00
2024-04-26 08:30:27 -07:00
2024-02-05 14:07:09 +01:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2025-03-27 19:31:38 -03:00
2024-08-08 17:33:54 -07:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-10-01 22:09:27 -07:00
2024-10-01 22:09:27 -07:00
2024-11-27 10:24:34 -08:00
2025-03-06 13:01:58 +08:00
2024-11-09 10:02:06 +00:00
2024-11-15 17:53:14 +08:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-02-01 22:10:52 +08:00
2024-12-04 13:52:20 -08:00
2025-05-19 17:07:57 -07:00
2025-05-19 14:14:47 -07:00
2024-07-05 10:55:36 +08:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2025-04-22 19:24:29 -07:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-05-19 23:13:08 +02:00
2024-11-06 00:20:21 +03:00
2024-10-11 20:25:53 +01:00
2025-03-27 07:45:42 -07:00
2025-04-11 15:07:51 +03:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2024-12-11 16:06:49 +00:00
2024-12-11 16:06:49 +00:00
2024-12-11 16:06:49 +00:00
2024-12-11 16:06:49 +00:00
2024-12-11 16:06:49 +00:00
2025-03-17 12:51:39 +08:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2025-03-27 19:31:38 -03:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-09-26 22:56:12 -07:00
2025-03-06 13:01:58 +08:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-09-03 16:04:51 -07:00
2024-12-04 13:52:20 -08:00
2024-10-11 20:25:53 +01:00
2025-04-08 19:34:03 -07:00
2025-05-13 07:46:16 +05:30
2025-02-13 09:57:33 -08:00
2025-03-25 07:59:44 -07:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-04-29 08:12:32 -07:00
2024-08-26 13:30:23 +03:00
2024-11-06 00:20:21 +03:00
2024-02-01 10:18:42 -08:00
2024-02-01 10:18:42 -08:00
2024-12-06 00:48:05 +08:00
2024-09-30 23:52:35 -07:00
2024-10-18 18:17:23 -07:00
2024-11-06 00:20:21 +03:00
2024-10-18 10:40:38 +01:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-05-06 18:01:17 -07:00
2024-11-15 17:53:14 +08:00
2025-05-09 08:40:27 -07:00
2025-03-26 18:25:59 -07:00
2025-03-28 19:23:56 +00:00
2025-02-04 10:02:42 -03:00
2025-01-31 14:05:34 -08:00
2025-01-31 14:05:34 -08:00
2025-01-08 16:19:31 -08:00
2025-01-28 21:03:12 +05:30
2025-04-08 19:42:43 -07:00
2024-11-15 17:53:14 +08:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2025-01-28 21:03:12 +05:30
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-02-17 11:37:13 -08:00
2025-03-07 09:21:36 +01:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2025-03-04 11:36:16 -08:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2025-03-10 13:22:59 +00:00
2025-05-08 12:33:14 +01:00
2025-02-21 12:53:13 +05:30
2024-11-26 23:39:45 +08:00
2024-11-26 23:39:45 +08:00
2024-11-26 23:39:45 +08:00
2024-11-26 23:39:45 +08:00
2024-11-26 23:39:45 +08:00
2024-12-19 13:00:08 +08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-09-11 09:53:11 -07:00
2024-11-26 23:39:45 +08:00
2024-11-26 23:39:45 +08:00
2025-03-03 15:49:37 +05:30
2025-02-13 09:57:33 -08:00
2024-02-05 14:07:09 +01:00
2024-09-26 22:56:12 -07:00
2024-09-16 12:51:07 -07:00
2024-10-01 22:09:27 -07:00
2025-05-23 11:37:42 -07:00
2024-02-22 15:51:19 +08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-04-16 15:40:32 -07:00
2025-01-13 12:06:26 +08:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-10-11 20:25:53 +01:00
2024-11-15 17:53:14 +08:00
2025-02-12 18:54:39 +05:30
2025-04-22 17:36:41 -04:00
2024-07-09 10:45:56 -07:00
2025-05-16 09:40:11 +08:00
2025-05-16 09:40:11 +08:00
2024-10-18 09:35:42 +04:00
2025-02-13 09:57:33 -08:00
2024-11-06 00:20:21 +03:00
2025-05-14 11:48:59 +08:00
2025-03-14 13:11:45 +01:00
2025-03-27 19:31:38 -03:00
2025-01-31 15:19:44 -08:00
2025-03-26 11:14:16 -07:00
2025-05-23 18:44:15 -07:00
2025-02-25 10:04:57 -08:00
2025-02-13 09:57:33 -08:00
2024-10-04 12:22:11 +03:00
2025-03-28 19:23:56 +00:00
2025-04-08 19:42:43 -07:00
2025-04-10 11:29:14 -04:00
2025-02-08 16:25:27 -08:00
2025-02-13 09:57:33 -08:00
2024-04-16 15:40:32 -07:00
2025-04-24 10:13:05 +03:00
2024-11-06 00:20:21 +03:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-03-20 08:44:24 -07:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2025-03-26 18:25:59 -07:00
2024-02-01 13:25:15 -08:00
2024-03-07 15:03:51 -08:00
2024-12-19 21:38:20 +01:00
2024-11-06 00:20:21 +03:00
2024-05-01 06:51:36 +08:00
2024-05-22 00:48:26 +08:00
2024-05-15 12:39:28 -07:00
2024-06-02 10:34:48 +01:00
2024-07-29 17:15:02 -07:00
2025-04-24 10:13:05 +03:00
2024-10-31 16:40:29 +00:00
2024-07-03 20:32:46 +08:00
2024-09-27 13:48:01 -07:00
2025-04-23 08:54:10 +03:00
2025-04-18 09:12:52 -07:00
2024-04-16 15:37:31 +08:00
2024-04-16 15:37:31 +08:00
2024-02-05 14:07:09 +01:00
2024-11-06 00:20:21 +03:00
2025-03-19 11:09:49 -07:00
2025-04-23 17:36:00 -07:00
2025-03-06 13:31:08 -08:00
2025-04-28 08:12:45 -07:00
2025-02-04 10:04:19 -05:00
2024-02-21 13:12:14 +08:00
2025-03-31 10:02:12 -04:00
2024-10-01 13:45:30 +01:00
2025-03-18 08:25:49 -07:00
2025-03-28 07:06:17 -07:00
2025-04-08 10:11:20 -07:00
2025-03-28 19:23:56 +00:00
2024-08-27 10:08:43 +08:00
2025-05-12 13:34:46 +08:00
2024-08-15 10:37:04 +08:00
2025-04-28 10:07:51 +08:00
2025-04-28 10:07:51 +08:00
2024-04-16 15:40:32 -07:00
2024-08-01 12:24:25 +08:00
2025-05-16 14:20:53 +08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-03-07 10:52:04 +08:00
2025-05-19 09:26:46 +08:00
2025-05-10 11:16:39 +08:00
2025-04-29 22:33:40 +03:00
2025-05-12 10:41:53 +08:00
2025-03-19 06:06:13 +01:00
2025-05-17 12:18:52 +02:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-04-08 16:40:02 +08:00
2024-11-06 11:36:30 -08:00
2025-02-13 09:57:33 -08:00
2024-12-02 09:06:08 -08:00
2024-12-02 09:06:08 -08:00
2024-12-02 09:06:08 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-11-06 00:20:21 +03:00
2024-12-11 17:41:19 +08:00
2024-02-05 14:07:09 +01:00
2024-11-06 00:20:21 +03:00
2024-02-05 14:07:09 +01:00
2024-04-11 12:19:56 +08:00
2024-04-11 12:19:56 +08:00
2024-11-06 00:20:21 +03:00
2025-02-13 09:57:33 -08:00
2024-03-28 21:22:05 -07:00
2024-11-05 21:48:38 -08:00
2024-11-05 21:12:09 -08:00
2024-11-05 21:48:38 -08:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2024-11-25 18:59:31 -08:00
2025-05-19 09:26:46 +08:00
2025-05-10 11:16:39 +08:00
2025-05-16 09:40:11 +08:00
2025-05-19 15:49:41 -07:00
2024-11-15 17:53:14 +08:00
2025-03-19 06:06:13 +01:00
2025-05-17 12:18:52 +02:00
2025-03-28 19:23:56 +00:00
2024-10-04 16:03:09 +08:00
2024-08-14 15:18:10 -07:00
2024-09-03 13:33:14 -07:00
2024-09-03 13:33:14 -07:00
2024-04-08 16:40:02 +08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2024-08-23 14:06:12 +01:00
2025-04-15 23:17:03 +02:00
2025-04-15 23:17:03 +02:00
2024-11-15 17:53:14 +08:00
2025-04-15 23:17:03 +02:00
2025-02-25 10:04:57 -08:00
2025-04-02 09:56:09 -07:00
2025-02-13 09:57:33 -08:00
2024-06-04 09:23:52 +08:00
2025-04-15 23:17:03 +02:00
2025-02-25 10:04:57 -08:00
2025-04-22 09:13:11 +08:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2025-04-24 10:13:05 +03:00
2024-11-08 00:16:45 +08:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2025-01-31 14:05:34 -08:00
2024-11-27 11:14:51 -08:00
2024-12-12 11:24:07 +08:00
2025-04-25 17:12:27 -07:00
2025-04-28 19:35:11 -07:00
2024-02-13 09:57:48 -08:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2024-07-17 13:06:58 -07:00
2024-03-21 08:52:51 -07:00
2024-05-08 11:33:05 +08:00
2025-02-19 12:11:00 -08:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2025-05-16 09:40:11 +08:00
2025-02-13 09:57:33 -08:00
2024-03-11 13:57:06 +08:00
2024-11-15 17:53:14 +08:00
2024-02-04 23:15:58 -08:00
2024-12-10 12:37:45 -08:00
2025-01-16 11:58:42 -08:00
2024-10-02 16:33:31 -07:00
2024-10-02 16:33:31 -07:00
2025-01-28 21:03:12 +05:30
2025-05-16 05:47:04 +05:30
2024-05-13 08:52:59 -07:00
2024-11-06 00:20:21 +03:00
2024-11-06 00:20:21 +03:00
2025-03-06 09:28:44 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2024-01-23 16:16:07 -08:00
2024-03-20 13:39:39 -07:00
2024-11-15 17:53:14 +08:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2024-11-15 17:53:14 +08:00
2025-05-16 09:40:11 +08:00
2025-02-13 09:57:33 -08:00
2025-03-28 19:23:56 +00:00
2024-11-15 17:53:14 +08:00
2025-02-13 09:57:33 -08:00
2024-11-06 19:30:32 +03:00
2024-12-04 13:40:02 +08:00
2024-07-15 12:42:44 +08:00
2024-11-06 00:20:21 +03:00
2024-08-28 12:48:20 +01:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-02-13 09:57:33 -08:00
2025-05-06 09:57:07 +08:00
2024-11-06 00:20:21 +03:00
2024-07-15 10:25:25 +10:00
2024-12-31 10:56:28 +08:00
2025-04-07 23:45:54 +07:00
2025-03-05 10:59:45 -08:00
2025-05-16 09:40:11 +08:00
2025-04-23 17:36:00 -07:00
2025-03-05 10:59:45 -08:00
2025-03-05 10:59:45 -08:00
2025-04-23 17:36:00 -07:00
2025-04-23 17:36:00 -07:00
2025-04-22 15:40:03 +05:30
2025-05-22 08:57:26 +05:30
2025-05-16 12:49:14 +05:30
2025-04-16 06:48:56 +05:30
2025-04-16 11:19:13 +05:30
2025-04-16 13:10:56 +05:30
2024-12-10 17:57:04 -08:00
2024-02-05 14:07:09 +01:00
2024-11-15 17:53:14 +08:00
2025-02-19 12:11:00 -08:00
2025-02-13 09:57:33 -08:00
2025-04-23 14:47:42 -07:00
2025-04-07 20:47:21 +02:00
2025-03-28 19:23:56 +00:00
2025-03-28 19:23:56 +00:00
2025-05-16 09:40:11 +08:00
2025-03-05 10:59:45 -08:00
2025-01-28 21:03:12 +05:30
2024-11-06 00:20:21 +03:00
2025-04-23 17:36:00 -07:00
2025-02-13 09:57:33 -08:00
2025-05-15 08:35:43 -07:00
2025-05-14 12:35:49 -07:00
2025-05-15 08:35:43 -07:00
2025-05-15 08:34:18 -07:00
2025-04-21 11:02:04 +08:00
2024-11-25 16:12:45 -08:00
2024-11-25 16:12:45 -08:00
2024-09-01 12:15:00 -07:00
2024-05-02 10:32:40 +08:00
2025-05-14 09:54:07 -07:00