[llvm] r206971 - Create MCTargetOptions.

Timur Iskhodzhanov timurrrr at google.com
Wed Apr 23 07:24:49 PDT 2014


(this fires on Chromium on Windows. I'm trying to get a repro for you)

2014-04-23 18:21 GMT+04:00 Timur Iskhodzhanov <timurrrr at google.com>:
> Assertion failed: Op && Op->isMem() && "Op should be a memory
> operand.", file ..\lib\Target\X86\AsmParser\X86AsmInstrumentation.cpp,
> line 68
>
> 2014-04-23 15:16 GMT+04:00 Evgeniy Stepanov <eugeni.stepanov at gmail.com>:
>> Author: eugenis
>> Date: Wed Apr 23 06:16:03 2014
>> New Revision: 206971
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=206971&view=rev
>> Log:
>> Create MCTargetOptions.
>>
>> For now it contains a single flag, SanitizeAddress, which enables
>> AddressSanitizer instrumentation of inline assembly.
>>
>> Patch by Yuri Gorshenin.
>>
>> Added:
>>     llvm/trunk/include/llvm/MC/MCTargetOptions.h   (with props)
>>     llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h   (with props)
>>     llvm/trunk/lib/MC/MCTargetOptions.cpp   (with props)
>>     llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_attr.ll
>> Modified:
>>     llvm/trunk/include/llvm/CodeGen/CommandFlags.h
>>     llvm/trunk/include/llvm/MC/MCTargetAsmParser.h
>>     llvm/trunk/include/llvm/Support/TargetRegistry.h
>>     llvm/trunk/include/llvm/Target/TargetOptions.h
>>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
>>     llvm/trunk/lib/LTO/LTOModule.cpp
>>     llvm/trunk/lib/MC/CMakeLists.txt
>>     llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
>>     llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
>>     llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp
>>     llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
>>     llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
>>     llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
>>     llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
>>     llvm/trunk/lib/Target/TargetMachine.cpp
>>     llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp
>>     llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.h
>>     llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
>>     llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll
>>     llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.s
>>     llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s
>>     llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>>
>> Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)
>> +++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Wed Apr 23 06:16:03 2014
>> @@ -16,6 +16,7 @@
>>  #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
>>  #define LLVM_CODEGEN_COMMANDFLAGS_H
>>
>> +#include "llvm/MC/MCTargetOptionsCommandFlags.h"
>>  #include "llvm/Support/CodeGen.h"
>>  #include "llvm/Support/CommandLine.h"
>>  #include "llvm/Target/TargetMachine.h"
>> @@ -225,6 +226,9 @@ static inline TargetOptions InitTargetOp
>>    Options.TrapFuncName = TrapFuncName;
>>    Options.PositionIndependentExecutable = EnablePIE;
>>    Options.UseInitArray = UseInitArray;
>> +
>> +  Options.MCOptions = InitMCTargetOptionsFromFlags();
>> +
>>    return Options;
>>  }
>>
>>
>> Modified: llvm/trunk/include/llvm/MC/MCTargetAsmParser.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetAsmParser.h?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCTargetAsmParser.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCTargetAsmParser.h Wed Apr 23 06:16:03 2014
>> @@ -12,14 +12,15 @@
>>
>>  #include "llvm/MC/MCExpr.h"
>>  #include "llvm/MC/MCParser/MCAsmParserExtension.h"
>> +#include "llvm/MC/MCTargetOptions.h"
>>
>>  namespace llvm {
>> -class MCStreamer;
>> -class StringRef;
>> -class SMLoc;
>>  class AsmToken;
>> -class MCParsedAsmOperand;
>>  class MCInst;
>> +class MCParsedAsmOperand;
>> +class MCStreamer;
>> +class SMLoc;
>> +class StringRef;
>>  template <typename T> class SmallVectorImpl;
>>
>>  enum AsmRewriteKind {
>> @@ -97,6 +98,9 @@ protected: // Can only create subclasses
>>    /// ms-style inline assembly.
>>    MCAsmParserSemaCallback *SemaCallback;
>>
>> +  /// Set of options which affects instrumentation of inline assembly.
>> +  MCTargetOptions MCOptions;
>> +
>>  public:
>>    virtual ~MCTargetAsmParser();
>>
>>
>> Added: llvm/trunk/include/llvm/MC/MCTargetOptions.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetOptions.h?rev=206971&view=auto
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCTargetOptions.h (added)
>> +++ llvm/trunk/include/llvm/MC/MCTargetOptions.h Wed Apr 23 06:16:03 2014
>> @@ -0,0 +1,40 @@
>> +//===- MCTargetOptions.h - MC Target Options -------------------*- C++ -*-===//
>> +//
>> +//                     The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===----------------------------------------------------------------------===//
>> +
>> +#ifndef LLVM_MC_MCTARGETOPTIONS_H
>> +#define LLVM_MC_MCTARGETOPTIONS_H
>> +
>> +namespace llvm {
>> +
>> +class MCTargetOptions {
>> +public:
>> +  enum AsmInstrumentation {
>> +    AsmInstrumentationNone,
>> +    AsmInstrumentationAddress
>> +  };
>> +
>> +  /// Enables AddressSanitizer instrumentation at machine level.
>> +  bool SanitizeAddress : 1;
>> +
>> +  MCTargetOptions();
>> +};
>> +
>> +inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
>> +#define ARE_EQUAL(X) LHS.X == RHS.X
>> +  return ARE_EQUAL(SanitizeAddress);
>> +#undef ARE_EQUAL
>> +}
>> +
>> +inline bool operator!=(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
>> +  return !(LHS == RHS);
>> +}
>> +
>> +} // end namespace llvm
>> +
>> +#endif
>>
>> Propchange: llvm/trunk/include/llvm/MC/MCTargetOptions.h
>> ------------------------------------------------------------------------------
>>     svn:eol-style = LF
>>
>> Added: llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h?rev=206971&view=auto
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h (added)
>> +++ llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h Wed Apr 23 06:16:03 2014
>> @@ -0,0 +1,42 @@
>> +//===-- MCTargetOptionsCommandFlags.h --------------------------*- C++ -*-===//
>> +//
>> +//                     The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===----------------------------------------------------------------------===//
>> +//
>> +// This file contains machine code-specific flags that are shared between
>> +// different command line tools.
>> +//
>> +//===----------------------------------------------------------------------===//
>> +
>> +#ifndef LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
>> +#define LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
>> +
>> +#include "llvm/Support/CommandLine.h"
>> +#include "llvm/MC/MCTargetOptions.h"
>> +using namespace llvm;
>> +
>> +cl::opt<MCTargetOptions::AsmInstrumentation> AsmInstrumentation(
>> +    "asm-instrumentation",
>> +    cl::desc("Instrumentation of inline assembly and "
>> +             "assembly source files"),
>> +    cl::init(MCTargetOptions::AsmInstrumentationNone),
>> +    cl::values(clEnumValN(MCTargetOptions::AsmInstrumentationNone,
>> +                          "none",
>> +                          "no instrumentation at all"),
>> +               clEnumValN(MCTargetOptions::AsmInstrumentationAddress,
>> +                          "address",
>> +                          "instrument instructions with memory arguments"),
>> +               clEnumValEnd));
>> +
>> +static inline MCTargetOptions InitMCTargetOptionsFromFlags() {
>> +  MCTargetOptions Options;
>> +  Options.SanitizeAddress =
>> +      (AsmInstrumentation == MCTargetOptions::AsmInstrumentationAddress);
>> +  return Options;
>> +}
>> +
>> +#endif
>>
>> Propchange: llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h
>> ------------------------------------------------------------------------------
>>     svn:eol-style = LF
>>
>> Modified: llvm/trunk/include/llvm/Support/TargetRegistry.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Support/TargetRegistry.h (original)
>> +++ llvm/trunk/include/llvm/Support/TargetRegistry.h Wed Apr 23 06:16:03 2014
>> @@ -45,6 +45,7 @@ namespace llvm {
>>    class MCSymbolizer;
>>    class MCRelocationInfo;
>>    class MCTargetAsmParser;
>> +  class MCTargetOptions;
>>    class TargetMachine;
>>    class TargetOptions;
>>    class raw_ostream;
>> @@ -104,9 +105,11 @@ namespace llvm {
>>                                                  const MCRegisterInfo &MRI,
>>                                                  StringRef TT,
>>                                                  StringRef CPU);
>> -    typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(MCSubtargetInfo &STI,
>> -                                                    MCAsmParser &P,
>> -                                                    const MCInstrInfo &MII);
>> +    typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
>> +        MCSubtargetInfo &STI,
>> +        MCAsmParser &P,
>> +        const MCInstrInfo &MII,
>> +        const MCTargetOptions &Options);
>>      typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
>>                                                      const MCSubtargetInfo &STI,
>>                                                      MCContext &Ctx);
>> @@ -362,12 +365,14 @@ namespace llvm {
>>      ///
>>      /// \param Parser The target independent parser implementation to use for
>>      /// parsing and lexing.
>> -    MCTargetAsmParser *createMCAsmParser(MCSubtargetInfo &STI,
>> -                                         MCAsmParser &Parser,
>> -                                         const MCInstrInfo &MII) const {
>> +    MCTargetAsmParser *createMCAsmParser(
>> +        MCSubtargetInfo &STI,
>> +        MCAsmParser &Parser,
>> +        const MCInstrInfo &MII,
>> +        const MCTargetOptions &Options) const {
>>        if (!MCAsmParserCtorFn)
>>          return nullptr;
>> -      return MCAsmParserCtorFn(STI, Parser, MII);
>> +      return MCAsmParserCtorFn(STI, Parser, MII, Options);
>>      }
>>
>>      /// createAsmPrinter - Create a target specific assembly printer pass.  This
>> @@ -1099,8 +1104,9 @@ namespace llvm {
>>
>>    private:
>>      static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI, MCAsmParser &P,
>> -                                        const MCInstrInfo &MII) {
>> -      return new MCAsmParserImpl(STI, P, MII);
>> +                                        const MCInstrInfo &MII,
>> +                                        const MCTargetOptions &Options) {
>> +      return new MCAsmParserImpl(STI, P, MII, Options);
>>      }
>>    };
>>
>>
>> Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
>> +++ llvm/trunk/include/llvm/Target/TargetOptions.h Wed Apr 23 06:16:03 2014
>> @@ -15,6 +15,7 @@
>>  #ifndef LLVM_TARGET_TARGETOPTIONS_H
>>  #define LLVM_TARGET_TARGETOPTIONS_H
>>
>> +#include "llvm/MC/MCTargetOptions.h"
>>  #include <string>
>>
>>  namespace llvm {
>> @@ -197,6 +198,9 @@ namespace llvm {
>>      /// via the llvm.fma.* intrinsic) will always be honored, regardless of
>>      /// the value of this option.
>>      FPOpFusion::FPOpFusionMode AllowFPOpFusion;
>> +
>> +    /// Machine level options.
>> +    MCTargetOptions MCOptions;
>>    };
>>
>>  // Comparison operators:
>> @@ -223,7 +227,8 @@ inline bool operator==(const TargetOptio
>>      ARE_EQUAL(TrapUnreachable) &&
>>      ARE_EQUAL(TrapFuncName) &&
>>      ARE_EQUAL(FloatABIType) &&
>> -    ARE_EQUAL(AllowFPOpFusion);
>> +    ARE_EQUAL(AllowFPOpFusion) &&
>> +    ARE_EQUAL(MCOptions);
>>  #undef ARE_EQUAL
>>  }
>>
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Wed Apr 23 06:16:03 2014
>> @@ -15,6 +15,7 @@
>>  #include "llvm/ADT/SmallString.h"
>>  #include "llvm/ADT/Twine.h"
>>  #include "llvm/CodeGen/MachineBasicBlock.h"
>> +#include "llvm/CodeGen/MachineFunction.h"
>>  #include "llvm/CodeGen/MachineModuleInfo.h"
>>  #include "llvm/IR/Constants.h"
>>  #include "llvm/IR/DataLayout.h"
>> @@ -135,8 +136,11 @@ void AsmPrinter::EmitInlineAsm(StringRef
>>    // emitInlineAsmEnd().
>>    MCSubtargetInfo STIOrig = *STI;
>>
>> +  MCTargetOptions MCOptions;
>> +  if (MF)
>> +    MCOptions = MF->getTarget().Options.MCOptions;
>>    std::unique_ptr<MCTargetAsmParser> TAP(
>> -      TM.getTarget().createMCAsmParser(*STI, *Parser, *MII));
>> +      TM.getTarget().createMCAsmParser(*STI, *Parser, *MII, MCOptions));
>>    if (!TAP)
>>      report_fatal_error("Inline asm not supported by this streamer because"
>>                         " we don't have an asm parser for this target\n");
>>
>> Modified: llvm/trunk/lib/LTO/LTOModule.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/LTO/LTOModule.cpp (original)
>> +++ llvm/trunk/lib/LTO/LTOModule.cpp Wed Apr 23 06:16:03 2014
>> @@ -739,7 +739,8 @@ bool LTOModule::addAsmGlobalSymbols(std:
>>        _target->getTargetTriple(), _target->getTargetCPU(),
>>        _target->getTargetFeatureString()));
>>    std::unique_ptr<MCTargetAsmParser> TAP(
>> -      T.createMCAsmParser(*STI, *Parser.get(), *MCII));
>> +      T.createMCAsmParser(*STI, *Parser.get(), *MCII,
>> +                          _target->Options.MCOptions));
>>    if (!TAP) {
>>      errMsg = "target " + std::string(T.getName()) +
>>        " does not define AsmParser.";
>>
>> Modified: llvm/trunk/lib/MC/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/CMakeLists.txt?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/MC/CMakeLists.txt (original)
>> +++ llvm/trunk/lib/MC/CMakeLists.txt Wed Apr 23 06:16:03 2014
>> @@ -45,6 +45,7 @@ add_llvm_library(LLVMMC
>>    MCSubtargetInfo.cpp
>>    MCSymbol.cpp
>>    MCSymbolizer.cpp
>> +  MCTargetOptions.cpp
>>    MCValue.cpp
>>    MCWin64EH.cpp
>>    MachObjectWriter.cpp
>>
>> Added: llvm/trunk/lib/MC/MCTargetOptions.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCTargetOptions.cpp?rev=206971&view=auto
>> ==============================================================================
>> --- llvm/trunk/lib/MC/MCTargetOptions.cpp (added)
>> +++ llvm/trunk/lib/MC/MCTargetOptions.cpp Wed Apr 23 06:16:03 2014
>> @@ -0,0 +1,16 @@
>> +//===- lib/MC/MCTargetOptions.cpp - MC Target Options --------------------===//
>> +//
>> +//                     The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===----------------------------------------------------------------------===//
>> +
>> +#include "llvm/MC/MCTargetOptions.h"
>> +
>> +namespace llvm {
>> +
>> +MCTargetOptions::MCTargetOptions() : SanitizeAddress(false) {}
>> +
>> +} // end namespace llvm
>>
>> Propchange: llvm/trunk/lib/MC/MCTargetOptions.cpp
>> ------------------------------------------------------------------------------
>>     svn:eol-style = LF
>>
>> Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -55,7 +55,8 @@ public:
>>    };
>>
>>    AArch64AsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
>> -                   const MCInstrInfo &MII)
>> +                   const MCInstrInfo &MII,
>> +                   const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
>>      MCAsmParserExtension::Initialize(_Parser);
>>
>>
>> Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -344,7 +344,8 @@ public:
>>    };
>>
>>    ARMAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
>> -               const MCInstrInfo &MII)
>> +               const MCInstrInfo &MII,
>> +               const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(_STI), Parser(_Parser), MII(MII), UC(_Parser) {
>>      MCAsmParserExtension::Initialize(_Parser);
>>
>>
>> Modified: llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -104,7 +104,8 @@ public:
>>  #include "ARM64GenAsmMatcher.inc"
>>    };
>>    ARM64AsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
>> -                 const MCInstrInfo &MII)
>> +                 const MCInstrInfo &MII,
>> +                 const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
>>      MCAsmParserExtension::Initialize(_Parser);
>>
>>
>> Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -229,7 +229,8 @@ class MipsAsmParser : public MCTargetAsm
>>
>>  public:
>>    MipsAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
>> -                const MCInstrInfo &MII)
>> +                const MCInstrInfo &MII,
>> +                const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(sti), Parser(parser) {
>>      // Initialize the set of available features.
>>      setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
>>
>> Modified: llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -264,7 +264,8 @@ class PPCAsmParser : public MCTargetAsmP
>>
>>  public:
>>    PPCAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
>> -               const MCInstrInfo &_MII)
>> +               const MCInstrInfo &_MII,
>> +               const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(_STI), Parser(_Parser), MII(_MII) {
>>      // Check for 64-bit vs. 32-bit pointer mode.
>>      Triple TheTriple(STI.getTargetTriple());
>>
>> Modified: llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -83,7 +83,8 @@ class SparcAsmParser : public MCTargetAs
>>    bool is64Bit() const { return STI.getTargetTriple().startswith("sparcv9"); }
>>  public:
>>    SparcAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
>> -                const MCInstrInfo &MII)
>> +                const MCInstrInfo &MII,
>> +                const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(sti), Parser(parser) {
>>      // Initialize the set of available features.
>>      setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
>>
>> Modified: llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -331,7 +331,8 @@ private:
>>
>>  public:
>>    SystemZAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
>> -                   const MCInstrInfo &MII)
>> +                   const MCInstrInfo &MII,
>> +                   const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(sti), Parser(parser) {
>>      MCAsmParserExtension::Initialize(Parser);
>>
>>
>> Modified: llvm/trunk/lib/Target/TargetMachine.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/TargetMachine.cpp (original)
>> +++ llvm/trunk/lib/Target/TargetMachine.cpp Wed Apr 23 06:16:03 2014
>> @@ -21,6 +21,7 @@
>>  #include "llvm/MC/MCAsmInfo.h"
>>  #include "llvm/MC/MCCodeGenInfo.h"
>>  #include "llvm/MC/MCContext.h"
>> +#include "llvm/MC/MCTargetOptions.h"
>>  #include "llvm/MC/SectionKind.h"
>>  #include "llvm/Support/CommandLine.h"
>>  #include "llvm/Target/TargetLowering.h"
>> @@ -89,6 +90,8 @@ void TargetMachine::resetTargetOptions(c
>>    RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math");
>>    RESET_OPTION(UseSoftFloat, "use-soft-float");
>>    RESET_OPTION(DisableTailCalls, "disable-tail-calls");
>> +
>> +  TO.MCOptions.SanitizeAddress = F->hasFnAttribute(Attribute::SanitizeAddress);
>>  }
>>
>>  /// getRelocationModel - Returns the code generation relocation model. The
>>
>> Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp Wed Apr 23 06:16:03 2014
>> @@ -11,22 +11,18 @@
>>  #include "X86AsmInstrumentation.h"
>>  #include "X86Operand.h"
>>  #include "llvm/ADT/StringExtras.h"
>> +#include "llvm/IR/Function.h"
>>  #include "llvm/MC/MCContext.h"
>>  #include "llvm/MC/MCInst.h"
>>  #include "llvm/MC/MCInstBuilder.h"
>> +#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
>>  #include "llvm/MC/MCStreamer.h"
>>  #include "llvm/MC/MCSubtargetInfo.h"
>> -#include "llvm/Support/CommandLine.h"
>> -#include "llvm/Support/Compiler.h"
>> -#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
>> +#include "llvm/MC/MCTargetOptions.h"
>>
>>  namespace llvm {
>>  namespace {
>>
>> -static cl::opt<bool> ClAsanInstrumentInlineAssembly(
>> -    "asan-instrument-inline-assembly", cl::desc("instrument inline assembly"),
>> -    cl::Hidden, cl::init(false));
>> -
>>  bool IsStackReg(unsigned Reg) {
>>    return Reg == X86::RSP || Reg == X86::ESP || Reg == X86::SP;
>>  }
>> @@ -38,7 +34,7 @@ std::string FuncName(unsigned AccessSize
>>
>>  class X86AddressSanitizer : public X86AsmInstrumentation {
>>  public:
>> -  X86AddressSanitizer(MCSubtargetInfo &sti) : STI(sti) {}
>> +  X86AddressSanitizer(const MCSubtargetInfo &STI) : STI(STI) {}
>>    virtual ~X86AddressSanitizer() {}
>>
>>    // X86AsmInstrumentation implementation:
>> @@ -63,7 +59,7 @@ public:
>>    }
>>
>>  protected:
>> -  MCSubtargetInfo &STI;
>> +  const MCSubtargetInfo &STI;
>>  };
>>
>>  void X86AddressSanitizer::InstrumentMemOperand(
>> @@ -144,7 +140,8 @@ void X86AddressSanitizer::InstrumentMOV(
>>
>>  class X86AddressSanitizer32 : public X86AddressSanitizer {
>>  public:
>> -  X86AddressSanitizer32(MCSubtargetInfo &sti) : X86AddressSanitizer(sti) {}
>> +  X86AddressSanitizer32(const MCSubtargetInfo &STI)
>> +      : X86AddressSanitizer(STI) {}
>>    virtual ~X86AddressSanitizer32() {}
>>
>>    virtual void InstrumentMemOperandImpl(X86Operand *Op, unsigned AccessSize,
>> @@ -179,7 +176,8 @@ void X86AddressSanitizer32::InstrumentMe
>>
>>  class X86AddressSanitizer64 : public X86AddressSanitizer {
>>  public:
>> -  X86AddressSanitizer64(MCSubtargetInfo &sti) : X86AddressSanitizer(sti) {}
>> +  X86AddressSanitizer64(const MCSubtargetInfo &STI)
>> +      : X86AddressSanitizer(STI) {}
>>    virtual ~X86AddressSanitizer64() {}
>>
>>    virtual void InstrumentMemOperandImpl(X86Operand *Op, unsigned AccessSize,
>> @@ -223,8 +221,10 @@ void X86AsmInstrumentation::InstrumentIn
>>      const MCInst &Inst, SmallVectorImpl<MCParsedAsmOperand *> &Operands,
>>      MCContext &Ctx, MCStreamer &Out) {}
>>
>> -X86AsmInstrumentation *CreateX86AsmInstrumentation(MCSubtargetInfo &STI) {
>> -  if (ClAsanInstrumentInlineAssembly) {
>> +X86AsmInstrumentation *
>> +CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions, const MCContext &Ctx,
>> +                            const MCSubtargetInfo &STI) {
>> +  if (MCOptions.SanitizeAddress) {
>>      if ((STI.getFeatureBits() & X86::Mode32Bit) != 0)
>>        return new X86AddressSanitizer32(STI);
>>      if ((STI.getFeatureBits() & X86::Mode64Bit) != 0)
>>
>> Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.h?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.h (original)
>> +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmInstrumentation.h Wed Apr 23 06:16:03 2014
>> @@ -19,10 +19,13 @@ class MCInst;
>>  class MCParsedAsmOperand;
>>  class MCStreamer;
>>  class MCSubtargetInfo;
>> +class MCTargetOptions;
>>
>>  class X86AsmInstrumentation;
>>
>> -X86AsmInstrumentation *CreateX86AsmInstrumentation(MCSubtargetInfo &STI);
>> +X86AsmInstrumentation *
>> +CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions,
>> +                            const MCContext &Ctx, const MCSubtargetInfo &STI);
>>
>>  class X86AsmInstrumentation {
>>  public:
>> @@ -36,11 +39,12 @@ public:
>>
>>  protected:
>>    friend X86AsmInstrumentation *
>> -  CreateX86AsmInstrumentation(MCSubtargetInfo &STI);
>> +  CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions,
>> +                              const MCContext &Ctx, const MCSubtargetInfo &STI);
>>
>>    X86AsmInstrumentation();
>>  };
>>
>> -}  // End llvm namespace
>> +} // End llvm namespace
>>
>> -#endif  // X86_ASM_INSTRUMENTATION_H
>> +#endif // X86_ASM_INSTRUMENTATION_H
>>
>> Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Wed Apr 23 06:16:03 2014
>> @@ -710,13 +710,16 @@ private:
>>
>>  public:
>>    X86AsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
>> -               const MCInstrInfo &MII)
>> +               const MCInstrInfo &MII,
>> +               const MCTargetOptions &Options)
>>        : MCTargetAsmParser(), STI(sti), Parser(parser), InstInfo(0) {
>>
>>      // Initialize the set of available features.
>>      setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
>> -    Instrumentation.reset(CreateX86AsmInstrumentation(STI));
>> +    Instrumentation.reset(
>> +        CreateX86AsmInstrumentation(Options, Parser.getContext(), STI));
>>    }
>> +
>>    bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override;
>>
>>    bool
>>
>> Added: llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_attr.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_attr.ll?rev=206971&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_attr.ll (added)
>> +++ llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_attr.ll Wed Apr 23 06:16:03 2014
>> @@ -0,0 +1,20 @@
>> +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address | FileCheck %s
>> +
>> +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>> +target triple = "x86_64-unknown-linux-gnu"
>> +
>> +; CHECK-LABEL: mov_no_attr
>> +; CHECK-NOT: callq __sanitizer_sanitize_load8 at PLT
>> +; CHECK-NOT: callq __sanitizer_sanitize_store8 at PLT
>> +define void @mov_no_attr(i64* %dst, i64* %src) {
>> +  tail call void asm sideeffect "movq ($1), %rax  \0A\09movq %rax, ($0)  \0A\09", "r,r,~{memory},~{rax},~{dirflag},~{fpsr},~{flags}"(i64* %dst, i64* %src)
>> +  ret void
>> +}
>> +
>> +; CHECK-LABEL: mov_sanitize
>> +; CHECK: callq __sanitizer_sanitize_load8 at PLT
>> +; CHECK: callq __sanitizer_sanitize_store8 at PLT
>> +define void @mov_sanitize(i64* %dst, i64* %src) sanitize_address {
>> +  tail call void asm sideeffect "movq ($1), %rax  \0A\09movq %rax, ($0)  \0A\09", "r,r,~{memory},~{rax},~{dirflag},~{fpsr},~{flags}"(i64* %dst, i64* %src)
>> +  ret void
>> +}
>>
>> Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll (original)
>> +++ llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll Wed Apr 23 06:16:03 2014
>> @@ -1,4 +1,4 @@
>> -; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asan-instrument-inline-assembly | FileCheck %s
>> +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address | FileCheck %s
>>
>>  target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
>>  target triple = "x86_64-unknown-linux-gnu"
>> @@ -113,7 +113,7 @@ entry:
>>    ret void
>>  }
>>
>> -attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
>> +attributes #0 = { nounwind uwtable sanitize_address "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
>>  attributes #1 = { nounwind }
>>
>>  !0 = metadata !{i32 98, i32 122, i32 160}
>>
>> Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.s
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.s?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.s (original)
>> +++ llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov.s Wed Apr 23 06:16:03 2014
>> @@ -1,4 +1,4 @@
>> -# RUN: llvm-mc %s -triple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asan-instrument-inline-assembly | FileCheck %s
>> +# RUN: llvm-mc %s -triple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address | FileCheck %s
>>
>>         .text
>>         .globl  mov1b
>>
>> Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s (original)
>> +++ llvm/trunk/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s Wed Apr 23 06:16:03 2014
>> @@ -20,25 +20,5 @@ mov1b:
>>         .size   mov1b, .Ltmp0-mov1b
>>         .cfi_endproc
>>
>> -       .globl  mov16b
>> -       .align  16, 0x90
>> -       .type   mov16b, at function
>> -# CHECK-LABEL: mov16b
>> -# CHECK-NOT: callq __sanitizer_sanitize_load16 at PLT
>> -# CHECK-NOT: callq __sanitizer_sanitize_store16 at PLT
>> -mov16b:                                 # @mov16b
>> -       .cfi_startproc
>> -# BB#0:
>> -       #APP
>> -       movaps  (%rsi), %xmm0
>> -       movaps  %xmm0, (%rdi)
>> -
>> -       #NO_APP
>> -       retq
>> -.Ltmp1:
>> -       .size   mov16b, .Ltmp1-mov16b
>> -       .cfi_endproc
>> -
>> -
>>         .ident  "clang version 3.5 "
>>         .section        ".note.GNU-stack","", at progbits
>>
>> Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=206971&r1=206970&r2=206971&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
>> +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Wed Apr 23 06:16:03 2014
>> @@ -25,6 +25,7 @@
>>  #include "llvm/MC/MCStreamer.h"
>>  #include "llvm/MC/MCSubtargetInfo.h"
>>  #include "llvm/MC/MCTargetAsmParser.h"
>> +#include "llvm/MC/MCTargetOptionsCommandFlags.h"
>>  #include "llvm/Support/CommandLine.h"
>>  #include "llvm/Support/Compression.h"
>>  #include "llvm/Support/FileUtilities.h"
>> @@ -320,9 +321,11 @@ static int AsLexInput(SourceMgr &SrcMgr,
>>  static int AssembleInput(const char *ProgName, const Target *TheTarget,
>>                           SourceMgr &SrcMgr, MCContext &Ctx, MCStreamer &Str,
>>                           MCAsmInfo &MAI, MCSubtargetInfo &STI, MCInstrInfo &MCII) {
>> -  std::unique_ptr<MCAsmParser> Parser(createMCAsmParser(SrcMgr, Ctx, Str, MAI));
>> +  std::unique_ptr<MCAsmParser> Parser(
>> +      createMCAsmParser(SrcMgr, Ctx, Str, MAI));
>>    std::unique_ptr<MCTargetAsmParser> TAP(
>> -      TheTarget->createMCAsmParser(STI, *Parser, MCII));
>> +      TheTarget->createMCAsmParser(STI, *Parser, MCII,
>> +                                   InitMCTargetOptionsFromFlags()));
>>    if (!TAP) {
>>      errs() << ProgName
>>             << ": error: this target does not support assembly parsing.\n";
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list