2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -DDEFINE_GUID -triple=i386-pc-linux -fms-extensions | FileCheck %s --check-prefix=CHECK-DEFINE-GUID
|
2016-09-03 11:25:22 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -DDEFINE_GUID -DBRACKET_ATTRIB -triple=i386-pc-linux -fms-extensions | FileCheck %s --check-prefix=CHECK-DEFINE-GUID
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-linux -fms-extensions | FileCheck %s
|
2016-03-27 12:46:14 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux -fms-extensions | FileCheck %s --check-prefix=CHECK-64
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -DDEFINE_GUID -DWRONG_GUID -triple=i386-pc-linux -fms-extensions | FileCheck %s --check-prefix=CHECK-DEFINE-WRONG-GUID
|
2012-10-11 18:13:44 +08:00
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
#ifdef DEFINE_GUID
|
|
|
|
struct _GUID {
|
|
|
|
#ifdef WRONG_GUID
|
|
|
|
unsigned int SomethingWentWrong;
|
|
|
|
#else
|
2012-10-11 18:13:44 +08:00
|
|
|
unsigned long Data1;
|
|
|
|
unsigned short Data2;
|
|
|
|
unsigned short Data3;
|
|
|
|
unsigned char Data4[8];
|
2013-08-16 03:59:14 +08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
typedef struct _GUID GUID;
|
2012-10-11 18:13:44 +08:00
|
|
|
|
2016-09-03 11:25:22 +08:00
|
|
|
#ifdef BRACKET_ATTRIB
|
|
|
|
[uuid(12345678-1234-1234-1234-1234567890aB)] struct S1 { } s1;
|
|
|
|
[uuid(87654321-4321-4321-4321-ba0987654321)] struct S2 { };
|
|
|
|
[uuid({12345678-1234-1234-1234-1234567890ac})] struct Curly;
|
|
|
|
[uuid({12345678-1234-1234-1234-1234567890ac})] struct Curly;
|
|
|
|
#else
|
2013-08-09 16:35:59 +08:00
|
|
|
struct __declspec(uuid("12345678-1234-1234-1234-1234567890aB")) S1 { } s1;
|
2012-10-11 18:13:44 +08:00
|
|
|
struct __declspec(uuid("87654321-4321-4321-4321-ba0987654321")) S2 { };
|
2013-08-09 16:56:20 +08:00
|
|
|
struct __declspec(uuid("{12345678-1234-1234-1234-1234567890ac}")) Curly;
|
2015-01-21 09:04:28 +08:00
|
|
|
struct __declspec(uuid("{12345678-1234-1234-1234-1234567890ac}")) Curly;
|
2016-09-03 11:25:22 +08:00
|
|
|
#endif
|
2013-08-09 16:56:20 +08:00
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
#ifdef DEFINE_GUID
|
2013-08-09 16:56:20 +08:00
|
|
|
// Make sure we can properly generate code when the UUID has curly braces on it.
|
|
|
|
GUID thing = __uuidof(Curly);
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK-DEFINE-GUID: @thing = global %struct._GUID zeroinitializer, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: @thing = global %struct._GUID zeroinitializer, align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
|
|
|
|
// This gets initialized in a static initializer.
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK-DEFINE-GUID: @g = global %struct._GUID zeroinitializer, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: @g = global %struct._GUID zeroinitializer, align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
GUID g = __uuidof(S1);
|
2013-08-16 03:59:14 +08:00
|
|
|
#endif
|
2012-10-11 18:13:44 +08:00
|
|
|
|
|
|
|
// First global use of __uuidof(S1) forces the creation of the global.
|
2015-01-21 09:04:28 +08:00
|
|
|
// CHECK: @_GUID_12345678_1234_1234_1234_1234567890ab = linkonce_odr constant { i32, i16, i16, [8 x i8] } { i32 305419896, i16 4660, i16 4660, [8 x i8] c"\124\124Vx\90\AB" }, comdat
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: @gr = constant %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to %struct._GUID*), align 4
|
2016-03-27 12:46:14 +08:00
|
|
|
// CHECK-64: @gr = constant %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to %struct._GUID*), align 8
|
2012-10-11 18:13:44 +08:00
|
|
|
const GUID& gr = __uuidof(S1);
|
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: @gp = global %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to %struct._GUID*), align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
const GUID* gp = &__uuidof(S1);
|
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: @cp = global %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ac to %struct._GUID*), align 4
|
2013-08-09 16:56:20 +08:00
|
|
|
const GUID* cp = &__uuidof(Curly);
|
|
|
|
|
2012-10-11 18:13:44 +08:00
|
|
|
// Special case: _uuidof(0)
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: @zeroiid = constant %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_00000000_0000_0000_0000_000000000000 to %struct._GUID*), align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
const GUID& zeroiid = __uuidof(0);
|
|
|
|
|
|
|
|
// __uuidof(S2) hasn't been used globally yet, so it's emitted when it's used
|
|
|
|
// in a function and is emitted at the end of the globals section.
|
2015-01-21 09:04:28 +08:00
|
|
|
// CHECK: @_GUID_87654321_4321_4321_4321_ba0987654321 = linkonce_odr constant { i32, i16, i16, [8 x i8] } { i32 -2023406815, i16 17185, i16 17185, [8 x i8] c"C!\BA\09\87eC!" }, comdat
|
2013-08-16 03:59:14 +08:00
|
|
|
|
|
|
|
// The static initializer for thing.
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK-DEFINE-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 bitcast (%struct._GUID* @thing to i8*), i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ac to i8*), i32 16, i1 false)
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 bitcast (%struct._GUID* @thing to i8*), i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ac to i8*), i32 4, i1 false)
|
2012-10-11 18:13:44 +08:00
|
|
|
|
|
|
|
// The static initializer for g.
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK-DEFINE-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 bitcast (%struct._GUID* @g to i8*), i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 16, i1 false)
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 bitcast (%struct._GUID* @g to i8*), i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 4, i1 false)
|
2012-10-11 18:13:44 +08:00
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
#ifdef DEFINE_GUID
|
2012-10-11 18:13:44 +08:00
|
|
|
void fun() {
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK-DEFINE-GUID: %s1_1 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: %s1_1 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-GUID: %s1_2 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: %s1_2 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-GUID: %s1_3 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: %s1_3 = alloca %struct._GUID, align 4
|
|
|
|
|
|
|
|
// CHECK-DEFINE-GUID: [[U1:%.+]] = bitcast %struct._GUID* %s1_1 to i8*
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: [[U1:%.+]] = bitcast %struct._GUID* %s1_1 to i8*
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK-DEFINE-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[U1]], i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 16, i1 false)
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[U1]], i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 4, i1 false)
|
2012-10-11 18:13:44 +08:00
|
|
|
GUID s1_1 = __uuidof(S1);
|
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK-DEFINE-GUID: [[U2:%.+]] = bitcast %struct._GUID* %s1_2 to i8*
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: [[U2:%.+]] = bitcast %struct._GUID* %s1_2 to i8*
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK-DEFINE-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[U2]], i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 16, i1 false)
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[U2]], i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 4, i1 false)
|
2012-10-11 18:13:44 +08:00
|
|
|
GUID s1_2 = __uuidof(S1);
|
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK-DEFINE-GUID: [[U3:%.+]] = bitcast %struct._GUID* %s1_3 to i8*
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: [[U3:%.+]] = bitcast %struct._GUID* %s1_3 to i8*
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK-DEFINE-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[U3]], i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 16, i1 false)
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[U3]], i8* align 4 bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab to i8*), i32 4, i1 false)
|
2012-10-11 18:13:44 +08:00
|
|
|
GUID s1_3 = __uuidof(s1);
|
|
|
|
}
|
2013-08-16 03:59:14 +08:00
|
|
|
#endif
|
2012-10-11 18:13:44 +08:00
|
|
|
|
|
|
|
void gun() {
|
2013-08-16 03:59:14 +08:00
|
|
|
#ifdef DEFINE_GUID
|
|
|
|
// CHECK-DEFINE-GUID: %s2_1 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: %s2_1 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-GUID: %s2_2 = alloca %struct._GUID, align 4
|
|
|
|
// CHECK-DEFINE-WRONG-GUID: %s2_2 = alloca %struct._GUID, align 4
|
|
|
|
GUID s2_1 = __uuidof(S2);
|
|
|
|
GUID s2_2 = __uuidof(S2);
|
|
|
|
#endif
|
2012-10-11 18:13:44 +08:00
|
|
|
// CHECK: %r = alloca %struct._GUID*, align 4
|
|
|
|
// CHECK: %p = alloca %struct._GUID*, align 4
|
|
|
|
// CHECK: %zeroiid = alloca %struct._GUID*, align 4
|
|
|
|
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: store %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_87654321_4321_4321_4321_ba0987654321 to %struct._GUID*), %struct._GUID** %r, align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
const GUID& r = __uuidof(S2);
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: store %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_87654321_4321_4321_4321_ba0987654321 to %struct._GUID*), %struct._GUID** %p, align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
const GUID* p = &__uuidof(S2);
|
|
|
|
|
|
|
|
// Special case _uuidof(0), local scope version.
|
2013-08-16 03:59:14 +08:00
|
|
|
// CHECK: store %struct._GUID* bitcast ({ i32, i16, i16, [8 x i8] }* @_GUID_00000000_0000_0000_0000_000000000000 to %struct._GUID*), %struct._GUID** %zeroiid, align 4
|
2012-10-11 18:13:44 +08:00
|
|
|
const GUID& zeroiid = __uuidof(0);
|
|
|
|
}
|