Skip to content

Commit 35c1f1c

Browse files
committed
fixup! [clang][CodeGen] add addr space cast if needed when storing ptrs
1 parent e058013 commit 35c1f1c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
15661566
AllocaAddr =
15671567
RawAddress(ReturnValue.emitRawPointer(*this),
15681568
ReturnValue.getElementType(), ReturnValue.getAlignment());
1569-
address = MaybeCastAllocaAddressSpace(AllocaAddr, Ty.getAddressSpace());
1569+
address = MaybeCastStackAddressSpace(AllocaAddr, Ty.getAddressSpace());
15701570

15711571
if (const RecordType *RecordTy = Ty->getAs<RecordType>()) {
15721572
const auto *RD = RecordTy->getOriginalDecl()->getDefinitionOrSelf();

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits Align,
108108
return RawAddress(Alloca, Ty, Align, KnownNonNull);
109109
}
110110

111-
RawAddress CodeGenFunction::MaybeCastAllocaAddressSpace(
112-
RawAddress Alloca, LangAS DestLangAS, llvm::Value *ArraySize) {
111+
RawAddress CodeGenFunction::MaybeCastStackAddressSpace(RawAddress Alloca,
112+
LangAS DestLangAS,
113+
llvm::Value *ArraySize) {
113114

114115
llvm::Value *V = Alloca.getPointer();
115116
// Alloca always returns a pointer in alloca address space, which may
@@ -141,7 +142,7 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, LangAS DestLangAS,
141142
RawAddress Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize);
142143
if (AllocaAddr)
143144
*AllocaAddr = Alloca;
144-
return MaybeCastAllocaAddressSpace(Alloca, DestLangAS, ArraySize);
145+
return MaybeCastStackAddressSpace(Alloca, DestLangAS, ArraySize);
145146
}
146147

147148
/// CreateTempAlloca - This creates an alloca and inserts it into the entry

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,8 +2807,8 @@ class CodeGenFunction : public CodeGenTypeCache {
28072807
private:
28082808
/// If \p Alloca is not in the same address space as \p DestLangAS, insert an
28092809
/// address space cast and return a new RawAddress based on this value.
2810-
RawAddress MaybeCastAllocaAddressSpace(RawAddress Alloca, LangAS DestLangAS,
2811-
llvm::Value *ArraySize = nullptr);
2810+
RawAddress MaybeCastStackAddressSpace(RawAddress Alloca, LangAS DestLangAS,
2811+
llvm::Value *ArraySize = nullptr);
28122812

28132813
public:
28142814
/// CreateTempAlloca - This creates an alloca and inserts it into the entry

0 commit comments

Comments
 (0)