@@ -450,9 +450,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
450
450
Address Object = createReferenceTemporary (*this , M, E);
451
451
if (auto *Var = dyn_cast<llvm::GlobalVariable>(Object.getPointer ())) {
452
452
llvm::Type *Ty = ConvertTypeForMem (E->getType ());
453
- Object = Address (llvm::ConstantExpr::getBitCast (
454
- Var, Ty->getPointerTo (Object.getAddressSpace ())),
455
- Ty, Object.getAlignment ());
453
+ Object = Object.withElementType (Ty);
456
454
457
455
// createReferenceTemporary will promote the temporary to a global with a
458
456
// constant initializer if it can. It can only do this to a value of
@@ -508,11 +506,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
508
506
if (auto *Var = dyn_cast<llvm::GlobalVariable>(
509
507
Object.getPointer ()->stripPointerCasts ())) {
510
508
llvm::Type *TemporaryType = ConvertTypeForMem (E->getType ());
511
- Object = Address (llvm::ConstantExpr::getBitCast (
512
- cast<llvm::Constant>(Object.getPointer ()),
513
- TemporaryType->getPointerTo ()),
514
- TemporaryType,
515
- Object.getAlignment ());
509
+ Object = Object.withElementType (TemporaryType);
516
510
// If the temporary is a global and has a constant initializer or is a
517
511
// constant temporary that we promoted to a global, we may have already
518
512
// initialized it.
@@ -2678,19 +2672,6 @@ static llvm::Constant *EmitFunctionDeclPointer(CodeGenModule &CGM,
2678
2672
}
2679
2673
2680
2674
llvm::Constant *V = CGM.GetAddrOfFunction (GD);
2681
- if (!FD->hasPrototype ()) {
2682
- if (const FunctionProtoType *Proto =
2683
- FD->getType ()->getAs <FunctionProtoType>()) {
2684
- // Ugly case: for a K&R-style definition, the type of the definition
2685
- // isn't the same as the type of a use. Correct for this with a
2686
- // bitcast.
2687
- QualType NoProtoType =
2688
- CGM.getContext ().getFunctionNoProtoType (Proto->getReturnType ());
2689
- NoProtoType = CGM.getContext ().getPointerType (NoProtoType);
2690
- V = llvm::ConstantExpr::getBitCast (V,
2691
- CGM.getTypes ().ConvertType (NoProtoType));
2692
- }
2693
- }
2694
2675
return V;
2695
2676
}
2696
2677
0 commit comments