Add arm64 -> arm64e fallback

If we are building for ARM64 but we try to import a module with only an ARM64e interface, fall back to importing said interface.

This is the reverse of a similar fallback briefly introduced last year, but removed in #31196.
This commit is contained in:
Becca Royal-Gordon
2021-08-27 15:07:08 -07:00
parent 9358d7644a
commit 2240a39446
8 changed files with 90 additions and 17 deletions

View File

@@ -46,8 +46,23 @@ namespace {
void forEachTargetModuleBasename(const ASTContext &Ctx,
llvm::function_ref<void(StringRef)> body) {
auto normalizedTarget = getTargetSpecificModuleTriple(Ctx.LangOpts.Target);
// An arm64 module can import an arm64e module.
Optional<llvm::Triple> normalizedAltTarget;
if ((normalizedTarget.getArch() == llvm::Triple::ArchType::aarch64) &&
(normalizedTarget.getSubArch() !=
llvm::Triple::SubArchType::AArch64SubArch_arm64e)) {
auto altTarget = normalizedTarget;
altTarget.setArchName("arm64e");
normalizedAltTarget = getTargetSpecificModuleTriple(altTarget);
}
body(normalizedTarget.str());
if (normalizedAltTarget) {
body(normalizedAltTarget->str());
}
// We used the un-normalized architecture as a target-specific
// module name. Fall back to that behavior.
body(Ctx.LangOpts.Target.getArchName());
@@ -61,6 +76,10 @@ void forEachTargetModuleBasename(const ASTContext &Ctx,
if (Ctx.LangOpts.Target.getArch() == llvm::Triple::ArchType::arm) {
body("arm");
}
if (normalizedAltTarget) {
body(normalizedAltTarget->getArchName());
}
}
enum class SearchPathKind {