diff options
| author | Eli Friedman <efriedma@codeaurora.org> | 2018-04-27 00:21:34 +0000 |
|---|---|---|
| committer | Eli Friedman <efriedma@codeaurora.org> | 2018-04-27 00:21:34 +0000 |
| commit | da018e5687a8694585d20db87ee135c0638e14bf (patch) | |
| tree | 9377cfd93c3be015c7d7df310aea7ecd1e14ff73 | |
| parent | e0658119ba90f97717334f7631d258a8f7a6a2ba (diff) | |
| download | bcm5719-llvm-da018e5687a8694585d20db87ee135c0638e14bf.tar.gz bcm5719-llvm-da018e5687a8694585d20db87ee135c0638e14bf.zip | |
[MachineOutliner] Don't outline from functions with a section marking.
The program might have unusual expectations for functions; for example,
the Linux kernel's build system warns if it finds references from .text
to .init.data.
I'm not sure this is something we actually want to make any guarantees
about (there isn't any explicit rule that would disallow outlining
in this case), but we might want to be conservative anyway.
Differential Revision: https://reviews.llvm.org/D46091
llvm-svn: 331007
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/CodeGen/AArch64/machine-outliner.ll | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 6de4bb2143d..ee81c16c260 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -4989,6 +4989,13 @@ bool AArch64InstrInfo::isFunctionSafeToOutlineFrom( if (!OutlineFromLinkOnceODRs && F.hasLinkOnceODRLinkage()) return false; + // Don't outline from functions with section markings; the program could + // expect that all the code is in the named section. + // FIXME: Allow outlining from multiple functions with the same section + // marking. + if (F.hasSection()) + return false; + // Outlining from functions with redzones is unsafe since the outliner may // modify the stack. Check if hasRedZone is true or unknown; if yes, don't // outline from it. diff --git a/llvm/test/CodeGen/AArch64/machine-outliner.ll b/llvm/test/CodeGen/AArch64/machine-outliner.ll index 9bea4e2e8d0..d8d8ddeded9 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner.ll +++ b/llvm/test/CodeGen/AArch64/machine-outliner.ll @@ -17,6 +17,21 @@ define linkonce_odr void @fish() #0 { ret void } +define void @turtle() section "TURTLE,turtle" { + ; CHECK-LABEL: _turtle: + ; ODR-LABEL: _turtle: + ; CHECK-NOT: OUTLINED + %1 = alloca i32, align 4 + %2 = alloca i32, align 4 + %3 = alloca i32, align 4 + %4 = alloca i32, align 4 + store i32 0, i32* %1, align 4 + store i32 1, i32* %2, align 4 + store i32 2, i32* %3, align 4 + store i32 3, i32* %4, align 4 + ret void +} + define void @cat() #0 { ; CHECK-LABEL: _cat: ; CHECK: [[OUTLINED:OUTLINED_FUNCTION_[0-9]+]] |

