brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · feaa7c1 Raw
52 lines · cpp
1// Check that instrprof does not introduce references to discarded sections when2// using comdats.3//4// Occasionally, it is possible that the same function can be compiled in5// different TUs with slightly different linkages, e.g., due to different6// compiler options. However, if these are comdat functions, a single7// implementation will be chosen at link time. we want to ensure that the8// profiling data does not contain a reference to the discarded section.9 10// UNSUPPORTED: target={{.*windows.*}}11 12// RUN: mkdir -p %t.d13// RUN: %clangxx_pgogen -O2 -fPIC -ffunction-sections -fdata-sections -c %s -o %t.d/a1.o -DOBJECT_1 -mllvm -disable-preinline14// RUN: %clangxx_pgogen -O2 -fPIC -ffunction-sections -fdata-sections -c %s -o %t.d/a2.o15// RUN: %clangxx_pgogen -fPIC -shared -o %t.d/liba.so %t.d/a1.o %t.d/a2.o 2>&1 | FileCheck %s --allow-empty16 17// Ensure that we don't get an error when linking18// CHECK-NOT: relocation refers to a discarded section: .text._ZN1CIiE1fEi19 20template <typename T> struct C {21  void f(T x);22  int g(T x) {23    f(x);24    return v;25  }26  int v;27};28 29template <typename T>30#ifdef OBJECT_131__attribute__((weak))32#else33__attribute__((noinline))34#endif35void C<T>::f(T x) {36  v += x;37}38 39#ifdef OBJECT_140int foo() {41  C<int> c;42  c.f(1);43  return c.g(2);44}45#else46int bar() {47  C<int> c;48  c.f(3);49  return c.g(4);50}51#endif52