Skip to content

Commit 6bb47f4

Browse files
committed
wip hotpatch attribute always on x86, missing hotpatch debuginfo for arm
1 parent 229ea9b commit 6bb47f4

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ pub fn from_fn_attrs<'ll, 'tcx>(
341341
to_add.push(llvm::CreateAttrString(cx.llcx, "use-sample-profile"));
342342
}
343343

344-
if cx.sess().opts.unstable_opts.ms_hotpatch && cx.sess().target.is_x86() && cx.sess().target.is_like_msvc {
344+
// patchable-function is only implemented on x86 on LLVM
345+
if cx.sess().opts.unstable_opts.ms_hotpatch && cx.sess().target.is_x86() {
345346
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "patchable-function", "prologue-short-redirect"));
346347
}
347348

compiler/rustc_codegen_llvm/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub fn target_machine_factory(
220220
let use_init_array =
221221
!sess.opts.unstable_opts.use_ctors_section.unwrap_or(sess.target.use_ctors_section);
222222

223-
let use_hotpatch = sess.opts.unstable_opts.ms_hotpatch && sess.target.is_x86() && sess.target.is_like_msvc;
223+
let use_hotpatch = sess.opts.unstable_opts.ms_hotpatch && sess.target.is_x86();
224224

225225
let path_mapping = sess.source_map().path_mapping().clone();
226226

compiler/rustc_codegen_ssa/src/back/link.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2347,17 +2347,6 @@ fn add_order_independent_options(
23472347

23482348
add_link_script(cmd, sess, tmpdir, crate_type);
23492349

2350-
if sess.opts.unstable_opts.ms_hotpatch && sess.target.is_x86() && sess.target.is_like_msvc {
2351-
// when using hotpatch also automatically instruct the linker to pad the functions
2352-
// so there is space for a absolute jump instructions
2353-
match flavor {
2354-
LinkerFlavor::Msvc(_) => {
2355-
cmd.arg("-functionpadmin");
2356-
},
2357-
_ => (),
2358-
}
2359-
}
2360-
23612350
if sess.target.os == "fuchsia"
23622351
&& crate_type == CrateType::Executable
23632352
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))

compiler/rustc_target/src/spec/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,6 @@ impl Target {
19111911
Ok(dl)
19121912
}
19131913
pub fn is_x86(&self) -> bool {
1914-
// ["x86", "x86_64"].contains(&self.arch.as_ref())
19151914
["x86", "x86_64"].contains(&&self.arch[..])
19161915
}
19171916
}

tests/codegen/ms-hotpatch.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ compile-flags: -Z ms-hotpatch
2+
3+
#![crate_type = "lib"]
4+
5+
6+
pub fn foo() {}
7+
8+
// CHECK: @foo() unnamed_addr #0
9+
// CHECK: attributes #0 = { {{.*}} "patchable-function"="prologue-short-redirect" {{.*}}}

0 commit comments

Comments
 (0)