Add a new 'hotpatch' attribute. This attribute will insert a two-byte no-op
authorCharles Davis <cdavis@mines.edu>
Mon, 25 Oct 2010 15:37:09 +0000 (15:37 +0000)
committerCharles Davis <cdavis@mines.edu>
Mon, 25 Oct 2010 15:37:09 +0000 (15:37 +0000)
instruction at the beginning of each function that has the attribute, allowing
the function to be easily hooked and/or patched.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117264 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.html
include/llvm/Attributes.h
lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLToken.h
lib/VMCore/Attributes.cpp

index e5db8c69cfa666b9baa7b21e9d18c5d1b18cc96a..c2ee7019b9601d76aeedb4b49a5a3d2a3b6133c8 100644 (file)
@@ -1131,6 +1131,11 @@ define void @f() optsize { ... }
       function into callers whenever possible, ignoring any active inlining size
       threshold for this caller.</dd>
 
+  <dt><tt><b>hotpatch</b></tt></dt>
+  <dd>This attribute indicates that the prologue should contain a 'hotpatch'
+      sequence at the beginning. This is the same sequence used in the
+      system DLLs in Microsoft Windows XP Service Pack 2 and higher.</dd>
+
   <dt><tt><b>inlinehint</b></tt></dt>
   <dd>This attribute indicates that the source code contained a hint that inlining
       this function is desirable (such as the "inline" keyword in C/C++).  It
index 0325c89626b03f61dfb49e8ec1ee1119872505f1..da6188b1a8eae693100f0157f445771db5528acd 100644 (file)
@@ -65,6 +65,8 @@ const Attributes StackAlignment  = 7<<26; ///< Alignment of stack for
                                           ///of alignment with +1 bias
                                           ///0 means unaligned (different from
                                           ///alignstack(1))
+const Attributes Hotpatch    = 1<<29;     ///< Function should have special
+                                          ///'hotpatch' sequence in prologue
 
 /// @brief Attributes that only apply to function parameters.
 const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
@@ -73,7 +75,8 @@ const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
 /// be used on return values or function parameters.
 const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
   NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
-  NoRedZone | NoImplicitFloat | Naked | InlineHint | StackAlignment;
+  NoRedZone | NoImplicitFloat | Naked | InlineHint | StackAlignment |
+  Hotpatch;
 
 /// @brief Parameter attributes that do not apply to vararg call arguments.
 const Attributes VarArgsIncompatible = StructRet;
index eeaadf68ea14ff7abb1bc3a3fa23a337886e6cf2..f924b5a908986e1b1c9e2c69e4faa24f7f44c967 100644 (file)
@@ -573,6 +573,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(noredzone);
   KEYWORD(noimplicitfloat);
   KEYWORD(naked);
+  KEYWORD(hotpatch);
 
   KEYWORD(type);
   KEYWORD(opaque);
index 4d3bd879320202539c3598842628eb1f983d3699..a1f70fb0249ceee5de67efcf22c79701009241f7 100644 (file)
@@ -982,6 +982,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
     case lltok::kw_noredzone:       Attrs |= Attribute::NoRedZone; break;
     case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break;
     case lltok::kw_naked:           Attrs |= Attribute::Naked; break;
+    case lltok::kw_hotpatch:        Attrs |= Attribute::Hotpatch; break;
 
     case lltok::kw_alignstack: {
       unsigned Alignment;
index 8a8663e739ab609ceee8577c34b9e9f14bdfe481..72128c9ae0560a0bb70861a586311826e9eb847c 100644 (file)
@@ -96,6 +96,7 @@ namespace lltok {
     kw_noredzone,
     kw_noimplicitfloat,
     kw_naked,
+    kw_hotpatch,
 
     kw_type,
     kw_opaque,
index 3422faf27303beeb22cfa114b0f744640b6f0408..6f5ecd278d880102fab47387b07ce737574a6ba5 100644 (file)
@@ -70,6 +70,8 @@ std::string Attribute::getAsString(Attributes Attrs) {
     Result += "noimplicitfloat ";
   if (Attrs & Attribute::Naked)
     Result += "naked ";
+  if (Attrs & Attribute::Hotpatch)
+    Result += "hotpatch ";
   if (Attrs & Attribute::StackAlignment) {
     Result += "alignstack(";
     Result += utostr(Attribute::getStackAlignmentFromAttrs(Attrs));