diff options
| author | Jon Chesterfield <jonathanchesterfield@gmail.com> | 2023-03-30 13:42:37 +0100 |
|---|---|---|
| committer | Jon Chesterfield <jonathanchesterfield@gmail.com> | 2023-03-30 13:42:38 +0100 |
| commit | 75c7019b7ea4a846575337fa5cf4f1780a2d5b74 (patch) | |
| tree | 029642d3991ede97b1318907d54ae274d7109a3a /llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp | |
| parent | 273cbb58e5e272d265a247234555a42526ee5e9a (diff) | |
[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
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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"); } } |
