From 0ee7bd4ac5862ed18ba41faa5d67160734d4b493 Mon Sep 17 00:00:00 2001 From: Michael Liao Date: Thu, 21 Feb 2019 19:40:20 +0000 Subject: [CodeGen] Fix string literal address space casting. Summary: - If a string literal is reused directly, need to add necessary address space casting if the target requires that. Reviewers: yaxunl Subscribers: jvesely, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58509 llvm-svn: 354610 --- clang/lib/CodeGen/CodeGenModule.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 972d2afa8e6..65116dba095 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4522,7 +4522,8 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S, if (auto GV = *Entry) { if (Alignment.getQuantity() > GV->getAlignment()) GV->setAlignment(Alignment.getQuantity()); - return ConstantAddress(GV, Alignment); + return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV), + Alignment); } } @@ -4584,7 +4585,8 @@ ConstantAddress CodeGenModule::GetAddrOfConstantCString( if (auto GV = *Entry) { if (Alignment.getQuantity() > GV->getAlignment()) GV->setAlignment(Alignment.getQuantity()); - return ConstantAddress(GV, Alignment); + return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV), + Alignment); } } -- cgit v1.2.3