[llvm] [clang] [flang] [clang-tools-extra] [libcxx] [lldb] [openmp] [compiler-rt] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
ggeorgakoudis wrote: LGTM but fix comments: 1. Comments should be in their own line, move them above the relevant line 2. Comments should be complete sentences ending with a full stop https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [compiler-rt] [clang-tools-extra] [clang] [openmp] [llvm] [libcxx] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/ggeorgakoudis approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
ggeorgakoudis wrote: @nmustakin What's the use-case/motivation for this patch? https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
ggeorgakoudis wrote: > @ggeorgakoudis To reduce the memory consumption for kernel tuning using > record/replay. I do not see this so much about saving memory consumption but more as saving disk space. Makes sense to me this way, will review shortly. https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
ggeorgakoudis wrote: > @ggeorgakoudis To reduce the memory consumption for kernel tuning using > record/replay. I do not see this so much about saving memory consumption but more as saving disk space. Makes sense to me this way, will review shortly. https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [libcxx] [flang] [openmp] [clang-tools-extra] [lldb] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/ggeorgakoudis requested changes to this pull request. https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [openmp] [flang] [clang] [lldb] [compiler-rt] [llvm] [clang-tools-extra] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -274,7 +317,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, /*saveDiff*/ true); ggeorgakoudis wrote: If `saveDiff` is always `true` when replaying then this is incompatible with verification in the `llvm-omp-kernel-replay` tool, right? We should set `saveDiff` either through an env var or through the `llvm-omp-kernel-replay` tool (latter is better) and make the `llvm-omp-kernel-replay` tool aware. If `saveDiff` is true then the tool should just show the differences already saved in the diff files. https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [libcxx] [llvm] [lldb] [compiler-rt] [openmp] [flang] [clang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -141,13 +141,56 @@ struct RecordReplayTy { if (Err) report_fatal_error("Error retrieving data for target pointer"); -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); std::error_code EC; raw_fd_ostream OS(Filename, EC); if (EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; + +if (saveDiff) { + // Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + // read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if (std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if (InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + // get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + // compare pre-record memorydump to current contents + size_t i = 0; + while (i < MemorySize) { +// if mismatch found, create a new diff line +// current format - location, size, differences ... +if (InputBufferContents[i] != DeviceMemoryContents[i]) { + OS << i << " "; // marks the start offset + SmallVector modified; + modified.push_back(DeviceMemoryContents[i]); + size_t j = 1; ggeorgakoudis wrote: rename j -> J https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [openmp] [compiler-rt] [clang-tools-extra] [libcxx] [flang] [clang] [lldb] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -141,13 +141,56 @@ struct RecordReplayTy { if (Err) report_fatal_error("Error retrieving data for target pointer"); -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); std::error_code EC; raw_fd_ostream OS(Filename, EC); if (EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; + +if (saveDiff) { + // Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + // read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if (std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if (InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + // get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + // compare pre-record memorydump to current contents + size_t i = 0; + while (i < MemorySize) { +// if mismatch found, create a new diff line +// current format - location, size, differences ... +if (InputBufferContents[i] != DeviceMemoryContents[i]) { + OS << i << " "; // marks the start offset + SmallVector modified; ggeorgakoudis wrote: rename modified -> Modified https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [clang] [flang] [llvm] [openmp] [compiler-rt] [clang-tools-extra] [libcxx] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/ggeorgakoudis edited https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [openmp] [llvm] [compiler-rt] [flang] [lldb] [libcxx] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -130,7 +130,7 @@ struct RecordReplayTy { return preAllocateHeuristic(DevMemSize, ReqVAddr); } - void dumpDeviceMemory(StringRef Filename) { + void dumpDeviceMemory(StringRef Filename, bool saveDiff) { ggeorgakoudis wrote: rename saveDiff -> SaveDiff https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [compiler-rt] [clang] [openmp] [lldb] [libcxx] [flang] [clang-tools-extra] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -141,13 +141,56 @@ struct RecordReplayTy { if (Err) report_fatal_error("Error retrieving data for target pointer"); -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); std::error_code EC; raw_fd_ostream OS(Filename, EC); if (EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; + +if (saveDiff) { + // Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + // read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if (std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if (InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + // get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + // compare pre-record memorydump to current contents + size_t i = 0; ggeorgakoudis wrote: rename i -> I https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [openmp] [clang] [libcxx] [flang] [compiler-rt] [clang-tools-extra] [lldb] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -274,7 +317,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; ggeorgakoudis wrote: Create a new extensions when outputting in the diff format, e.g., `.replay.diff.output` to avoid mixing up verification from the `llvm-omp-kernel-replay` tool https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[openmp] [clang-tools-extra] [llvm] [compiler-rt] [lldb] [libcxx] [flang] [clang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -141,13 +141,56 @@ struct RecordReplayTy { if (Err) report_fatal_error("Error retrieving data for target pointer"); -StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); std::error_code EC; raw_fd_ostream OS(Filename, EC); if (EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); -OS << DeviceMemory; + +if (saveDiff) { + // Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + // read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if (std::error_code EC = InputFileBuffer.getError()) +report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if (InputBufferContents.size() != MemorySize) +report_fatal_error("Error: Pre-record device memory size mismatch"); + + // get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + // compare pre-record memorydump to current contents + size_t i = 0; + while (i < MemorySize) { +// if mismatch found, create a new diff line +// current format - location, size, differences ... +if (InputBufferContents[i] != DeviceMemoryContents[i]) { + OS << i << " "; // marks the start offset + SmallVector modified; + modified.push_back(DeviceMemoryContents[i]); + size_t j = 1; + // loop until next match is found + while (InputBufferContents[i + j] != DeviceMemoryContents[i + j]) { +modified.push_back(DeviceMemoryContents[i + j]); +j++; + } + OS << j << " "; // marks the length of the mismatching sequence + for (const auto &value : modified) +OS << value << " "; + OS << "\n"; + i += j + 1; +} else + i++; + } +} else { + StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), + MemorySize); + OS << DeviceMemory; +} ggeorgakoudis wrote: Simplify control flow for readability: ``` for(size_t I = 0; I < MemorySize; ++I) { If (InputBufferContest[I] == DeviceMemoryContest[I] continue; ... // do stuff, simplify too ... I += J; } ``` https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [clang-tools-extra] [lldb] [openmp] [llvm] [libcxx] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -274,7 +317,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, /*saveDiff*/ true); ggeorgakoudis wrote: OK, I understand better now. You basically save the diff from input memory for kernel outputs on both record and replay. This make more sense to me and it is indeed compatible with verification in the replay tool. https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [openmp] [lldb] [libcxx] [flang] [compiler-rt] [clang-tools-extra] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -274,7 +317,7 @@ struct RecordReplayTy { void saveKernelOutputInfo(const char *Name) { SmallString<128> OutputFilename = { Name, (isRecording() ? ".original.output" : ".replay.output")}; -dumpDeviceMemory(OutputFilename); +dumpDeviceMemory(OutputFilename, /*saveDiff*/ true); ggeorgakoudis wrote: Create a different function `dumpDeviceMemoryDiff` and put the logic there, instead of conflating the existing one with the `saveDiff` flag https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [compiler-rt] [libcxx] [clang-tools-extra] [openmp] [lldb] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/ggeorgakoudis requested changes to this pull request. https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [clang] [compiler-rt] [clang-tools-extra] [flang] [lldb] [openmp] [llvm] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
https://github.com/ggeorgakoudis edited https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [openmp] [compiler-rt] [clang] [libcxx] [clang-tools-extra] [llvm] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -151,6 +151,74 @@ struct RecordReplayTy { OS.close(); } + void dumpDeviceMemoryDiff(StringRef Filename) { +ErrorOr> DeviceMemoryMB = +WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize); +if (!DeviceMemoryMB) + report_fatal_error("Error creating MemoryBuffer for device memory"); + +auto Err = Device->dataRetrieve(DeviceMemoryMB.get()->getBufferStart(), +MemoryStart, MemorySize, nullptr); +if (Err) + report_fatal_error("Error retrieving data for target pointer"); + +// Get the pre-record memory filename +SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + +// Read the pre-record memorydump +auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); +if (std::error_code EC = InputFileBuffer.getError()) + report_fatal_error("Error reading pre-record device memory"); + +StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); +if (InputBufferContents.size() != MemorySize) + report_fatal_error("Error: Pre-record device memory size mismatch"); + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if (EC) + report_fatal_error("Error dumping memory to file " + Filename + " :" + + EC.message()); + +// Get current memory contents +StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + +for (size_t I = 0; I < MemorySize; ++I) { + // If buffers are same, continue + if (InputBufferContents[I] == DeviceMemoryContents[I]) +continue; + + // If mismatch is found create a new diff line + // Current format: location, size, differences + OS << I << " "; // Marks the start offset + + SmallVector Modified; + Modified.push_back(DeviceMemoryContents[I]); + + size_t J; // Length of current diff line + // Loop until next match is found + for (J = 1; J < MemorySize - I; ++J) { +// If no more mismatch, break out of the loop +if (InputBufferContents[I + J] == DeviceMemoryContents[I + J]) + break; + +// If mismatch continues - push diff to Modified +Modified.push_back(DeviceMemoryContents[I + J]); + } + + OS << J << " "; // Marks the length of the mismatching sequence + for (const auto &value : Modified) ggeorgakoudis wrote: value -> Value https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [openmp] [clang] [flang] [llvm] [lldb] [libcxx] [clang-tools-extra] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -151,6 +151,74 @@ struct RecordReplayTy { OS.close(); } + void dumpDeviceMemoryDiff(StringRef Filename) { +ErrorOr> DeviceMemoryMB = +WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize); +if (!DeviceMemoryMB) + report_fatal_error("Error creating MemoryBuffer for device memory"); + +auto Err = Device->dataRetrieve(DeviceMemoryMB.get()->getBufferStart(), +MemoryStart, MemorySize, nullptr); +if (Err) + report_fatal_error("Error retrieving data for target pointer"); + +// Get the pre-record memory filename +SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + +// Read the pre-record memorydump +auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); +if (std::error_code EC = InputFileBuffer.getError()) + report_fatal_error("Error reading pre-record device memory"); + +StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); +if (InputBufferContents.size() != MemorySize) + report_fatal_error("Error: Pre-record device memory size mismatch"); + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if (EC) + report_fatal_error("Error dumping memory to file " + Filename + " :" + + EC.message()); + +// Get current memory contents +StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + +for (size_t I = 0; I < MemorySize; ++I) { + // If buffers are same, continue + if (InputBufferContents[I] == DeviceMemoryContents[I]) +continue; + + // If mismatch is found create a new diff line + // Current format: location, size, differences + OS << I << " "; // Marks the start offset + + SmallVector Modified; + Modified.push_back(DeviceMemoryContents[I]); + + size_t J; // Length of current diff line + // Loop until next match is found + for (J = 1; J < MemorySize - I; ++J) { +// If no more mismatch, break out of the loop +if (InputBufferContents[I + J] == DeviceMemoryContents[I + J]) + break; + +// If mismatch continues - push diff to Modified +Modified.push_back(DeviceMemoryContents[I + J]); + } + + OS << J << " "; // Marks the length of the mismatching sequence + for (const auto &value : Modified) +OS << value << " "; + OS << "\n"; + + // Increment I by J to skip ahead to next + // matching sequence in the buffer + I += J; ggeorgakoudis wrote: Simpler, more readable as: ``` for (I+=1; I < MemorySize; ++I) { // If no more mismatch, break out of the loop if (InputBufferContents[I] == DeviceMemoryContents[I]) break; // If mismatch continues - push diff to Modified Modified.push_back(DeviceMemoryContents[I]); } ... OS << Modified.size() << " "; ``` Avoids the skip-ahead increment too https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang-tools-extra] [openmp] [clang] [libcxx] [lldb] [compiler-rt] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)
@@ -151,6 +151,74 @@ struct RecordReplayTy { OS.close(); } + void dumpDeviceMemoryDiff(StringRef Filename) { +ErrorOr> DeviceMemoryMB = +WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize); +if (!DeviceMemoryMB) + report_fatal_error("Error creating MemoryBuffer for device memory"); + +auto Err = Device->dataRetrieve(DeviceMemoryMB.get()->getBufferStart(), +MemoryStart, MemorySize, nullptr); +if (Err) + report_fatal_error("Error retrieving data for target pointer"); + +// Get the pre-record memory filename +SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + +// Read the pre-record memorydump +auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); +if (std::error_code EC = InputFileBuffer.getError()) + report_fatal_error("Error reading pre-record device memory"); + +StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); +if (InputBufferContents.size() != MemorySize) + report_fatal_error("Error: Pre-record device memory size mismatch"); + +std::error_code EC; +raw_fd_ostream OS(Filename, EC); +if (EC) + report_fatal_error("Error dumping memory to file " + Filename + " :" + + EC.message()); + +// Get current memory contents +StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + +for (size_t I = 0; I < MemorySize; ++I) { + // If buffers are same, continue + if (InputBufferContents[I] == DeviceMemoryContents[I]) +continue; + + // If mismatch is found create a new diff line + // Current format: location, size, differences + OS << I << " "; // Marks the start offset ggeorgakoudis wrote: Move comment above https://github.com/llvm/llvm-project/pull/70667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 60d4c73 - Run non-filechecked commands in update_cc_test_checks.py
Author: Giorgis Georgakoudis Date: 2021-03-08T07:18:01-08:00 New Revision: 60d4c73b30a0e324c6ae314722eb036f70f4b03a URL: https://github.com/llvm/llvm-project/commit/60d4c73b30a0e324c6ae314722eb036f70f4b03a DIFF: https://github.com/llvm/llvm-project/commit/60d4c73b30a0e324c6ae314722eb036f70f4b03a.diff LOG: Run non-filechecked commands in update_cc_test_checks.py Some tests in clang require running non-filechecked commands to generate the actual filecheck input. For example, tests for openmp offloading require generating the host bc without any checking, before running the clang command to actually generate the filechecked IR of the target device. This patch enables `update_cc_test_checks.py` to run non-filechecked run lines in-place. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97068 Added: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected clang/test/utils/update_cc_test_checks/exec-all-runlines.test Modified: llvm/utils/update_cc_test_checks.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c new file mode 100644 index ..bf18179392dc --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c @@ -0,0 +1,10 @@ +// Check that the non-clang/non-filechecked runlines execute +// RUN: cp %s %s.copy.c +// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc +// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s + +void use(int); + +void test(int a) +{ +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected new file mode 100644 index ..ffc8caac0f23 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected @@ -0,0 +1,17 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// Check that the non-clang/non-filechecked runlines execute +// RUN: cp %s %s.copy.c +// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc +// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s + +void use(int); + +// CHECK-LABEL: @test( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK-NEXT:ret void +// +void test(int a) +{ +} diff --git a/clang/test/utils/update_cc_test_checks/exec-all-runlines.test b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test new file mode 100644 index ..caf39934266c --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test @@ -0,0 +1,8 @@ +## Test that non-clang/non-filechecked runlines execute + +# RUN: cp %S/Inputs/exec-all-runlines.c %t-generated.c && %update_cc_test_checks %t-generated.c +# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c + +## Check that re-running update_cc_test_checks doesn't change the output +# RUN: %update_cc_test_checks %t-generated.c +# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index e5ca91502cf9..d084bc6d0795 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -203,6 +203,14 @@ def get_function_body(builder, args, filename, clang_args, extra_commands, 'are discouraged in Clang testsuite.', file=sys.stderr) sys.exit(1) +def exec_run_line(exe): + popen = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + stdout, stderr = popen.communicate() + if popen.returncode != 0: +sys.stderr.write('Failed to run ' + ' '.join(exe) + '\n') +sys.stderr.write(stderr) +sys.stderr.write(stdout) +sys.exit(3) def main(): initial_args, parser = config() @@ -221,25 +229,31 @@ def main(): if m: triple_in_cmd = m.groups()[0] - # Apply %clang substitution rule, replace %s by `filename`, and append args.clang_args - clang_args = shlex.split(commands[0]) - if clang_args[0] not in SUBST: -print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr) + # Parse executable args. + exec_args = shlex.split(commands[0]) + # Execute non-clang runline. + if exec_args[0] not in SUBST: +print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr) +# Replace %s by `filename`. +exec_args = [i.replace('%s', ti.path) if '%s' in i else i for i in exec_args] +exec_run_line(exec_args) continue +
[clang] a2abe22 - Run non-filechecked commands in update_cc_test_checks.py
Author: Giorgis Georgakoudis Date: 2021-03-10T12:25:35-08:00 New Revision: a2abe2259c2d5b8c494f3513b840adf1572b21bc URL: https://github.com/llvm/llvm-project/commit/a2abe2259c2d5b8c494f3513b840adf1572b21bc DIFF: https://github.com/llvm/llvm-project/commit/a2abe2259c2d5b8c494f3513b840adf1572b21bc.diff LOG: Run non-filechecked commands in update_cc_test_checks.py Some tests in clang require running non-filechecked commands to generate the actual filecheck input. For example, tests for openmp offloading require generating the host bc without any checking, before running the clang command to actually generate the filechecked IR of the target device. This patch enables `update_cc_test_checks.py` to run non-filechecked run lines in-place. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97068 Added: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected clang/test/utils/update_cc_test_checks/exec-all-runlines.test Modified: llvm/utils/update_cc_test_checks.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c new file mode 100644 index ..1626eb540841 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c @@ -0,0 +1,10 @@ +// Check that the non-clang/non-filechecked runlines execute +// RUN: cp %s %s.copy.c +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s + +void use(int); + +void test(int a) +{ +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected new file mode 100644 index ..5edf11e668e4 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected @@ -0,0 +1,17 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// Check that the non-clang/non-filechecked runlines execute +// RUN: cp %s %s.copy.c +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s + +void use(int); + +// CHECK-LABEL: @test( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK-NEXT:ret void +// +void test(int a) +{ +} diff --git a/clang/test/utils/update_cc_test_checks/exec-all-runlines.test b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test new file mode 100644 index ..caf39934266c --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test @@ -0,0 +1,8 @@ +## Test that non-clang/non-filechecked runlines execute + +# RUN: cp %S/Inputs/exec-all-runlines.c %t-generated.c && %update_cc_test_checks %t-generated.c +# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c + +## Check that re-running update_cc_test_checks doesn't change the output +# RUN: %update_cc_test_checks %t-generated.c +# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index e5ca91502cf9..d084bc6d0795 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -203,6 +203,14 @@ def get_function_body(builder, args, filename, clang_args, extra_commands, 'are discouraged in Clang testsuite.', file=sys.stderr) sys.exit(1) +def exec_run_line(exe): + popen = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + stdout, stderr = popen.communicate() + if popen.returncode != 0: +sys.stderr.write('Failed to run ' + ' '.join(exe) + '\n') +sys.stderr.write(stderr) +sys.stderr.write(stdout) +sys.exit(3) def main(): initial_args, parser = config() @@ -221,25 +229,31 @@ def main(): if m: triple_in_cmd = m.groups()[0] - # Apply %clang substitution rule, replace %s by `filename`, and append args.clang_args - clang_args = shlex.split(commands[0]) - if clang_args[0] not in SUBST: -print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr) + # Parse executable args. + exec_args = shlex.split(commands[0]) + # Execute non-clang runline. + if exec_args[0] not in SUBST: +print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr) +# Replace %s by `filename`. +ex
[clang] bf58d6a - Replace func name with regex in update_cc_test_checks
Author: Giorgis Georgakoudis Date: 2021-03-10T12:57:35-08:00 New Revision: bf58d6a1f92244c797a280d318a56d7d3fc4a704 URL: https://github.com/llvm/llvm-project/commit/bf58d6a1f92244c797a280d318a56d7d3fc4a704 DIFF: https://github.com/llvm/llvm-project/commit/bf58d6a1f92244c797a280d318a56d7d3fc4a704.diff LOG: Replace func name with regex in update_cc_test_checks The patch adds an argument to update_cc_test_checks for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107 Added: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected clang/test/utils/update_cc_test_checks/generated-funcs-regex.test Modified: llvm/utils/UpdateTestChecks/common.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c new file mode 100644 index ..3d51d48568ef --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s + +void __test_offloading_42_abcdef_bar_l123(); +void use(int); + +void foo(int a) +{ +#pragma omp target +use(a); + +__test_offloading_42_abcdef_bar_l123(); +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected new file mode 100644 index ..49e041b93621 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected @@ -0,0 +1,36 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s + +void __test_offloading_42_abcdef_bar_l123(); +void use(int); + +void foo(int a) +{ +#pragma omp target +use(a); + +__test_offloading_42_abcdef_bar_l123(); +} +// CHECK-LABEL: @foo( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT:[[A_CASTED:%.*]] = alloca i64, align 8 +// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_CASTED]] to i32* +// CHECK-NEXT:store i32 [[TMP0]], i32* [[CONV]], align 4 +// CHECK-NEXT:[[TMP1:%.*]] = load i64, i64* [[A_CASTED]], align 8 +// CHECK-NEXT:call void @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}(i64 [[TMP1]]) [[ATTR3:#.*]] +// CHECK-NEXT:call void (...) @{{__test_offloading_[a-z0-9]+_[a-z0-9]+_bar_l[0-9]+}}() +// CHECK-NEXT:ret void +// +// +// CHECK-LABEL: @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8 +// CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 +// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_ADDR]] to i32* +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[CONV]], align 8 +// CHECK-NEXT:call void @use(i32 [[TMP0]]) +// CHECK-NEXT:ret void +// diff --git a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test new file mode 100644 index ..4051d0a5181f --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test @@ -0,0 +1,9 @@ +## Test that CHECK lines are generated for clang-generated functions replaced +## by regex + +## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c +# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c + +## Check that re-running update_cc_test_checks doesn't change the output +# RUN: %update_cc_test_checks %t-generated-funcs-regex.c +# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 0082c4ecd181..2118b003fb18 100644 --
[clang] ecf6897 - Revert "Replace func name with regex in update_cc_test_checks"
Author: Giorgis Georgakoudis Date: 2021-03-10T15:05:35-08:00 New Revision: ecf68972fd020cee80c5503bbe0f2028a184c8f3 URL: https://github.com/llvm/llvm-project/commit/ecf68972fd020cee80c5503bbe0f2028a184c8f3 DIFF: https://github.com/llvm/llvm-project/commit/ecf68972fd020cee80c5503bbe0f2028a184c8f3.diff LOG: Revert "Replace func name with regex in update_cc_test_checks" This reverts commit bf58d6a1f92244c797a280d318a56d7d3fc4a704. Breaks tests, fix Added: Modified: llvm/utils/UpdateTestChecks/common.py Removed: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected clang/test/utils/update_cc_test_checks/generated-funcs-regex.test diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c deleted file mode 100644 index 3d51d48568ef.. --- a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s - -void __test_offloading_42_abcdef_bar_l123(); -void use(int); - -void foo(int a) -{ -#pragma omp target -use(a); - -__test_offloading_42_abcdef_bar_l123(); -} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected deleted file mode 100644 index 49e041b93621.. --- a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected +++ /dev/null @@ -1,36 +0,0 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s - -void __test_offloading_42_abcdef_bar_l123(); -void use(int); - -void foo(int a) -{ -#pragma omp target -use(a); - -__test_offloading_42_abcdef_bar_l123(); -} -// CHECK-LABEL: @foo( -// CHECK-NEXT: entry: -// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:[[A_CASTED:%.*]] = alloca i64, align 8 -// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 -// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 -// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_CASTED]] to i32* -// CHECK-NEXT:store i32 [[TMP0]], i32* [[CONV]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = load i64, i64* [[A_CASTED]], align 8 -// CHECK-NEXT:call void @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}(i64 [[TMP1]]) [[ATTR3:#.*]] -// CHECK-NEXT:call void (...) @{{__test_offloading_[a-z0-9]+_[a-z0-9]+_bar_l[0-9]+}}() -// CHECK-NEXT:ret void -// -// -// CHECK-LABEL: @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}( -// CHECK-NEXT: entry: -// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8 -// CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 -// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_ADDR]] to i32* -// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[CONV]], align 8 -// CHECK-NEXT:call void @use(i32 [[TMP0]]) -// CHECK-NEXT:ret void -// diff --git a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test deleted file mode 100644 index 4051d0a5181f.. --- a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test +++ /dev/null @@ -1,9 +0,0 @@ -## Test that CHECK lines are generated for clang-generated functions replaced -## by regex - -## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c -# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c - -## Check that re-running update_cc_test_checks doesn't change the output -# RUN: %update_cc_test_checks %t-generated-funcs-regex.c -# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 2118b003fb18..0082c4ecd181 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -30,8 +30,6 @@ def parse_commandline_args(parser): help='Activate CHECK line generation from this point forward') parser.add_argument('--disable', action='store_false', dest='enabled', help='Deactivate CHECK line generation from this point forward') - parser.add_argument('--replace-function-regex', nargs='+', default=[], -
[clang] 5eaf70a - Replace func name with regex for update test scripts
Author: Giorgis Georgakoudis Date: 2021-03-12T17:00:42-08:00 New Revision: 5eaf70afb5f8ae6789587e60d51c60f56caf18b0 URL: https://github.com/llvm/llvm-project/commit/5eaf70afb5f8ae6789587e60d51c60f56caf18b0 DIFF: https://github.com/llvm/llvm-project/commit/5eaf70afb5f8ae6789587e60d51c60f56caf18b0.diff LOG: Replace func name with regex for update test scripts The patch adds an argument to update test scripts, such as update_cc_test_checks, for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107 Added: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected clang/test/utils/update_cc_test_checks/generated-funcs-regex.test Modified: llvm/utils/UpdateTestChecks/common.py llvm/utils/update_llc_test_checks.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c new file mode 100644 index ..3d51d48568ef --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s + +void __test_offloading_42_abcdef_bar_l123(); +void use(int); + +void foo(int a) +{ +#pragma omp target +use(a); + +__test_offloading_42_abcdef_bar_l123(); +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected new file mode 100644 index ..49e041b93621 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected @@ -0,0 +1,36 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s + +void __test_offloading_42_abcdef_bar_l123(); +void use(int); + +void foo(int a) +{ +#pragma omp target +use(a); + +__test_offloading_42_abcdef_bar_l123(); +} +// CHECK-LABEL: @foo( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT:[[A_CASTED:%.*]] = alloca i64, align 8 +// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_CASTED]] to i32* +// CHECK-NEXT:store i32 [[TMP0]], i32* [[CONV]], align 4 +// CHECK-NEXT:[[TMP1:%.*]] = load i64, i64* [[A_CASTED]], align 8 +// CHECK-NEXT:call void @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}(i64 [[TMP1]]) [[ATTR3:#.*]] +// CHECK-NEXT:call void (...) @{{__test_offloading_[a-z0-9]+_[a-z0-9]+_bar_l[0-9]+}}() +// CHECK-NEXT:ret void +// +// +// CHECK-LABEL: @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8 +// CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 +// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_ADDR]] to i32* +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[CONV]], align 8 +// CHECK-NEXT:call void @use(i32 [[TMP0]]) +// CHECK-NEXT:ret void +// diff --git a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test new file mode 100644 index ..4051d0a5181f --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test @@ -0,0 +1,9 @@ +## Test that CHECK lines are generated for clang-generated functions replaced +## by regex + +## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c +# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c + +## Check that re-running update_cc_test_checks doesn't change the output +# RUN: %update_cc_test_checks %t-generated-funcs-regex.c +# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/util
[clang] 9f9a4df - Revert "Replace func name with regex for update test scripts"
Author: Giorgis Georgakoudis Date: 2021-03-12T17:20:00-08:00 New Revision: 9f9a4dfda7348eddbc840ae558e7082677c3bab6 URL: https://github.com/llvm/llvm-project/commit/9f9a4dfda7348eddbc840ae558e7082677c3bab6 DIFF: https://github.com/llvm/llvm-project/commit/9f9a4dfda7348eddbc840ae558e7082677c3bab6.diff LOG: Revert "Replace func name with regex for update test scripts" This reverts commit 5eaf70afb5f8ae6789587e60d51c60f56caf18b0. Added: Modified: llvm/utils/UpdateTestChecks/common.py llvm/utils/update_llc_test_checks.py Removed: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected clang/test/utils/update_cc_test_checks/generated-funcs-regex.test diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c deleted file mode 100644 index 3d51d48568ef.. --- a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s - -void __test_offloading_42_abcdef_bar_l123(); -void use(int); - -void foo(int a) -{ -#pragma omp target -use(a); - -__test_offloading_42_abcdef_bar_l123(); -} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected deleted file mode 100644 index 49e041b93621.. --- a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected +++ /dev/null @@ -1,36 +0,0 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s - -void __test_offloading_42_abcdef_bar_l123(); -void use(int); - -void foo(int a) -{ -#pragma omp target -use(a); - -__test_offloading_42_abcdef_bar_l123(); -} -// CHECK-LABEL: @foo( -// CHECK-NEXT: entry: -// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:[[A_CASTED:%.*]] = alloca i64, align 8 -// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 -// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 -// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_CASTED]] to i32* -// CHECK-NEXT:store i32 [[TMP0]], i32* [[CONV]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = load i64, i64* [[A_CASTED]], align 8 -// CHECK-NEXT:call void @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}(i64 [[TMP1]]) [[ATTR3:#.*]] -// CHECK-NEXT:call void (...) @{{__test_offloading_[a-z0-9]+_[a-z0-9]+_bar_l[0-9]+}}() -// CHECK-NEXT:ret void -// -// -// CHECK-LABEL: @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}( -// CHECK-NEXT: entry: -// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8 -// CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 -// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_ADDR]] to i32* -// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[CONV]], align 8 -// CHECK-NEXT:call void @use(i32 [[TMP0]]) -// CHECK-NEXT:ret void -// diff --git a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test deleted file mode 100644 index 4051d0a5181f.. --- a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test +++ /dev/null @@ -1,9 +0,0 @@ -## Test that CHECK lines are generated for clang-generated functions replaced -## by regex - -## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c -# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c - -## Check that re-running update_cc_test_checks doesn't change the output -# RUN: %update_cc_test_checks %t-generated-funcs-regex.c -# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index b3ca33f07428..5cf509013f94 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -30,8 +30,6 @@ def parse_commandline_args(parser): help='Activate CHECK line generation from this point forward') parser.add_argument('--disable', action='store_false', dest='enabled', help='Deactivate CHECK line generation from this point forward') - parser.add_argument('--replace-function-regex', nargs='+
[clang] 1ce846b - Replace func name with regex for update test scripts
Author: Giorgis Georgakoudis Date: 2021-03-12T17:37:09-08:00 New Revision: 1ce846be04f8ce7f899e37424772c0bef1851f76 URL: https://github.com/llvm/llvm-project/commit/1ce846be04f8ce7f899e37424772c0bef1851f76 DIFF: https://github.com/llvm/llvm-project/commit/1ce846be04f8ce7f899e37424772c0bef1851f76.diff LOG: Replace func name with regex for update test scripts The patch adds an argument to update test scripts, such as update_cc_test_checks, for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107 Added: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected clang/test/utils/update_cc_test_checks/generated-funcs-regex.test Modified: llvm/utils/UpdateTestChecks/common.py llvm/utils/update_llc_test_checks.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c new file mode 100644 index ..3d51d48568ef --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s + +void __test_offloading_42_abcdef_bar_l123(); +void use(int); + +void foo(int a) +{ +#pragma omp target +use(a); + +__test_offloading_42_abcdef_bar_l123(); +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected new file mode 100644 index ..838db8d8e606 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected @@ -0,0 +1,36 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s -emit-llvm -o - | FileCheck %s + +void __test_offloading_42_abcdef_bar_l123(); +void use(int); + +void foo(int a) +{ +#pragma omp target +use(a); + +__test_offloading_42_abcdef_bar_l123(); +} +// CHECK-LABEL: @foo( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT:[[A_CASTED:%.*]] = alloca i64, align 8 +// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_CASTED]] to i32* +// CHECK-NEXT:store i32 [[TMP0]], i32* [[CONV]], align 4 +// CHECK-NEXT:[[TMP1:%.*]] = load i64, i64* [[A_CASTED]], align 8 +// CHECK-NEXT:call void @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}(i64 [[TMP1]]) #[[ATTR3:[0-9]+]] +// CHECK-NEXT:call void (...) @{{__test_offloading_[a-z0-9]+_[a-z0-9]+_bar_l[0-9]+}}() +// CHECK-NEXT:ret void +// +// +// CHECK-LABEL: @{{__omp_offloading_[a-z0-9]+_[a-z0-9]+_foo_l[0-9]+}}( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8 +// CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8 +// CHECK-NEXT:[[CONV:%.*]] = bitcast i64* [[A_ADDR]] to i32* +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[CONV]], align 8 +// CHECK-NEXT:call void @use(i32 [[TMP0]]) +// CHECK-NEXT:ret void +// diff --git a/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test new file mode 100644 index ..4051d0a5181f --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/generated-funcs-regex.test @@ -0,0 +1,9 @@ +## Test that CHECK lines are generated for clang-generated functions replaced +## by regex + +## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c +# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c + +## Check that re-running update_cc_test_checks doesn't change the output +# RUN: %update_cc_test_checks %t-generated-funcs-regex.c +# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/
[clang] a27ca15 - [OpenMP] Fix non-determinism in clang task codegen
Author: Giorgis Georgakoudis Date: 2021-05-03T10:34:38-07:00 New Revision: a27ca15dd08342b199e2feb5ae896475fd90a518 URL: https://github.com/llvm/llvm-project/commit/a27ca15dd08342b199e2feb5ae896475fd90a518 DIFF: https://github.com/llvm/llvm-project/commit/a27ca15dd08342b199e2feb5ae896475fd90a518.diff LOG: [OpenMP] Fix non-determinism in clang task codegen Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101739 Added: Modified: clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntime.h clang/lib/CodeGen/CGStmtOpenMP.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index fce6efe9fee0..1980c5c91af2 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -12107,8 +12107,8 @@ CGOpenMPRuntime::NontemporalDeclsRAII::~NontemporalDeclsRAII() { CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::UntiedTaskLocalDeclsRAII( CodeGenFunction &CGF, -const llvm::DenseMap, - std::pair> &LocalVars) +const llvm::MapVector, + std::pair> &LocalVars) : CGM(CGF.CGM), NeedToPush(!LocalVars.empty()) { if (!NeedToPush) return; diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h index 7be9c3b1da22..5155370f46cf 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -253,8 +253,8 @@ class CGOpenMPRuntime { public: UntiedTaskLocalDeclsRAII( CodeGenFunction &CGF, -const llvm::DenseMap, - std::pair> &LocalVars); +const llvm::MapVector, + std::pair> &LocalVars); ~UntiedTaskLocalDeclsRAII(); }; @@ -723,8 +723,8 @@ class CGOpenMPRuntime { llvm::SmallVector NontemporalDeclsStack; using UntiedLocalVarsAddressesMap = - llvm::DenseMap, - std::pair>; + llvm::MapVector, + std::pair>; llvm::SmallVector UntiedLocalVarsStack; /// Stack for list of addresses of declarations in current context marked as diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 83d3dd0fc813..e7ddc0aa4c8d 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4339,7 +4339,8 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs, CapturedRegion](CodeGenFunction &CGF, PrePostActionTy &Action) { -llvm::DenseMap, std::pair> +llvm::MapVector, +std::pair> UntiedLocalVars; // Set proper addresses for generated private copies. OMPPrivateScope Scope(CGF); @@ -4392,7 +4393,12 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Ty = CGF.getContext().getPointerType(Ty); Address PrivatePtr = CGF.CreateMemTemp( CGF.getContext().getPointerType(Ty), ".local.ptr.addr"); -UntiedLocalVars.try_emplace(VD, PrivatePtr, Address::invalid()); +auto Result = UntiedLocalVars.insert( +std::make_pair(VD, std::make_pair(PrivatePtr, Address::invalid(; +// If key exists update in place. +if (Result.second == false) + *Result.first = std::make_pair( + VD, std::make_pair(PrivatePtr, Address::invalid())); CallArgs.push_back(PrivatePtr.getPointer()); ParamTypes.push_back(PrivatePtr.getType()); } @@ -4424,14 +4430,14 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( if (isAllocatableDecl(Pair.first)) { llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first); Address Replacement(Ptr, CGF.getPointerAlign()); - Pair.getSecond().first = Replacement; + Pair.second.first = Replacement; Ptr = CGF.Builder.CreateLoad(Replacement); Replacement = Address(Ptr, CGF.getContext().getDeclAlign(Pair.first)); - Pair.getSecond().second = Replacement; + Pair.second.second = Replacement; } else { llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first); Address Replacement(Ptr, CGF.getContext().getDeclAlign(Pair.first)); - Pair.getSecond().first = Replacement; + Pair.second.first = Replacement; } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 313ee60 - [OpenMP] Fix non-determinism in clang task codegen (lastprivates)
Author: Giorgis Georgakoudis Date: 2021-05-04T11:56:31-07:00 New Revision: 313ee609e16b93a7d81cd595f8cffdb408390495 URL: https://github.com/llvm/llvm-project/commit/313ee609e16b93a7d81cd595f8cffdb408390495 DIFF: https://github.com/llvm/llvm-project/commit/313ee609e16b93a7d81cd595f8cffdb408390495.diff LOG: [OpenMP] Fix non-determinism in clang task codegen (lastprivates) Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101800 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index e7ddc0aa4c8d..1f714b01b3f1 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4293,7 +4293,7 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( } } // Get list of lastprivate variables (for taskloops). - llvm::DenseMap LastprivateDstsOrigs; + llvm::MapVector LastprivateDstsOrigs; for (const auto *C : S.getClausesOfKind()) { auto IRef = C->varlist_begin(); auto ID = C->destination_exprs().begin(); @@ -4304,8 +4304,8 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Data.LastprivateCopies.push_back(IInit); } LastprivateDstsOrigs.insert( - {cast(cast(*ID)->getDecl()), - cast(*IRef)}); + std::make_pair(cast(cast(*ID)->getDecl()), + cast(*IRef))); ++IRef; ++ID; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 92f2c39 - [Utils] Run non-filecheck runlines in-order in update_cc_test_checks
Author: Giorgis Georgakoudis Date: 2021-05-04T12:06:03-07:00 New Revision: 92f2c39f915adc8f71be02d2604df4916069c9d4 URL: https://github.com/llvm/llvm-project/commit/92f2c39f915adc8f71be02d2604df4916069c9d4 DIFF: https://github.com/llvm/llvm-project/commit/92f2c39f915adc8f71be02d2604df4916069c9d4.diff LOG: [Utils] Run non-filecheck runlines in-order in update_cc_test_checks The script update_cc_test_checks runs all non-filechecked runlines before the filechecked ones. This creates problems since outputs of those non-filechecked runlines may conflict and that will fail the execution of update_cc_test_checks. This patch executes non-filechecked in the order specified in the test file to avoid this issue. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101683 Added: Modified: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected llvm/utils/update_cc_test_checks.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c index e0dfc42c4bd6..60d608b8cadd 100644 --- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c @@ -2,10 +2,20 @@ // RUN: cp %s %S/Output/execute-all-runlines.copy.c // RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-pch %s -o %t +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2 +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-pch %s -o %t +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK3 + + +#ifndef HEADER +#define HEADER void use(int); void test(int a) { } + +#endif diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected index ae9745fa9b1e..cebd3846b2d9 100644 --- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected @@ -3,16 +3,38 @@ // RUN: cp %s %S/Output/execute-all-runlines.copy.c // RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-pch %s -o %t +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2 +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-pch %s -o %t +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -include-pch %t %s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK3 + + +#ifndef HEADER +#define HEADER void use(int); -// CHECK-LABEL: @test( -// CHECK-NEXT: entry: -// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 -// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 -// CHECK-NEXT:ret void +// CHECK1-LABEL: @test( +// CHECK1-NEXT: entry: +// CHECK1-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK1-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK1-NEXT:ret void +// +// CHECK2-LABEL: @test( +// CHECK2-NEXT: entry: +// CHECK2-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK2-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK2-NEXT:ret void +// +// CHECK3-LABEL: @test( +// CHECK3-NEXT: entry: +// CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK3-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4 +// CHECK3-NEXT:ret void // void test(int a) { } + +#endif diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index d3af5308ac6a..cbe58765f9fc 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -218,7 +218,7 @@ def main(): for ti in commo
[clang] 78a7d8c - [Utils][NFC] Rename replace-function-regex in update_cc_test_checks
Author: Giorgis Georgakoudis Date: 2021-05-05T14:19:30-07:00 New Revision: 78a7d8c4dd1076dccfde2c48fc924d8f5529f4d1 URL: https://github.com/llvm/llvm-project/commit/78a7d8c4dd1076dccfde2c48fc924d8f5529f4d1 DIFF: https://github.com/llvm/llvm-project/commit/78a7d8c4dd1076dccfde2c48fc924d8f5529f4d1.diff LOG: [Utils][NFC] Rename replace-function-regex in update_cc_test_checks This patch renames the replace-function-regex to replace-value-regex to indicate that the existing regex replacement functionality can replace any IR value besides functions. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101934 Added: Modified: clang/test/OpenMP/nvptx_allocate_codegen.cpp clang/test/OpenMP/nvptx_data_sharing.cpp clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp clang/test/OpenMP/nvptx_lambda_capturing.cpp clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp clang/test/OpenMP/nvptx_parallel_codegen.cpp clang/test/OpenMP/nvptx_parallel_for_codegen.cpp clang/test/OpenMP/nvptx_target_codegen.cpp clang/test/OpenMP/nvptx_target_parallel_codegen.cpp clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp clang/test/OpenMP/nvptx_target_teams_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp clang/test/OpenMP/target_parallel_debug_codegen.cpp clang/test/OpenMP/target_parallel_for_debug_codegen.cpp clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected clang/test/utils/update_cc_test_checks/generated-funcs-regex.test llvm/utils/UpdateTestChecks/common.py llvm/utils/update_analyze_test_checks.py llvm/utils/update_llc_test_checks.py Removed: diff --git a/clang/test/OpenMP/nvptx_allocate_codegen.cpp b/clang/test/OpenMP/nvptx_allocate_codegen.cpp index 4ca4796cbd27c..50b482d606d59 100644 --- a/clang/test/OpenMP/nvptx_allocate_codegen.cpp +++ b/clang/test/OpenMP/nvptx_allocate_codegen.cpp @@ -1,4 +1,4 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-function-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc -o %t-host.bc %s // RUN: %clang_cc1 -verify -fopenmp -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - -disable-llvm-optzns | FileCheck %s // expected-no-diagnostics diff --git a/clang/test/OpenMP/nvptx_data_sharing.cpp b/clang/test/OpenMP/nvptx_data_sharing.cpp index 792d9c664591b..6a68d46ee2884 100644 --- a/clang/test/OpenMP/nvptx_data_sharing.cpp +++ b/clang/test/OpenMP/nvptx_data_sharing.cpp @@ -1,4 +1,4 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-function-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" // Test device global memory data sharing codegen. ///==/// diff --git a/clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp b/clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp index f3485f4f0b4b2..0a74ecaec9025 100644 --- a/clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp +++ b/clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp @@ -1,4 +1,4 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-function-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" // Test target codegen - host bc file has to be created first. // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x
[clang] f97b843 - [OpenMP] Fix non-determinism in clang copyin codegen
Author: Giorgis Georgakoudis Date: 2021-05-05T19:24:03-07:00 New Revision: f97b843d8819f824dcc1b6afa746ce9a7a386db3 URL: https://github.com/llvm/llvm-project/commit/f97b843d8819f824dcc1b6afa746ce9a7a386db3 DIFF: https://github.com/llvm/llvm-project/commit/f97b843d8819f824dcc1b6afa746ce9a7a386db3.diff LOG: [OpenMP] Fix non-determinism in clang copyin codegen Codegen for OpeMP copyin has non-deterministic IR output due to the unspecified evaluation order in a codegen conditional branch, which makes automatic test generation unreliable. This patch refactors codegen code to avoid this non-determinism. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101952 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 1f714b01b3f1c..344fa90253ec3 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -1006,12 +1006,14 @@ bool CodeGenFunction::EmitOMPCopyinClause(const OMPExecutableDirective &D) { // need to copy data. CopyBegin = createBasicBlock("copyin.not.master"); CopyEnd = createBasicBlock("copyin.not.master.end"); + // TODO: Avoid ptrtoint conversion. + auto *MasterAddrInt = + Builder.CreatePtrToInt(MasterAddr.getPointer(), CGM.IntPtrTy); + auto *PrivateAddrInt = + Builder.CreatePtrToInt(PrivateAddr.getPointer(), CGM.IntPtrTy); Builder.CreateCondBr( - Builder.CreateICmpNE( - Builder.CreatePtrToInt(MasterAddr.getPointer(), CGM.IntPtrTy), - Builder.CreatePtrToInt(PrivateAddr.getPointer(), - CGM.IntPtrTy)), - CopyBegin, CopyEnd); + Builder.CreateICmpNE(MasterAddrInt, PrivateAddrInt), CopyBegin, + CopyEnd); EmitBlock(CopyBegin); } const auto *SrcVD = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a80a33e - [Utils] Support lit-like substitutions in update_cc_test_checks
Author: Giorgis Georgakoudis Date: 2021-03-16T10:36:22-07:00 New Revision: a80a33e8b55393c060e51486cfd8085b380eb36d URL: https://github.com/llvm/llvm-project/commit/a80a33e8b55393c060e51486cfd8085b380eb36d DIFF: https://github.com/llvm/llvm-project/commit/a80a33e8b55393c060e51486cfd8085b380eb36d.diff LOG: [Utils] Support lit-like substitutions in update_cc_test_checks Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D98712 Added: Modified: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected llvm/utils/update_cc_test_checks.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c index 1626eb540841..e0dfc42c4bd6 100644 --- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c @@ -1,5 +1,6 @@ // Check that the non-clang/non-filechecked runlines execute -// RUN: cp %s %s.copy.c +// RUN: cp %s %S/Output/execute-all-runlines.copy.c +// RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s diff --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected index 5edf11e668e4..ae9745fa9b1e 100644 --- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected @@ -1,6 +1,7 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // Check that the non-clang/non-filechecked runlines execute -// RUN: cp %s %s.copy.c +// RUN: cp %s %S/Output/execute-all-runlines.copy.c +// RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index d084bc6d0795..d3af5308ac6a 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -176,7 +176,7 @@ def config(): return args, parser -def get_function_body(builder, args, filename, clang_args, extra_commands, +def get_function_body(builder, args, filename, clang_args, extra_commands, prefixes): # TODO Clean up duplication of asm/common build_function_body_dictionary # Invoke external tool and extract function bodies. @@ -221,6 +221,13 @@ def main(): # Build a list of clang command lines and check prefixes from RUN lines. run_list = [] line2spell_and_mangled_list = collections.defaultdict(list) + +subs = { + '%s' : ti.path, + '%t' : tempfile.NamedTemporaryFile().name, + '%S' : os.getcwd(), +} + for l in ti.run_lines: commands = [cmd.strip() for cmd in l.split('|')] @@ -234,15 +241,18 @@ def main(): # Execute non-clang runline. if exec_args[0] not in SUBST: print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr) -# Replace %s by `filename`. -exec_args = [i.replace('%s', ti.path) if '%s' in i else i for i in exec_args] +# Do lit-like substitutions. +for s in subs: + exec_args = [i.replace(s, subs[s]) if s in i else i for i in exec_args] exec_run_line(exec_args) continue - # This is a clang runline, apply %clang substitution rule, replace %s by `filename`, + # This is a clang runline, apply %clang substitution rule, do lit-like substitutions, # and append args.clang_args clang_args = exec_args clang_args[0:1] = SUBST[clang_args[0]] - clang_args = [i.replace('%s', ti.path) if '%s' in i else i for i in clang_args] + ti.args.clang_args + for s in subs: +clang_args = [i.replace(s, subs[s]) if s in i else i for i in clang_args] + clang_args += ti.args.clang_args # Extract -check-prefix in FileCheck args filecheck_cmd = commands[-1] @@ -271,7 +281,7 @@ def main(): common.debug('Extracted clang cmd: clang {}'.format(clang_args)) common.debug('Extracted FileCheck prefixes: {}'.format(prefixes)) - get_function_body(builder, ti.args, ti.path, clang_args, extra_commands, + get_function_body(builder, ti.args, ti.path, clang_args, extra_commands, prefixes)
[clang] 8bc2c66 - [Utils] Add prefix parameter in update test checks to avoid FileCheck conflicts
Author: Giorgis Georgakoudis Date: 2021-03-26T11:49:42-07:00 New Revision: 8bc2c662d9c0f241fb8538979f8db1af7f2e353e URL: https://github.com/llvm/llvm-project/commit/8bc2c662d9c0f241fb8538979f8db1af7f2e353e DIFF: https://github.com/llvm/llvm-project/commit/8bc2c662d9c0f241fb8538979f8db1af7f2e353e.diff LOG: [Utils] Add prefix parameter in update test checks to avoid FileCheck conflicts IR values convert to check prefix FileCheck variables for IR checks. For example, nameless values, e.g., %0, convert to check prefix TMP FileCheck variables, e.g., [[TMP0:%.*]]. This check prefix may clash with named values that have the same name and that causes auto-generated tests to fail. Currently a warning is emitted to change the names of the IR values but this is not always possible, if for example they are generated by clang. Manual intervention to fix the FileCheck variable names is too tedious. This patch add a parameter to prefix conflicting FileCheck variable names with a user-provided string to automate the process. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D99415 Added: clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp.expected clang/test/utils/update_cc_test_checks/resolve-tmp-conflict.test Modified: llvm/utils/UpdateTestChecks/common.py Removed: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp b/clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp new file mode 100644 index ..d82490ea3c88 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s + +void foo(int a) { + int &tmp0 = a; + int &&tmp1 = 1; + tmp1 = a; + return; +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp.expected b/clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp.expected new file mode 100644 index ..9a3c4580f4c1 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/resolve-tmp-conflict.cpp.expected @@ -0,0 +1,25 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --prefix-filecheck-ir-name _ +// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s + +// CHECK-LABEL: define {{[^@]+}}@_Z3fooi +// CHECK-SAME: (i32 [[A:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT:[[_TMP0:%.*]] = alloca i32*, align 8 +// CHECK-NEXT:[[_TMP1:%.*]] = alloca i32*, align 8 +// CHECK-NEXT:[[REF_TMP:%.*]] = alloca i32, align 4 +// CHECK-NEXT:store i32 [[A]], i32* [[A_ADDR]], align 4 +// CHECK-NEXT:store i32* [[A_ADDR]], i32** [[_TMP0]], align 8 +// CHECK-NEXT:store i32 1, i32* [[REF_TMP]], align 4 +// CHECK-NEXT:store i32* [[REF_TMP]], i32** [[_TMP1]], align 8 +// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4 +// CHECK-NEXT:[[TMP1:%.*]] = load i32*, i32** [[_TMP1]], align 8 +// CHECK-NEXT:store i32 [[TMP0]], i32* [[TMP1]], align 4 +// CHECK-NEXT:ret void +// +void foo(int a) { + int &tmp0 = a; + int &&tmp1 = 1; + tmp1 = a; + return; +} diff --git a/clang/test/utils/update_cc_test_checks/resolve-tmp-conflict.test b/clang/test/utils/update_cc_test_checks/resolve-tmp-conflict.test new file mode 100644 index ..a802e1aeecd8 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/resolve-tmp-conflict.test @@ -0,0 +1,8 @@ +## Test that CHECK lines generated avoid naming conflicts with FileCheck IR variables + +# RUN: cp %S/Inputs/resolve-tmp-conflict.cpp %t.cpp && %update_cc_test_checks --function-signature --prefix-filecheck-ir-name _ %t.cpp +# RUN: diff -u %S/Inputs/resolve-tmp-conflict.cpp.expected %t.cpp + +## Check that re-running update_cc_test_checks doesn't change the output +# RUN: %update_cc_test_checks %t.cpp +# RUN: diff -u %S/Inputs/resolve-tmp-conflict.cpp.expected %t.cpp diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 1940ac3e8153..45984751d6e7 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -16,6 +16,7 @@ class string: _verbose = False +_prefix_filecheck_ir_name = '' def parse_commandline_args(parser): parser.add_argument('--include-generated-funcs', action='store_true', @@ -32,6 +33,8 @@ def parse_commandline_args(parser): help='Deactivate CHECK line generation from this point forward') parser.add_argument('--replace-function-regex', nargs='+', default=[], help='List of regular expressions t