Skip to content

Commit d16d2cc

Browse files
committed
---
yaml --- r: 2247 b: refs/heads/master c: b0980b7 h: refs/heads/master i: 2245: 16c1647 2243: 240c54a 2239: 0ec8bba v: v3
1 parent b720e8e commit d16d2cc

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 6daca7ea8d0ef1f99c928a0b6bacc8cefc17969a
2+
refs/heads/master: b0980b7d79e8209ba91a2a85c720f238bbc478ed

trunk/src/comp/back/x86.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,42 @@ fn wstr(int i) -> str {
1111
ret istr(i * wordsz);
1212
}
1313

14+
fn start() -> vec[str] {
15+
ret vec(".cfi_startproc");
16+
}
17+
18+
fn end() -> vec[str] {
19+
ret vec(".cfi_endproc");
20+
}
21+
1422
fn save_callee_saves() -> vec[str] {
1523
ret vec("pushl %ebp",
1624
"pushl %edi",
1725
"pushl %esi",
1826
"pushl %ebx");
1927
}
2028

29+
fn save_callee_saves_with_cfi() -> vec[str] {
30+
auto offset = 8;
31+
auto t;
32+
t = vec("pushl %ebp");
33+
t += vec(".cfi_def_cfa_offset " + istr(offset));
34+
t += vec(".cfi_offset 5, -" + istr(offset));
35+
36+
t += vec("pushl %edi");
37+
offset += 4;
38+
t += vec(".cfi_def_cfa_offset " + istr(offset));
39+
40+
t += vec("pushl %esi");
41+
offset += 4;
42+
t += vec(".cfi_def_cfa_offset " + istr(offset));
43+
44+
t += vec("pushl %ebx");
45+
offset += 4;
46+
t += vec(".cfi_def_cfa_offset " + istr(offset));
47+
ret t;
48+
}
49+
2150
fn restore_callee_saves() -> vec[str] {
2251
ret vec("popl %ebx",
2352
"popl %esi",
@@ -211,9 +240,11 @@ fn native_glue(int n_args, bool pass_task) -> vec[str] {
211240
auto carg = bind copy_arg(pass_task, _);
212241

213242
ret
214-
save_callee_saves()
243+
start()
244+
+ save_callee_saves_with_cfi()
215245

216246
+ vec("movl %esp, %ebp # ebp = rust_sp")
247+
+ vec(".cfi_def_cfa_register 5")
217248

218249
+ store_esp_to_rust_sp_second_arg()
219250
+ load_esp_from_runtime_sp_second_arg()
@@ -229,7 +260,8 @@ fn native_glue(int n_args, bool pass_task) -> vec[str] {
229260

230261
+ load_esp_from_rust_sp_second_arg()
231262
+ restore_callee_saves()
232-
+ vec("ret");
263+
+ vec("ret")
264+
+ end();
233265

234266
}
235267

trunk/src/rustllvm/RustWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, LLVMModuleRef M,
5454
LLVMCodeGenFileType FileType) {
5555

5656
// Set compilation options.
57-
llvm::NoFramePointerElim = true;
57+
llvm::UnwindTablesMandatory = true;
5858

5959
InitializeAllTargets();
6060
InitializeAllAsmPrinters();

0 commit comments

Comments
 (0)