diff --git a/lib/Target/ARM64/ARM64TargetMachine.cpp b/lib/Target/ARM64/ARM64TargetMachine.cpp index 946a0ee59e2..8070ce0d8b2 100644 --- a/lib/Target/ARM64/ARM64TargetMachine.cpp +++ b/lib/Target/ARM64/ARM64TargetMachine.cpp @@ -165,7 +165,8 @@ bool ARM64PassConfig::addPreEmitPass() { // Relax conditional branch instructions if they're otherwise out of // range of their destination. addPass(createARM64BranchRelaxation()); - if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH) + if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH && + TM->getSubtarget().isTargetMachO()) addPass(createARM64CollectLOHPass()); return true; } diff --git a/test/CodeGen/ARM64/collect-loh.ll b/test/CodeGen/ARM64/collect-loh.ll index 08ab0620b8b..e92690b04f8 100644 --- a/test/CodeGen/ARM64/collect-loh.ll +++ b/test/CodeGen/ARM64/collect-loh.ll @@ -1,4 +1,10 @@ ; RUN: llc -mtriple=arm64-apple-ios -O2 -arm64-collect-loh -arm64-collect-loh-bb-only=false < %s -o - | FileCheck %s +; RUN: llc -mtriple=arm64-linux-gnu -O2 -arm64-collect-loh -arm64-collect-loh-bb-only=false < %s -o - | FileCheck %s --check-prefix=CHECK-ELF + +; CHECK-ELF-NOT: .loh +; CHECK-ELF-NOT: AdrpAdrp +; CHECK-ELF-NOT: AdrpAdd +; CHECK-ELF-NOT: AdrpLdrGot @a = internal unnamed_addr global i32 0, align 4 @b = external global i32