[lld] [LLD][COFF] Add support for range extension thunks for ARM64EC targets. (PR #106289)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 15:18:17 PDT 2024


================
@@ -421,25 +424,25 @@ bool Writer::isInRange(uint16_t relType, uint64_t s, uint64_t p, int margin) {
       return true;
     }
   } else {
-    llvm_unreachable("Unexpected architecture");
+    return true;
   }
 }
 
 // Return the last thunk for the given target if it is in range,
 // or create a new one.
 std::pair<Defined *, bool>
 Writer::getThunk(DenseMap<uint64_t, Defined *> &lastThunks, Defined *target,
-                 uint64_t p, uint16_t type, int margin) {
+                 uint64_t p, uint16_t type, int margin, MachineTypes machine) {
   Defined *&lastThunk = lastThunks[target->getRVA()];
-  if (lastThunk && isInRange(type, lastThunk->getRVA(), p, margin))
+  if (lastThunk && isInRange(type, lastThunk->getRVA(), p, margin, machine))
     return {lastThunk, false};
   Chunk *c;
-  switch (ctx.config.machine) {
-  case ARMNT:
+  switch (getMachineArchType(machine)) {
----------------
cjacek wrote:

Yes, that or using `if (isAnyArm64(...))`. Such `switch` statements were a common enough (with a bit confusing `ARM64X` case) that led to #87370 and followups.

https://github.com/llvm/llvm-project/pull/106289


More information about the llvm-commits mailing list