Skip to content

functions with align $N can get merged without align $N #145123

Open
@workingjubilee

Description

@workingjubilee

Godbolt of opt -passes="module(mergefunc)": https://godbolt.org/z/cPTc9j1b6

LLVMIR diff:

-define internal i64 @aligned_to_2p8() unnamed_addr align 256 {
-entry:
-  ret i64 4
-}
 
 define i64 @aligned_to_default() unnamed_addr {
 entry:
   ret i64 4
 }

"What's the problem? You said to merge the functions, and it did!"

Well, in Rust, generally function pointers aren't expected to point to unique blocks of code. For this reason, we specify unnamed_addr on... essentially every function, ish? However, for some cases we would like to be able to force the alignment of function entry symbols while still running function merging where applicable. In a more complex case where the code would produce a result that depends on the address of the code in question, the correct semantic for Rust would be that the value does depend on this alignment but may not be unique. Thus, we would prefer that merging functions is allowed to work in this case, but the resulting merged function takes the highest alignment of all merges.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions