Skip to content

Commit 7fcb506

Browse files
committed
Strip less.
1 parent 667fd20 commit 7fcb506

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5857,9 +5857,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
58575857
/*IndexTypeQuals=*/0);
58585858
auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
58595859
llvm::Value *TmpPtr = Tmp.getPointer();
5860+
// The EmitLifetime* pair expect a naked Alloca as their last argument,
5861+
// however for cases where the default AS is not the Alloca AS, Tmp is
5862+
// actually the Alloca ascasted to the default AS, hence the
5863+
// stripPointerCasts()
5864+
llvm::Value *Alloca = TmpPtr->stripPointerCasts();
58605865
llvm::Value *TmpSize = EmitLifetimeStart(
5861-
CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()),
5862-
TmpPtr->stripPointerCasts());
5866+
CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), Alloca);
58635867
llvm::Value *ElemPtr;
58645868
// Each of the following arguments specifies the size of the corresponding
58655869
// argument passed to the enqueued block.
@@ -5875,7 +5879,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
58755879
Builder.CreateAlignedStore(
58765880
V, GEP, CGM.getDataLayout().getPrefTypeAlign(SizeTy));
58775881
}
5878-
return std::tie(ElemPtr, TmpSize, TmpPtr);
5882+
// Return the Alloca itself rather than a potential ascast as this is only
5883+
// used by the paired EmitLifetimeEnd.
5884+
return std::tie(ElemPtr, TmpSize, Alloca);
58795885
};
58805886

58815887
// Could have events and/or varargs.
@@ -5904,7 +5910,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
59045910
auto Call = RValue::get(
59055911
EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name), Args));
59065912
if (TmpSize)
5907-
EmitLifetimeEnd(TmpSize, TmpPtr->stripPointerCasts());
5913+
EmitLifetimeEnd(TmpSize, TmpPtr);
59085914
return Call;
59095915
}
59105916
// Any calls now have event arguments passed.

0 commit comments

Comments
 (0)