Skip to content

Silence illegal address computation warning #83244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

MartinWehking
Copy link
Contributor

Add an assertion before an access of ValMappings to ensure that it is within the array bounds.
Silence a static analyzer warning through this.

Add an assertion before an access of ValMappings to ensure that
it is within the array bounds.
Silence a static analyzer warning through this.
@MartinWehking MartinWehking marked this pull request as ready for review February 28, 2024 12:40
@llvmbot
Copy link
Member

llvmbot commented Feb 28, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Martin Wehking (MartinWehking)

Changes

Add an assertion before an access of ValMappings to ensure that it is within the array bounds.
Silence a static analyzer warning through this.


Full diff: https://github.com/llvm/llvm-project/pull/83244.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def (+1)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def b/llvm/lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def
index d6a94c972340ea..e7b3afc91d6520 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def
+++ b/llvm/lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def
@@ -284,6 +284,7 @@ const RegisterBankInfo::ValueMapping *getValueMapping(unsigned BankID,
     break;
   }
 
+  assert(Idx < sizeof(ValMappings) / sizeof(ValMappings[0]));
   assert(Log2_32_Ceil(Size) == Log2_32_Ceil(ValMappings[Idx].BreakDown->Length));
   assert(BankID == ValMappings[Idx].BreakDown->RegBank->getID());
 

@arsenm arsenm merged commit 92fe6c6 into llvm:main Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants