[llvm] e1b569b - Revert "[memprof] Refactor tests to generate binaries and profiles on the fly."
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 15:51:48 PST 2023
Author: Snehasish Kumar
Date: 2023-03-06T23:48:52Z
New Revision: e1b569b96a06efe0993f7e478657337a6075cd71
URL: https://github.com/llvm/llvm-project/commit/e1b569b96a06efe0993f7e478657337a6075cd71
DIFF: https://github.com/llvm/llvm-project/commit/e1b569b96a06efe0993f7e478657337a6075cd71.diff
LOG: Revert "[memprof] Refactor tests to generate binaries and profiles on the fly."
This reverts commit 599b7690fa917ea4e9cd67275e34d0b5a0f51aa9. Since
adding a cross project dependency is a concern.
Added:
llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe
llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw
llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe
llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw
llvm/test/tools/llvm-profdata/Inputs/memprof-inline.exe
llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe
llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw
llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe
llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw
llvm/test/tools/llvm-profdata/memprof-basic.test
llvm/test/tools/llvm-profdata/memprof-inline.test
llvm/test/tools/llvm-profdata/memprof-merge.test
llvm/test/tools/llvm-profdata/memprof-multi.test
llvm/test/tools/llvm-profdata/memprof-pic.test
Modified:
compiler-rt/test/memprof/CMakeLists.txt
compiler-rt/test/memprof/lit.cfg.py
Removed:
compiler-rt/test/memprof/TestCases/memprof_basic.c
compiler-rt/test/memprof/TestCases/memprof_inline.c
compiler-rt/test/memprof/TestCases/memprof_merge.c
compiler-rt/test/memprof/TestCases/memprof_multi.c
compiler-rt/test/memprof/TestCases/memprof_pic.c
################################################################################
diff --git a/compiler-rt/test/memprof/CMakeLists.txt b/compiler-rt/test/memprof/CMakeLists.txt
index 1549a33191bbf..8a29919b17702 100644
--- a/compiler-rt/test/memprof/CMakeLists.txt
+++ b/compiler-rt/test/memprof/CMakeLists.txt
@@ -13,7 +13,6 @@ endmacro()
set(MEMPROF_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
if(NOT COMPILER_RT_STANDALONE_BUILD)
- list(APPEND MEMPROF_TEST_DEPS llvm-profdata)
list(APPEND MEMPROF_TEST_DEPS memprof)
if(COMPILER_RT_HAS_LLD AND TARGET lld)
list(APPEND MEMPROF_TEST_DEPS lld)
diff --git a/compiler-rt/test/memprof/TestCases/memprof_basic.c b/compiler-rt/test/memprof/TestCases/memprof_basic.c
deleted file mode 100644
index 660811bc1cedd..0000000000000
--- a/compiler-rt/test/memprof/TestCases/memprof_basic.c
+++ /dev/null
@@ -1,106 +0,0 @@
-// REQUIRES: x86_64-linux
-// RUN: %clang_memprof -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie %s -o %t.memprofexe
-// RUN: env MEMPROF_OPTIONS=log_path=stdout %t.memprofexe > %t.memprofraw
-// RUN: %llvm_profdata show --memory %t.memprofraw --profiled-binary %t.memprofexe -o - | FileCheck %s
-#include <stdlib.h>
-#include <string.h>
-int main(int argc, char **argv) {
- char *x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- return 0;
-}
-
-// COM: We expect 2 MIB entries, 1 each for the malloc calls in the program. Any
-// COM: additional allocations which do not originate from the main binary are pruned.
-
-// CHECK: MemprofProfile:
-// CHECK-NEXT: Summary:
-// CHECK-NEXT: Version: 2
-// CHECK-NEXT: NumSegments: {{[0-9]+}}
-// CHECK-NEXT: NumMibInfo: 2
-// CHECK-NEXT: NumAllocFunctions: 1
-// CHECK-NEXT: NumStackOffsets: 2
-// CHECK-NEXT: Segments:
-// CHECK-NEXT: -
-// CHECK-NEXT: BuildId: <None>
-// CHECK-NEXT: Start: 0x{{[0-9]+}}
-// CHECK-NEXT: End: 0x{{[0-9]+}}
-// CHECK-NEXT: Offset: 0x{{[0-9]+}}
-// CHECK-NEXT: -
-
-// CHECK: Records:
-// CHECK-NEXT: -
-// CHECK-NEXT: FunctionGUID: {{[0-9]+}}
-// CHECK-NEXT: AllocSites:
-// CHECK-NEXT: -
-// CHECK-NEXT: Callstack:
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: {{[0-9]+}}
-// CHECK-NEXT: SymbolName: main
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 21
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: MemInfoBlock:
-// CHECK-NEXT: AllocCount: 1
-// CHECK-NEXT: TotalAccessCount: 2
-// CHECK-NEXT: MinAccessCount: 2
-// CHECK-NEXT: MaxAccessCount: 2
-// CHECK-NEXT: TotalSize: 10
-// CHECK-NEXT: MinSize: 10
-// CHECK-NEXT: MaxSize: 10
-// CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: TotalLifetime: 0
-// CHECK-NEXT: MinLifetime: 0
-// CHECK-NEXT: MaxLifetime: 0
-// CHECK-NEXT: AllocCpuId: {{[0-9]+}}
-// CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
-// CHECK-NEXT: NumMigratedCpu: 0
-// CHECK-NEXT: NumLifetimeOverlaps: 0
-// CHECK-NEXT: NumSameAllocCpu: 0
-// CHECK-NEXT: NumSameDeallocCpu: 0
-// CHECK-NEXT: DataTypeId: {{[0-9]+}}
-// CHECK-NEXT: TotalAccessDensity: 20
-// CHECK-NEXT: MinAccessDensity: 20
-// CHECK-NEXT: MaxAccessDensity: 20
-// CHECK-NEXT: TotalLifetimeAccessDensity: 20000
-// CHECK-NEXT: MinLifetimeAccessDensity: 20000
-// CHECK-NEXT: MaxLifetimeAccessDensity: 20000
-// CHECK-NEXT: -
-// CHECK-NEXT: Callstack:
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: {{[0-9]+}}
-// CHECK-NEXT: SymbolName: main
-// CHECK-NEXT: LineOffset: 4
-// CHECK-NEXT: Column: 15
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: MemInfoBlock:
-// CHECK-NEXT: AllocCount: 1
-// CHECK-NEXT: TotalAccessCount: 2
-// CHECK-NEXT: MinAccessCount: 2
-// CHECK-NEXT: MaxAccessCount: 2
-// CHECK-NEXT: TotalSize: 10
-// CHECK-NEXT: MinSize: 10
-// CHECK-NEXT: MaxSize: 10
-// CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: TotalLifetime: 0
-// CHECK-NEXT: MinLifetime: 0
-// CHECK-NEXT: MaxLifetime: 0
-// CHECK-NEXT: AllocCpuId: {{[0-9]+}}
-// CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
-// CHECK-NEXT: NumMigratedCpu: 0
-// CHECK-NEXT: NumLifetimeOverlaps: 0
-// CHECK-NEXT: NumSameAllocCpu: 0
-// CHECK-NEXT: NumSameDeallocCpu: 0
-// CHECK-NEXT: DataTypeId: {{[0-9]+}}
-// CHECK-NEXT: TotalAccessDensity: 20
-// CHECK-NEXT: MinAccessDensity: 20
-// CHECK-NEXT: MaxAccessDensity: 20
-// CHECK-NEXT: TotalLifetimeAccessDensity: 20000
-// CHECK-NEXT: MinLifetimeAccessDensity: 20000
-// CHECK-NEXT: MaxLifetimeAccessDensity: 20000
diff --git a/compiler-rt/test/memprof/TestCases/memprof_inline.c b/compiler-rt/test/memprof/TestCases/memprof_inline.c
deleted file mode 100644
index bb97608637674..0000000000000
--- a/compiler-rt/test/memprof/TestCases/memprof_inline.c
+++ /dev/null
@@ -1,183 +0,0 @@
-// REQUIRES: x86_64-linux
-// RUN: %clang_memprof -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie %s -o %t.memprofexe
-// RUN: env MEMPROF_OPTIONS=log_path=stdout %t.memprofexe > %t.memprofraw
-// RUN: %llvm_profdata show --memory %t.memprofraw --profiled-binary %t.memprofexe | FileCheck %s
-#include <stdlib.h>
-#include <string.h>
-
-__attribute__((always_inline)) void qux(int x) {
- char *ptr = malloc(x);
- memset(ptr, 0, x);
- free(ptr);
-}
-
-__attribute__((noinline)) void foo(int x) { qux(x); }
-
-__attribute__((noinline)) void bar(int x) { foo(x); }
-
-int main(int argc, char **argv) {
- bar(argc);
- return 0;
-}
-
-// CHECK: MemprofProfile:
-// CHECK-NEXT: Summary:
-// CHECK-NEXT: Version: 2
-// CHECK-NEXT: NumSegments: {{[0-9]+}}
-// CHECK-NEXT: NumMibInfo: 2
-// CHECK-NEXT: NumAllocFunctions: 2
-// CHECK-NEXT: NumStackOffsets: 1
-// CHECK-NEXT: Segments:
-// CHECK-NEXT: -
-// CHECK-NEXT: BuildId: <None>
-// CHECK-NEXT: Start: 0x{{[0-9]+}}
-// CHECK-NEXT: End: 0x{{[0-9]+}}
-// CHECK-NEXT: Offset: 0x{{[0-9]+}}
-// CHECK-NEXT: -
-
-// CHECK: Records:
-// CHECK-NEXT: -
-// CHECK-NEXT: FunctionGUID: 15505678318020221912
-// CHECK-NEXT: AllocSites:
-// CHECK-NEXT: -
-// CHECK-NEXT: Callstack:
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 15505678318020221912
-// CHECK-NEXT: SymbolName: qux
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 15
-// CHECK-NEXT: Inline: 1
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 6699318081062747564
-// CHECK-NEXT: SymbolName: foo
-// CHECK-NEXT: LineOffset: 0
-// CHECK-NEXT: Column: 45
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 16434608426314478903
-// CHECK-NEXT: SymbolName: bar
-// CHECK-NEXT: LineOffset: 0
-// CHECK-NEXT: Column: 45
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 15822663052811949562
-// CHECK-NEXT: SymbolName: main
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 3
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: MemInfoBlock:
-// CHECK-NEXT: AllocCount: 1
-// CHECK-NEXT: TotalAccessCount: 1
-// CHECK-NEXT: MinAccessCount: 1
-// CHECK-NEXT: MaxAccessCount: 1
-// CHECK-NEXT: TotalSize: 1
-// CHECK-NEXT: MinSize: 1
-// CHECK-NEXT: MaxSize: 1
-// CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: TotalLifetime: 0
-// CHECK-NEXT: MinLifetime: 0
-// CHECK-NEXT: MaxLifetime: 0
-// CHECK-NEXT: AllocCpuId: {{[0-9]+}}
-// CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
-// CHECK-NEXT: NumMigratedCpu: 0
-// CHECK-NEXT: NumLifetimeOverlaps: 0
-// CHECK-NEXT: NumSameAllocCpu: 0
-// CHECK-NEXT: NumSameDeallocCpu: 0
-// CHECK-NEXT: DataTypeId: {{[0-9]+}}
-// CHECK-NEXT: TotalAccessDensity: 100
-// CHECK-NEXT: MinAccessDensity: 100
-// CHECK-NEXT: MaxAccessDensity: 100
-// CHECK-NEXT: TotalLifetimeAccessDensity: 100000
-// CHECK-NEXT: MinLifetimeAccessDensity: 100000
-// CHECK-NEXT: MaxLifetimeAccessDensity: 100000
-// CHECK-NEXT: -
-// CHECK-NEXT: FunctionGUID: 6699318081062747564
-// CHECK-NEXT: AllocSites:
-// CHECK-NEXT: -
-// CHECK-NEXT: Callstack:
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 15505678318020221912
-// CHECK-NEXT: SymbolName: qux
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 15
-// CHECK-NEXT: Inline: 1
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 6699318081062747564
-// CHECK-NEXT: SymbolName: foo
-// CHECK-NEXT: LineOffset: 0
-// CHECK-NEXT: Column: 45
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 16434608426314478903
-// CHECK-NEXT: SymbolName: bar
-// CHECK-NEXT: LineOffset: 0
-// CHECK-NEXT: Column: 45
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 15822663052811949562
-// CHECK-NEXT: SymbolName: main
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 3
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: MemInfoBlock:
-// CHECK-NEXT: AllocCount: 1
-// CHECK-NEXT: TotalAccessCount: 1
-// CHECK-NEXT: MinAccessCount: 1
-// CHECK-NEXT: MaxAccessCount: 1
-// CHECK-NEXT: TotalSize: 1
-// CHECK-NEXT: MinSize: 1
-// CHECK-NEXT: MaxSize: 1
-// CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
-// CHECK-NEXT: TotalLifetime: 0
-// CHECK-NEXT: MinLifetime: 0
-// CHECK-NEXT: MaxLifetime: 0
-// CHECK-NEXT: AllocCpuId: {{[0-9]+}}
-// CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
-// CHECK-NEXT: NumMigratedCpu: 0
-// CHECK-NEXT: NumLifetimeOverlaps: 0
-// CHECK-NEXT: NumSameAllocCpu: 0
-// CHECK-NEXT: NumSameDeallocCpu: 0
-// CHECK-NEXT: DataTypeId: {{[0-9]+}}
-// CHECK-NEXT: TotalAccessDensity: 100
-// CHECK-NEXT: MinAccessDensity: 100
-// CHECK-NEXT: MaxAccessDensity: 100
-// CHECK-NEXT: TotalLifetimeAccessDensity: 100000
-// CHECK-NEXT: MinLifetimeAccessDensity: 100000
-// CHECK-NEXT: MaxLifetimeAccessDensity: 100000
-// CHECK-NEXT: CallSites:
-// CHECK-NEXT: -
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 15505678318020221912
-// CHECK-NEXT: SymbolName: qux
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 15
-// CHECK-NEXT: Inline: 1
-// CHECK-NEXT: -
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 6699318081062747564
-// CHECK-NEXT: SymbolName: foo
-// CHECK-NEXT: LineOffset: 0
-// CHECK-NEXT: Column: 45
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: -
-// CHECK-NEXT: FunctionGUID: 16434608426314478903
-// CHECK-NEXT: CallSites:
-// CHECK-NEXT: -
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 16434608426314478903
-// CHECK-NEXT: SymbolName: bar
-// CHECK-NEXT: LineOffset: 0
-// CHECK-NEXT: Column: 45
-// CHECK-NEXT: Inline: 0
-// CHECK-NEXT: -
-// CHECK-NEXT: FunctionGUID: 15822663052811949562
-// CHECK-NEXT: CallSites:
-// CHECK-NEXT: -
-// CHECK-NEXT: -
-// CHECK-NEXT: Function: 15822663052811949562
-// CHECK-NEXT: SymbolName: main
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 3
-// CHECK-NEXT: Inline: 0
diff --git a/compiler-rt/test/memprof/TestCases/memprof_merge.c b/compiler-rt/test/memprof/TestCases/memprof_merge.c
deleted file mode 100644
index 0250623a56641..0000000000000
--- a/compiler-rt/test/memprof/TestCases/memprof_merge.c
+++ /dev/null
@@ -1,27 +0,0 @@
-// REQUIRES: x86_64-linux
-// COM: Name compression disabled since some buildbots do not have zlib.
-// RUN: %clang -mllvm -enable-name-compression=false -fprofile-generate %s -o %t.instr.out
-// RUN: env LLVM_PROFILE_FILE=%t.profraw %t.instr.out
-// RUN: %clang_memprof -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie %s -o %t.memprofexe
-// RUN: env MEMPROF_OPTIONS=log_path=stdout %t.memprofexe > %t.memprofraw
-// RUN: %llvm_profdata merge %t.profraw %t.memprofraw --profiled-binary %t.memprofexe -o %t.prof
-// RUN: %llvm_profdata show %t.prof | FileCheck %s
-#include <stdlib.h>
-#include <string.h>
-int main(int argc, char **argv) {
- char *x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- return 0;
-}
-
-// COM: For now we only check the validity of the instrumented profile since we don't
-// COM: have a way to display the contents of the memprof indexed format yet.
-
-// CHECK: Instrumentation level: IR entry_first = 0
-// CHECK: Total functions: 1
-// CHECK: Maximum function count: 1
-// CHECK: Maximum internal block count: 0
diff --git a/compiler-rt/test/memprof/TestCases/memprof_multi.c b/compiler-rt/test/memprof/TestCases/memprof_multi.c
deleted file mode 100644
index ebbb5a5bbcf42..0000000000000
--- a/compiler-rt/test/memprof/TestCases/memprof_multi.c
+++ /dev/null
@@ -1,35 +0,0 @@
-// REQUIRES: x86_64-linux
-// RUN: %clang_memprof -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie %s -o %t.memprofexe
-// RUN: env MEMPROF_OPTIONS=log_path=stdout %t.memprofexe > %t.memprofraw
-// RUN: %llvm_profdata show --memory %t.memprofraw --profiled-binary %t.memprofexe -o - | FileCheck %s
-#include <sanitizer/memprof_interface.h>
-#include <stdlib.h>
-#include <string.h>
-int main(int argc, char **argv) {
- char *x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- __memprof_profile_dump();
- x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- return 0;
-}
-
-// COM: We expect 2 MIB entries, 1 each for the malloc calls in the program.
-
-// CHECK: MemprofProfile:
-// CHECK-NEXT: Summary:
-// CHECK-NEXT: Version: 2
-// CHECK-NEXT: NumSegments: {{[0-9]+}}
-// CHECK-NEXT: NumMibInfo: 2
-// CHECK-NEXT: NumAllocFunctions: 1
-// CHECK-NEXT: NumStackOffsets: 2
-
-// CHECK: SymbolName: main
-// CHECK-NEXT: LineOffset: 1
-// CHECK-NEXT: Column: 21
-
-// CHECK: SymbolName: main
-// CHECK-NEXT: LineOffset: 5
-// CHECK-NEXT: Column: 15
diff --git a/compiler-rt/test/memprof/TestCases/memprof_pic.c b/compiler-rt/test/memprof/TestCases/memprof_pic.c
deleted file mode 100644
index 1709ce2c63da9..0000000000000
--- a/compiler-rt/test/memprof/TestCases/memprof_pic.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// REQUIRES: x86_64-linux
-// RUN: %clang_memprof -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -pie %s -o %t.memprofexe
-// RUN: env MEMPROF_OPTIONS=log_path=stdout %t.memprofexe > %t.memprofraw
-// RUN: not %llvm_profdata show --memory %t.memprofraw --profiled-binary %t.memprofexe -o - 2>&1 | FileCheck %s
-#include <stdlib.h>
-#include <string.h>
-int main(int argc, char **argv) {
- char *x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- x = (char *)malloc(10);
- memset(x, 0, 10);
- free(x);
- return 0;
-}
-
-// COM: This test ensures that llvm-profdata fails with a descriptive error message
-// COM: when invoked on a memprof profiled binary which was built with position
-// COM: independent code.
-// CHECK: Unsupported position independent code
diff --git a/compiler-rt/test/memprof/lit.cfg.py b/compiler-rt/test/memprof/lit.cfg.py
index bf284392178bb..e472101b1f16e 100644
--- a/compiler-rt/test/memprof/lit.cfg.py
+++ b/compiler-rt/test/memprof/lit.cfg.py
@@ -65,9 +65,6 @@ def get_required_attr(config, attr_name):
def build_invocation(compile_flags):
return ' ' + ' '.join([config.clang] + compile_flags) + ' '
-# We need llvm-profdata for tests with raw binary profiles.
-config.substitutions.append( ("%llvm_profdata ", config.llvm_tools_dir+'/llvm-profdata ') )
-
config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
config.substitutions.append( ("%clang_memprof ", build_invocation(clang_memprof_cflags)) )
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe
new file mode 100755
index 0000000000000..4d3e4798e4791
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw
new file mode 100644
index 0000000000000..88da4a76e47f0
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe
new file mode 100755
index 0000000000000..82aad1948982d
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw
new file mode 100755
index 0000000000000..f9f84e227b220
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/memprof-inline.exe b/llvm/test/tools/llvm-profdata/Inputs/memprof-inline.exe
new file mode 100755
index 0000000000000..9b6fd16e9a272
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/memprof-inline.exe
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe
new file mode 100755
index 0000000000000..507cf982993e7
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw
new file mode 100644
index 0000000000000..b6b895ff96fa9
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe
new file mode 100755
index 0000000000000..eb1cd9b4bb778
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe
diff er
diff --git a/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw
new file mode 100644
index 0000000000000..9b16c8f5dd0b5
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw
diff er
diff --git a/llvm/test/tools/llvm-profdata/memprof-basic.test b/llvm/test/tools/llvm-profdata/memprof-basic.test
new file mode 100644
index 0000000000000..a070845b5ab06
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-basic.test
@@ -0,0 +1,126 @@
+REQUIRES: x86_64-linux
+
+The input raw profile test has been generated from the following source code:
+
+```
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char *x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ return 0;
+}
+```
+
+The following commands were used to compile the source to a memprof instrumented
+executable and collect a raw binary format profile. Since the profile contains
+virtual addresses for the callstack, we do not expect the raw binary profile to
+be deterministic. The summary should be deterministic apart from changes to
+the shared libraries linked in which could change the number of segments
+recorded.
+
+```
+clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
+ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
+ -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie \
+ source.c -o basic.memprofexe
+
+env MEMPROF_OPTIONS=log_path=stdout ./basic.memprofexe > basic.memprofraw
+```
+
+RUN: llvm-profdata show --memory %p/Inputs/basic.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o - | FileCheck %s
+
+We expect 2 MIB entries, 1 each for the malloc calls in the program. Any
+additional allocations which do not originate from the main binary are pruned.
+
+CHECK: MemprofProfile:
+CHECK-NEXT: Summary:
+CHECK-NEXT: Version: 2
+CHECK-NEXT: NumSegments: {{[0-9]+}}
+CHECK-NEXT: NumMibInfo: 2
+CHECK-NEXT: NumAllocFunctions: 1
+CHECK-NEXT: NumStackOffsets: 2
+CHECK-NEXT: Segments:
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x{{[0-9]+}}
+CHECK-NEXT: End: 0x{{[0-9]+}}
+CHECK-NEXT: Offset: 0x{{[0-9]+}}
+CHECK-NEXT: -
+
+CHECK: Records:
+CHECK-NEXT: -
+CHECK-NEXT: FunctionGUID: {{[0-9]+}}
+CHECK-NEXT: AllocSites:
+CHECK-NEXT: -
+CHECK-NEXT: Callstack:
+CHECK-NEXT: -
+CHECK-NEXT: Function: {{[0-9]+}}
+CHECK-NEXT: SymbolName: main
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 21
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: MemInfoBlock:
+CHECK-NEXT: AllocCount: 1
+CHECK-NEXT: TotalAccessCount: 2
+CHECK-NEXT: MinAccessCount: 2
+CHECK-NEXT: MaxAccessCount: 2
+CHECK-NEXT: TotalSize: 10
+CHECK-NEXT: MinSize: 10
+CHECK-NEXT: MaxSize: 10
+CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
+CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
+CHECK-NEXT: TotalLifetime: 0
+CHECK-NEXT: MinLifetime: 0
+CHECK-NEXT: MaxLifetime: 0
+CHECK-NEXT: AllocCpuId: {{[0-9]+}}
+CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
+CHECK-NEXT: NumMigratedCpu: 0
+CHECK-NEXT: NumLifetimeOverlaps: 0
+CHECK-NEXT: NumSameAllocCpu: 0
+CHECK-NEXT: NumSameDeallocCpu: 0
+CHECK-NEXT: DataTypeId: {{[0-9]+}}
+CHECK-NEXT: TotalAccessDensity: 20
+CHECK-NEXT: MinAccessDensity: 20
+CHECK-NEXT: MaxAccessDensity: 20
+CHECK-NEXT: TotalLifetimeAccessDensity: 20000
+CHECK-NEXT: MinLifetimeAccessDensity: 20000
+CHECK-NEXT: MaxLifetimeAccessDensity: 20000
+CHECK-NEXT: -
+CHECK-NEXT: Callstack:
+CHECK-NEXT: -
+CHECK-NEXT: Function: {{[0-9]+}}
+CHECK-NEXT: SymbolName: main
+CHECK-NEXT: LineOffset: 4
+CHECK-NEXT: Column: 15
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: MemInfoBlock:
+CHECK-NEXT: AllocCount: 1
+CHECK-NEXT: TotalAccessCount: 2
+CHECK-NEXT: MinAccessCount: 2
+CHECK-NEXT: MaxAccessCount: 2
+CHECK-NEXT: TotalSize: 10
+CHECK-NEXT: MinSize: 10
+CHECK-NEXT: MaxSize: 10
+CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
+CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
+CHECK-NEXT: TotalLifetime: 0
+CHECK-NEXT: MinLifetime: 0
+CHECK-NEXT: MaxLifetime: 0
+CHECK-NEXT: AllocCpuId: {{[0-9]+}}
+CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
+CHECK-NEXT: NumMigratedCpu: 0
+CHECK-NEXT: NumLifetimeOverlaps: 0
+CHECK-NEXT: NumSameAllocCpu: 0
+CHECK-NEXT: NumSameDeallocCpu: 0
+CHECK-NEXT: DataTypeId: {{[0-9]+}}
+CHECK-NEXT: TotalAccessDensity: 20
+CHECK-NEXT: MinAccessDensity: 20
+CHECK-NEXT: MaxAccessDensity: 20
+CHECK-NEXT: TotalLifetimeAccessDensity: 20000
+CHECK-NEXT: MinLifetimeAccessDensity: 20000
+CHECK-NEXT: MaxLifetimeAccessDensity: 20000
diff --git a/llvm/test/tools/llvm-profdata/memprof-inline.test b/llvm/test/tools/llvm-profdata/memprof-inline.test
new file mode 100644
index 0000000000000..87eaa8364d308
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-inline.test
@@ -0,0 +1,201 @@
+REQUIRES: x86_64-linux
+
+The input raw profile test has been generated from the following source code:
+
+```
+#include <stdlib.h>
+#include <string.h>
+
+__attribute__((always_inline))
+void qux(int x) {
+ char *ptr = malloc(x);
+ memset(ptr, 0, x);
+ free(ptr);
+}
+
+__attribute__((noinline))
+void foo(int x){ qux(x); }
+
+__attribute__((noinline))
+void bar(int x) { foo(x); }
+
+int main(int argc, char **argv) {
+ bar(argc);
+ return 0;
+}
+```
+
+Compile and run with the following commands:
+
+```
+bin/clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
+ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
+ -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie \
+ inline.c -o inline.memprofexe
+
+env MEMPROF_OPTIONS=log_path=stdout ./inline.memprofexe > inline.memprofraw
+```
+
+RUN: llvm-profdata show --memory %p/Inputs/inline.memprofraw --profiled-binary %p/Inputs/inline.memprofexe | FileCheck %s
+
+CHECK: MemprofProfile:
+CHECK-NEXT: Summary:
+CHECK-NEXT: Version: 2
+CHECK-NEXT: NumSegments: {{[0-9]+}}
+CHECK-NEXT: NumMibInfo: 2
+CHECK-NEXT: NumAllocFunctions: 2
+CHECK-NEXT: NumStackOffsets: 1
+CHECK-NEXT: Segments:
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x{{[0-9]+}}
+CHECK-NEXT: End: 0x{{[0-9]+}}
+CHECK-NEXT: Offset: 0x{{[0-9]+}}
+CHECK-NEXT: -
+
+CHECK: Records:
+CHECK-NEXT: -
+CHECK-NEXT: FunctionGUID: 15505678318020221912
+CHECK-NEXT: AllocSites:
+CHECK-NEXT: -
+CHECK-NEXT: Callstack:
+CHECK-NEXT: -
+CHECK-NEXT: Function: 15505678318020221912
+CHECK-NEXT: SymbolName: qux
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 15
+CHECK-NEXT: Inline: 1
+CHECK-NEXT: -
+CHECK-NEXT: Function: 6699318081062747564
+CHECK-NEXT: SymbolName: foo
+CHECK-NEXT: LineOffset: 0
+CHECK-NEXT: Column: 18
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: -
+CHECK-NEXT: Function: 16434608426314478903
+CHECK-NEXT: SymbolName: bar
+CHECK-NEXT: LineOffset: 0
+CHECK-NEXT: Column: 19
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: -
+CHECK-NEXT: Function: 15822663052811949562
+CHECK-NEXT: SymbolName: main
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 3
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: MemInfoBlock:
+CHECK-NEXT: AllocCount: 1
+CHECK-NEXT: TotalAccessCount: 1
+CHECK-NEXT: MinAccessCount: 1
+CHECK-NEXT: MaxAccessCount: 1
+CHECK-NEXT: TotalSize: 1
+CHECK-NEXT: MinSize: 1
+CHECK-NEXT: MaxSize: 1
+CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
+CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
+CHECK-NEXT: TotalLifetime: 0
+CHECK-NEXT: MinLifetime: 0
+CHECK-NEXT: MaxLifetime: 0
+CHECK-NEXT: AllocCpuId: {{[0-9]+}}
+CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
+CHECK-NEXT: NumMigratedCpu: 0
+CHECK-NEXT: NumLifetimeOverlaps: 0
+CHECK-NEXT: NumSameAllocCpu: 0
+CHECK-NEXT: NumSameDeallocCpu: 0
+CHECK-NEXT: DataTypeId: {{[0-9]+}}
+CHECK-NEXT: TotalAccessDensity: 100
+CHECK-NEXT: MinAccessDensity: 100
+CHECK-NEXT: MaxAccessDensity: 100
+CHECK-NEXT: TotalLifetimeAccessDensity: 100000
+CHECK-NEXT: MinLifetimeAccessDensity: 100000
+CHECK-NEXT: MaxLifetimeAccessDensity: 100000
+CHECK-NEXT: -
+CHECK-NEXT: FunctionGUID: 6699318081062747564
+CHECK-NEXT: AllocSites:
+CHECK-NEXT: -
+CHECK-NEXT: Callstack:
+CHECK-NEXT: -
+CHECK-NEXT: Function: 15505678318020221912
+CHECK-NEXT: SymbolName: qux
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 15
+CHECK-NEXT: Inline: 1
+CHECK-NEXT: -
+CHECK-NEXT: Function: 6699318081062747564
+CHECK-NEXT: SymbolName: foo
+CHECK-NEXT: LineOffset: 0
+CHECK-NEXT: Column: 18
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: -
+CHECK-NEXT: Function: 16434608426314478903
+CHECK-NEXT: SymbolName: bar
+CHECK-NEXT: LineOffset: 0
+CHECK-NEXT: Column: 19
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: -
+CHECK-NEXT: Function: 15822663052811949562
+CHECK-NEXT: SymbolName: main
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 3
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: MemInfoBlock:
+CHECK-NEXT: AllocCount: 1
+CHECK-NEXT: TotalAccessCount: 1
+CHECK-NEXT: MinAccessCount: 1
+CHECK-NEXT: MaxAccessCount: 1
+CHECK-NEXT: TotalSize: 1
+CHECK-NEXT: MinSize: 1
+CHECK-NEXT: MaxSize: 1
+CHECK-NEXT: AllocTimestamp: {{[0-9]+}}
+CHECK-NEXT: DeallocTimestamp: {{[0-9]+}}
+CHECK-NEXT: TotalLifetime: 0
+CHECK-NEXT: MinLifetime: 0
+CHECK-NEXT: MaxLifetime: 0
+CHECK-NEXT: AllocCpuId: {{[0-9]+}}
+CHECK-NEXT: DeallocCpuId: {{[0-9]+}}
+CHECK-NEXT: NumMigratedCpu: 0
+CHECK-NEXT: NumLifetimeOverlaps: 0
+CHECK-NEXT: NumSameAllocCpu: 0
+CHECK-NEXT: NumSameDeallocCpu: 0
+CHECK-NEXT: DataTypeId: {{[0-9]+}}
+CHECK-NEXT: TotalAccessDensity: 100
+CHECK-NEXT: MinAccessDensity: 100
+CHECK-NEXT: MaxAccessDensity: 100
+CHECK-NEXT: TotalLifetimeAccessDensity: 100000
+CHECK-NEXT: MinLifetimeAccessDensity: 100000
+CHECK-NEXT: MaxLifetimeAccessDensity: 100000
+CHECK-NEXT: CallSites:
+CHECK-NEXT: -
+CHECK-NEXT: -
+CHECK-NEXT: Function: 15505678318020221912
+CHECK-NEXT: SymbolName: qux
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 15
+CHECK-NEXT: Inline: 1
+CHECK-NEXT: -
+CHECK-NEXT: -
+CHECK-NEXT: Function: 6699318081062747564
+CHECK-NEXT: SymbolName: foo
+CHECK-NEXT: LineOffset: 0
+CHECK-NEXT: Column: 18
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: -
+CHECK-NEXT: FunctionGUID: 16434608426314478903
+CHECK-NEXT: CallSites:
+CHECK-NEXT: -
+CHECK-NEXT: -
+CHECK-NEXT: Function: 16434608426314478903
+CHECK-NEXT: SymbolName: bar
+CHECK-NEXT: LineOffset: 0
+CHECK-NEXT: Column: 19
+CHECK-NEXT: Inline: 0
+CHECK-NEXT: -
+CHECK-NEXT: FunctionGUID: 15822663052811949562
+CHECK-NEXT: CallSites:
+CHECK-NEXT: -
+CHECK-NEXT: -
+CHECK-NEXT: Function: 15822663052811949562
+CHECK-NEXT: SymbolName: main
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 3
+CHECK-NEXT: Inline: 0
diff --git a/llvm/test/tools/llvm-profdata/memprof-merge.test b/llvm/test/tools/llvm-profdata/memprof-merge.test
new file mode 100644
index 0000000000000..46de2adc9941e
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-merge.test
@@ -0,0 +1,48 @@
+REQUIRES: x86_64-linux
+
+The input memprof and instrumented raw profiles were generated from the following source code:
+
+```
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char *x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ return 0;
+}
+```
+
+Steps to collect the memprof raw profile and the instrprof raw profile:
+
+```
+# Collect instrprof profile with name compression disabled since some buildbots
+# do not have zlib.
+clang -mllvm -enable-name-compression=false -fprofile-generate source.c -o instr.out
+./instr.out
+mv *.profraw basic.profraw
+
+# Collect memprof profile.
+clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
+ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
+ -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie \
+ source.c -o basic.memprofexe
+
+env MEMPROF_OPTIONS=log_path=stdout ./basic.memprofexe > basic.memprofraw
+```
+
+RUN: llvm-profdata merge %p/Inputs/basic.profraw %p/Inputs/basic.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof
+RUN: llvm-profdata show %t.prof | FileCheck %s
+
+For now we only check the validity of the instrumented profile since we don't
+have a way to display the contents of the memprof indexed format yet.
+
+CHECK: Instrumentation level: IR entry_first = 0
+CHECK: Total functions: 1
+CHECK: Maximum function count: 1
+CHECK: Maximum internal block count: 0
+
+
diff --git a/llvm/test/tools/llvm-profdata/memprof-multi.test b/llvm/test/tools/llvm-profdata/memprof-multi.test
new file mode 100644
index 0000000000000..cb5b7dfaeb0a7
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-multi.test
@@ -0,0 +1,55 @@
+REQUIRES: x86_64-linux
+
+The input raw profile test has been generated from the following source code:
+
+```
+#include <sanitizer/memprof_interface.h>
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char *x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ __memprof_profile_dump();
+ x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ return 0;
+}
+```
+
+The following commands were used to compile the source to a memprof instrumented
+executable and collect a raw binary format profile. Since the profile contains
+virtual addresses for the callstack, we do not expect the raw binary profile to
+be deterministic. The summary should be deterministic apart from changes to
+the shared libraries linked in which could change the number of segments
+recorded.
+
+```
+clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
+ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
+ -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie \
+ source.c -o multi.memprofexe
+
+env MEMPROF_OPTIONS=log_path=stdout ./multi.memprofexe > multi.memprofraw
+```
+
+RUN: llvm-profdata show --memory %p/Inputs/multi.memprofraw --profiled-binary %p/Inputs/multi.memprofexe -o - | FileCheck %s
+
+We expect 2 MIB entries, 1 each for the malloc calls in the program.
+
+CHECK: MemprofProfile:
+CHECK-NEXT: Summary:
+CHECK-NEXT: Version: 2
+CHECK-NEXT: NumSegments: {{[0-9]+}}
+CHECK-NEXT: NumMibInfo: 2
+CHECK-NEXT: NumAllocFunctions: 1
+CHECK-NEXT: NumStackOffsets: 2
+
+CHECK: SymbolName: main
+CHECK-NEXT: LineOffset: 1
+CHECK-NEXT: Column: 21
+
+CHECK: SymbolName: main
+CHECK-NEXT: LineOffset: 5
+CHECK-NEXT: Column: 15
diff --git a/llvm/test/tools/llvm-profdata/memprof-pic.test b/llvm/test/tools/llvm-profdata/memprof-pic.test
new file mode 100644
index 0000000000000..f993c441ceaa5
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-pic.test
@@ -0,0 +1,40 @@
+REQUIRES: x86_64-linux
+
+This test ensures that llvm-profdata fails with a descriptive error message
+when invoked on a memprof profiled binary which was built with position
+independent code.
+
+The input raw profile test has been generated from the following source code:
+
+```
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char *x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ x = (char *)malloc(10);
+ memset(x, 0, 10);
+ free(x);
+ return 0;
+}
+```
+
+The following commands were used to compile the source to a memprof instrumented
+executable and collect a raw binary format profile. Since the profile contains
+virtual addresses for the callstack, we do not expect the raw binary profile to
+be deterministic. The summary should be deterministic apart from changes to
+the shared libraries linked in which could change the number of segments
+recorded.
+
+```
+clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
+ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
+ -fno-optimize-sibling-calls -m64 -Wl,-build-id -pie \
+ source.c -o pic.memprofexe
+
+env MEMPROF_OPTIONS=log_path=stdout ./pic.memprofexe > pic.memprofraw
+```
+
+RUN: not llvm-profdata show --memory %p/Inputs/pic.memprofraw --profiled-binary %p/Inputs/pic.memprofexe -o - 2>&1 | FileCheck %s
+CHECK: Unsupported position independent code
More information about the llvm-commits
mailing list