Skip to content

Commit

Permalink
Merge rust-lang#28
Browse files Browse the repository at this point in the history
28: Add the `yk_outline` function attribute. r=ltratt a=vext01



Co-authored-by: Edd Barrett <vext01@gmail.com>
  • Loading branch information
bors[bot] and vext01 authored Mar 22, 2022
2 parents 3375c6f + f40944f commit 4c38c71
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -3823,3 +3823,10 @@ def EnforceTCBLeaf : InheritableAttr {
let Documentation = [EnforceTCBLeafDocs];
bit InheritEvenIfAlreadyPresent = 1;
}

def YkOutline : InheritableAttr {
let Spellings = [GCC<"yk_outline">, Declspec<"yk_outline">];
let Subjects = SubjectList<[Function]>;
let Documentation = [YkOutlineDocs];
let SimpleHandler = 1;
}
8 changes: 8 additions & 0 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -6045,3 +6045,11 @@ def EnforceTCBLeafDocs : Documentation {
- ``enforce_tcb_leaf(Name)`` indicates that this function is a part of the TCB named ``Name``
}];
}

def YkOutlineDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
The ``yk_outline`` attribute tells the Yk JIT to outline (not inline) calls
to the annotated function.
}];
}
7 changes: 7 additions & 0 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,13 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
B.addAttribute(llvm::Attribute::MinSize);
}

if (D->hasAttr<YkOutlineAttr>()) {
// Prevent the Yk trace compiler from inlining the call.
B.addAttribute("yk_outline");
// Prevent LLVM from inlining the call when optimising the trace.
B.addAttribute(llvm::Attribute::NoInline);
}

F->addAttributes(llvm::AttributeList::FunctionIndex, B);

unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@
// CHECK-NEXT: WorkGroupSizeHint (SubjectMatchRule_function)
// CHECK-NEXT: XRayInstrument (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: XRayLogArgs (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: YkOutline (SubjectMatchRule_function)
// CHECK-NEXT: End of supported attributes.

0 comments on commit 4c38c71

Please sign in to comment.