Skip to content

Commit 34a3fb9

Browse files
authored
[Libomptarget][NFC] Remove use of VLA in the AMDGPU plugin (#69761)
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.
1 parent 1d4601a commit 34a3fb9

File tree

1 file changed

+4
-5
lines changed
  • openmp/libomptarget/plugins-nextgen/amdgpu/src

1 file changed

+4
-5
lines changed

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,15 +2869,14 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
28692869
if (Status != HSA_STATUS_SUCCESS)
28702870
return Status;
28712871

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

2878-
llvm::StringRef TripleTarget(ISAName);
2877+
llvm::StringRef TripleTarget(ISAName.begin(), Length);
28792878
if (TripleTarget.consume_front("amdgcn-amd-amdhsa"))
2880-
Target = TripleTarget.ltrim('-').str();
2879+
Target = TripleTarget.ltrim('-').rtrim('\0').str();
28812880
return HSA_STATUS_SUCCESS;
28822881
});
28832882
if (Err)

0 commit comments

Comments
 (0)