Skip to content

Commit 1b68af8

Browse files
committed
merge main into amd-stg-open
Change-Id: If10dae46b3703133c0d228e7c94481cd41e8e23b
2 parents b9556ed + 7f3ee3c commit 1b68af8

File tree

223 files changed

+8682
-5784
lines changed

Some content is hidden

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

223 files changed

+8682
-5784
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#include <stdio.h>
2-
#include <stdlib.h>
3-
#include <unistd.h>
4-
51
int add(int a, int b) { return a + b; }
62
int minus(int a, int b) { return a - b; }
73
int multiple(int a, int b) { return a * b; }
@@ -15,12 +11,12 @@ int main() {
1511
int a = 16;
1612
int b = 8;
1713

18-
for (int i = 1; i < 100000; i++) {
14+
for (int i = 1; i < 1000000; i++) {
1915
add(a, b);
2016
minus(a, b);
2117
multiple(a, b);
2218
divide(a, b);
2319
}
2420

2521
return 0;
26-
}
22+
}

clang/docs/LanguageExtensions.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,22 @@ The pragma can take two values: ``on`` and ``off``.
46294629
float v = t + z;
46304630
}
46314631
4632+
``#pragma clang fp reciprocal`` allows control over using reciprocal
4633+
approximations in floating point expressions. When enabled, this
4634+
pragma allows the expression ``x / y`` to be approximated as ``x *
4635+
(1.0 / y)``. This pragma can be used to disable reciprocal
4636+
approximation when it is otherwise enabled for the translation unit
4637+
with the ``-freciprocal-math`` flag or other fast-math options. The
4638+
pragma can take two values: ``on`` and ``off``.
4639+
4640+
.. code-block:: c++
4641+
4642+
float f(float x, float y)
4643+
{
4644+
// Enable floating point reciprocal approximation
4645+
#pragma clang fp reciprocal(on)
4646+
return x / y;
4647+
}
46324648
46334649
``#pragma clang fp contract`` specifies whether the compiler should
46344650
contract a multiply and an addition (or subtraction) into a fused FMA

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ Non-comprehensive list of changes in this release
286286
* ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``
287287
and vector types as return value ``19``, to match GCC 14's behavior.
288288

289+
* Added ``#pragma clang fp reciprocal``.
290+
289291
New Compiler Flags
290292
------------------
291293

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,12 +1594,13 @@ def note_pragma_loop_invalid_vectorize_option : Note<
15941594
"vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')">;
15951595

15961596
def err_pragma_fp_invalid_option : Error<
1597-
"%select{invalid|missing}0 option%select{ %1|}0; expected 'contract', 'reassociate' or 'exceptions'">;
1597+
"%select{invalid|missing}0 option%select{ %1|}0; expected 'contract', 'reassociate', 'reciprocal', or 'exceptions'">;
15981598
def err_pragma_fp_invalid_argument : Error<
15991599
"unexpected argument '%0' to '#pragma clang fp %1'; expected "
16001600
"%select{"
16011601
"'fast' or 'on' or 'off'|"
16021602
"'on' or 'off'|"
1603+
"'on' or 'off'|"
16031604
"'ignore', 'maytrap' or 'strict'|"
16041605
"'source', 'double' or 'extended'}2">;
16051606

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6759,7 +6759,7 @@ def warn_floatingpoint_eq : Warning<
67596759

67606760
def err_setting_eval_method_used_in_unsafe_context : Error <
67616761
"%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be used with "
6762-
"%select{option 'fapprox-func'|option 'mreassociate'|option 'freciprocal'|option 'ffp-eval-method'|'#pragma clang fp reassociate'}1">;
6762+
"%select{option 'fapprox-func'|option 'mreassociate'|option 'freciprocal'|option 'ffp-eval-method'|'#pragma clang fp reassociate'|'#pragma clang fp reciprocal'}1">;
67636763

67646764
def warn_remainder_division_by_zero : Warning<
67656765
"%select{remainder|division}0 by zero is undefined">,

clang/include/clang/Basic/PragmaKinds.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ enum PragmaFloatControlKind {
3434
PFC_Push, // #pragma float_control(push)
3535
PFC_Pop // #pragma float_control(pop)
3636
};
37+
38+
enum PragmaFPKind {
39+
PFK_Contract, // #pragma clang fp contract
40+
PFK_Reassociate, // #pragma clang fp reassociate
41+
PFK_Reciprocal, // #pragma clang fp reciprocal
42+
PFK_Exceptions, // #pragma clang fp exceptions
43+
PFK_EvalMethod // #pragma clang fp eval_method
44+
};
3745
}
3846

3947
#endif

clang/include/clang/ExtractAPI/DeclarationFragments.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/AST/DeclObjC.h"
2525
#include "clang/AST/DeclTemplate.h"
2626
#include "clang/AST/ExprCXX.h"
27+
#include "clang/AST/TypeLoc.h"
2728
#include "clang/Basic/Specifiers.h"
2829
#include "clang/Lex/MacroInfo.h"
2930
#include "llvm/ADT/SmallVector.h"
@@ -410,6 +411,11 @@ class DeclarationFragmentsBuilder {
410411
/// Build DeclarationFragments for a parameter variable declaration
411412
/// ParmVarDecl.
412413
static DeclarationFragments getFragmentsForParam(const ParmVarDecl *);
414+
415+
static DeclarationFragments
416+
getFragmentsForBlock(const NamedDecl *BlockDecl, FunctionTypeLoc &Block,
417+
FunctionProtoTypeLoc &BlockProto,
418+
DeclarationFragments &After);
413419
};
414420

415421
template <typename FunctionT>

clang/include/clang/Sema/Sema.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3853,6 +3853,12 @@ class Sema final {
38533853
const FunctionProtoType *NewType,
38543854
unsigned *ArgPos = nullptr,
38553855
bool Reversed = false);
3856+
3857+
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
3858+
const FunctionDecl *NewFunction,
3859+
unsigned *ArgPos = nullptr,
3860+
bool Reversed = false);
3861+
38563862
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
38573863
QualType FromType, QualType ToType);
38583864

@@ -11000,7 +11006,10 @@ class Sema final {
1100011006

1100111007
/// Called on well formed
1100211008
/// \#pragma clang fp reassociate
11003-
void ActOnPragmaFPReassociate(SourceLocation Loc, bool IsEnabled);
11009+
/// or
11010+
/// \#pragma clang fp reciprocal
11011+
void ActOnPragmaFPValueChangingOption(SourceLocation Loc, PragmaFPKind Kind,
11012+
bool IsEnabled);
1100411013

1100511014
/// ActOnPragmaFenvAccess - Called on well formed
1100611015
/// \#pragma STDC FENV_ACCESS

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ class SValBuilder {
215215
const LocationContext *LCtx,
216216
QualType type, unsigned Count);
217217

218+
/// Create an SVal representing the result of an alloca()-like call, that is,
219+
/// an AllocaRegion on the stack.
220+
///
221+
/// After calling this function, it's a good idea to set the extent of the
222+
/// returned AllocaRegion.
223+
loc::MemRegionVal getAllocaRegionVal(const Expr *E,
224+
const LocationContext *LCtx,
225+
unsigned Count);
226+
218227
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(
219228
SymbolRef parentSymbol, const TypedValueRegion *region);
220229

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,14 +1731,26 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy,
17311731
unsigned LineNumber = getLineNumber(Var->getLocation());
17321732
StringRef VName = Var->getName();
17331733

1734+
// FIXME: to avoid complications with type merging we should
1735+
// emit the constant on the definition instead of the declaration.
1736+
llvm::Constant *C = nullptr;
1737+
if (Var->getInit()) {
1738+
const APValue *Value = Var->evaluateValue();
1739+
if (Value) {
1740+
if (Value->isInt())
1741+
C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
1742+
if (Value->isFloat())
1743+
C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
1744+
}
1745+
}
1746+
17341747
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
17351748
auto Tag = CGM.getCodeGenOpts().DwarfVersion >= 5
17361749
? llvm::dwarf::DW_TAG_variable
17371750
: llvm::dwarf::DW_TAG_member;
17381751
auto Align = getDeclAlignIfRequired(Var, CGM.getContext());
1739-
llvm::DIDerivedType *GV =
1740-
DBuilder.createStaticMemberType(RecordTy, VName, VUnit, LineNumber, VTy,
1741-
Flags, /* Val */ nullptr, Tag, Align);
1752+
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
1753+
RecordTy, VName, VUnit, LineNumber, VTy, Flags, C, Tag, Align);
17421754
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
17431755
StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl());
17441756
return GV;

0 commit comments

Comments
 (0)