[llvm] 1025189 - [JITLink][AArch32] Don't adjust Thumb bit in fixup code; it doesn't contribute to branch ranges

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 09:59:39 PDT 2023


Author: Stefan Gränitz
Date: 2023-09-13T18:59:07+02:00
New Revision: 1025189ea0bfc6a3a387a8753300366b95db07b3

URL: https://github.com/llvm/llvm-project/commit/1025189ea0bfc6a3a387a8753300366b95db07b3
DIFF: https://github.com/llvm/llvm-project/commit/1025189ea0bfc6a3a387a8753300366b95db07b3.diff

LOG: [JITLink][AArch32] Don't adjust Thumb bit in fixup code; it doesn't contribute to branch ranges

We don't have to set or clear the Thumb bit in relocation fixup values.
It's not part of the branch range and the respective encoding functions
like encodeImmBT4BlT1BlxT2() shift out the least significant bit anyway.

This was a leftover from the initial patch before we switched to store
Thumb state in target-flags with D146641.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/aarch32.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index ef278e39982c06a..b5ed00878cbcfaa 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -400,8 +400,6 @@ Error applyFixupArm(LinkGraph &G, Block &B, const Edge &E) {
   int64_t Addend = E.getAddend();
   Symbol &TargetSymbol = E.getTarget();
   uint64_t TargetAddress = TargetSymbol.getAddress().getValue();
-  if (hasTargetFlags(TargetSymbol, ThumbSymbol))
-    TargetAddress |= 0x01;
 
   switch (Kind) {
   case Arm_Jump24: {
@@ -437,11 +435,9 @@ Error applyFixupArm(LinkGraph &G, Block &B, const Edge &E) {
     bool InstrIsBlx = (~R.Wd & FixupInfo<Arm_Call>::BitBlx) == 0;
     if (TargetIsThumb != InstrIsBlx) {
       if (LLVM_LIKELY(TargetIsThumb)) {
-        // Change opcode BL -> BLX and fix range value
+        // Change opcode BL -> BLX
         R.Wd = R.Wd | FixupInfo<Arm_Call>::BitBlx;
         R.Wd = R.Wd & ~FixupInfo<Arm_Call>::BitH;
-        // Set Thumb bit
-        Value |= 0x01;
       } else {
         // Change opcode BLX -> BL
         R.Wd = R.Wd & ~FixupInfo<Arm_Call>::BitBlx;
@@ -473,8 +469,6 @@ Error applyFixupThumb(LinkGraph &G, Block &B, const Edge &E,
   int64_t Addend = E.getAddend();
   Symbol &TargetSymbol = E.getTarget();
   uint64_t TargetAddress = TargetSymbol.getAddress().getValue();
-  if (hasTargetFlags(TargetSymbol, ThumbSymbol))
-    TargetAddress |= 0x01;
 
   switch (Kind) {
   case Thumb_Jump24: {
@@ -511,16 +505,14 @@ Error applyFixupThumb(LinkGraph &G, Block &B, const Edge &E,
     bool InstrIsBlx = (R.Lo & FixupInfo<Thumb_Call>::LoBitNoBlx) == 0;
     if (TargetIsArm != InstrIsBlx) {
       if (LLVM_LIKELY(TargetIsArm)) {
-        // Change opcode BL -> BLX and fix range value (account for 4-byte
+        // Change opcode BL -> BLX and fix range value: account for 4-byte
         // aligned destination while instruction may only be 2-byte aligned
-        // and clear Thumb bit).
         R.Lo = R.Lo & ~FixupInfo<Thumb_Call>::LoBitNoBlx;
         R.Lo = R.Lo & ~FixupInfo<Thumb_Call>::LoBitH;
         Value = alignTo(Value, 4);
       } else {
-        // Change opcode BLX -> BL and set Thumb bit
+        // Change opcode BLX -> BL
         R.Lo = R.Lo & ~FixupInfo<Thumb_Call>::LoBitNoBlx;
-        Value |= 0x01;
       }
     }
 


        


More information about the llvm-commits mailing list