Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,7 @@ For example:
to signify an unbounded maximum. The syntax `vscale_range(<val>)` can be
used to set both `min` and `max` to the same value. Functions that don't
include this attribute make no assumptions about the value of `vscale`.
``"nooutline"``
``nooutline``
This attribute indicates that outlining passes should not modify the
function.

Expand Down
3 changes: 3 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Changes to the LLVM IR
address component of a pointer type variable but unlike `ptrtoint` does not
capture provenance ([#125687](https://github.com/llvm/llvm-project/pull/125687)).

* The `"nooutline"` attribute is now writen as `nooutline`. Existing IR and
bitcode will be automatically updated.

Changes to LLVM infrastructure
------------------------------

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Bitcode/LLVMBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ enum AttributeKindCodes {
ATTR_KIND_CAPTURES = 102,
ATTR_KIND_DEAD_ON_RETURN = 103,
ATTR_KIND_SANITIZE_ALLOC_TOKEN = 104,
ATTR_KIND_NOOUTLINE = 105,
};

enum ComdatSelectionKindCodes {
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/IR/Attributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ def NoImplicitFloat : EnumAttr<"noimplicitfloat", IntersectPreserve, [FnAttr]>;
/// inline=never.
def NoInline : EnumAttr<"noinline", IntersectPreserve, [FnAttr]>;

/// nooutline
def NoOutline : EnumAttr<"nooutline", IntersectPreserve, [FnAttr]>;

/// Function is called early and/or often, so lazy binding isn't worthwhile.
def NonLazyBind : EnumAttr<"nonlazybind", IntersectPreserve, [FnAttr]>;

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2257,6 +2257,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::Captures;
case bitc::ATTR_KIND_DEAD_ON_RETURN:
return Attribute::DeadOnReturn;
case bitc::ATTR_KIND_NOOUTLINE:
return Attribute::NoOutline;
}
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
return bitc::ATTR_KIND_CAPTURES;
case Attribute::DeadOnReturn:
return bitc::ATTR_KIND_DEAD_ON_RETURN;
case Attribute::NoOutline:
return bitc::ATTR_KIND_NOOUTLINE;
case Attribute::EndAttrKinds:
llvm_unreachable("Can not encode end-attribute kinds marker.");
case Attribute::None:
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineOutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ void MachineOutliner::populateMapper(InstructionMapper &Mapper, Module &M) {
for (Function &F : M) {
LLVM_DEBUG(dbgs() << "MAPPING FUNCTION: " << F.getName() << "\n");

if (F.hasFnAttribute("nooutline")) {
if (F.hasFnAttribute(Attribute::NoOutline)) {
LLVM_DEBUG(dbgs() << "SKIP: Function has nooutline attribute\n");
continue;
}
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/IR/AutoUpgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5956,6 +5956,12 @@ void llvm::UpgradeFunctionAttributes(Function &F) {
F.removeFnAttr("implicit-section-name");
}

if (Attribute A = F.getFnAttribute("nooutline");
A.isValid() && A.isStringAttribute()) {
F.removeFnAttr("nooutline");
F.addFnAttr(Attribute::NoOutline);
}

if (!F.empty()) {
// For some reason this is called twice, and the first time is before any
// instructions are loaded into the body.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/IROutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ void IROutliner::pruneIncompatibleRegions(
if (FnForCurrCand.hasOptNone())
continue;

if (FnForCurrCand.hasFnAttribute("nooutline")) {
if (FnForCurrCand.hasFnAttribute(Attribute::NoOutline)) {
LLVM_DEBUG({
dbgs() << "... Skipping function with nooutline attribute: "
<< FnForCurrCand.getName() << "\n";
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Utils/CodeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,10 @@ Function *CodeExtractor::constructFunctionDeclaration(
case Attribute::CoroDestroyOnlyWhenComplete:
case Attribute::CoroElideSafe:
case Attribute::NoDivergenceSource:
// CodeExtractor is used by the IROutliner, so we should not be extracting
// from a function with nooutline, but if we do, we should not be
// propagating this attribute.
case Attribute::NoOutline:
continue;
// Those attributes should be safe to propagate to the extracted function.
case Attribute::AlwaysInline:
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/Bitcode/upgrade-nooutline.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; RUN: llvm-as < %s | llvm-dis - | FileCheck %s

; CHECK: define void @f() [[ATTR:#[0-9]+]]
; CHECK-NOT: "nooutline"
; CHECK: attributes [[ATTR]] = {
; CHECK-NOT: "nooutline"
; CHECK-SAME: nooutline
; CHECK-NOT: "nooutline"

define void @f() "nooutline" {
ret void
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

--- |
define void @block_too_small() noredzone { unreachable }
define void @no_outline() noredzone "nooutline" { unreachable }
define void @no_outline() noredzone nooutline { unreachable }
define void @redzone() { unreachable }
declare void @no_mf()
define void @block_addr_fn() noredzone {
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/IROutliner/nooutline-attribute.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

define void @outlinable() { ret void }

define i8 @nooutline1(ptr noalias %s, ptr noalias %d, i64 %len) "nooutline" {
define i8 @nooutline1(ptr noalias %s, ptr noalias %d, i64 %len) nooutline {
%a = load i8, ptr %s
%b = load i8, ptr %d
call void @llvm.memcpy.p0.p0.i64(ptr %d, ptr %s, i64 %len, i1 false)
Expand All @@ -17,7 +17,7 @@ define i8 @nooutline1(ptr noalias %s, ptr noalias %d, i64 %len) "nooutline" {
ret i8 %ret
}

define i8 @nooutline2(ptr noalias %s, ptr noalias %d, i64 %len) "nooutline" {
define i8 @nooutline2(ptr noalias %s, ptr noalias %d, i64 %len) nooutline {
%a = load i8, ptr %s
%b = load i8, ptr %d
call void @llvm.memcpy.p0.p0.i64(ptr %d, ptr %s, i64 %len, i1 false)
Expand Down
Loading