Skip to content

Commit bb93930

Browse files
committed
Add a workaround for 8199 for now
1 parent 4ace3b7 commit bb93930

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/librustc/lib/llvm.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ pub enum Attribute {
8787
NonLazyBindAttribute = 1 << 31,
8888

8989
// Not added to LLVM yet, so may need to stay updated if LLVM changes.
90+
// FIXME(#8199): if this changes, be sure to change the relevant constant
91+
// down below
9092
FixedStackSegment = 1 << 41,
9193
}
9294

@@ -2116,6 +2118,17 @@ pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
21162118
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
21172119
}
21182120
}
2121+
2122+
// FIXME(#8199): this shouldn't require this hackery. On i686
2123+
// (FixedStackSegment as u64) will return 0 instead of 1 << 41.
2124+
// Furthermore, if we use a match of any sort then an LLVM
2125+
// assertion is generated!
2126+
pub fn SetFixedStackSegmentAttribute(Fn: ValueRef) {
2127+
let attr = 1u64 << 41;
2128+
let lower = attr & 0xffffffff;
2129+
let upper = (attr >> 32) & 0xffffffff;
2130+
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
2131+
}
21192132
/* Memory-managed object interface to type handles. */
21202133

21212134
pub struct TypeNames {

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ pub fn set_always_inline(f: ValueRef) {
456456
}
457457

458458
pub fn set_fixed_stack_segment(f: ValueRef) {
459-
lib::llvm::SetFunctionAttribute(f, lib::llvm::FixedStackSegment)
459+
lib::llvm::SetFixedStackSegmentAttribute(f);
460460
}
461461

462462
pub fn set_glue_inlining(f: ValueRef, t: ty::t) {

0 commit comments

Comments
 (0)