[llvm] r331007 - [MachineOutliner] Don't outline from functions with a section marking.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 26 17:21:34 PDT 2018


Author: efriedma
Date: Thu Apr 26 17:21:34 2018
New Revision: 331007

URL: http://llvm.org/viewvc/llvm-project?rev=331007&view=rev
Log:
[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


Modified:
    llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
    llvm/trunk/test/CodeGen/AArch64/machine-outliner.ll

Modified: llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp?rev=331007&r1=331006&r2=331007&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp Thu Apr 26 17:21:34 2018
@@ -4989,6 +4989,13 @@ bool AArch64InstrInfo::isFunctionSafeToO
   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.

Modified: llvm/trunk/test/CodeGen/AArch64/machine-outliner.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/machine-outliner.ll?rev=331007&r1=331006&r2=331007&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/machine-outliner.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/machine-outliner.ll Thu Apr 26 17:21:34 2018
@@ -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]+]]




More information about the llvm-commits mailing list