From d4590c38ab960bdd7f0fed52a67a6263373a45a8 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Wed, 1 Aug 2018 06:50:18 +0000 Subject: [PATCH] [AArch64] Disallow the MachO specific .loh directive for windows Also add a test for it being unsupported for linux. Differential Revision: https://reviews.llvm.org/D49929 llvm-svn: 338493 --- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 12 ++++++------ llvm/test/MC/AArch64/arm64-directive_loh.s | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index ee9443b..30a9a08 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4859,7 +4859,6 @@ bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) { const MCObjectFileInfo::Environment Format = getContext().getObjectFileInfo()->getObjectFileType(); bool IsMachO = Format == MCObjectFileInfo::IsMachO; - bool IsCOFF = Format == MCObjectFileInfo::IsCOFF; StringRef IDVal = DirectiveID.getIdentifier(); SMLoc Loc = DirectiveID.getLoc(); @@ -4875,11 +4874,12 @@ bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) { parseDirectiveUnreq(Loc); else if (IDVal == ".inst") parseDirectiveInst(Loc); - else if (!IsMachO && !IsCOFF) - return true; - else if (IDVal == MCLOHDirectiveName()) - parseDirectiveLOH(IDVal, Loc); - else + else if (IsMachO) { + if (IDVal == MCLOHDirectiveName()) + parseDirectiveLOH(IDVal, Loc); + else + return true; + } else return true; return false; } diff --git a/llvm/test/MC/AArch64/arm64-directive_loh.s b/llvm/test/MC/AArch64/arm64-directive_loh.s index 76d2d7f..654dc9e 100644 --- a/llvm/test/MC/AArch64/arm64-directive_loh.s +++ b/llvm/test/MC/AArch64/arm64-directive_loh.s @@ -1,5 +1,7 @@ # RUN: not llvm-mc -triple arm64-apple-darwin < %s 2> %t | FileCheck %s # RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s +# RUN: not llvm-mc -triple aarch64-linux-gnu < %s 2>&1 | FileCheck --check-prefix=UNKNOWN %s +# RUN: not llvm-mc -triple aarch64-win32-gnu < %s 2>&1 | FileCheck --check-prefix=UNKNOWN %s .globl _fct1 _fct1: @@ -15,6 +17,8 @@ _fct1: # CHECK: .loh AdrpAdrp L1, L2 # CHECK: .loh AdrpAdrp L1, L2 +# UNKNOWN: error: unknown directive +# UNKNOWN-NEXT: .loh AdrpAdrp L1, L2 .loh AdrpAdrp L1, L2 .loh 1 L1, L2 -- 2.7.4