diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe b/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe deleted file mode 100755 index 39bc43023559e..0000000000000 Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe and /dev/null differ diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw deleted file mode 100644 index fcb661c0ba81d..0000000000000 Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw and /dev/null differ diff --git a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh index f06e6418edd65..ba648bf5ac9f7 100755 --- a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh +++ b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh @@ -95,39 +95,6 @@ rm ${OUTDIR}/memprof.cc rm ${OUTDIR}/pgo.exe rm ${OUTDIR}/memprof_pgo.profraw -# Use musttail to simulate a missing leaf debug frame in the profiled binary. -# Note we don't currently match onto explicit ::operator new calls, which is -# why the non-musttail case uses implicit new (which doesn't support musttail). -# Note that changes in the code below which affect relative line number -# offsets of calls from their parent function can affect callsite matching in -# the LLVM IR. -cat > ${OUTDIR}/memprof_missing_leaf.cc << EOF -#include -#ifndef USE_MUSTTAIL -#define USE_MUSTTAIL 0 -#endif - -// clang::musttail requires that the argument signature matches that of the caller. -void *bar(std::size_t s) { -#if USE_MUSTTAIL - [[clang::musttail]] return ::operator new (s); -#else - return new char[s]; -#endif -} - -int main() { - char *a = (char *)bar(1); - delete a; - return 0; -} -EOF - -${CLANG} ${COMMON_FLAGS} -fmemory-profile -DUSE_MUSTTAIL=1 ${OUTDIR}/memprof_missing_leaf.cc -o ${OUTDIR}/memprof_missing_leaf.exe -env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof_missing_leaf.exe > ${OUTDIR}/memprof_missing_leaf.memprofraw - -rm ${OUTDIR}/memprof_missing_leaf.cc - cat > ${OUTDIR}/memprof_internal_linkage.cc << EOF #include #include diff --git a/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll b/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll index e46945b763b1d..e6fb1863acbce 100644 --- a/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll +++ b/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll @@ -6,15 +6,58 @@ ;; Avoid failures on big-endian systems that can't read the profile properly ; REQUIRES: x86_64-linux -;; TODO: Use text profile inputs once that is available for memprof. -;; # To update the Inputs below, run Inputs/update_memprof_inputs.sh. ;; # To generate below LLVM IR for use in matching. ;; $ clang++ -gmlt -fdebug-info-for-profiling -S memprof_missing_leaf.cc \ ;; -O2 -emit-llvm +;; +;; where memprof_missing_leaf.cc is as follows: +;; +;; #include +;; +;; // Use musttail to simulate a missing leaf debug frame in the profiled binary. +;; // Note we don't currently match onto explicit ::operator new calls, which is +;; // why the non-musttail case uses implicit new (which doesn't support musttail). +;; // Note that changes in the code below which affect relative line number +;; // offsets of calls from their parent function can affect callsite matching in +;; // the LLVM IR. +;; #ifndef USE_MUSTTAIL +;; #define USE_MUSTTAIL 0 +;; #endif +;; +;; // clang::musttail requires that the argument signature matches that of the caller. +;; void *bar(std::size_t s) { +;; #if USE_MUSTTAIL +;; [[clang::musttail]] return ::operator new (s); +;; #else +;; return new char[s]; +;; #endif +;; } +;; +;; int main() { +;; char *a = (char *)bar(1); +;; delete a; +;; return 0; +;;} -; RUN: llvm-profdata merge %S/Inputs/memprof_missing_leaf.memprofraw --profiled-binary %S/Inputs/memprof_missing_leaf.exe -o %t.memprofdata -; RUN: opt < %s -passes='memprof-use' -S | FileCheck %s +; RUN: split-file %s %t +; RUN: llvm-profdata merge %t/memprof_missing_leaf.yaml -o %t/memprof_missing_leaf.memprofdata +; RUN: opt < %t/memprof_missing_leaf.ll -passes='memprof-use' -S | FileCheck %s +;--- memprof_missing_leaf.yaml +--- +HeapProfileRecords: + - GUID: main + AllocSites: + - Callstack: + - { Function: main, LineOffset: 1, Column: 21, IsInlineFrame: false } + MemInfoBlock: + AllocCount: 1 + TotalSize: 1 + TotalLifetime: 0 + TotalLifetimeAccessDensity: 0 + CallSites: [] +... +;--- memprof_missing_leaf.ll ; CHECK: call {{.*}} @_Znam{{.*}} #[[ATTR:[0-9]+]] ; CHECK: attributes #[[ATTR]] = {{.*}} "memprof"="notcold"