Skip to content

Commit 7d6a25a

Browse files
authored
merge main into amd-staging (#608)
2 parents 8ad44f5 + 5a5462d commit 7d6a25a

File tree

230 files changed

+3554
-2054
lines changed

Some content is hidden

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

230 files changed

+3554
-2054
lines changed

clang/Maintainers.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ Clang static analyzer
147147
148148
| Balázs Benics
149149
| benicsbalazs\@gmail.com (email), steakhal (Phabricator), steakhal (GitHub)
150-
| balazs.benics\@sonarsource.com (email), balazs-benics-sonarsource (GitHub)
151150
152151
Compiler options
153152
~~~~~~~~~~~~~~~~

clang/docs/analyzer/checkers.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ as error. Specifically on x86/x86-64 target if the pointer address space is
198198
dereference is not defined as error. See `X86/X86-64 Language Extensions
199199
<https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments>`__
200200
for reference.
201-
201+
202202
If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
203203
to true (the default value), then this checker never reports dereference of
204204
pointers with a specified address space. If the option is set to false, then
@@ -1664,6 +1664,23 @@ Warn on uses of the 'bzero' function.
16641664
bzero(ptr, n); // warn
16651665
}
16661666
1667+
.. _security-insecureAPI-decodeValueOfObjCType:
1668+
1669+
security.insecureAPI.decodeValueOfObjCType (C)
1670+
""""""""""""""""""""""""""""""""""""""""""""""
1671+
Warn on uses of the Objective-C method ``-decodeValueOfObjCType:at:``.
1672+
1673+
.. code-block:: objc
1674+
1675+
void test(NSCoder *decoder) {
1676+
unsigned int x;
1677+
[decoder decodeValueOfObjCType:"I" at:&x]; // warn
1678+
}
1679+
1680+
This diagnostic is emitted only on Apple platforms where the safer
1681+
``-decodeValueOfObjCType:at:size:`` alternative is available
1682+
(iOS 11+, macOS 10.13+, tvOS 11+, watchOS 4.0+).
1683+
16671684
.. _security-insecureAPI-getpw:
16681685
16691686
security.insecureAPI.getpw (C)

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
9292
def cmpsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant char)">;
9393
}
9494

95-
96-
let Features = "sse3" in {
95+
let Features = "sse3",
96+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
9797
foreach Op = ["addsub"] in {
9898
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
9999
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
@@ -121,8 +121,9 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
121121
}
122122

123123
// AVX
124-
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in {
125-
foreach Op = ["addsub", "max", "min"] in {
124+
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>],
125+
Features = "avx" in {
126+
foreach Op = ["max", "min"] in {
126127
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
127128
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
128129
}
@@ -571,6 +572,15 @@ let Features = "avx",
571572
def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
572573
}
573574

575+
let Features = "avx",
576+
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
577+
def addsubpd256
578+
: X86Builtin<
579+
"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
580+
def addsubps256
581+
: X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
582+
}
583+
574584
let Features = "avx", Attributes = [NoThrow] in {
575585
def vzeroall : X86Builtin<"void()">;
576586
def vzeroupper : X86Builtin<"void()">;

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,35 @@ static bool interp_builtin_horizontal_fp_binop(
27152715
return true;
27162716
}
27172717

2718+
static bool interp__builtin_ia32_addsub(InterpState &S, CodePtr OpPC,
2719+
const CallExpr *Call) {
2720+
// Addsub: alternates between subtraction and addition
2721+
// Result[i] = (i % 2 == 0) ? (a[i] - b[i]) : (a[i] + b[i])
2722+
const Pointer &RHS = S.Stk.pop<Pointer>();
2723+
const Pointer &LHS = S.Stk.pop<Pointer>();
2724+
const Pointer &Dst = S.Stk.peek<Pointer>();
2725+
FPOptions FPO = Call->getFPFeaturesInEffect(S.Ctx.getLangOpts());
2726+
llvm::RoundingMode RM = getRoundingMode(FPO);
2727+
const auto *VT = Call->getArg(0)->getType()->castAs<VectorType>();
2728+
unsigned NumElems = VT->getNumElements();
2729+
2730+
using T = PrimConv<PT_Float>::T;
2731+
for (unsigned I = 0; I != NumElems; ++I) {
2732+
APFloat LElem = LHS.elem<T>(I).getAPFloat();
2733+
APFloat RElem = RHS.elem<T>(I).getAPFloat();
2734+
if (I % 2 == 0) {
2735+
// Even indices: subtract
2736+
LElem.subtract(RElem, RM);
2737+
} else {
2738+
// Odd indices: add
2739+
LElem.add(RElem, RM);
2740+
}
2741+
Dst.elem<T>(I) = static_cast<T>(LElem);
2742+
}
2743+
Dst.initializeAllElements();
2744+
return true;
2745+
}
2746+
27182747
static bool interp__builtin_elementwise_triop_fp(
27192748
InterpState &S, CodePtr OpPC, const CallExpr *Call,
27202749
llvm::function_ref<APFloat(const APFloat &, const APFloat &,
@@ -4196,6 +4225,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
41964225
F.subtract(RHS, RM);
41974226
return F;
41984227
});
4228+
case clang::X86::BI__builtin_ia32_addsubpd:
4229+
case clang::X86::BI__builtin_ia32_addsubps:
4230+
case clang::X86::BI__builtin_ia32_addsubpd256:
4231+
case clang::X86::BI__builtin_ia32_addsubps256:
4232+
return interp__builtin_ia32_addsub(S, OpPC, Call);
41994233

42004234
case clang::X86::BI__builtin_ia32_pmuldq128:
42014235
case clang::X86::BI__builtin_ia32_pmuldq256:

clang/lib/AST/ExprConstant.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13373,6 +13373,35 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1337313373
}
1337413374
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
1337513375
}
13376+
case clang::X86::BI__builtin_ia32_addsubpd:
13377+
case clang::X86::BI__builtin_ia32_addsubps:
13378+
case clang::X86::BI__builtin_ia32_addsubpd256:
13379+
case clang::X86::BI__builtin_ia32_addsubps256: {
13380+
// Addsub: alternates between subtraction and addition
13381+
// Result[i] = (i % 2 == 0) ? (a[i] - b[i]) : (a[i] + b[i])
13382+
APValue SourceLHS, SourceRHS;
13383+
if (!EvaluateAsRValue(Info, E->getArg(0), SourceLHS) ||
13384+
!EvaluateAsRValue(Info, E->getArg(1), SourceRHS))
13385+
return false;
13386+
unsigned NumElems = SourceLHS.getVectorLength();
13387+
SmallVector<APValue, 8> ResultElements;
13388+
ResultElements.reserve(NumElems);
13389+
llvm::RoundingMode RM = getActiveRoundingMode(getEvalInfo(), E);
13390+
13391+
for (unsigned I = 0; I != NumElems; ++I) {
13392+
APFloat LHS = SourceLHS.getVectorElt(I).getFloat();
13393+
APFloat RHS = SourceRHS.getVectorElt(I).getFloat();
13394+
if (I % 2 == 0) {
13395+
// Even indices: subtract
13396+
LHS.subtract(RHS, RM);
13397+
} else {
13398+
// Odd indices: add
13399+
LHS.add(RHS, RM);
13400+
}
13401+
ResultElements.push_back(APValue(LHS));
13402+
}
13403+
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
13404+
}
1337613405
case Builtin::BI__builtin_elementwise_fshl:
1337713406
case Builtin::BI__builtin_elementwise_fshr: {
1337813407
APValue SourceHi, SourceLo, SourceShift;

0 commit comments

Comments
 (0)