mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 11:56:07 +00:00

This patch updates Clang's IRGen to add !annotation nodes with an "auto-init" annotation to all stores for auto-initialization. As discussed in 'RFC: Combining Annotation Metadata and Remarks' (http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html) this allows using optimization remarks to track down where auto-init code was inserted (and not removed by optimizations). There are a few cases in the tests where !annotation gets dropped by optimizations. Those optimizations will be updated in subsequent patches. This patch is based on a patch by Francis Visoiu Mistrih. Reviewed By: thegameg, paquette Differential Revision: https://reviews.llvm.org/D91417
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks %s -emit-llvm -o - | FileCheck %s -check-prefix=UNINIT
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO
|
|
|
|
template<typename T> void used(T &) noexcept;
|
|
|
|
extern "C" {
|
|
|
|
// UNINIT-LABEL: test_attribute_uninitialized(
|
|
// UNINIT: alloca
|
|
// UNINIT-NEXT: call void
|
|
// ZERO-LABEL: test_attribute_uninitialized(
|
|
// ZERO: alloca
|
|
// ZERO-NOT: !annotation
|
|
// ZERO-NEXT: call void
|
|
// PATTERN-LABEL: test_attribute_uninitialized(
|
|
// PATTERN: alloca
|
|
// PATTERN-NOT: !annotation
|
|
// PATTERN-NEXT: call void
|
|
void test_attribute_uninitialized() {
|
|
[[clang::uninitialized]] int i;
|
|
used(i);
|
|
}
|
|
|
|
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable(is_local))
|
|
// UNINIT-LABEL: test_pragma_attribute_uninitialized(
|
|
// UNINIT: alloca
|
|
// UNINIT-NEXT: call void
|
|
// ZERO-LABEL: test_pragma_attribute_uninitialized(
|
|
// ZERO: alloca
|
|
// ZERO-NEXT: call void
|
|
// PATTERN-LABEL: test_pragma_attribute_uninitialized(
|
|
// PATTERN: alloca
|
|
// PATTERN-NEXT: call void
|
|
void test_pragma_attribute_uninitialized() {
|
|
int i;
|
|
used(i);
|
|
}
|
|
#pragma clang attribute pop
|
|
|
|
} // extern "C"
|