Skip to content

Commit

Permalink
[Libomptarget][NFC] Remove use of VLA in the AMDGPU plugin (#69761)
Browse files Browse the repository at this point in the history
Summary:
We should not rely on a VLA in C++ for the handling of this string. The
size is a true runtime value so we cannot rely on constexpr handling. We
simply use a small vector, whose default size is most likely large
enough to handle whatever size gets output within the stack, but is safe
in cases where it is not.
  • Loading branch information
jhuber6 authored Oct 20, 2023
1 parent 1d4601a commit 34a3fb9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2869,15 +2869,14 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
if (Status != HSA_STATUS_SUCCESS)
return Status;

// TODO: This is not allowed by the standard.
char ISAName[Length];
Status = hsa_isa_get_info_alt(ISA, HSA_ISA_INFO_NAME, ISAName);
llvm::SmallVector<char> ISAName(Length);
Status = hsa_isa_get_info_alt(ISA, HSA_ISA_INFO_NAME, ISAName.begin());
if (Status != HSA_STATUS_SUCCESS)
return Status;

llvm::StringRef TripleTarget(ISAName);
llvm::StringRef TripleTarget(ISAName.begin(), Length);
if (TripleTarget.consume_front("amdgcn-amd-amdhsa"))
Target = TripleTarget.ltrim('-').str();
Target = TripleTarget.ltrim('-').rtrim('\0').str();
return HSA_STATUS_SUCCESS;
});
if (Err)
Expand Down

0 comments on commit 34a3fb9

Please sign in to comment.