Skip to content

Commit

Permalink
[COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.spon…
Browse files Browse the repository at this point in the history
…entry

Summary: ARM64 setjmp expects sp on entry instead of framepointer.

Reviewers: mgrang, rnk, TomTan, compnerd, mstorsjo, efriedma

Reviewed By: mstorsjo

Subscribers: javed.absar, kristof.beyls, chrib, cfe-commits

Differential Revision: https://reviews.llvm.org/D53684

llvm-svn: 345792
  • Loading branch information
Mandeep Singh Grang committed Oct 31, 2018
1 parent 88ad9ac commit e7c7934
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions clang/lib/CodeGen/CGBuiltin.cpp
Expand Up @@ -711,8 +711,11 @@ static RValue EmitMSVCRTSetJmp(CodeGenFunction &CGF, MSVCSetJmpKind SJKind,
} else {
Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
Arg1Ty = CGF.Int8PtrTy;
Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
llvm::ConstantInt::get(CGF.Int32Ty, 0));
if (CGF.getTarget().getTriple().getArch() == llvm::Triple::aarch64) {
Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::sponentry));
} else
Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
llvm::ConstantInt::get(CGF.Int32Ty, 0));
}

// Mark the call site and declaration with ReturnsTwice.
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGen/ms-setjmp.c
Expand Up @@ -25,7 +25,7 @@ int test_setjmp() {
// X64-NEXT: ret i32 %[[call]]

// AARCH64-LABEL: define dso_local i32 @test_setjmp
// AARCH64: %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
// AARCH64: %[[addr:.*]] = call i8* @llvm.sponentry()
// AARCH64: %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
// AARCH64-NEXT: ret i32 %[[call]]
}
Expand All @@ -38,7 +38,7 @@ int test_setjmpex() {
// X64-NEXT: ret i32 %[[call]]

// AARCH64-LABEL: define dso_local i32 @test_setjmpex
// AARCH64: %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
// AARCH64: %[[addr:.*]] = call i8* @llvm.sponentry()
// AARCH64: %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
// AARCH64-NEXT: ret i32 %[[call]]
}

0 comments on commit e7c7934

Please sign in to comment.