Skip to content

Commit 6f33cb1

Browse files
davidvoittamird
authored andcommitted
---
yaml --- r: 212279 b: refs/heads/master c: e36e97b h: refs/heads/master i: 212277: c778d10 212275: f8d85a3 212271: 311dc16 v: v3
1 parent 4d97a09 commit 6f33cb1

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ce32f6412e1937c0844aa48e5b4e876b96dcd66d
2+
refs/heads/master: e36e97ba51f512de2fd05e3250db4a7b72caae04
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/src/librustc_trans/trans/context.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,11 +933,33 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
933933
ifn!("llvm.lifetime.end", fn(t_i64, i8p) -> void);
934934

935935
ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
936-
ifn!("llvm.assume", fn(i1) -> void);
937936

938937
// Some intrinsics were introduced in later versions of LLVM, but they have
939938
// fallbacks in libc or libm and such.
940939
macro_rules! compatible_ifn {
940+
($name:expr, noop($cname:ident ($($arg:expr),*) -> void), $llvm_version:expr) => (
941+
if unsafe { llvm::LLVMVersionMinor() >= $llvm_version } {
942+
// The `if key == $name` is already in ifn!
943+
ifn!($name, fn($($arg),*) -> void);
944+
} else if *key == $name {
945+
let f = declare::declare_cfn(ccx, stringify!($cname),
946+
Type::func(&[$($arg),*], &void),
947+
ty::mk_nil(ccx.tcx()));
948+
llvm::SetLinkage(f, llvm::InternalLinkage);
949+
950+
let bld = ccx.builder();
951+
let llbb = unsafe {
952+
llvm::LLVMAppendBasicBlockInContext(ccx.llcx(), f,
953+
"entry-block\0".as_ptr() as *const _)
954+
};
955+
956+
bld.position_at_end(llbb);
957+
bld.ret_void();
958+
959+
ccx.intrinsics().borrow_mut().insert($name, f.clone());
960+
return Some(f);
961+
}
962+
);
941963
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr, $llvm_version:expr) => (
942964
if unsafe { llvm::LLVMVersionMinor() >= $llvm_version } {
943965
// The `if key == $name` is already in ifn!
@@ -952,6 +974,8 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
952974
)
953975
}
954976

977+
compatible_ifn!("llvm.assume", noop(llvmcompat_assume(i1) -> void), 6);
978+
955979
if ccx.sess().opts.debuginfo != NoDebugInfo {
956980
ifn!("llvm.dbg.declare", fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
957981
ifn!("llvm.dbg.value", fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);

0 commit comments

Comments
 (0)