Skip to content

Commit f9f5125

Browse files
authored
Merge branch 'main' into api_captialization
2 parents 45778ad + 7e71466 commit f9f5125

File tree

6 files changed

+61
-8
lines changed

6 files changed

+61
-8
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,8 @@ if(LLVM_LIBC_FULL_BUILD)
933933
# setjmp.h entrypoints
934934
libc.src.setjmp.longjmp
935935
libc.src.setjmp.setjmp
936+
libc.src.setjmp.siglongjmp
937+
libc.src.setjmp.sigsetjmp
936938

937939
# stdio.h entrypoints
938940
libc.src.stdio.clearerr

libc/include/llvm-libc-types/jmp_buf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// TODO: implement sigjmp_buf related functions for other architectures
1313
// Issue: https://github.com/llvm/llvm-project/issues/136358
1414
#if defined(__linux__)
15-
#if defined(__i386__) || defined(__x86_64__)
15+
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
1616
#define __LIBC_HAS_SIGJMP_BUF
1717
#endif
1818
#endif

libc/src/setjmp/aarch64/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ add_entrypoint_object(
2626
libc.hdr.types.jmp_buf
2727
${setjmp_config_options}
2828
)
29+
30+
add_entrypoint_object(
31+
sigsetjmp
32+
SRCS
33+
sigsetjmp.cpp
34+
HDRS
35+
../sigsetjmp.h
36+
DEPENDS
37+
libc.hdr.types.jmp_buf
38+
libc.hdr.types.sigset_t
39+
libc.hdr.offsetof_macros
40+
libc.src.setjmp.sigsetjmp_epilogue
41+
libc.src.setjmp.setjmp
42+
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===-- Implementation of sigsetjmp ---------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/setjmp/sigsetjmp.h"
10+
#include "hdr/offsetof_macros.h"
11+
#include "src/__support/common.h"
12+
#include "src/__support/macros/config.h"
13+
#include "src/setjmp/setjmp_impl.h"
14+
#include "src/setjmp/sigsetjmp_epilogue.h"
15+
16+
namespace LIBC_NAMESPACE_DECL {
17+
[[gnu::naked]]
18+
LLVM_LIBC_FUNCTION(int, sigsetjmp, (sigjmp_buf, int)) {
19+
asm(R"(
20+
cbz w1, %c[setjmp]
21+
22+
str x30, [x0, %c[retaddr]]
23+
str x19, [x0, %c[extra]]
24+
mov x19, x0
25+
bl %c[setjmp]
26+
27+
mov w1, w0
28+
mov x0, x19
29+
ldr x30, [x0, %c[retaddr]]
30+
ldr x19, [x0, %c[extra]]
31+
b %c[epilogue])" ::[retaddr] "i"(offsetof(__jmp_buf, sig_retaddr)),
32+
[extra] "i"(offsetof(__jmp_buf, sig_extra)), [setjmp] "i"(setjmp),
33+
[epilogue] "i"(sigsetjmp_epilogue)
34+
: "x0", "x1", "x19", "x30");
35+
}
36+
} // namespace LIBC_NAMESPACE_DECL

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9760,8 +9760,9 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
97609760
// Tail folding is not supported for outer loops, so the induction increment
97619761
// is guaranteed to not wrap.
97629762
bool HasNUW = true;
9763-
addCanonicalIVRecipes(*Plan, Legal->getWidestInductionType(), HasNUW,
9764-
DebugLoc());
9763+
addCanonicalIVRecipes(
9764+
*Plan, Legal->getWidestInductionType(), HasNUW,
9765+
getDebugLocFromInstOrOperands(Legal->getPrimaryInduction()));
97659766

97669767
if (!VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
97679768
Plan,

llvm/test/Transforms/LoopVectorize/dbg-outer-loop-vect.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define void @foo(ptr %h) !dbg !4 {
1212
; CHECK: vector.ph:
1313
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]], !dbg [[DBG21]]
1414
; CHECK: vector.body:
15-
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[FOR_COND_CLEANUP32:%.*]] ]
15+
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[FOR_COND_CLEANUP32:%.*]] ], !dbg [[DBG222:![0-9]+]]
1616
; CHECK-NEXT: br label [[FOR_COND5_PREHEADER1:%.*]], !dbg [[DBG21]]
1717
; CHECK: for.cond5.preheader1:
1818
; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i64> [ zeroinitializer, [[VECTOR_BODY]] ], [ [[TMP4:%.*]], [[FOR_COND5_PREHEADER1]] ], !dbg [[DBG22:![0-9]+]]
@@ -29,9 +29,9 @@ define void @foo(ptr %h) !dbg !4 {
2929
; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i1> [[TMP5]], i32 0, !dbg [[DBG28:![0-9]+]]
3030
; CHECK-NEXT: br i1 [[TMP6]], label [[FOR_COND_CLEANUP32]], label [[FOR_COND5_PREHEADER1]], !dbg [[DBG28]]
3131
; CHECK: vector.latch:
32-
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
33-
; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i64 [[INDEX_NEXT]], 20
34-
; CHECK-NEXT: br i1 [[TMP9]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP29:![0-9]+]]
32+
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4, !dbg [[DBG222]]
33+
; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i64 [[INDEX_NEXT]], 20, !dbg [[DBG222]]
34+
; CHECK-NEXT: br i1 [[TMP9]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !dbg [[DBG222]], !llvm.loop [[LOOP29:![0-9]+]]
3535
; CHECK: middle.block:
3636
; CHECK-NEXT: br i1 false, label [[EXIT:%.*]], label [[SCALAR_PH]], !dbg [[DBG21]]
3737
; CHECK: scalar.ph:
@@ -156,6 +156,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
156156
; CHECK: [[META19]] = distinct !DILexicalBlock(scope: [[META15]], file: [[META1]], line: 11, column: 5)
157157
; CHECK: [[META20]] = !DILocation(line: 0, scope: [[META12]])
158158
; CHECK: [[DBG21]] = !DILocation(line: 10, column: 3, scope: [[META12]])
159+
; CHECK: [[DBG222]] = !DILocation(line: 10, column: 30, scope: [[META16]])
159160
; CHECK: [[DBG22]] = !DILocation(line: 10, column: 5, scope: [[META12]])
160161
; CHECK: [[DBG23]] = !DILocation(line: 13, column: 11, scope: [[META24:![0-9]+]])
161162
; CHECK: [[META24]] = distinct !DILexicalBlock(scope: [[META18]], file: [[META1]], line: 12, column: 7)
@@ -167,7 +168,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
167168
; CHECK: [[META30]] = !DILocation(line: 13, column: 13, scope: [[META12]])
168169
; CHECK: [[META31]] = !{!"llvm.loop.isvectorized", i32 1}
169170
; CHECK: [[META32]] = !{!"llvm.loop.unroll.runtime.disable"}
170-
; CHECK: [[DBG33]] = !DILocation(line: 10, column: 30, scope: [[META16]])
171171
; CHECK: [[DBG34]] = !DILocation(line: 10, column: 24, scope: [[META16]])
172172
; CHECK: [[LOOP35]] = distinct !{[[LOOP35]], [[DBG21]], [[META30]], [[META31]]}
173173
; CHECK: [[DBG36]] = !DILocation(line: 14, column: 1, scope: [[DBG4]])

0 commit comments

Comments
 (0)