From b38cfced8d6737b5652f9c6240b05cf8c3c6e677 Mon Sep 17 00:00:00 2001 From: Weiming Zhao Date: Mon, 5 Dec 2016 23:55:13 +0000 Subject: [PATCH] Summary: Currently there is no way to disable deprecated warning from asm like this clang -target arm deprecated-asm.s -c deprecated-asm.s:30:9: warning: use of SP or PC in the list is deprecated stmia r4!, {r12-r14} We have to have an option what can disable it. Patched by Yin Ma! Reviewers: joey, echristo, weimingz Subscribers: llvm-commits, aemerson Differential Revision: https://reviews.llvm.org/D27219 llvm-svn: 288734 --- llvm/include/llvm/MC/MCTargetOptions.h | 2 + llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h | 4 ++ llvm/lib/MC/MCTargetOptions.cpp | 3 +- llvm/test/CodeGen/ARM/deprecated-asm.s | 43 ++++++++++++++++++++++ llvm/utils/TableGen/AsmMatcherEmitter.cpp | 4 +- 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/ARM/deprecated-asm.s diff --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h index 21091b3..a300c4f 100644 --- a/llvm/include/llvm/MC/MCTargetOptions.h +++ b/llvm/include/llvm/MC/MCTargetOptions.h @@ -38,6 +38,7 @@ public: bool MCNoExecStack : 1; bool MCFatalWarnings : 1; bool MCNoWarn : 1; + bool MCNoDeprecatedWarn : 1; bool MCSaveTempLabels : 1; bool MCUseDwarfDirectory : 1; bool MCIncrementalLinkerCompatible : 1; @@ -65,6 +66,7 @@ inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) { ARE_EQUAL(MCNoExecStack) && ARE_EQUAL(MCFatalWarnings) && ARE_EQUAL(MCNoWarn) && + ARE_EQUAL(MCNoDeprecatedWarn) && ARE_EQUAL(MCSaveTempLabels) && ARE_EQUAL(MCUseDwarfDirectory) && ARE_EQUAL(MCIncrementalLinkerCompatible) && diff --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h index cb02084..96179be 100644 --- a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h +++ b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h @@ -53,6 +53,9 @@ cl::opt FatalWarnings("fatal-warnings", cl::opt NoWarn("no-warn", cl::desc("Suppress all warnings")); cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"), cl::aliasopt(NoWarn)); +cl::opt NoDeprecatedWarn("no-deprecated-warn", + cl::desc("Suppress all deprecated warnings")); + cl::opt ABIName("target-abi", cl::Hidden, cl::desc("The name of the ABI to be targeted from the backend."), @@ -70,6 +73,7 @@ static inline MCTargetOptions InitMCTargetOptionsFromFlags() { Options.ABIName = ABIName; Options.MCFatalWarnings = FatalWarnings; Options.MCNoWarn = NoWarn; + Options.MCNoDeprecatedWarn = NoDeprecatedWarn; return Options; } diff --git a/llvm/lib/MC/MCTargetOptions.cpp b/llvm/lib/MC/MCTargetOptions.cpp index e847a17..4192105 100644 --- a/llvm/lib/MC/MCTargetOptions.cpp +++ b/llvm/lib/MC/MCTargetOptions.cpp @@ -14,7 +14,8 @@ namespace llvm { MCTargetOptions::MCTargetOptions() : SanitizeAddress(false), MCRelaxAll(false), MCNoExecStack(false), - MCFatalWarnings(false), MCNoWarn(false), MCSaveTempLabels(false), + MCFatalWarnings(false), MCNoWarn(false), MCNoDeprecatedWarn(false), + MCSaveTempLabels(false), MCUseDwarfDirectory(false), MCIncrementalLinkerCompatible(false), MCPIECopyRelocations(false), ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false), diff --git a/llvm/test/CodeGen/ARM/deprecated-asm.s b/llvm/test/CodeGen/ARM/deprecated-asm.s new file mode 100644 index 0000000..7318e6a --- /dev/null +++ b/llvm/test/CodeGen/ARM/deprecated-asm.s @@ -0,0 +1,43 @@ +// REQUIRES: asserts +// RUN: llvm-mc < %s -triple=armv4t-linux-gnueabi -filetype=obj -o %t.o -no-deprecated-warn -stats 2>&1 | FileCheck %s +// RUN: llvm-mc < %s -triple=armv4t-linux-gnueabi -filetype=obj -o %t.o 2>&1 | FileCheck %s -check-prefix=WARN + + .text + .syntax unified + .eabi_attribute 67, "2.09" @ Tag_conformance + .cpu arm7tdmi + .eabi_attribute 6, 2 @ Tag_CPU_arch + .eabi_attribute 8, 1 @ Tag_ARM_ISA_use + .eabi_attribute 17, 1 @ Tag_ABI_PCS_GOT_use + .eabi_attribute 20, 1 @ Tag_ABI_FP_denormal + .eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions + .eabi_attribute 23, 3 @ Tag_ABI_FP_number_model + .eabi_attribute 34, 0 @ Tag_CPU_unaligned_access + .eabi_attribute 24, 1 @ Tag_ABI_align_needed + .eabi_attribute 25, 1 @ Tag_ABI_align_preserved + .eabi_attribute 38, 1 @ Tag_ABI_FP_16bit_format + .eabi_attribute 18, 4 @ Tag_ABI_PCS_wchar_t + .eabi_attribute 26, 2 @ Tag_ABI_enum_size + .eabi_attribute 14, 0 @ Tag_ABI_PCS_R9_use + .file "t.c" + .globl foo + .p2align 2 + .type foo,%function +foo: @ @foo + .fnstart +@ BB#0: @ %entry + mov r0, #0 + bx lr + stmia r4!, {r12-r14} +.Lfunc_end0: +.Ltmp0: + .size foo, .Ltmp0-foo + .cantunwind + .fnend + + + +// CHECK: Statistic +// CHECK-NOT: warning + +// WARN: warning diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 3719d88..1272d2b 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -3199,7 +3199,9 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { if (HasDeprecation) { OS << " std::string Info;\n"; - OS << " if (MII.get(Inst.getOpcode()).getDeprecatedInfo(Inst, getSTI(), Info)) {\n"; + OS << " if (!getParser().getTargetParser().\n"; + OS << " getTargetOptions().MCNoDeprecatedWarn &&\n"; + OS << " MII.get(Inst.getOpcode()).getDeprecatedInfo(Inst, getSTI(), Info)) {\n"; OS << " SMLoc Loc = ((" << Target.getName() << "Operand&)*Operands[0]).getStartLoc();\n"; OS << " getParser().Warning(Loc, Info, None);\n"; -- 2.7.4