Skip to content

Commit d86188b

Browse files
split codegen tests based on feedback
1 parent 3cd3157 commit d86188b

6 files changed

+261
-280
lines changed

clang/test/OpenMP/target_vtable_codegen.cpp

Lines changed: 0 additions & 280 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple x86_64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=52 -stdlib=libc++
2+
// RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -debug-info-kind=limited -fopenmp-version=52 -stdlib=libc++ | FileCheck %s
3+
// expected-no-diagnostics
4+
5+
// CHECK-DAG: @_ZTV7Derived
6+
// CHECK-DAG: @_ZTV4Base
7+
template <typename T>
8+
class Container {
9+
private:
10+
T value;
11+
public:
12+
Container() : value() {}
13+
Container(T val) : value(val) {}
14+
15+
T getValue() const { return value; }
16+
17+
void setValue(T val) { value = val; }
18+
};
19+
20+
class Base {
21+
public:
22+
virtual void foo() {}
23+
};
24+
class Derived : public Base {};
25+
26+
class Test {
27+
public:
28+
Container<Derived> v;
29+
};
30+
31+
int main() {
32+
Test test;
33+
Derived d;
34+
test.v.setValue(d);
35+
36+
// Make sure we emit VTable for type indirectly (template specialized type)
37+
#pragma omp target map(test)
38+
{
39+
test.v.getValue().foo();
40+
}
41+
return 0;
42+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple x86_64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=52
2+
// RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -debug-info-kind=limited -fopenmp-version=52 | FileCheck %s
3+
// expected-no-diagnostics
4+
5+
// Make sure both host and device compilation emit vtable for Dervied
6+
// CHECK-DAG: $_ZN7DerivedD1Ev = comdat any
7+
// CHECK-DAG: $_ZN7DerivedD0Ev = comdat any
8+
// CHECK-DAG: $_ZN7Derived5BaseAEi = comdat any
9+
// CHECK-DAG: $_ZN7Derived8DerivedBEv = comdat any
10+
// CHECK-DAG: $_ZN7DerivedD2Ev = comdat any
11+
// CHECK-DAG: $_ZN4BaseD2Ev = comdat any
12+
// CHECK-DAG: $_ZTV7Derived = comdat any
13+
class Base {
14+
public:
15+
16+
virtual ~Base() = default;
17+
18+
virtual void BaseA(int a) { }
19+
};
20+
21+
// CHECK: @_ZTV7Derived = linkonce_odr unnamed_addr constant { [6 x ptr] }
22+
class Derived : public Base {
23+
public:
24+
25+
~Derived() override = default;
26+
27+
void BaseA(int a) override { x = a; }
28+
29+
virtual void DerivedB() { }
30+
private:
31+
int x;
32+
};
33+
34+
int main() {
35+
36+
Derived d;
37+
Base& c = d;
38+
int a = 50;
39+
// Should emit vtable for Derived since d is added to map clause
40+
#pragma omp target data map (to: d, a)
41+
{
42+
#pragma omp target map(d)
43+
{
44+
c.BaseA(a);
45+
}
46+
}
47+
return 0;
48+
}

0 commit comments

Comments
 (0)