Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHERIoT] Allow __cheri_libcall annotations on function pointers. #67

Closed
wants to merge 1 commit into from
Closed
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 clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@ def CHERICompartmentName : DeclOrTypeAttr {
def CHERILibCall : DeclOrTypeAttr {
let Spellings = [GNU<"cheri_libcall">];
let Documentation = [Undocumented];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Subjects = SubjectList<[Function, FunctionPointer], ErrorDiag>;
}


Expand Down
8 changes: 7 additions & 1 deletion clang/test/CodeGen/cheri/cheri-mcu-call-libcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int add(int a, int b);
LIBCALL
int foo(void);

// CHECK: define dso_local i32 @callFromNotLibcall() local_unnamed_addr addrspace(200) #0 {
// CHECK-LABEL: define dso_local i32 @callFromNotLibcall() local_unnamed_addr addrspace(200) #0 {
int callFromNotLibcall(void) {
// CHECK: call cherilibcallcc i32 @_Z3addii(i32 noundef 1, i32 noundef 2) #2
// CHECK: call cherilibcallcc i32 @_Z3foov() #2
Expand All @@ -17,5 +17,11 @@ int callFromNotLibcall(void) {
// CHECK: declare cherilibcallcc i32 @_Z3addii(i32 noundef, i32 noundef) local_unnamed_addr addrspace(200) #1
// CHECK: declare cherilibcallcc i32 @_Z3foov() local_unnamed_addr addrspace(200) #1

// CHECK-LABEL: define dso_local i32 @callThroughFunctionPointer(ptr addrspace(200) nocapture noundef readonly %target) local_unnamed_addr addrspace(200) #0 {
int callThroughFunctionPointer(LIBCALL int target(void)) {
// CHECK: call cherilibcallcc i32 %target()
return target();
}

// CHECK: attributes #0
// CHECK-SAME: "cheri-compartment"="example"
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
// CHECK-NEXT: CFUnknownTransfer (SubjectMatchRule_function)
// CHECK-NEXT: CHERICCallee (SubjectMatchRule_function)
// CHECK-NEXT: CHERICompartmentName (SubjectMatchRule_function)
// CHECK-NEXT: CHERILibCall (SubjectMatchRule_function)
// CHECK-NEXT: CHERISubobjectBoundsUseRemainingSize (SubjectMatchRule_field, SubjectMatchRule_record)
// CHECK-NEXT: CPUDispatch (SubjectMatchRule_function)
// CHECK-NEXT: CPUSpecific (SubjectMatchRule_function)
Expand Down