|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir |
| 2 | +// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR |
| 3 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 | +// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll |
| 6 | +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 | + |
| 8 | +template<class T> |
| 9 | +class X { |
| 10 | +public: |
| 11 | + int f() { return 0; } |
| 12 | +}; |
| 13 | + |
| 14 | +template<> class X<int> { |
| 15 | +public: |
| 16 | + int f() { return 1; } |
| 17 | +}; |
| 18 | + |
| 19 | +// TODO: This will get dropped when we are deferring functions |
| 20 | +// The speecialization is instantiated first |
| 21 | +// CIR: cir.func{{.*}} @_ZN1XIiE1fEv |
| 22 | +// CIR: cir.const #cir.int<1> |
| 23 | + |
| 24 | +// LLVM: define{{.*}} i32 @_ZN1XIiE1fEv |
| 25 | +// LLVM: store i32 1 |
| 26 | + |
| 27 | +void test_double() { |
| 28 | + X<double> d; |
| 29 | + d.f(); |
| 30 | +} |
| 31 | + |
| 32 | +// CIR: cir.func{{.*}} @_ZN1XIdE1fEv |
| 33 | +// CIR: cir.const #cir.int<0> |
| 34 | +// |
| 35 | +// CIR: cir.func{{.*}} @_Z11test_doublev() |
| 36 | +// CIR: cir.call @_ZN1XIdE1fEv |
| 37 | + |
| 38 | +// LLVM: define{{.*}} i32 @_ZN1XIdE1fEv |
| 39 | +// LLVM: store i32 0 |
| 40 | +// |
| 41 | +// LLVM: define{{.*}} void @_Z11test_doublev() |
| 42 | +// LLVM: call i32 @_ZN1XIdE1fEv |
| 43 | + |
| 44 | +// OGCG: define{{.*}} void @_Z11test_doublev() |
| 45 | +// OGCG: call{{.*}} i32 @_ZN1XIdE1fEv |
| 46 | +// |
| 47 | +// OGCG: define{{.*}} i32 @_ZN1XIdE1fEv |
| 48 | +// OGCG: ret i32 0 |
| 49 | + |
| 50 | +void test_int() { |
| 51 | + X<int> n; |
| 52 | + n.f(); |
| 53 | +} |
| 54 | + |
| 55 | +// CIR: cir.func{{.*}} @_Z8test_intv() |
| 56 | +// CIR: cir.call @_ZN1XIiE1fEv |
| 57 | + |
| 58 | +// LLVM: define{{.*}} void @_Z8test_intv() |
| 59 | +// LLVM: call i32 @_ZN1XIiE1fEv |
| 60 | + |
| 61 | +// OGCG: define{{.*}} void @_Z8test_intv() |
| 62 | +// OGCG: call{{.*}} i32 @_ZN1XIiE1fEv |
| 63 | +// |
| 64 | +// OGCG: define{{.*}} i32 @_ZN1XIiE1fEv |
| 65 | +// OGCG: ret i32 1 |
| 66 | + |
| 67 | +void test_short() { |
| 68 | + X<short> s; |
| 69 | + s.f(); |
| 70 | +} |
| 71 | + |
| 72 | +// CIR: cir.func{{.*}} @_ZN1XIsE1fEv |
| 73 | +// CIR: cir.const #cir.int<0> |
| 74 | +// |
| 75 | +// CIR: cir.func{{.*}} @_Z10test_shortv() |
| 76 | +// CIR: cir.call @_ZN1XIsE1fEv |
| 77 | + |
| 78 | +// LLVM: define{{.*}} i32 @_ZN1XIsE1fEv |
| 79 | +// LLVM: store i32 0 |
| 80 | +// |
| 81 | +// LLVM: define{{.*}} void @_Z10test_shortv() |
| 82 | +// LLVM: call i32 @_ZN1XIsE1fEv |
| 83 | + |
| 84 | +// OGCG: define{{.*}} void @_Z10test_shortv() |
| 85 | +// OGCG: call{{.*}} i32 @_ZN1XIsE1fEv |
| 86 | +// |
| 87 | +// OGCG: define{{.*}} i32 @_ZN1XIsE1fEv |
| 88 | +// OGCG: ret i32 0 |
0 commit comments