Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit c98d5ad

Browse files
committed
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
1 parent 0cfb502 commit c98d5ad

7 files changed

+11
-91
lines changed

lib/CodeGen/CGCall.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
23172317

23182318
// If we have the trivial case, handle it with no muss and fuss.
23192319
if (!isa<llvm::StructType>(ArgI.getCoerceToType()) &&
2320-
ArgI.getCoerceToType() == ConvertType(Arg->getType()) &&
2320+
ArgI.getCoerceToType() == ConvertType(Ty) &&
23212321
ArgI.getDirectOffset() == 0) {
23222322
assert(NumIRArgs == 1);
23232323
llvm::Value *V = FnArgs[FirstIRArg];
@@ -2414,8 +2414,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
24142414
break;
24152415
}
24162416

2417-
Address Alloca = CreateMemTemp(
2418-
Arg->getType(), getContext().getDeclAlign(Arg), Arg->getName());
2417+
Address Alloca = CreateMemTemp(Ty, getContext().getDeclAlign(Arg),
2418+
Arg->getName());
24192419

24202420
// Pointer to store into.
24212421
Address Ptr = emitAddressAtOffset(*this, Alloca, ArgI);
@@ -2461,9 +2461,9 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
24612461
}
24622462

24632463
// Match to what EmitParmDecl is expecting for this type.
2464-
if (CodeGenFunction::hasScalarEvaluationKind(Arg->getType())) {
2464+
if (CodeGenFunction::hasScalarEvaluationKind(Ty)) {
24652465
llvm::Value *V =
2466-
EmitLoadOfScalar(Alloca, false, Arg->getType(), Arg->getLocStart());
2466+
EmitLoadOfScalar(Alloca, false, Ty, Arg->getLocStart());
24672467
if (isPromoted)
24682468
V = emitArgumentDemotion(*this, Arg, V);
24692469
ArgVals.push_back(ParamValue::forDirect(V));

test/CodeGen/kr-func-promote.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
2-
// CHECK: i32 @a(i32
2+
// CHECK: i32 @a(i32)
33

44
int a();
55
int a(x) short x; {return x;}

test/CodeGen/transparent-union-redecl.c

-36
This file was deleted.

test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ void ChildOverride::right() {
8888
// ChildOverride::right gets 'this' cast to Right* in ECX (i.e. this+4) so we
8989
// need to adjust 'this' before use.
9090
//
91-
// CHECK: %[[THIS_STORE:.*]] = alloca %struct.ChildOverride*, align 4
9291
// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.ChildOverride*, align 4
93-
// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
94-
// CHECK: store %struct.ChildOverride* %[[COERCE_VAL]], %struct.ChildOverride** %[[THIS_STORE]], align 4
95-
// CHECK: %[[THIS_INIT:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_STORE]], align 4
92+
// CHECK: %[[THIS_INIT:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
9693
// CHECK: store %struct.ChildOverride* %[[THIS_INIT]], %struct.ChildOverride** %[[THIS_ADDR]], align 4
9794
// CHECK: %[[THIS_RELOAD:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_ADDR]]
9895
// CHECK: %[[THIS_i8:.*]] = bitcast %struct.ChildOverride* %[[THIS_RELOAD]] to i8*
@@ -135,11 +132,8 @@ struct GrandchildOverride : ChildOverride {
135132
void GrandchildOverride::right() {
136133
// CHECK-LABEL: define x86_thiscallcc void @"\01?right@GrandchildOverride@@UAEXXZ"(i8*
137134
//
138-
// CHECK: %[[THIS_STORE:.*]] = alloca %struct.GrandchildOverride*, align 4
139135
// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.GrandchildOverride*, align 4
140-
// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %[[ECX:.*]] to %struct.GrandchildOverride*
141-
// CHECK: store %struct.GrandchildOverride* %[[COERCE_VAL]], %struct.GrandchildOverride** %[[THIS_STORE]], align 4
142-
// CHECK: %[[THIS_INIT:.*]] = load %struct.GrandchildOverride*, %struct.GrandchildOverride** %[[THIS_STORE]], align 4
136+
// CHECK: %[[THIS_INIT:.*]] = bitcast i8* %[[ECX:.*]] to %struct.GrandchildOverride*
143137
// CHECK: store %struct.GrandchildOverride* %[[THIS_INIT]], %struct.GrandchildOverride** %[[THIS_ADDR]], align 4
144138
// CHECK: %[[THIS_RELOAD:.*]] = load %struct.GrandchildOverride*, %struct.GrandchildOverride** %[[THIS_ADDR]]
145139
// CHECK: %[[THIS_i8:.*]] = bitcast %struct.GrandchildOverride* %[[THIS_RELOAD]] to i8*

test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ D::D() {} // Forces vftable emission.
2525

2626
// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPPPPPM@A@AEXXZ"
2727
// Note that the vtordisp is applied before really adjusting to D*.
28-
// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
2928
// CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
3029
// CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
3130
// CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
@@ -37,7 +36,6 @@ D::D() {} // Forces vftable emission.
3736
// CHECK: ret void
3837

3938
// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPPPPPI@3AEXXZ"
40-
// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
4139
// CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
4240
// CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
4341
// CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -8
@@ -66,8 +64,7 @@ struct G : virtual F, virtual E {
6664

6765
G::G() {} // Forces vftable emission.
6866

69-
// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPPPPPM@7AEXXZ"(i8*
70-
// CHECK: %[[COERCE_LOAD:.*]] = load %struct.E*, %struct.E** %{{.*}}
67+
// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPPPPPM@7AEXXZ"(i8*)
7168
// CHECK: %[[ECX:.*]] = load %struct.E*, %struct.E** %{{.*}}
7269
// CHECK: %[[ECX_i8:.*]] = bitcast %struct.E* %[[ECX]] to i8*
7370
// CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4

test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,9 @@ void B::foo() {
115115
// B::foo gets 'this' cast to VBase* in ECX (i.e. this+8) so we
116116
// need to adjust 'this' before use.
117117
//
118-
// Coerce this to correct type:
119-
// CHECK: %[[THIS_STORE:.*]] = alloca %struct.B*
120-
// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.B*
121-
// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %{{.*}} to %struct.B*
122-
// CHECK: store %struct.B* %[[COERCE_VAL]], %struct.B** %[[THIS_STORE]], align 4
123-
//
124118
// Store initial this:
125-
// CHECK: %[[THIS_INIT:.*]] = load %struct.B*, %struct.B** %[[THIS_STORE]]
126-
// CHECK: store %struct.B* %[[THIS_INIT]], %struct.B** %[[THIS_ADDR]], align 4
119+
// CHECK: %[[THIS_ADDR:.*]] = alloca %struct.B*
120+
// CHECK: store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
127121
//
128122
// Reload and adjust the this parameter:
129123
// CHECK: %[[THIS_RELOAD:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]

test/Sema/transparent-union.c

-29
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,6 @@ void fi(int i) {} // expected-error{{conflicting types}}
4343
void fvpp(TU); // expected-note{{previous declaration is here}}
4444
void fvpp(void **v) {} // expected-error{{conflicting types}}
4545

46-
/* Test redeclaring a function taking a transparent_union arg more than twice.
47-
Merging different declarations depends on their order, vary order too. */
48-
49-
void f_triple0(TU tu) {}
50-
void f_triple0(int *); // expected-note{{previous declaration is here}}
51-
void f_triple0(float *f); // expected-error{{conflicting types}}
52-
53-
void f_triple1(int *);
54-
void f_triple1(TU tu) {} // expected-note{{previous definition is here}}
55-
void f_triple1(float *f); // expected-error{{conflicting types}}
56-
57-
void f_triple2(int *); // expected-note{{previous declaration is here}}
58-
void f_triple2(float *f); // expected-error{{conflicting types}}
59-
void f_triple2(TU tu) {}
60-
61-
/* Test calling redeclared function taking a transparent_union arg. */
62-
63-
void f_callee(TU);
64-
void f_callee(int *i) {} // expected-note{{passing argument to parameter 'i' here}}
65-
66-
void caller(void) {
67-
TU tu;
68-
f_callee(tu); // expected-error{{passing 'TU' to parameter of incompatible type 'int *'}}
69-
70-
int *i;
71-
f_callee(i);
72-
}
73-
74-
7546
/* FIXME: we'd like to just use an "int" here and align it differently
7647
from the normal "int", but if we do so we lose the alignment
7748
information from the typedef within the compiler. */

0 commit comments

Comments
 (0)