mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-01 17:36:06 +00:00

This switches everything to use the memory attribute proposed in https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579. The old argmemonly, inaccessiblememonly and inaccessiblemem_or_argmemonly attributes are dropped. The readnone, readonly and writeonly attributes are restricted to parameters only. The old attributes are auto-upgraded both in bitcode and IR. The bitcode upgrade is a policy requirement that has to be retained indefinitely. The IR upgrade is mainly there so it's not necessary to update all tests using memory attributes in this patch, which is already large enough. We could drop that part after migrating tests, or retain it longer term, to make it easier to import IR from older LLVM versions. High-level Function/CallBase APIs like doesNotAccessMemory() or setDoesNotAccessMemory() are mapped transparently to the memory attribute. Code that directly manipulates attributes (e.g. via AttributeList) on the other hand needs to switch to working with the memory attribute instead. Differential Revision: https://reviews.llvm.org/D135780
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -O2 -disable-llvm-passes -o - | FileCheck %s
|
|
|
|
__declspec(selectany) int x1 = 1;
|
|
const __declspec(selectany) int x2 = 2;
|
|
// CHECK: @x1 = weak_odr dso_local global i32 1, comdat, align 4
|
|
// CHECK: @x2 = weak_odr dso_local constant i32 2, comdat, align 4
|
|
|
|
// selectany turns extern variable declarations into definitions.
|
|
__declspec(selectany) int x3;
|
|
extern __declspec(selectany) int x4;
|
|
// CHECK: @x3 = weak_odr dso_local global i32 0, comdat, align 4
|
|
// CHECK: @x4 = weak_odr dso_local global i32 0, comdat, align 4
|
|
|
|
struct __declspec(align(16)) S {
|
|
char x;
|
|
};
|
|
union { struct S s; } u;
|
|
|
|
// CHECK: @u = {{.*}}zeroinitializer, align 16
|
|
|
|
|
|
// CHECK: define dso_local void @t3() [[NAKED:#[0-9]+]] {
|
|
__declspec(naked) void t3(void) {}
|
|
|
|
// CHECK: define dso_local void @t22() [[NUW:#[0-9]+]]
|
|
void __declspec(nothrow) t22(void);
|
|
void t22(void) {}
|
|
|
|
// CHECK: define dso_local void @t2() [[NI:#[0-9]+]] {
|
|
__declspec(noinline) void t2(void) {}
|
|
|
|
// CHECK: call void @f20_t() [[NR:#[0-9]+]]
|
|
__declspec(noreturn) void f20_t(void);
|
|
void f20(void) { f20_t(); }
|
|
|
|
__declspec(noalias) void noalias_callee(int *x);
|
|
// CHECK: call void @noalias_callee({{.*}}) [[NA:#[0-9]+]]
|
|
void noalias_caller(int *x) { noalias_callee(x); }
|
|
|
|
// CHECK: attributes [[NAKED]] = { naked noinline nounwind{{.*}} }
|
|
// CHECK: attributes [[NUW]] = { nounwind{{.*}} }
|
|
// CHECK: attributes [[NI]] = { noinline nounwind{{.*}} }
|
|
// CHECK: attributes [[NR]] = { noreturn }
|
|
// CHECK: attributes [[NA]] = { nounwind memory(argmem: readwrite){{.*}} }
|