[LLVMdev] [RFC] Section Declarations in LLVM IR (original) (raw)

David Majnemer david.majnemer at gmail.com
Tue Mar 11 00:44:00 PDT 2014


Hi all,

I'd like to propose that LLVM IR have a mechanism to describe sections in a more explicit way than we can today.

Currently, we provide an attribute called "section" on GlobalVariables and Functions. This attribute will choose which section the Value will end up in. However, it does not describe the attributes of the section. Without a way of describing the section, we try to infer the section's attribute from the first Value from that section that MC comes across.

This means that if the first value is constant, the rest of the values will end up in .rodata even if the intention was for them to be mutable.

Equally problematic is our inability to verify the appropriate use of sections, consider the following:

The IR verifier does not catch this nonsensical arrangement of IR.

Further motivation stems from being able to represent the MS ABI's RTTI data:

I think LLVM needs new IR to represent these semantics properly.

I propose that we do the following:

A concrete example of a const variable inside of a read-only section:

$.my_section = appending read @my_var = constant float 1.0, section $.my_section, align 4

The following is how I imagine MS RTTI would look like if we had this IR construct:

$.vdata_for_type = pick_largest read @my_rtti_for_type = pick_largest unnamed_addr constant %rtti_ptr_ty @rtti_complete_object_locator, section $.vdata_for_type, align 4 @vftable_for_type = pick_largest unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.S*)* @"\01?fun at S@@UAEXXZ" to i8*)], section $.vdata_for_type, align 4

Attached is a patch to the LangRef.

Thanks for reading! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140311/0c06bae6/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: SectionIRLangRef.patch Type: application/octet-stream Size: 2245 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140311/0c06bae6/attachment.obj>



More information about the llvm-dev mailing list