From e9287e55cc6f95354632be646be18b92af2f9a08 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 30 Sep 2011 18:20:28 -0700 Subject: [PATCH] rustc: Stub a --stack-growth option; it's behind a flag for now because it requires patches to LLVM. --- src/comp/driver/rustc.rs | 8 ++++++-- src/comp/driver/session.rs | 3 ++- src/comp/lib/llvm.rs | 4 ++-- src/comp/middle/trans.rs | 14 +++++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 20dfe674fd1..de9862f9e5e 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -263,6 +263,7 @@ fn usage(argv0: str) { --no-typestate don't run the typestate pass (unsafe!) --test build test harness --gc garbage collect shared data (experimental/temporary) + --stack-growth perform stack checks (experimental) "); } @@ -386,6 +387,7 @@ fn build_session_options(binary: str, match: getopts::match) let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg")); let test = opt_present(match, "test"); let do_gc = opt_present(match, "gc"); + let stack_growth = opt_present(match, "stack-growth"); let sopts: @session::options = @{library: library, static: static, @@ -405,7 +407,8 @@ fn build_session_options(binary: str, match: getopts::match) test: test, parse_only: parse_only, no_trans: no_trans, - do_gc: do_gc}; + do_gc: do_gc, + stack_growth: stack_growth}; ret sopts; } @@ -439,7 +442,8 @@ fn opts() -> [getopts::opt] { optflag("time-passes"), optflag("time-llvm-passes"), optflag("no-typestate"), optflag("noverify"), optmulti("cfg"), optflag("test"), - optflag("lib"), optflag("static"), optflag("gc")]; + optflag("lib"), optflag("static"), optflag("gc"), + optflag("stack-growth")]; } fn main(args: [str]) { diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs index 9324a4dd45a..001bc9ce2fb 100644 --- a/src/comp/driver/session.rs +++ b/src/comp/driver/session.rs @@ -39,7 +39,8 @@ test: bool, parse_only: bool, no_trans: bool, - do_gc: bool}; + do_gc: bool, + stack_growth: bool}; type crate_metadata = {name: str, data: [u8]}; diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index c849db64b87..627d273666d 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -455,9 +455,9 @@ fn LLVMAddFunction(M: ModuleRef, Name: sbuf, FunctionTy: TypeRef) -> fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: uint); fn LLVMGetGC(Fn: ValueRef) -> sbuf; fn LLVMSetGC(Fn: ValueRef, Name: sbuf); - fn LLVMAddFunctionAttr(Fn: ValueRef, PA: Attribute); + fn LLVMAddFunctionAttr(Fn: ValueRef, PA: Attribute, HighPA: uint); fn LLVMGetFunctionAttr(Fn: ValueRef) -> Attribute; - fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: Attribute); + fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: Attribute, HighPA: uint); /* Operations on parameters */ fn LLVMCountParams(Fn: ValueRef) -> uint; diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index d40734449c4..ae5d3ca25d1 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -1087,7 +1087,8 @@ fn get_static_tydesc(cx: @block_ctxt, orig_t: ty::t, ty_params: [uint], fn set_no_inline(f: ValueRef) { llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMNoInlineAttribute as - lib::llvm::llvm::Attribute); + lib::llvm::llvm::Attribute, + 0u); } // Tell LLVM to emit the information necessary to unwind the stack for the @@ -1095,13 +1096,20 @@ fn set_no_inline(f: ValueRef) { fn set_uwtable(f: ValueRef) { llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMUWTableAttribute as - lib::llvm::llvm::Attribute); + lib::llvm::llvm::Attribute, + 0u); } fn set_always_inline(f: ValueRef) { llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMAlwaysInlineAttribute as - lib::llvm::llvm::Attribute); + lib::llvm::llvm::Attribute, + 0u); +} + +fn set_custom_stack_growth_fn(f: ValueRef) { + // TODO: Remove this hack to work around the lack of u64 in the FFI. + llvm::LLVMAddFunctionAttr(f, 0 as lib::llvm::llvm::Attribute, 1u); } fn set_glue_inlining(cx: @local_ctxt, f: ValueRef, t: ty::t) { -- GitLab