2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-passes -o - %s | FileCheck %s
|
2012-03-07 04:05:56 +08:00
|
|
|
|
|
|
|
#include "literal-support.h"
|
|
|
|
|
|
|
|
// Check the various selector names we'll be using, in order.
|
|
|
|
|
|
|
|
// CHECK: c"numberWithInt:\00"
|
|
|
|
// CHECK: c"numberWithUnsignedInt:\00"
|
|
|
|
// CHECK: c"numberWithUnsignedLongLong:\00"
|
|
|
|
// CHECK: c"numberWithChar:\00"
|
2014-10-29 02:28:16 +08:00
|
|
|
// CHECK: c"arrayWithObjects:count:\00"
|
|
|
|
// CHECK: c"dictionaryWithObjects:forKeys:count:\00"
|
2012-03-07 04:05:56 +08:00
|
|
|
// CHECK: c"prop\00"
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test_numeric()
|
2012-03-07 04:05:56 +08:00
|
|
|
void test_numeric() {
|
|
|
|
// CHECK: {{call.*objc_msgSend.*i32 17}}
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue
|
2012-03-07 04:05:56 +08:00
|
|
|
id ilit = @17;
|
|
|
|
// CHECK: {{call.*objc_msgSend.*i32 25}}
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue
|
2012-03-07 04:05:56 +08:00
|
|
|
id ulit = @25u;
|
|
|
|
// CHECK: {{call.*objc_msgSend.*i64 42}}
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue
|
2012-03-07 04:05:56 +08:00
|
|
|
id ulllit = @42ull;
|
|
|
|
// CHECK: {{call.*objc_msgSend.*i8 signext 97}}
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue
|
2012-03-07 04:05:56 +08:00
|
|
|
id charlit = @'a';
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2012-03-07 04:05:56 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test_array
|
2012-03-07 04:05:56 +08:00
|
|
|
void test_array(id a, id b) {
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK: [[A:%.*]] = alloca i8*,
|
|
|
|
// CHECK: [[B:%.*]] = alloca i8*,
|
|
|
|
|
2012-03-07 04:05:56 +08:00
|
|
|
// Retaining parameters
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain(i8*
|
|
|
|
// CHECK: call i8* @llvm.objc.retain(i8*
|
2012-03-07 04:05:56 +08:00
|
|
|
|
|
|
|
// Constructing the array
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i64 0, i64 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[V0:%.*]] = load i8*, i8** [[A]],
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: store i8* [[V0]], i8** [[T0]]
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 1
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[B]],
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: store i8* [[V1]], i8** [[T0]]
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]*, [[CLASS_T:%.*]]** @"OBJC_CLASSLIST
|
|
|
|
// CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8*
|
2014-10-29 02:28:16 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8**
|
|
|
|
// CHECK-NEXT: [[T3:%.*]] = call i8* bitcast ({{.*@objc_msgSend.*}})(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i64 2)
|
2019-03-22 03:59:49 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T3]])
|
2018-12-21 02:05:41 +08:00
|
|
|
// CHECK: call void (...) @llvm.objc.clang.arc.use(i8* [[V0]], i8* [[V1]])
|
2012-03-07 04:05:56 +08:00
|
|
|
id arr = @[a, b];
|
|
|
|
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call void @llvm.objc.release
|
2012-03-07 04:05:56 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test_dictionary
|
2012-03-07 04:05:56 +08:00
|
|
|
void test_dictionary(id k1, id o1, id k2, id o2) {
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK: [[K1:%.*]] = alloca i8*,
|
|
|
|
// CHECK: [[O1:%.*]] = alloca i8*,
|
|
|
|
// CHECK: [[K2:%.*]] = alloca i8*,
|
|
|
|
// CHECK: [[O2:%.*]] = alloca i8*,
|
|
|
|
|
2012-03-07 04:05:56 +08:00
|
|
|
// Retaining parameters
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain(i8*
|
|
|
|
// CHECK: call i8* @llvm.objc.retain(i8*
|
|
|
|
// CHECK: call i8* @llvm.objc.retain(i8*
|
|
|
|
// CHECK: call i8* @llvm.objc.retain(i8*
|
2012-03-07 04:05:56 +08:00
|
|
|
|
|
|
|
// Constructing the arrays
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[KEYS:%[A-Za-z0-9]+]], i64 0, i64 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[V0:%.*]] = load i8*, i8** [[K1]],
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: store i8* [[V0]], i8** [[T0]]
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i64 0, i64 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[O1]],
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: store i8* [[V1]], i8** [[T0]]
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[KEYS]], i64 0, i64 1
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[K2]],
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: store i8* [[V2]], i8** [[T0]]
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 1
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[V3:%.*]] = load i8*, i8** [[O2]],
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: store i8* [[V3]], i8** [[T0]]
|
2012-03-07 04:05:56 +08:00
|
|
|
|
|
|
|
// Constructing the dictionary
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]*, [[CLASS_T:%.*]]** @"OBJC_CLASSLIST
|
|
|
|
// CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8*
|
2014-10-29 02:28:16 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8**
|
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast [2 x i8*]* [[KEYS]] to i8**
|
|
|
|
// CHECK-NEXT: [[T4:%.*]] = call i8* bitcast ({{.*@objc_msgSend.*}})(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i8** [[T3]], i64 2)
|
2019-03-22 03:59:49 +08:00
|
|
|
// CHECK-NEXT: [[T5:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T4]])
|
2018-12-21 02:05:41 +08:00
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.use(i8* [[V0]], i8* [[V1]], i8* [[V2]], i8* [[V3]])
|
2013-04-04 08:20:38 +08:00
|
|
|
|
2012-03-07 04:05:56 +08:00
|
|
|
id dict = @{ k1 : o1, k2 : o2 };
|
|
|
|
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call void @llvm.objc.release
|
2012-03-07 04:05:56 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
@interface A
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface B
|
|
|
|
@property (retain) A* prop;
|
|
|
|
@end
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test_property
|
2012-03-07 04:05:56 +08:00
|
|
|
void test_property(B *b) {
|
|
|
|
// Retain parameter
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
2012-03-07 04:05:56 +08:00
|
|
|
|
Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment. Introduce APIs on CGBuilderTy to work with Address
values. Change core APIs on CGF/CGM to traffic in Address where
appropriate. Require alignments to be non-zero. Update a ton
of code to compute and propagate alignment information.
As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.
The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned. Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay. I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.
Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.
We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment. In particular,
field access now uses alignmentAtOffset instead of min.
Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs. For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint. That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.
ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments. In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments. That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.
I partially punted on applying this work to CGBuiltin. Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.
llvm-svn: 246985
2015-09-08 16:05:57 +08:00
|
|
|
// CHECK: [[T0:%.*]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OBJECTS:%.*]], i64 0, i64 0
|
2013-04-04 08:20:38 +08:00
|
|
|
|
2012-03-07 04:05:56 +08:00
|
|
|
// Invoke 'prop'
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast
|
|
|
|
// CHECK-NEXT: [[T2:%.*]] = call [[B:%.*]]* bitcast ({{.*}} @objc_msgSend to {{.*}})(i8* [[T1]], i8* [[SEL]])
|
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast [[B]]* [[T2]] to i8*
|
2019-03-22 03:59:49 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T3]])
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: [[V0:%.*]] = bitcast i8* [[T4]] to [[B]]*
|
|
|
|
// CHECK-NEXT: [[V1:%.*]] = bitcast [[B]]* [[V0]] to i8*
|
|
|
|
|
|
|
|
// Store to array.
|
|
|
|
// CHECK-NEXT: store i8* [[V1]], i8** [[T0]]
|
2012-03-07 04:05:56 +08:00
|
|
|
|
2014-10-29 02:28:16 +08:00
|
|
|
// Invoke arrayWithObjects:count:
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T]]*, [[CLASS_T]]** @"OBJC_CLASSLIST
|
|
|
|
// CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8*
|
2014-10-29 02:28:16 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast [1 x i8*]* [[OBJECTS]] to i8**
|
|
|
|
// CHECK-NEXT: [[T3:%.*]] = call i8* bitcast ({{.*}} @objc_msgSend to {{.*}}(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i64 1)
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T3]])
|
2018-12-21 02:05:41 +08:00
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.use(i8* [[V1]])
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: store
|
2012-03-07 04:05:56 +08:00
|
|
|
id arr = @[ b.prop ];
|
|
|
|
|
|
|
|
// Release b.prop
|
2013-04-04 08:20:38 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = bitcast [[B]]* [[V0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
|
2012-03-07 04:05:56 +08:00
|
|
|
|
|
|
|
// Destroy arr
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2012-03-07 04:05:56 +08:00
|
|
|
|
|
|
|
// Destroy b
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2012-03-07 04:05:56 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|