Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,13 @@
struct FOO {
FOO() : a(0), b(0) {}
int callee();
__attribute__((noinline)) void caller(int n) {
int r = callee();
if (r == 0) {
a += n;
b += 1;
}
}
int a;
int volatile b;
};

View File

@@ -0,0 +1,33 @@
#include "comdat_rename.h"
// callee's out-of-line instance profile data -- it comes
// from external calls to it from comdat_rename_2.cc.
// Its inline instance copy's profile data is different and
// is collected in 'caller''s context.
int FOO::callee() {
// CHECK-LABEL: define {{.*}}callee{{.*}}
// CHECK-NOT: br i1 {{.*}}
// CHECK: br {{.*}}label{{.*}}, label %[[BB1:.*]], !prof ![[PD1:[0-9]+]]
// CHECK: {{.*}}[[BB1]]:
if (b != 0)
return a / b;
if (a != 0)
return 10 / a;
return 0;
}
// This is the 'caller''s comdat copy (after renaming) in this module.
// The profile counters include a copy of counters from 'callee':
//
// CHECK-LABEL: define {{.*}}caller{{.*}}
// CHECK-NOT: br i1 {{.*}}
// CHECK: br {{.*}}label{{.*}}, label %[[BB2:.*]], !prof ![[PD2:[0-9]+]]
// CHECK: {{.*}}[[BB2]]:
// CHECK: br {{.*}}label{{.*}}, label %{{.*}}, !prof !{{.*}}
// CHECK: br {{.*}}label %[[BB3:.*]], label %{{.*}} !prof ![[PD3:[0-9]+]]
// CHECK: {{.*}}[[BB3]]:
//
// CHECK:![[PD1]] = !{!"branch_weights", i32 0, i32 1}
// CHECK:![[PD2]] = !{!"branch_weights", i32 1, i32 0}
// CHECK:![[PD3]] = !{!"branch_weights", i32 {{.*}}, i32 0}
void test(FOO *foo) { foo->caller(10); }

View File

@@ -0,0 +1,18 @@
#include "comdat_rename.h"
extern void test(FOO *);
FOO foo;
int main() {
test(&foo);
foo.caller(20);
return 0;
}
// The copy of 'caller' defined in this module -- it has
// 'callee' call remaining.
//
// CHECK-LABEL: define {{.*}}caller{{.*}}
// CHECK: {{.*}} call {{.*}}
// CHECK-NOT: br i1 {{.*}}
// CHECK: br {{.*}}label %[[BB1:.*]], label{{.*}}!prof ![[PD1:[0-9]+]]
// CHECK: {{.*}}[[BB1]]:
// CHECK:![[PD1]] = !{!"branch_weights", i32 0, i32 1}

View File

@@ -0,0 +1,14 @@
#define DEF
#include "extern_template.h"
#undef DEF
extern int bar();
extern int foo();
extern Test<int> TO;
int main() {
foo();
int R = bar();
if (R != 10)
return 1;
return 0;
}

View File

@@ -0,0 +1,17 @@
template <typename T> struct Test {
Test() : M(10) {}
void doIt(int N) { // CHECK: [[@LINE]]| 2| void doIt
if (N > 10) { // CHECK: [[@LINE]]| 2| if (N > 10) {
M += 2; // CHECK: [[@LINE]]| 1| M += 2;
} else // CHECK: [[@LINE]]| 1| } else
M -= 2; // CHECK: [[@LINE]]| 1| M -= 2;
}
T M;
};
#ifdef USE
extern template struct Test<int>;
#endif
#ifdef DEF
template struct Test<int>;
#endif

View File

@@ -0,0 +1,9 @@
#define USE
#include "extern_template.h"
#undef USE
Test<int> TO;
int foo() {
TO.doIt(20);
return TO.M;
}

View File

@@ -0,0 +1,9 @@
#define USE
#include "extern_template.h"
#undef USE
extern Test<int> TO;
int bar() {
TO.doIt(5);
return TO.M;
}

View File

@@ -0,0 +1,8 @@
int X = 0;
int main() {
int i;
for (i = 0; i < 100; i++)
X += i;
return 0;
}

View File

@@ -0,0 +1,41 @@
/* This test case tests that when static allocation for value
* profiler is on, no malloc/calloc calls will be invoked by
* profile runtime library. */
#include <stdlib.h>
__attribute__((noinline)) void foo() {}
__attribute__((noinline)) void foo2() {}
void (*FP)();
int MainEntered = 0;
int CallocCalled = 0;
int MallocCalled = 0;
extern void *__real_calloc(size_t s, size_t n);
extern void *__real_malloc(size_t s);
void *__wrap_calloc(size_t s, size_t n) {
if (MainEntered)
CallocCalled = 1;
return __real_calloc(s, n);
}
void *__wrap_malloc(size_t s) {
if (MainEntered)
MallocCalled = 1;
return __real_malloc(s);
}
void getFP(int i) {
if (i % 2)
FP = foo;
else
FP = foo2;
}
int main() {
int i;
MainEntered = 1;
for (i = 0; i < 100; i++) {
getFP(i);
FP();
}
return CallocCalled + MallocCalled;
}

View File

@@ -0,0 +1,17 @@
#include "instrprof-comdat.h"
int g;
extern int bar(int);
int main() {
FOO<int> Foo;
int Res = Foo.DoIt(10);
if (Res > 10)
g = bar(10);
else
g = bar(1) + bar(2);
return 0;
}

View File

@@ -0,0 +1,12 @@
#include "instrprof-comdat.h"
int bar(int I) {
FOO<long> Foo;
FOO<int> Foo2;
if (I > 5)
return (int)Foo.DoIt(10);
else
return (int)Foo2.DoIt(I);
}

View File

@@ -0,0 +1,23 @@
// Template instantiations are placed into comdat sections. Check that
// coverage data from different instantiations are mapped back to the correct
// source regions.
template <class T> class FOO {
public:
FOO() : t(0) {}
T DoIt(T ti);
private:
T t;
};
template <class T> T FOO<T>::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template
for (T I = 0; I < ti; I++) { // HEADER: [[@LINE]]| 22| for (T
t += I; // HEADER: [[@LINE]]| 20| t += I;
if (I > ti / 2) // HEADER: [[@LINE]]| 20| if (I > ti
t -= 1; // HEADER: [[@LINE]]| 8| t -= 1;
} // HEADER: [[@LINE]]| 10| }
// HEADER: [[@LINE]]| 1|
return t; // HEADER: [[@LINE]]| 1| return t;
}

View File

@@ -0,0 +1,26 @@
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
dlerror();
void *f1_handle = dlopen("func.shared", RTLD_LAZY | RTLD_GLOBAL);
if (f1_handle == NULL) {
fprintf(stderr, "unable to open 'func.shared': %s\n", dlerror());
return EXIT_FAILURE;
}
void *f2_handle = dlopen("func2.shared", RTLD_LAZY | RTLD_GLOBAL);
if (f2_handle == NULL) {
fprintf(stderr, "unable to open 'func2.shared': %s\n", dlerror());
return EXIT_FAILURE;
}
if (dlclose(f2_handle) != 0) {
fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1 @@
void func(int K) { if (K) {} }

View File

@@ -0,0 +1 @@
void func2(int K) { if (K) {} }

View File

@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef DLOPEN_FUNC_DIR
#include <dlfcn.h>
#else
void func(int K);
void func2(int K);
#endif
int main(int argc, char *argv[]) {
#ifdef DLOPEN_FUNC_DIR
dlerror();
void *f1_handle = dlopen(DLOPEN_FUNC_DIR"/func.shared", DLOPEN_FLAGS);
if (f1_handle == NULL) {
fprintf(stderr, "unable to open '" DLOPEN_FUNC_DIR "/func.shared': %s\n",
dlerror());
return EXIT_FAILURE;
}
void (*func)(int) = (void (*)(int))dlsym(f1_handle, "func");
if (func == NULL) {
fprintf(stderr, "unable to lookup symbol 'func': %s\n", dlerror());
return EXIT_FAILURE;
}
void *f2_handle = dlopen(DLOPEN_FUNC_DIR"/func2.shared", DLOPEN_FLAGS);
if (f2_handle == NULL) {
fprintf(stderr, "unable to open '" DLOPEN_FUNC_DIR "/func2.shared': %s\n",
dlerror());
return EXIT_FAILURE;
}
void (*func2)(int) = (void (*)(int))dlsym(f2_handle, "func2");
if (func2 == NULL) {
fprintf(stderr, "unable to lookup symbol 'func2': %s\n", dlerror());
return EXIT_FAILURE;
}
#endif
func(1);
func2(0);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,7 @@
#include "instrprof-dynamic-header.h"
void a() { // COV: [[@LINE]]| 1|void a
if (true) { // COV: [[@LINE]]| 1| if
bar<void>(1); // COV: [[@LINE]]| 1| bar
bar<char>(1); // COV: [[@LINE]]| 1| bar
} // COV: [[@LINE]]| 1| }
}

View File

@@ -0,0 +1,7 @@
#include "instrprof-dynamic-header.h"
void b() {
if (true) {
bar<void>(1);
bar<int>(1);
}
}

View File

@@ -0,0 +1,7 @@
template <class T> void bar(int X) {
if (X) {
X *= 4;
}
}
void a();
void b();

View File

@@ -0,0 +1,9 @@
#include "instrprof-dynamic-header.h"
void foo(int K) { if (K) {} }
int main(int argc, char *argv[]) {
foo(5);
bar<void>(1);
a();
b();
return 0;
}

Some files were not shown because too many files have changed in this diff Show More