diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b6f365e6661a4..9f3fd383af533 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -11856,10 +11856,11 @@ QualType ASTContext::GetBuiltinType(unsigned Id, "'.' should only occur at end of builtin type list!"); bool Variadic = (TypeStr[0] == '.'); - + bool IsCheriLibcall = Id != Builtin::BIsetjmp && Id != Builtin::BIlongjmp; + IsCheriLibcall &= Target->getTargetOpts().ABI != "cheriot-baremetal"; FunctionType::ExtInfo EI(getDefaultCallingConvention( Variadic, /*IsCXXMethod=*/false, /*IsBuiltin=*/true, - /*IsLibcall*/ Target->getTargetOpts().ABI != "cheriot-baremetal")); + /*IsLibcall*/ IsCheriLibcall)); if (BuiltinInfo.isNoReturn(Id)) EI = EI.withNoReturn(true); diff --git a/clang/test/CodeGen/cheri/riscv/cheriot-setjmp.c b/clang/test/CodeGen/cheri/riscv/cheriot-setjmp.c new file mode 100644 index 0000000000000..9acd284342d03 --- /dev/null +++ b/clang/test/CodeGen/cheri/riscv/cheriot-setjmp.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 %s -o - "-triple" "riscv32cheriot-unknown-unknown" "-emit-llvm" "-mframe-pointer=none" "-mcmodel=small" "-target-abi" "cheriot" "-Oz" "-Werror" -std=c2x | FileCheck %s +// Verify that setjmp is called without cherilibcallcc +struct __jmp_buf +{ + unsigned __cs0; + unsigned __cs1; + unsigned __csp; + unsigned __cra; +}; + +typedef struct __jmp_buf jmp_buf[1]; + +__attribute__((returns_twice)) int setjmp(jmp_buf env) __asm__("setjmp"); + +jmp_buf buf; + +// CHECK-LABEL: @test +// CHECK: call i32 @setjmp +void test() { + setjmp(buf); +} \ No newline at end of file