brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 485ec47 Raw
107 lines · cpp
1// REQUIRES: lld-available2 3// FIXME: Investigate and fix.4// XFAIL: powerpc64-target-arch5 6// RUN: %clang_profgen -fcoverage-mapping -c %s -o %t0.o7// RUN: %clang_profgen -fcoverage-mapping -c %s -DOBJ_1 -o %t1.o8// RUN: %clang_profgen -fcoverage-mapping -c %s -DOBJ_2 -o %t2.o9 10/// An external symbol can override a weak external symbol.11// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld %t0.o %t1.o -o %t112// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t1 | FileCheck %s --check-prefix=CHECK113// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE1_NOGC14// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld -Wl,--gc-sections %t0.o %t1.o -o %t115// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t1 | FileCheck %s --check-prefix=CHECK116// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE1_NOGC17 18// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld %t0.o %t2.o -o %t219// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t2 | FileCheck %s --check-prefix=CHECK220// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE2_NOGC21// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld -Wl,--gc-sections %t0.o %t2.o -o %t222// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t2 | FileCheck %s --check-prefix=CHECK223// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE2_GC24 25/// Repeat the above tests with -ffunction-sections.26// RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -c %s -o %t0.o27// RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -c %s -DOBJ_1 -o %t1.o28// RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -c %s -DOBJ_2 -o %t2.o29 30// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld %t0.o %t1.o -o %t131// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t1 | FileCheck %s --check-prefix=CHECK132// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE1_NOGC33// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld -Wl,--gc-sections %t0.o %t1.o -o %t134// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t1 | FileCheck %s --check-prefix=CHECK135// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE1_GC36 37// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld %t0.o %t2.o -o %t238// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t2 | FileCheck %s --check-prefix=CHECK239// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE2_NOGC40// RUN: %clang_profgen -fcoverage-mapping -fuse-ld=lld -Wl,--gc-sections %t0.o %t2.o -o %t241// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t2 | FileCheck %s --check-prefix=CHECK242// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s --check-prefix=PROFILE2_GC43 44// CHECK1: strong45// CHECK1: strong46 47/// __profc__Z4weakv in %t1.o is local and has a zero value.48/// Without GC it takes a duplicate entry.49// PROFILE1_NOGC:      _Z4weakv:50// PROFILE1_NOGC-NEXT:    Hash:51// PROFILE1_NOGC-NEXT:    Counters: 152// PROFILE1_NOGC-NEXT:    Function count: 053// PROFILE1_NOGC:      _Z4weakv:54// PROFILE1_NOGC-NEXT:    Hash:55// PROFILE1_NOGC-NEXT:    Counters: 156// PROFILE1_NOGC-NEXT:    Function count: 257 58// PROFILE1_GC:      _Z4weakv:59// PROFILE1_GC-NEXT:    Hash:60// PROFILE1_GC-NEXT:    Counters: 161// PROFILE1_GC-NEXT:    Function count: 262// PROFILE1_GC-NOT:  _Z4weakv:63 64// CHECK2: weak65// CHECK2: weak66 67/// __profc__Z4weakv in %t2.o is weak and resolves to the value of %t0.o's copy.68/// Without GC it takes a duplicate entry.69// PROFILE2_NOGC:      _Z4weakv:70// PROFILE2_NOGC-NEXT:    Hash:71// PROFILE2_NOGC-NEXT:    Counters: 172// PROFILE2_NOGC-NEXT:    Function count: 273// PROFILE2_NOGC:      _Z4weakv:74// PROFILE2_NOGC-NEXT:    Hash:75// PROFILE2_NOGC-NEXT:    Counters: 176// PROFILE2_NOGC-NEXT:    Function count: 277 78// PROFILE2_GC:      _Z4weakv:79// PROFILE2_GC-NEXT:    Hash:80// PROFILE2_GC-NEXT:    Counters: 181// PROFILE2_GC-NEXT:    Function count: 282// PROFILE2_GC-NOT:  _Z4weakv:83 84#ifdef OBJ_185#include <stdio.h>86 87void weak() { puts("strong"); }88void foo() { weak(); }89 90#elif defined(OBJ_2)91#include <stdio.h>92 93__attribute__((weak)) void weak() { puts("unreachable"); }94void foo() { weak(); }95 96#else97#include <stdio.h>98 99__attribute__((weak)) void weak() { puts("weak"); }100void foo();101 102int main() {103  foo();104  weak();105}106#endif107