Skip to content

Commit 7c3c8ae

Browse files
committed
mark glue functions with unnamed_addr
1 parent 317248f commit 7c3c8ae

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustc/middle/trans/glue.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,12 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
717717
note_unique_llvm_symbol(ccx, fn_nm);
718718
let llfn = decl_cdecl_fn(ccx.llmod, *fn_nm, llfnty);
719719
set_glue_inlining(llfn, t);
720-
return llfn;
720+
721+
// glue functions aren't visible to user code, so function pointer addresses are never
722+
// semantically relevant - we can inform LLVM and allow it to merge the functions
723+
lib::llvm::set_unnamed_addr(llfn, true);
724+
725+
llfn
721726
}
722727

723728
pub fn make_generic_glue_inner(ccx: @CrateContext,

0 commit comments

Comments
 (0)