[llvm] 75c7019 - [amdgpu] Fix broken error detection in LDS lowering
Jon Chesterfield via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 05:43:05 PDT 2023
Author: Jon Chesterfield
Date: 2023-03-30T13:42:38+01:00
New Revision: 75c7019b7ea4a846575337fa5cf4f1780a2d5b74
URL: https://github.com/llvm/llvm-project/commit/75c7019b7ea4a846575337fa5cf4f1780a2d5b74
DIFF: https://github.com/llvm/llvm-project/commit/75c7019b7ea4a846575337fa5cf4f1780a2d5b74.diff
LOG: [amdgpu] Fix broken error detection in LDS lowering
std::optional<uint32_t> can be compared to uint32_t without warning, but does
not compare to the value within the optional. It needs to be prefixed *.
Wconversion does not warn about this.
```
bool bug(uint32_t Offset, std::optional<uint32_t> Expect)
{
return (Offset != Expect);
}
bool deref(uint32_t Offset, std::optional<uint32_t> Expect)
{
return (Offset != *Expect);
}
```
Both compile without warnings. Wrote the former, intended the latter.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D146775
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
index e70afd72462e..6c6cc0127a2b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
@@ -135,7 +135,7 @@ void AMDGPUMachineFunction::allocateKnownAddressLDSGlobal(const Function &F) {
if (GV && !canElideModuleLDS(F)) {
unsigned Offset = allocateLDSGlobal(M->getDataLayout(), *GV, Align());
std::optional<uint32_t> Expect = getLDSAbsoluteAddress(*GV);
- if (!Expect || (Offset != Expect)) {
+ if (!Expect || (Offset != *Expect)) {
report_fatal_error("Inconsistent metadata on module LDS variable");
}
}
@@ -145,7 +145,7 @@ void AMDGPUMachineFunction::allocateKnownAddressLDSGlobal(const Function &F) {
// before any other non-module LDS variables.
unsigned Offset = allocateLDSGlobal(M->getDataLayout(), *KV, Align());
std::optional<uint32_t> Expect = getLDSAbsoluteAddress(*KV);
- if (!Expect || (Offset != Expect)) {
+ if (!Expect || (Offset != *Expect)) {
report_fatal_error("Inconsistent metadata on kernel LDS variable");
}
}
More information about the llvm-commits
mailing list