[llvm] 0563725 - [NFC][AMDGPU] Guard the custom fixups kind array from invalid access

Luke Drummond via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 03:13:11 PDT 2023


Author: Georgi Mirazchiyski
Date: 2023-08-30T11:12:50+01:00
New Revision: 05637256005baef5aea2c4ea323e119e1f07ab5c

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

LOG: [NFC][AMDGPU] Guard the custom fixups kind array from invalid access

Protect from accidental passing of an invalid MCFixupKind value which
can cause an out-of-bounds access in the array.

Reviewed by: arsenm

Differential Revision: https://reviews.llvm.org/D158725

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
index 44109b9d2919b7..65efb553d9d63f 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -185,6 +185,8 @@ const MCFixupKindInfo &AMDGPUAsmBackend::getFixupKindInfo(
   if (Kind < FirstTargetFixupKind)
     return MCAsmBackend::getFixupKindInfo(Kind);
 
+  assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
+         "Invalid kind!");
   return Infos[Kind - FirstTargetFixupKind];
 }
 


        


More information about the llvm-commits mailing list