Skip to content

Commit 144170c

Browse files
authored
Merge branch 'main' into users/kparzysz/spr/a04-atomic-one
2 parents 2636fd6 + 54d544b commit 144170c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+617
-306
lines changed

clang/include/clang/Basic/BuiltinHeaders.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
HEADER(NO_HEADER, nullptr)
15+
HEADER(ARMACLE_H, "arm_acle.h")
1516
HEADER(BLOCKS_H, "Blocks.h")
1617
HEADER(COMPLEX_H, "complex.h")
1718
HEADER(CTYPE_H, "ctype.h")

clang/include/clang/Basic/BuiltinsAArch64.def

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ BUILTIN(__builtin_arm_wfi, "v", "")
5050
BUILTIN(__builtin_arm_sev, "v", "")
5151
BUILTIN(__builtin_arm_sevl, "v", "")
5252
BUILTIN(__builtin_arm_chkfeat, "WUiWUi", "")
53+
TARGET_HEADER_BUILTIN(__yield, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
54+
TARGET_HEADER_BUILTIN(__wfe, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
55+
TARGET_HEADER_BUILTIN(__wfi, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
56+
TARGET_HEADER_BUILTIN(__sev, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
57+
TARGET_HEADER_BUILTIN(__sevl, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
5358

5459
// Like __builtin_trap but provide an 16-bit immediate reason code (which goes into `brk #N`).
5560
BUILTIN(__builtin_arm_trap, "vUIs", "nr")
@@ -82,6 +87,9 @@ TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
8287
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
8388
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
8489
BUILTIN(__builtin_arm_isb, "vUi", "nc")
90+
TARGET_HEADER_BUILTIN(__dmb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
91+
TARGET_HEADER_BUILTIN(__dsb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
92+
TARGET_HEADER_BUILTIN(__isb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
8593

8694
TARGET_BUILTIN(__builtin_arm_jcvt, "Zid", "nc", "v8.3a")
8795

@@ -98,16 +106,6 @@ BUILTIN(__builtin_arm_wsr64, "vcC*WUi", "nc")
98106
TARGET_BUILTIN(__builtin_arm_wsr128, "vcC*LLLUi", "nc", "d128")
99107
BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
100108

101-
// MSVC
102-
LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
103-
LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
104-
LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
105-
LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
106-
LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
107-
LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
108-
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
109-
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
110-
111109
// Misc
112110
BUILTIN(__builtin_sponentry, "v*", "c")
113111

clang/include/clang/Basic/BuiltinsARM.def

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,19 @@ BUILTIN(__builtin_arm_wfi, "v", "")
186186
BUILTIN(__builtin_arm_sev, "v", "")
187187
BUILTIN(__builtin_arm_sevl, "v", "")
188188
BUILTIN(__builtin_arm_dbg, "vUi", "")
189+
TARGET_HEADER_BUILTIN(__yield, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
190+
TARGET_HEADER_BUILTIN(__wfe, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
191+
TARGET_HEADER_BUILTIN(__wfi, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
192+
TARGET_HEADER_BUILTIN(__sev, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
193+
TARGET_HEADER_BUILTIN(__sevl, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
189194

190195
// Data barrier
191196
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
192197
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
193198
BUILTIN(__builtin_arm_isb, "vUi", "nc")
199+
TARGET_HEADER_BUILTIN(__dmb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
200+
TARGET_HEADER_BUILTIN(__dsb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
201+
TARGET_HEADER_BUILTIN(__isb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
194202

195203
// Prefetch
196204
BUILTIN(__builtin_arm_prefetch, "vvC*UiUi", "nc")
@@ -209,15 +217,6 @@ BUILTIN(__builtin_sponentry, "v*", "c")
209217
// MSVC
210218
LANGBUILTIN(__emit, "vIUiC", "", ALL_MS_LANGUAGES)
211219

212-
LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
213-
LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
214-
LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
215-
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
216-
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
217-
218-
LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
219-
LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
220-
LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
221220
LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES)
222221
LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
223222
LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)

clang/lib/CodeGen/CGCall.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,9 +3929,9 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
39293929
return R;
39303930
}
39313931

3932-
void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
3933-
bool EmitRetDbgLoc,
3934-
SourceLocation EndLoc) {
3932+
void CodeGenFunction::EmitFunctionEpilog(
3933+
const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc,
3934+
uint64_t RetKeyInstructionsSourceAtom) {
39353935
if (FI.isNoReturn()) {
39363936
// Noreturn functions don't return.
39373937
EmitUnreachable(EndLoc);
@@ -3946,7 +3946,11 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
39463946

39473947
// Functions with no result always return void.
39483948
if (!ReturnValue.isValid()) {
3949-
Builder.CreateRetVoid();
3949+
auto *I = Builder.CreateRetVoid();
3950+
if (RetKeyInstructionsSourceAtom)
3951+
addInstToSpecificSourceAtom(I, nullptr, RetKeyInstructionsSourceAtom);
3952+
else
3953+
addInstToNewSourceAtom(I, nullptr);
39503954
return;
39513955
}
39523956

@@ -4126,6 +4130,12 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
41264130

41274131
if (RetDbgLoc)
41284132
Ret->setDebugLoc(std::move(RetDbgLoc));
4133+
4134+
llvm::Value *Backup = RV ? Ret->getOperand(0) : nullptr;
4135+
if (RetKeyInstructionsSourceAtom)
4136+
addInstToSpecificSourceAtom(Ret, Backup, RetKeyInstructionsSourceAtom);
4137+
else
4138+
addInstToNewSourceAtom(Ret, Backup);
41294139
}
41304140

41314141
void CodeGenFunction::EmitReturnValueCheck(llvm::Value *RV) {

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ static bool isSwiftAsyncCallee(const CallExpr *CE) {
16051605
/// if the function returns void, or may be missing one if the function returns
16061606
/// non-void. Fun stuff :).
16071607
void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
1608+
ApplyAtomGroup Grp(getDebugInfo());
16081609
if (requiresReturnValueCheck()) {
16091610
llvm::Constant *SLoc = EmitCheckSourceLocation(S.getBeginLoc());
16101611
auto *SLocPtr =
@@ -1680,16 +1681,19 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
16801681
// If this function returns a reference, take the address of the expression
16811682
// rather than the value.
16821683
RValue Result = EmitReferenceBindingToExpr(RV);
1683-
Builder.CreateStore(Result.getScalarVal(), ReturnValue);
1684+
auto *I = Builder.CreateStore(Result.getScalarVal(), ReturnValue);
1685+
addInstToCurrentSourceAtom(I, I->getValueOperand());
16841686
} else {
16851687
switch (getEvaluationKind(RV->getType())) {
16861688
case TEK_Scalar: {
16871689
llvm::Value *Ret = EmitScalarExpr(RV);
1688-
if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
1690+
if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) {
16891691
EmitStoreOfScalar(Ret, MakeAddrLValue(ReturnValue, RV->getType()),
16901692
/*isInit*/ true);
1691-
else
1692-
Builder.CreateStore(Ret, ReturnValue);
1693+
} else {
1694+
auto *I = Builder.CreateStore(Ret, ReturnValue);
1695+
addInstToCurrentSourceAtom(I, I->getValueOperand());
1696+
}
16931697
break;
16941698
}
16951699
case TEK_Complex:

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,10 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
444444

445445
// Reset the debug location to that of the simple 'return' expression, if any
446446
// rather than that of the end of the function's scope '}'.
447+
uint64_t RetKeyInstructionsAtomGroup = Loc ? Loc->getAtomGroup() : 0;
447448
ApplyDebugLocation AL(*this, Loc);
448-
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc);
449+
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc,
450+
RetKeyInstructionsAtomGroup);
449451
EmitEndEHSpec(CurCodeDecl);
450452

451453
assert(EHStack.empty() &&

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,9 +2551,12 @@ class CodeGenFunction : public CodeGenTypeCache {
25512551
const FunctionArgList &Args);
25522552

25532553
/// EmitFunctionEpilog - Emit the target specific LLVM code to return the
2554-
/// given temporary.
2554+
/// given temporary. Specify the source location atom group (Key Instructions
2555+
/// debug info feature) for the `ret` using \p RetKeyInstructionsSourceAtom.
2556+
/// If it's 0, the `ret` will get added to a new source atom group.
25552557
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
2556-
SourceLocation EndLoc);
2558+
SourceLocation EndLoc,
2559+
uint64_t RetKeyInstructionsSourceAtom);
25572560

25582561
/// Emit a test that checks if the return value \p RV is nonnull.
25592562
void EmitReturnValueCheck(llvm::Value *RV);

clang/lib/Headers/arm_acle.h

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,16 @@ extern "C" {
2929

3030
/* 7 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
3131
/* 7.3 Memory barriers */
32-
#if !__has_builtin(__dmb)
33-
#define __dmb(i) __builtin_arm_dmb(i)
34-
#endif
35-
#if !__has_builtin(__dsb)
36-
#define __dsb(i) __builtin_arm_dsb(i)
37-
#endif
38-
#if !__has_builtin(__isb)
39-
#define __isb(i) __builtin_arm_isb(i)
40-
#endif
32+
void __dmb(unsigned int);
33+
void __dsb(unsigned int);
34+
void __isb(unsigned int);
4135

4236
/* 7.4 Hints */
43-
44-
#if !__has_builtin(__wfi)
45-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
46-
__wfi(void) {
47-
__builtin_arm_wfi();
48-
}
49-
#endif
50-
51-
#if !__has_builtin(__wfe)
52-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
53-
__wfe(void) {
54-
__builtin_arm_wfe();
55-
}
56-
#endif
57-
58-
#if !__has_builtin(__sev)
59-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
60-
__sev(void) {
61-
__builtin_arm_sev();
62-
}
63-
#endif
64-
65-
#if !__has_builtin(__sevl)
66-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
67-
__sevl(void) {
68-
__builtin_arm_sevl();
69-
}
70-
#endif
71-
72-
#if !__has_builtin(__yield)
73-
static __inline__ void __attribute__((__always_inline__, __nodebug__))
74-
__yield(void) {
75-
__builtin_arm_yield();
76-
}
77-
#endif
37+
void __wfi(void);
38+
void __wfe(void);
39+
void __sev(void);
40+
void __sevl(void);
41+
void __yield(void);
7842

7943
#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE
8044
#define __dbg(t) __builtin_arm_dbg(t)

clang/lib/Sema/SemaARM.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,11 @@ bool SemaARM::CheckARMBuiltinFunctionCall(const TargetInfo &TI,
10101010
case ARM::BI__builtin_arm_vcvtr_d:
10111011
return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 1);
10121012
case ARM::BI__builtin_arm_dmb:
1013+
case ARM::BI__dmb:
10131014
case ARM::BI__builtin_arm_dsb:
1015+
case ARM::BI__dsb:
10141016
case ARM::BI__builtin_arm_isb:
1017+
case ARM::BI__isb:
10151018
case ARM::BI__builtin_arm_dbg:
10161019
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15);
10171020
case ARM::BI__builtin_arm_cdp:
@@ -1108,8 +1111,11 @@ bool SemaARM::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI,
11081111
switch (BuiltinID) {
11091112
default: return false;
11101113
case AArch64::BI__builtin_arm_dmb:
1114+
case AArch64::BI__dmb:
11111115
case AArch64::BI__builtin_arm_dsb:
1116+
case AArch64::BI__dsb:
11121117
case AArch64::BI__builtin_arm_isb:
1118+
case AArch64::BI__isb:
11131119
l = 0;
11141120
u = 15;
11151121
break;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -Wno-everything -Wimplicit-function-declaration -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -triple armv7-eabi -Wno-everything -Wimplicit-function-declaration -fsyntax-only -verify %s
3+
4+
void check__dmb(void) {
5+
// expected-warning@+2{{call to undeclared library function}}
6+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
7+
__dmb(0);
8+
}
9+
10+
void check__dsb(void) {
11+
// expected-warning@+2{{call to undeclared library function}}
12+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
13+
__dsb(0);
14+
}
15+
16+
void check__isb(void) {
17+
// expected-warning@+2{{call to undeclared library function}}
18+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
19+
__isb(0);
20+
}
21+
22+
void check__yield(void) {
23+
// expected-warning@+2{{call to undeclared library function}}
24+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
25+
__yield();
26+
}
27+
28+
void check__wfe(void) {
29+
// expected-warning@+2{{call to undeclared library function}}
30+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
31+
__wfe();
32+
}
33+
34+
void check__wfi(void) {
35+
// expected-warning@+2{{call to undeclared library function}}
36+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
37+
__wfi();
38+
}
39+
40+
void check__sev(void) {
41+
// expected-warning@+2{{call to undeclared library function}}
42+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
43+
__sev();
44+
}
45+
46+
void check__sevl(void) {
47+
// expected-warning@+2{{call to undeclared library function}}
48+
// expected-note@+1{{include the header <arm_acle.h> or explicitly provide a declaration for}}
49+
__sevl();
50+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -emit-llvm -o - %s \
2+
// RUN: | FileCheck %s
3+
4+
// RUN: %clang_cc1 -triple armv7-eabi -Werror -emit-llvm -o - %s \
5+
// RUN: | FileCheck %s
6+
#include <arm_acle.h>
7+
void check__dmb(void) {
8+
__dmb(0);
9+
}
10+
11+
// CHECK: @llvm.arm.dmb(i32 0)
12+
13+
void check__dsb(void) {
14+
__dsb(0);
15+
}
16+
17+
// CHECK: @llvm.arm.dsb(i32 0)
18+
19+
void check__isb(void) {
20+
__isb(0);
21+
}
22+
23+
// CHECK: @llvm.arm.isb(i32 0)
24+
25+
void check__yield(void) {
26+
__yield();
27+
}
28+
29+
// CHECK: @llvm.arm.hint(i32 1)
30+
31+
void check__wfe(void) {
32+
__wfe();
33+
}
34+
35+
// CHECK: @llvm.arm.hint(i32 2)
36+
37+
void check__wfi(void) {
38+
__wfi();
39+
}
40+
41+
// CHECK: @llvm.arm.hint(i32 3)
42+
43+
void check__sev(void) {
44+
__sev();
45+
}
46+
47+
// CHECK: @llvm.arm.hint(i32 4)
48+
49+
void check__sevl(void) {
50+
__sevl();
51+
}
52+
53+
// CHECK: @llvm.arm.hint(i32 5)

clang/test/CodeGen/arm-microsoft-intrinsics.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@
44
// RUN: not %clang_cc1 -triple armv7-eabi -Werror -S -o /dev/null %s 2>&1 \
55
// RUN: | FileCheck %s -check-prefix CHECK-EABI
66

7-
void check__dmb(void) {
8-
__dmb(0);
9-
}
10-
11-
// CHECK-MSVC: @llvm.arm.dmb(i32 0)
12-
// CHECK-EABI: error: call to undeclared function '__dmb'
13-
14-
void check__dsb(void) {
15-
__dsb(0);
16-
}
17-
18-
// CHECK-MSVC: @llvm.arm.dsb(i32 0)
19-
// CHECK-EABI: error: call to undeclared function '__dsb'
20-
21-
void check__isb(void) {
22-
__isb(0);
23-
}
24-
25-
// CHECK-MSVC: @llvm.arm.isb(i32 0)
26-
// CHECK-EABI: error: call to undeclared function '__isb'
27-
287
__INT64_TYPE__ check__ldrexd(void) {
298
__INT64_TYPE__ i64;
309
return __ldrexd(&i64);

0 commit comments

Comments
 (0)