diff options
| author | Jessica Paquette <jpaquette@apple.com> | 2018-01-13 00:42:28 +0000 |
|---|---|---|
| committer | Jessica Paquette <jpaquette@apple.com> | 2018-01-13 00:42:28 +0000 |
| commit | 757e12037954abf78cbf25465494a651791f741e (patch) | |
| tree | 1620a7f300dde6fed17e4a3a6b3ce3d5dcf138ca | |
| parent | 5bbba4875204e718418b75137e0cdd602eefdd41 (diff) | |
| download | bcm5719-llvm-757e12037954abf78cbf25465494a651791f741e.tar.gz bcm5719-llvm-757e12037954abf78cbf25465494a651791f741e.zip | |
[MachineOutliner] Move hasAddressTaken check to MachineOutliner.cpp
*Mostly* NFC. Still updating the test though just for completeness.
This moves the hasAddressTaken check to MachineOutliner.cpp and replaces it
with a per-basic block test rather than a per-function test. The old test was
too conservative and was preventing functions in C programs from being
outlined even though they were safe to outline.
This was mostly a problem in C sources.
llvm-svn: 322425
| -rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/AArch64/machine-outliner.mir | 2 |
3 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index 58d546158a8..0ee04f7d900 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -1357,8 +1357,8 @@ bool MachineOutliner::runOnModule(Module &M) { // If it is, look at each MachineBasicBlock in the function. for (MachineBasicBlock &MBB : MF) { - // Is there anything in MBB? - if (MBB.empty()) + // Is there anything in MBB? And is it the target of an indirect branch? + if (MBB.empty() || MBB.hasAddressTaken()) continue; // If yes, map it. diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 8be6b24a92e..62414ea6f8b 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -4779,10 +4779,6 @@ bool AArch64InstrInfo::isFunctionSafeToOutlineFrom( if (!F.hasFnAttribute(Attribute::NoRedZone)) return false; - // If anyone is using the address of this function, don't outline from it. - if (F.hasAddressTaken()) - return false; - // Can F be deduplicated by the linker? If it can, don't outline from it. if (!OutlineFromLinkOnceODRs && F.hasLinkOnceODRLinkage()) return false; diff --git a/llvm/test/CodeGen/AArch64/machine-outliner.mir b/llvm/test/CodeGen/AArch64/machine-outliner.mir index 58c06411bc6..2c8a13b516a 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner.mir +++ b/llvm/test/CodeGen/AArch64/machine-outliner.mir @@ -23,6 +23,7 @@ # - Don't outline anything to do with LR or W30 # - Save LR when it's not available # - Don't outline stack instructions when we might need to save + restore +# - Functions whose addresses are taken can still be outlined # # CHECK-LABEL: name: main @@ -48,6 +49,7 @@ tracksRegLiveness: true body: | bb.0: %sp = frame-setup SUBXri %sp, 16, 0 + renamable %x9 = ADRP target-flags(aarch64-page) @bar %x9 = ORRXri %xzr, 1 %w16 = ORRWri %wzr, 1 %w30 = ORRWri %wzr, 1 |

