Include information about the Swift ABI version in

the objc_imageinfo record.

rdar://17528908

Swift SVN r21104
This commit is contained in:
John McCall
2014-08-08 02:52:42 +00:00
parent 4ceaaa53ee
commit 64a6a7393b
2 changed files with 32 additions and 4 deletions

View File

@@ -192,18 +192,38 @@ static std::unique_ptr<llvm::Module> performIRGeneration(IRGenOptions &Opts,
// Objective-C image information.
// Generate module-level named metadata to convey this information to the
// linker and code-gen.
unsigned version = 0; // Version is unused?
// The ABI version of the imageinfo header structure itself.
unsigned imageInfoVersion = 0;
// The ABI version of the ObjC data generated by this file.
unsigned objcVersion = 2;
// The ABI version of the Swift data generated by this file.
unsigned swiftVersion = 1;
const char *section = "__DATA, __objc_imageinfo, regular, no_dead_strip";
// These module flags don't affect code generation; they just let us
// error during LTO if the user tries to combine files across ABIs.
Module->addModuleFlag(llvm::Module::Error, "Objective-C Version",
objcVersion);
Module->addModuleFlag(llvm::Module::Error, "Swift Version",
swiftVersion);
// Add the ObjC ABI version to the module flags.
Module->addModuleFlag(llvm::Module::Error, "Objective-C Version", 2);
Module->addModuleFlag(llvm::Module::Error, "Objective-C Image Info Version",
version);
imageInfoVersion);
Module->addModuleFlag(llvm::Module::Error, "Objective-C Image Info Section",
llvm::MDString::get(Module->getContext(), section));
// LLVM's object-file emission collects a fixed set of keys for the
// image info.
// Using "Objective-C Garbage Collection" as the key here is a hack,
// but LLVM's object-file emission isn't general enough to collect
// arbitrary keys to put in the
Module->addModuleFlag(llvm::Module::Override,
"Objective-C Garbage Collection", (uint32_t)0);
"Objective-C Garbage Collection",
(uint32_t) (objcVersion << 8));
// Mark iOS simulator images.
if (tripleIsiOSSimulator(llvm::Triple(Opts.Triple)))

View File

@@ -107,3 +107,11 @@ class WeakObjC {
var bar: AnyObject? = id
}
}
// rdar://17528908
// CHECK: metadata !{i32 1, metadata !"Objective-C Version", i32 2}
// CHECK: metadata !{i32 1, metadata !"Swift Version", i32 1}
// CHECK: metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}
// CHECK: metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
// 512 == (1 << 8). 1 is the Swift ABI version.
// CHECK: metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 512}