Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -2029,6 +2029,12 @@ // Microsoft-related attributes +def MSHookPrologue : InheritableAttr { + let Spellings = [GCC<"ms_hook_prologue">]; + let Subjects = SubjectList<[Function]>; + let Documentation = [Undocumented]; +} + def MSNoVTable : InheritableAttr, TargetSpecificAttr { let Spellings = [Declspec<"novtable">]; let Subjects = SubjectList<[CXXRecord]>; Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -1743,6 +1743,10 @@ llvm::Function *Fn = cast(GV); Fn->setCallingConv(llvm::CallingConv::X86_INTR); } + if (FD->hasAttr()) { + llvm::Function *Fn = cast(GV); + Fn->addFnAttr("ms-hotpatch"); + } } } @@ -2073,6 +2077,10 @@ llvm::Function *Fn = cast(GV); Fn->setCallingConv(llvm::CallingConv::X86_INTR); } + if (FD->hasAttr()) { + llvm::Function *Fn = cast(GV); + Fn->addFnAttr("ms-hotpatch"); + } } } }; Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -5742,6 +5742,9 @@ break; // Microsoft attributes: + case AttributeList::AT_MSHookPrologue: + handleSimpleAttribute(S, D, Attr); + break; case AttributeList::AT_MSNoVTable: handleSimpleAttribute(S, D, Attr); break; Index: test/CodeGen/function-attributes.c =================================================================== --- test/CodeGen/function-attributes.c +++ test/CodeGen/function-attributes.c @@ -108,11 +108,18 @@ _setjmp(0); } +// CHECK-LABEL: define void @f21 +// CHECK: [[HOTPATCH:#[0-9]+]] +// CHECK: { +void __attribute__((ms_hook_prologue)) f21(void) { +} + // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} } // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} } // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} } // CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} } // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} } +// CHECK: attributes [[HOTPATCH]] = { nounwind optsize{{.*}}"ms-hotpatch"{{.*}} } // CHECK: attributes [[NR]] = { noreturn optsize } // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone } // CHECK: attributes [[RT_CALL]] = { optsize returns_twice }