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
107 lines
2.4 KiB
C++
107 lines
2.4 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/mod.cppm \
|
|
// RUN: -emit-module-interface -o %t/mod.pcm
|
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/use.cpp \
|
|
// RUN: -fmodule-file=mod=%t/mod.pcm -emit-llvm \
|
|
// RUN: -o - | opt -S --passes=simplifycfg | FileCheck %t/use.cpp
|
|
|
|
//--- mod.cppm
|
|
export module mod;
|
|
|
|
export struct Thing {
|
|
static const Thing One;
|
|
explicit Thing(int raw) :raw(raw) { }
|
|
int raw;
|
|
};
|
|
|
|
const Thing Thing::One = Thing(1);
|
|
|
|
export struct C {
|
|
int value;
|
|
};
|
|
export const C ConstantValue = {1};
|
|
|
|
export const C *ConstantPtr = &ConstantValue;
|
|
|
|
C NonConstantValue = {1};
|
|
export const C &ConstantRef = NonConstantValue;
|
|
|
|
export struct NonConstexprDtor {
|
|
constexpr NonConstexprDtor(int raw) : raw(raw) {}
|
|
~NonConstexprDtor();
|
|
|
|
int raw;
|
|
};
|
|
|
|
export const NonConstexprDtor NonConstexprDtorValue = {1};
|
|
|
|
//--- use.cpp
|
|
import mod;
|
|
|
|
int consume(int);
|
|
int consumeC(C);
|
|
|
|
extern "C" __attribute__((noinline)) inline int unneeded() {
|
|
return consume(43);
|
|
}
|
|
|
|
extern "C" __attribute__((noinline)) inline int needed() {
|
|
return consume(43);
|
|
}
|
|
|
|
int use() {
|
|
Thing t1 = Thing::One;
|
|
return consume(t1.raw);
|
|
}
|
|
|
|
int use2() {
|
|
if (ConstantValue.value)
|
|
return consumeC(ConstantValue);
|
|
return unneeded();
|
|
}
|
|
|
|
int use3() {
|
|
auto Ptr = ConstantPtr;
|
|
if (Ptr->value)
|
|
return consumeC(*Ptr);
|
|
return needed();
|
|
}
|
|
|
|
int use4() {
|
|
auto Ref = ConstantRef;
|
|
if (Ref.value)
|
|
return consumeC(Ref);
|
|
return needed();
|
|
}
|
|
|
|
int use5() {
|
|
NonConstexprDtor V = NonConstexprDtorValue;
|
|
if (V.raw)
|
|
return consume(V.raw);
|
|
return needed();
|
|
}
|
|
|
|
// CHECK: @_ZNW3mod5Thing3OneE = external
|
|
// CHECK: @_ZW3mod13ConstantValue ={{.*}}available_externally{{.*}} constant
|
|
// CHECK: @_ZW3mod11ConstantPtr = external
|
|
// CHECK: @_ZW3mod16NonConstantValue = external
|
|
// CHECK: @_ZW3mod21NonConstexprDtorValue = external
|
|
|
|
// Check that the middle end can optimize the program by the constant information.
|
|
// CHECK-NOT: @unneeded(
|
|
|
|
// Check that the use of ConstantPtr won't get optimized incorrectly.
|
|
// CHECK-LABEL: @_Z4use3v(
|
|
// CHECK: @needed(
|
|
|
|
// Check that the use of ConstantRef won't get optimized incorrectly.
|
|
// CHECK-LABEL: @_Z4use4v(
|
|
// CHECK: @needed(
|
|
|
|
// Check that the use of NonConstexprDtorValue won't get optimized incorrectly.
|
|
// CHECK-LABEL: @_Z4use5v(
|
|
// CHECK: @needed(
|