Skip to content

Commit cba5428

Browse files
committed
[cheriot] Do not treat setjmp/longjmp builtins as cherilibcallcc.
1 parent fbe4855 commit cba5428

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

clang/lib/AST/ASTContext.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -11856,10 +11856,11 @@ QualType ASTContext::GetBuiltinType(unsigned Id,
1185611856
"'.' should only occur at end of builtin type list!");
1185711857

1185811858
bool Variadic = (TypeStr[0] == '.');
11859-
11859+
bool IsCheriLibcall = Id != Builtin::BIsetjmp && Id != Builtin::BIlongjmp;
11860+
IsCheriLibcall &= Target->getTargetOpts().ABI != "cheriot-baremetal";
1186011861
FunctionType::ExtInfo EI(getDefaultCallingConvention(
1186111862
Variadic, /*IsCXXMethod=*/false, /*IsBuiltin=*/true,
11862-
/*IsLibcall*/ Target->getTargetOpts().ABI != "cheriot-baremetal"));
11863+
/*IsLibcall*/ IsCheriLibcall));
1186311864
if (BuiltinInfo.isNoReturn(Id)) EI = EI.withNoReturn(true);
1186411865

1186511866

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// 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
2+
// Verify that setjmp is called without cherilibcallcc
3+
struct __jmp_buf
4+
{
5+
unsigned __cs0;
6+
unsigned __cs1;
7+
unsigned __csp;
8+
unsigned __cra;
9+
};
10+
11+
typedef struct __jmp_buf jmp_buf[1];
12+
13+
__attribute__((returns_twice)) int setjmp(jmp_buf env) __asm__("setjmp");
14+
15+
jmp_buf buf;
16+
17+
// CHECK-LABEL: @test
18+
// CHECK: call i32 @setjmp
19+
void test() {
20+
setjmp(buf);
21+
}

0 commit comments

Comments
 (0)