[llvm] r213303 - ms inline asm: Don't add x86 segment registers to the clobber list.

Nico Weber nicolasweber at gmx.de
Thu Jul 17 13:24:55 PDT 2014


Author: nico
Date: Thu Jul 17 15:24:55 2014
New Revision: 213303

URL: http://llvm.org/viewvc/llvm-project?rev=213303&view=rev
Log:
ms inline asm: Don't add x86 segment registers to the clobber list.

Clang tries to check the clobber list but doesn't list segment registers in its
x86 register list. This fixes PR20343.

Modified:
    llvm/trunk/include/llvm/MC/MCTargetAsmParser.h
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp
    llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp

Modified: llvm/trunk/include/llvm/MC/MCTargetAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetAsmParser.h?rev=213303&r1=213302&r2=213303&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCTargetAsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCTargetAsmParser.h Thu Jul 17 15:24:55 2014
@@ -164,6 +164,9 @@ public:
                                        unsigned &ErrorInfo,
                                        bool MatchingInlineAsm) = 0;
 
+  /// Allows targets to let registers opt out of clobber lists.
+  virtual bool OmitRegisterFromClobberLists(unsigned RegNo) { return false; }
+
   /// Allow a target to add special case operand matching for things that
   /// tblgen doesn't/can't handle effectively. For example, literal
   /// immediates on ARM. TableGen expects a token operand, but the parser

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=213303&r1=213302&r2=213303&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Jul 17 15:24:55 2014
@@ -4510,7 +4510,8 @@ bool AsmParser::parseMSInlineAsm(
         continue;
 
       // Register operand.
-      if (Operand.isReg() && !Operand.needAddressOf()) {
+      if (Operand.isReg() && !Operand.needAddressOf() &&
+          !getTargetParser().OmitRegisterFromClobberLists(Operand.getReg())) {
         unsigned NumDefs = Desc.getNumDefs();
         // Clobber.
         if (NumDefs && Operand.getMCOperandNum() < NumDefs)

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=213303&r1=213302&r2=213303&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jul 17 15:24:55 2014
@@ -696,6 +696,8 @@ private:
                                unsigned &ErrorInfo,
                                bool MatchingInlineAsm) override;
 
+  virtual bool OmitRegisterFromClobberLists(unsigned RegNo) override;
+
   /// doSrcDstMatch - Returns true if operands are matching in their
   /// word size (%si and %di, %esi and %edi, etc.). Order depends on
   /// the parsing mode (Intel vs. AT&T).
@@ -2520,6 +2522,9 @@ bool X86AsmParser::MatchAndEmitInstructi
   return true;
 }
 
+bool X86AsmParser::OmitRegisterFromClobberLists(unsigned RegNo) {
+  return X86MCRegisterClasses[X86::SEGMENT_REGRegClassID].contains(RegNo);
+}
 
 bool X86AsmParser::ParseDirective(AsmToken DirectiveID) {
   StringRef IDVal = DirectiveID.getIdentifier();





More information about the llvm-commits mailing list