Skip to content

Commit 4c38c71

Browse files
bors[bot]vext01
andauthored
28: Add the `yk_outline` function attribute. r=ltratt a=vext01 Co-authored-by: Edd Barrett <[email protected]>
2 parents 3375c6f + f40944f commit 4c38c71

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,3 +3823,10 @@ def EnforceTCBLeaf : InheritableAttr {
38233823
let Documentation = [EnforceTCBLeafDocs];
38243824
bit InheritEvenIfAlreadyPresent = 1;
38253825
}
3826+
3827+
def YkOutline : InheritableAttr {
3828+
let Spellings = [GCC<"yk_outline">, Declspec<"yk_outline">];
3829+
let Subjects = SubjectList<[Function]>;
3830+
let Documentation = [YkOutlineDocs];
3831+
let SimpleHandler = 1;
3832+
}

clang/include/clang/Basic/AttrDocs.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6045,3 +6045,11 @@ def EnforceTCBLeafDocs : Documentation {
60456045
- ``enforce_tcb_leaf(Name)`` indicates that this function is a part of the TCB named ``Name``
60466046
}];
60476047
}
6048+
6049+
def YkOutlineDocs : Documentation {
6050+
let Category = DocCatFunction;
6051+
let Content = [{
6052+
The ``yk_outline`` attribute tells the Yk JIT to outline (not inline) calls
6053+
to the annotated function.
6054+
}];
6055+
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,13 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
18681868
B.addAttribute(llvm::Attribute::MinSize);
18691869
}
18701870

1871+
if (D->hasAttr<YkOutlineAttr>()) {
1872+
// Prevent the Yk trace compiler from inlining the call.
1873+
B.addAttribute("yk_outline");
1874+
// Prevent LLVM from inlining the call when optimising the trace.
1875+
B.addAttribute(llvm::Attribute::NoInline);
1876+
}
1877+
18711878
F->addAttributes(llvm::AttributeList::FunctionIndex, B);
18721879

18731880
unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();

clang/test/Misc/pragma-attribute-supported-attributes-list.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@
185185
// CHECK-NEXT: WorkGroupSizeHint (SubjectMatchRule_function)
186186
// CHECK-NEXT: XRayInstrument (SubjectMatchRule_function, SubjectMatchRule_objc_method)
187187
// CHECK-NEXT: XRayLogArgs (SubjectMatchRule_function, SubjectMatchRule_objc_method)
188+
// CHECK-NEXT: YkOutline (SubjectMatchRule_function)
188189
// CHECK-NEXT: End of supported attributes.

0 commit comments

Comments
 (0)