[lld] de15d36 - [NFC][ELF][Hexagon] Avoid pointless ArrayRef::drop_front

Jessica Clarke via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 3 13:30:23 PDT 2025


Author: Jessica Clarke
Date: 2025-08-03T21:30:17+01:00
New Revision: de15d365743e16848a9d15fc32ae6ab98d399ec2

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

LOG: [NFC][ELF][Hexagon] Avoid pointless ArrayRef::drop_front

Fixes: b42f96bc057f ("[lld] Add thunks for hexagon (#111217)")

Added: 
    

Modified: 
    lld/ELF/Relocations.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index db3a66ced2f8c..cc59070d61230 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -2152,9 +2152,8 @@ static int getHexagonPacketOffset(const InputSection &isec,
     if (i == 3 || rel.offset < (i + 1) * 4)
       return i * 4;
     uint32_t instWord = 0;
-    const ArrayRef<uint8_t> instWordContents =
-        data.drop_front(rel.offset - (i + 1) * 4);
-    memcpy(&instWord, instWordContents.data(), sizeof(instWord));
+    memcpy(&instWord, data.data() + (rel.offset - (i + 1) * 4),
+           sizeof(instWord));
     if (((instWord & HEXAGON_MASK_END_PACKET) == HEXAGON_END_OF_PACKET) ||
         ((instWord & HEXAGON_MASK_END_PACKET) == HEXAGON_END_OF_DUPLEX))
       return i * 4;


        


More information about the llvm-commits mailing list