CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -disable-O0-optnone -emit-llvm -o - | FileCheck %s
|
|
|
|
// Test optnone on template instantiations.
|
|
|
|
//-- Effect of optnone on generic add template function.
|
|
|
|
template <typename T> T template_normal(T a)
|
|
{
|
|
return a + a;
|
|
}
|
|
|
|
template <typename T> __attribute__((optnone)) T template_optnone(T a)
|
|
{
|
|
return a + a + a;
|
|
}
|
|
|
|
// This function should cause instantiations of each template, one marked
|
|
// with the 'optnone' attribute.
|
|
int container(int i)
|
|
{
|
|
return template_normal<int>(i) + template_optnone<int>(i);
|
|
}
|
|
|
|
// CHECK: @_Z15template_normalIiET_S0_({{.*}}) [[NORMAL:#[0-9]+]]
|
|
// CHECK: @_Z16template_optnoneIiET_S0_({{.*}}) [[OPTNONE:#[0-9]+]]
|
|
|
|
|
|
//-- Effect of optnone on a partial specialization.
|
|
// FIRST TEST: a method becomes marked with optnone in the specialization.
|
|
|
|
template <typename T, typename U> class template_normal_base {
|
|
public:
|
|
T method(T t, U u)
|
|
{
|
|
return t + static_cast<T>(u);
|
|
}
|
|
};
|
|
|
|
template <typename U> class template_normal_base<int, U>
|
|
{
|
|
public:
|
|
__attribute__((optnone)) int method (int t, U u)
|
|
{
|
|
return t - static_cast<int>(u);
|
|
}
|
|
};
|
|
|
|
// This function should cause an instantiation of the full template (whose
|
|
// method is not marked optnone) and an instantiation of the partially
|
|
// specialized template (whose method is marked optnone).
|
|
void container2()
|
|
{
|
|
int y = 2;
|
|
float z = 3.0;
|
|
template_normal_base<float, int> class_normal;
|
|
template_normal_base<int, float> class_optnone;
|
|
float r1 = class_normal.method(z, y);
|
|
float r2 = class_optnone.method(y, z);
|
|
}
|
|
|
|
// CHECK: @_ZN20template_normal_baseIfiE6methodEfi({{.*}}) [[NORMAL]]
|
|
// CHECK: @_ZN20template_normal_baseIifE6methodEif({{.*}}) [[OPTNONE]]
|
|
|
|
|
|
//-- Effect of optnone on a partial specialization.
|
|
// SECOND TEST: a method loses optnone in the specialization.
|
|
|
|
template <typename T, typename U> class template_optnone_base {
|
|
public:
|
|
__attribute__((optnone)) T method(T t, U u)
|
|
{
|
|
return t + static_cast<T>(u);
|
|
}
|
|
};
|
|
|
|
template <typename U> class template_optnone_base<int, U>
|
|
{
|
|
public:
|
|
int method (int t, U u)
|
|
{
|
|
return t - static_cast<int>(u);
|
|
}
|
|
};
|
|
|
|
// This function should cause an instantiation of the full template (whose
|
|
// method is marked optnone) and an instantiation of the partially
|
|
// specialized template (whose method is not marked optnone).
|
|
void container3()
|
|
{
|
|
int y = 2;
|
|
float z = 3.0;
|
|
template_optnone_base<float, int> class_optnone;
|
|
template_optnone_base<int, float> class_normal;
|
|
float r1 = class_optnone.method(z, y);
|
|
float r2 = class_normal.method(y, z);
|
|
}
|
|
|
|
// CHECK: @_ZN21template_optnone_baseIfiE6methodEfi({{.*}}) [[OPTNONE]]
|
|
// CHECK: @_ZN21template_optnone_baseIifE6methodEif({{.*}}) [[NORMAL]]
|
|
|
|
|
|
// CHECK: attributes [[NORMAL]] =
|
|
// CHECK-NOT: optnone
|
|
// CHECK: attributes [[OPTNONE]] = {{.*}} optnone
|