summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2017-12-21 20:52:59 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2017-12-21 20:52:59 +0000
commitc98d5adb4e64815effa4855a3804cc1a9a7d2958 (patch)
tree981a8637af50bc26cffee333bcd73007a93d52b8
parent0cfb502ef74bf3e9444debaad649f928179136be (diff)
downloadclang-c98d5adb4e64815effa4855a3804cc1a9a7d2958.tar.gz
Revert "[CodeGen] Fix crash when a function taking transparent union is redeclared."
This reverts commit r321296. It caused performance regressions FAIL: imp.execution_time FAIL: 2007-01-04-KNR-Args.execution_time FAIL: sse_expandfft.execution_time FAIL: sse_stepfft.execution_time git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321306 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGCall.cpp10
-rw-r--r--test/CodeGen/kr-func-promote.c2
-rw-r--r--test/CodeGen/transparent-union-redecl.c36
-rw-r--r--test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp10
-rw-r--r--test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp5
-rw-r--r--test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp10
-rw-r--r--test/Sema/transparent-union.c29
7 files changed, 11 insertions, 91 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 8d2fc5d6aa..38d7344572 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -2317,7 +2317,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
// If we have the trivial case, handle it with no muss and fuss.
if (!isa<llvm::StructType>(ArgI.getCoerceToType()) &&
- ArgI.getCoerceToType() == ConvertType(Arg->getType()) &&
+ ArgI.getCoerceToType() == ConvertType(Ty) &&
ArgI.getDirectOffset() == 0) {
assert(NumIRArgs == 1);
llvm::Value *V = FnArgs[FirstIRArg];
@@ -2414,8 +2414,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
break;
}
- Address Alloca = CreateMemTemp(
- Arg->getType(), getContext().getDeclAlign(Arg), Arg->getName());
+ Address Alloca = CreateMemTemp(Ty, getContext().getDeclAlign(Arg),
+ Arg->getName());
// Pointer to store into.
Address Ptr = emitAddressAtOffset(*this, Alloca, ArgI);
@@ -2461,9 +2461,9 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
}
// Match to what EmitParmDecl is expecting for this type.
- if (CodeGenFunction::hasScalarEvaluationKind(Arg->getType())) {
+ if (CodeGenFunction::hasScalarEvaluationKind(Ty)) {
llvm::Value *V =
- EmitLoadOfScalar(Alloca, false, Arg->getType(), Arg->getLocStart());
+ EmitLoadOfScalar(Alloca, false, Ty, Arg->getLocStart());
if (isPromoted)
V = emitArgumentDemotion(*this, Arg, V);
ArgVals.push_back(ParamValue::forDirect(V));
diff --git a/test/CodeGen/kr-func-promote.c b/test/CodeGen/kr-func-promote.c
index 615fe94f37..8e55dc91ed 100644
--- a/test/CodeGen/kr-func-promote.c
+++ b/test/CodeGen/kr-func-promote.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
-// CHECK: i32 @a(i32
+// CHECK: i32 @a(i32)
int a();
int a(x) short x; {return x;}
diff --git a/test/CodeGen/transparent-union-redecl.c b/test/CodeGen/transparent-union-redecl.c
deleted file mode 100644
index c0619f0cc5..0000000000
--- a/test/CodeGen/transparent-union-redecl.c
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
-
-// Test that different order of declarations is acceptable and that
-// implementing different redeclarations is acceptable.
-// rdar://problem/34949329
-
-typedef union {
- int i;
- float f;
-} TU __attribute__((transparent_union));
-
-// CHECK-LABEL: define void @f0(i32 %tu.coerce)
-// CHECK: %tu = alloca %union.TU, align 4
-// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
-// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
-void f0(TU tu) {}
-void f0(int i);
-
-// CHECK-LABEL: define void @f1(i32 %tu.coerce)
-// CHECK: %tu = alloca %union.TU, align 4
-// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
-// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
-void f1(int i);
-void f1(TU tu) {}
-
-// CHECK-LABEL: define void @f2(i32 %i)
-// CHECK: %i.addr = alloca i32, align 4
-// CHECK: store i32 %i, i32* %i.addr, align 4
-void f2(TU tu);
-void f2(int i) {}
-
-// CHECK-LABEL: define void @f3(i32 %i)
-// CHECK: %i.addr = alloca i32, align 4
-// CHECK: store i32 %i, i32* %i.addr, align 4
-void f3(int i) {}
-void f3(TU tu);
diff --git a/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
index d51c4bea99..5bed69ff11 100644
--- a/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
+++ b/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
@@ -88,11 +88,8 @@ void ChildOverride::right() {
// ChildOverride::right gets 'this' cast to Right* in ECX (i.e. this+4) so we
// need to adjust 'this' before use.
//
-// CHECK: %[[THIS_STORE:.*]] = alloca %struct.ChildOverride*, align 4
// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.ChildOverride*, align 4
-// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
-// CHECK: store %struct.ChildOverride* %[[COERCE_VAL]], %struct.ChildOverride** %[[THIS_STORE]], align 4
-// CHECK: %[[THIS_INIT:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_STORE]], align 4
+// CHECK: %[[THIS_INIT:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
// CHECK: store %struct.ChildOverride* %[[THIS_INIT]], %struct.ChildOverride** %[[THIS_ADDR]], align 4
// CHECK: %[[THIS_RELOAD:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_ADDR]]
// CHECK: %[[THIS_i8:.*]] = bitcast %struct.ChildOverride* %[[THIS_RELOAD]] to i8*
@@ -135,11 +132,8 @@ struct GrandchildOverride : ChildOverride {
void GrandchildOverride::right() {
// CHECK-LABEL: define x86_thiscallcc void @"\01?right@GrandchildOverride@@UAEXXZ"(i8*
//
-// CHECK: %[[THIS_STORE:.*]] = alloca %struct.GrandchildOverride*, align 4
// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.GrandchildOverride*, align 4
-// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %[[ECX:.*]] to %struct.GrandchildOverride*
-// CHECK: store %struct.GrandchildOverride* %[[COERCE_VAL]], %struct.GrandchildOverride** %[[THIS_STORE]], align 4
-// CHECK: %[[THIS_INIT:.*]] = load %struct.GrandchildOverride*, %struct.GrandchildOverride** %[[THIS_STORE]], align 4
+// CHECK: %[[THIS_INIT:.*]] = bitcast i8* %[[ECX:.*]] to %struct.GrandchildOverride*
// CHECK: store %struct.GrandchildOverride* %[[THIS_INIT]], %struct.GrandchildOverride** %[[THIS_ADDR]], align 4
// CHECK: %[[THIS_RELOAD:.*]] = load %struct.GrandchildOverride*, %struct.GrandchildOverride** %[[THIS_ADDR]]
// CHECK: %[[THIS_i8:.*]] = bitcast %struct.GrandchildOverride* %[[THIS_RELOAD]] to i8*
diff --git a/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp b/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
index 377a6701f3..2f141b2a66 100644
--- a/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
+++ b/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
@@ -25,7 +25,6 @@ D::D() {} // Forces vftable emission.
// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPPPPPM@A@AEXXZ"
// Note that the vtordisp is applied before really adjusting to D*.
-// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
// CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
// CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
// CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
@@ -37,7 +36,6 @@ D::D() {} // Forces vftable emission.
// CHECK: ret void
// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPPPPPI@3AEXXZ"
-// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
// CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
// CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
// CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -8
@@ -66,8 +64,7 @@ struct G : virtual F, virtual E {
G::G() {} // Forces vftable emission.
-// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPPPPPM@7AEXXZ"(i8*
-// CHECK: %[[COERCE_LOAD:.*]] = load %struct.E*, %struct.E** %{{.*}}
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPPPPPM@7AEXXZ"(i8*)
// CHECK: %[[ECX:.*]] = load %struct.E*, %struct.E** %{{.*}}
// CHECK: %[[ECX_i8:.*]] = bitcast %struct.E* %[[ECX]] to i8*
// CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
diff --git a/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
index 2eca906d00..c9dd1dd7d8 100644
--- a/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ b/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -115,15 +115,9 @@ void B::foo() {
// B::foo gets 'this' cast to VBase* in ECX (i.e. this+8) so we
// need to adjust 'this' before use.
//
-// Coerce this to correct type:
-// CHECK: %[[THIS_STORE:.*]] = alloca %struct.B*
-// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.B*
-// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %{{.*}} to %struct.B*
-// CHECK: store %struct.B* %[[COERCE_VAL]], %struct.B** %[[THIS_STORE]], align 4
-//
// Store initial this:
-// CHECK: %[[THIS_INIT:.*]] = load %struct.B*, %struct.B** %[[THIS_STORE]]
-// CHECK: store %struct.B* %[[THIS_INIT]], %struct.B** %[[THIS_ADDR]], align 4
+// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.B*
+// CHECK: store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
//
// Reload and adjust the this parameter:
// CHECK: %[[THIS_RELOAD:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c
index 7967535db8..0481127674 100644
--- a/test/Sema/transparent-union.c
+++ b/test/Sema/transparent-union.c
@@ -43,35 +43,6 @@ void fi(int i) {} // expected-error{{conflicting types}}
void fvpp(TU); // expected-note{{previous declaration is here}}
void fvpp(void **v) {} // expected-error{{conflicting types}}
-/* Test redeclaring a function taking a transparent_union arg more than twice.
- Merging different declarations depends on their order, vary order too. */
-
-void f_triple0(TU tu) {}
-void f_triple0(int *); // expected-note{{previous declaration is here}}
-void f_triple0(float *f); // expected-error{{conflicting types}}
-
-void f_triple1(int *);
-void f_triple1(TU tu) {} // expected-note{{previous definition is here}}
-void f_triple1(float *f); // expected-error{{conflicting types}}
-
-void f_triple2(int *); // expected-note{{previous declaration is here}}
-void f_triple2(float *f); // expected-error{{conflicting types}}
-void f_triple2(TU tu) {}
-
-/* Test calling redeclared function taking a transparent_union arg. */
-
-void f_callee(TU);
-void f_callee(int *i) {} // expected-note{{passing argument to parameter 'i' here}}
-
-void caller(void) {
- TU tu;
- f_callee(tu); // expected-error{{passing 'TU' to parameter of incompatible type 'int *'}}
-
- int *i;
- f_callee(i);
-}
-
-
/* FIXME: we'd like to just use an "int" here and align it differently
from the normal "int", but if we do so we lose the alignment
information from the typedef within the compiler. */