File tree Expand file tree Collapse file tree 4 files changed +29
-13
lines changed Expand file tree Collapse file tree 4 files changed +29
-13
lines changed Original file line number Diff line number Diff line change
1
+ // This verifies that hotpatch function attributes are correctly propagated when compiling directly to OBJ,
2
+ // and that name mangling works as expected.
3
+ //
4
+ // RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-list=?this_gets_hotpatched@@YAHXZ /Fo%t.obj %s
5
+ // RUN: llvm-readobj --codeview %t.obj | FileCheck %s
6
+
7
+ void this_might_have_side_effects ();
8
+
9
+ int __declspec (noinline) this_gets_hotpatched() {
10
+ this_might_have_side_effects ();
11
+ return 42 ;
12
+ }
13
+
14
+ // CHECK: Kind: S_HOTPATCHFUNC (0x1169)
15
+ // CHECK-NEXT: Function: this_gets_hotpatched
16
+ // CHECK-NEXT: Name: ?this_gets_hotpatched@@YAHXZ
17
+
18
+ extern " C" int __declspec (noinline) this_does_not_get_hotpatched() {
19
+ return this_gets_hotpatched () + 100 ;
20
+ }
21
+
22
+ // CHECK-NOT: S_HOTPATCHFUNC
Original file line number Diff line number Diff line change 2
2
//
3
3
// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt /Fo%t.obj %s
4
4
// RUN: llvm-readobj --codeview %t.obj | FileCheck %s
5
- // CHECK: Kind: S_HOTPATCHFUNC (0x1169)
6
- // CHECK-NEXT: Function: this_gets_hotpatched
7
5
8
6
void this_might_have_side_effects ();
9
7
@@ -12,6 +10,11 @@ int __declspec(noinline) this_gets_hotpatched() {
12
10
return 42 ;
13
11
}
14
12
13
+ // CHECK: Kind: S_HOTPATCHFUNC (0x1169)
14
+ // CHECK-NEXT: Function: this_gets_hotpatched
15
+
15
16
int __declspec(noinline ) this_does_not_get_hotpatched () {
16
17
return this_gets_hotpatched () + 100 ;
17
18
}
19
+
20
+ // CHECK-NOT: S_HOTPATCHFUNC
Original file line number Diff line number Diff line change @@ -398,7 +398,7 @@ def MarkedForWindowsHotPatching
398
398
/// decl, not the hotpatched function.
399
399
def AllowDirectAccessInHotPatchFunction
400
400
: EnumAttr<"allow_direct_access_in_hot_patch_function",
401
- IntersectPreserve, []>;
401
+ IntersectPreserve, [FnAttr ]>;
402
402
403
403
/// Target-independent string attributes.
404
404
def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
Original file line number Diff line number Diff line change @@ -130,16 +130,7 @@ bool WindowsHotPatch::runOnModule(Module &M) {
130
130
continue ;
131
131
}
132
132
133
- llvm::StringRef FuncName{};
134
- if (auto *SP = F.getSubprogram (); SP != nullptr ) {
135
- FuncName = SP->getLinkageName ();
136
- if (FuncName.empty ()) {
137
- FuncName = F.getName ();
138
- }
139
- } else {
140
- FuncName = F.getName ();
141
- }
142
- if (HotPatchFunctionsSet.contains (FuncName)) {
133
+ if (HotPatchFunctionsSet.contains (F.getName ())) {
143
134
F.addFnAttr (Attribute::MarkedForWindowsHotPatching);
144
135
}
145
136
}
You can’t perform that action at this time.
0 commit comments