summaryrefslogtreecommitdiff
path: root/openmp
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2023-03-01 15:02:00 -0600
committerJoseph Huber <jhuber6@vols.utk.edu>2023-03-01 15:03:21 -0600
commit48d5ad93cd6921de498a00421d696dba33fac7e4 (patch)
tree23937c5cd17cd2e1f41cc1c38b989d3a48e15bf8 /openmp
parente65e7b27fdcc286c799e748fa51dccdf39321ee3 (diff)
downloadllvm-48d5ad93cd6921de498a00421d696dba33fac7e4.tar.gz
[OpenMP][NFC] Clean up Twines and other issues in plugins
Summary: Tihs patch is mostly NFC to fix some warning currently present in OpenMP offloading plugins. Specifically this mostly removes the use of Twine variables in favor of LLVM's small string. Twine variables are prone to use-after-free and this is a cleaner way to concatenate a string.
Diffstat (limited to 'openmp')
-rw-r--r--openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp2
-rw-r--r--openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp19
2 files changed, 10 insertions, 11 deletions
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index 40c616c249fd..99b45ad386d8 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -2634,7 +2634,7 @@ Error AMDGPUKernelTy::printLaunchInfoDetails(GenericDeviceTy &GenericDevice,
// TODO set correctly once host services available
auto HostCallRequired = false;
INFO(OMP_INFOTYPE_PLUGIN_KERNEL, GenericDevice.getDeviceId(),
- "SGN:%s ConstWGSize:%d args:%d teamsXthrds:(%4dX%4d) "
+ "SGN:%s ConstWGSize:%d args:%d teamsXthrds:(%4luX%4d) "
"reqd:(%4dX%4d) lds_usage:%uB sgpr_count:%u vgpr_count:%u "
"sgpr_spill_count:%u vgpr_spill_count:%u tripcount:%lu rpc:%d n:%s\n",
getExecutionModeName(), ConstWGSize, ArgNum, NumGroups, ThreadsPerGroup,
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index 1d4d906bec4e..65983577f08f 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -117,12 +117,12 @@ public:
/* Default in GB */ 64) {}
void saveImage(const char *Name, DeviceImageTy &Image) {
- Twine ImageName = Twine(Name) + Twine(".image");
+ SmallString<128> ImageName = {Name, ".image"};
std::error_code EC;
- raw_fd_ostream OS(ImageName.str(), EC);
+ raw_fd_ostream OS(ImageName, EC);
if (EC)
report_fatal_error("Error saving image : " + StringRef(EC.message()));
- if (auto TgtImageBitcode = Image.getTgtImageBitcode()) {
+ if (const auto *TgtImageBitcode = Image.getTgtImageBitcode()) {
size_t Size =
getPtrDiff(TgtImageBitcode->ImageEnd, TgtImageBitcode->ImageStart);
MemoryBufferRef MBR = MemoryBufferRef(
@@ -158,11 +158,10 @@ public:
JsonArgOffsets.push_back(ArgOffsets[I]);
JsonKernelInfo["ArgOffsets"] = json::Value(std::move(JsonArgOffsets));
- Twine KernelName(Name);
- Twine MemoryFilename = KernelName + ".memory";
- dumpDeviceMemory(MemoryFilename.str(), AsyncInfoWrapper);
+ SmallString<128> MemoryFilename = {Name, ".memory"};
+ dumpDeviceMemory(MemoryFilename, AsyncInfoWrapper);
- Twine JsonFilename = KernelName + ".json";
+ SmallString<128> JsonFilename = {Name, ".json"};
std::error_code EC;
raw_fd_ostream JsonOS(JsonFilename.str(), EC);
if (EC)
@@ -174,9 +173,9 @@ public:
void saveKernelOutputInfo(const char *Name,
AsyncInfoWrapperTy &AsyncInfoWrapper) {
- Twine OutputFilename =
- Twine(Name) + (isRecording() ? ".original.output" : ".replay.output");
- dumpDeviceMemory(OutputFilename.str(), AsyncInfoWrapper);
+ SmallString<128> OutputFilename = {
+ Name, (isRecording() ? ".original.output" : ".replay.output")};
+ dumpDeviceMemory(OutputFilename, AsyncInfoWrapper);
}
void *alloc(uint64_t Size) {