This is an archive of the discontinued LLVM Phabricator instance.

Add target-independent backend modifications for pagerando
Needs ReviewPublic

Authored by rinon on Sep 7 2017, 12:23 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This patch adds several features to support codegen for pagerando. We add a new ISD opcode and pseudo-source value for the page offset table (analogous to the global offset table) which allows backends to emit references to the POT. The patch extends target-independent lowering slightly to store a POT base register for backends that support pagerando, and handles interactions between pagerando sections, unique sections, and jump tables. Finally, the bulk of the patch supports emission of the POT in AsmPrinter.

This patch set (D37580, D37581, D37582, D37583, D37584, D37585, D37586, D37587)
is a first draft of the pagerando implementation described in
http://lists.llvm.org/pipermail/llvm-dev/2017-June/113794.html.

Diff Detail

Event Timeline

rinon created this revision.Sep 7 2017, 12:23 PM

This patch set (D37580, D37581, D37582, D37583, D37584, D37585, D37586, D37587) is a first draft of the pagerando implementation described in http://lists.llvm.org/pipermail/llvm-dev/2017-June/113794.html.

rinon updated this revision to Diff 114743.Sep 11 2017, 6:26 PM
  • Fix style nits
rinon updated this revision to Diff 116882.Sep 27 2017, 2:19 PM
  • Rebase
peter.smith added inline comments.
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
435

I think that this is worth doing now, when reviewing I had to double check that the duplication was computing the same thing.

1829–1869

Given that POT is not as widely documented or known as the GOT, I think it would be helpful to put a comment describing what it is. I mention it here as we need to know the structure of it in order to emit it. There could be better places though.

1847

It may be worth taking some care over using _GLOBAL_OFFSET_TABLE_. It is a linker convention to define _GLOBAL_OFFSET_TABLE_ to be the base of the .GOT but it might not always hold. For example earlier versions of lld set _GLOBAL_OFFSET_TABLE_ to 0 as the relocation types used by the compiler didn't look up the symbol value. Some backends (not Arm or AArch64) recognize the symbol and do something special with it as well.

I think what you have will work for gold on Arm and AArch64 but it may be worth letting targets override it with a "get me the got base" relocation.

rinon updated this revision to Diff 121817.Nov 6 2017, 4:59 PM
  • Refactor constantpool section lookup
  • Document POT emission
  • Allow targets to customize GOT symbol
rinon marked 3 inline comments as done.Nov 6 2017, 5:01 PM
rinon added inline comments.
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
1847

I added a function to TargetObjectFileLowering for ELF, since other formats don't use a GOT. Targets can override this if they need a special symbol. Sound alright?

rinon edited the summary of this revision. (Show Details)Jan 22 2018, 3:22 PM
rinon updated this revision to Diff 130972.Jan 22 2018, 3:24 PM
rinon marked an inline comment as done.

Rebase

rinon updated this revision to Diff 156644.Jul 20 2018, 5:00 PM

Rebase.

Fix constantpool section lookup to propagate section alignment to its callers. This fixes test/CodeGen/X86/win_cst_pool.ll.