Skip to content

Commit b3422fe

Browse files
committed
Fix IRGen datalayout
Same issue as with TBDGen. Clang doesn't hold onto the Datalayout object anymore, but instead keeps the description string that is constructed on the fly. This patch updates IRGen to behave the same way.
1 parent 2416881 commit b3422fe

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ bool swift::performLLVM(const IRGenOptions &Opts, ASTContext &Ctx,
15331533

15341534
auto *Clang = static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
15351535
// Use clang's datalayout.
1536-
Module->setDataLayout(Clang->getTargetInfo().getDataLayout());
1536+
Module->setDataLayout(Clang->getTargetInfo().getDataLayoutString());
15371537

15381538
embedBitcode(Module, Opts);
15391539
if (::performLLVM(Opts, Ctx.Diags, nullptr, nullptr, Module,

lib/IRGen/IRGenModule.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,18 @@ static void sanityCheckStdlib(IRGenModule &IGM) {
192192

193193
IRGenModule::IRGenModule(IRGenerator &irgen,
194194
std::unique_ptr<llvm::TargetMachine> &&target,
195-
SourceFile *SF,
196-
StringRef ModuleName, StringRef OutputFilename,
195+
SourceFile *SF, StringRef ModuleName,
196+
StringRef OutputFilename,
197197
StringRef MainInputFilenameForDebugInfo,
198198
StringRef PrivateDiscriminator)
199-
: LLVMContext(new llvm::LLVMContext()),
200-
IRGen(irgen), Context(irgen.SIL.getASTContext()),
199+
: LLVMContext(new llvm::LLVMContext()), IRGen(irgen),
200+
Context(irgen.SIL.getASTContext()),
201201
// The LLVMContext (and the IGM itself) will get deleted by the IGMDeleter
202202
// as long as the IGM is registered with the IRGenerator.
203-
ClangCodeGen(createClangCodeGenerator(Context, *LLVMContext,
204-
irgen.Opts,
203+
ClangCodeGen(createClangCodeGenerator(Context, *LLVMContext, irgen.Opts,
205204
ModuleName, PrivateDiscriminator)),
206205
Module(*ClangCodeGen->GetModule()),
207-
DataLayout(irgen.getClangDataLayout()),
206+
DataLayout(irgen.getClangDataLayoutString()),
208207
Triple(irgen.getEffectiveClangTriple()), TargetMachine(std::move(target)),
209208
silConv(irgen.SIL), OutputFilename(OutputFilename),
210209
MainInputFilenameForDebugInfo(MainInputFilenameForDebugInfo),
@@ -1750,12 +1749,12 @@ llvm::Triple IRGenerator::getEffectiveClangTriple() {
17501749
return llvm::Triple(CI->getTargetInfo().getTargetOpts().Triple);
17511750
}
17521751

1753-
const llvm::DataLayout &IRGenerator::getClangDataLayout() {
1752+
const llvm::StringRef IRGenerator::getClangDataLayoutString() {
17541753
return static_cast<ClangImporter *>(
17551754
SIL.getASTContext().getClangModuleLoader())
17561755
->getTargetInfo()
1757-
.getDataLayout();
1758-
}
1756+
.getDataLayoutString();
1757+
}
17591758

17601759
TypeExpansionContext IRGenModule::getMaximalTypeExpansionContext() const {
17611760
return TypeExpansionContext::maximal(getSwiftModule(),

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ class IRGenerator {
519519
/// Return the effective triple used by clang.
520520
llvm::Triple getEffectiveClangTriple();
521521

522-
const llvm::DataLayout &getClangDataLayout();
522+
const llvm::StringRef getClangDataLayoutString();
523523
};
524524

525525
class ConstantReference {

0 commit comments

Comments
 (0)