Skip to content

Commit 313abfb

Browse files
committed
merge main into amd-staging
2 parents 9e538b3 + f23bbf6 commit 313abfb

File tree

104 files changed

+2741
-3973
lines changed

Some content is hidden

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

104 files changed

+2741
-3973
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ Windows Support
363363
which makes ``offsetof`` provided by Microsoft's ``<stddef.h>`` to be defined
364364
correctly. (#GH59689)
365365

366+
- Clang now can process the `i128` and `ui128` integeral suffixes when MSVC
367+
extensions are enabled. This allows for properly processing ``intsafe.h`` in
368+
the Windows SDK.
369+
366370
LoongArch Support
367371
^^^^^^^^^^^^^^^^^
368372

clang/include/clang/Lex/LiteralSupport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class NumericLiteralParser {
8282
bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk
8383
bool isBitInt : 1; // 1wb, 1uwb (C23) or 1__wb, 1__uwb (Clang extension in C++
8484
// mode)
85-
uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64.
86-
85+
uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, i64, or
86+
// i128.
8787

8888
bool isFixedPointLiteral() const {
8989
return (saw_period || saw_exponent) && saw_fixed_point_suffix;

clang/lib/AST/ASTImporter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10527,12 +10527,11 @@ void ASTImporter::CompleteDecl (Decl *D) {
1052710527
}
1052810528

1052910529
Decl *ASTImporter::MapImported(Decl *From, Decl *To) {
10530-
llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10531-
assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10532-
"Try to import an already imported Decl");
10533-
if (Pos != ImportedDecls.end())
10530+
auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
10531+
assert((Inserted || Pos->second == To) &&
10532+
"Try to import an already imported Decl");
10533+
if (!Inserted)
1053410534
return Pos->second;
10535-
ImportedDecls[From] = To;
1053610535
// This mapping should be maintained only in this function. Therefore do not
1053710536
// check for additional consistency.
1053810537
ImportedFromDecls[To] = From;

clang/lib/AST/ParentMapContext.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "clang/AST/ParentMapContext.h"
15-
#include "clang/AST/RecursiveASTVisitor.h"
1615
#include "clang/AST/Decl.h"
1716
#include "clang/AST/Expr.h"
17+
#include "clang/AST/RecursiveASTVisitor.h"
1818
#include "clang/AST/TemplateBase.h"
19+
#include "llvm/ADT/SmallPtrSet.h"
1920

2021
using namespace clang;
2122

@@ -69,17 +70,21 @@ class ParentMapContext::ParentMap {
6970
for (; N > 0; --N)
7071
push_back(Value);
7172
}
72-
bool contains(const DynTypedNode &Value) {
73-
return Seen.contains(Value);
73+
bool contains(const DynTypedNode &Value) const {
74+
const void *Identity = Value.getMemoizationData();
75+
assert(Identity);
76+
return Dedup.contains(Identity);
7477
}
7578
void push_back(const DynTypedNode &Value) {
76-
if (!Value.getMemoizationData() || Seen.insert(Value).second)
79+
const void *Identity = Value.getMemoizationData();
80+
if (!Identity || Dedup.insert(Identity).second) {
7781
Items.push_back(Value);
82+
}
7883
}
7984
llvm::ArrayRef<DynTypedNode> view() const { return Items; }
8085
private:
81-
llvm::SmallVector<DynTypedNode, 2> Items;
82-
llvm::SmallDenseSet<DynTypedNode, 2> Seen;
86+
llvm::SmallVector<DynTypedNode, 1> Items;
87+
llvm::SmallPtrSet<const void *, 2> Dedup;
8388
};
8489

8590
/// Maps from a node to its parents. This is used for nodes that have

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,15 @@ bool PPCTargetInfo::initFeatureMap(
609609
// Privileged instructions are off by default.
610610
Features["privileged"] = false;
611611

612-
// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
613-
// turned off by default.
614-
Features["aix-small-local-exec-tls"] = false;
615-
Features["aix-small-local-dynamic-tls"] = false;
612+
if (getTriple().isOSAIX()) {
613+
// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
614+
// turned off by default.
615+
Features["aix-small-local-exec-tls"] = false;
616+
Features["aix-small-local-dynamic-tls"] = false;
616617

617-
// Turn off TLS model opt by default.
618-
Features["aix-shared-lib-tls-model-opt"] = false;
618+
// Turn off TLS model opt by default.
619+
Features["aix-shared-lib-tls-model-opt"] = false;
620+
}
619621

620622
Features["spe"] = llvm::StringSwitch<bool>(CPU)
621623
.Case("8548", true)

clang/lib/Lex/LiteralSupport.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,8 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
10731073
continue;
10741074
case 'i':
10751075
case 'I':
1076-
if (LangOpts.MicrosoftExt && !isFPConstant) {
1077-
// Allow i8, i16, i32, and i64. First, look ahead and check if
1076+
if (LangOpts.MicrosoftExt && s + 1 < ThisTokEnd && !isFPConstant) {
1077+
// Allow i8, i16, i32, i64, and i128. First, look ahead and check if
10781078
// suffixes are Microsoft integers and not the imaginary unit.
10791079
uint8_t Bits = 0;
10801080
size_t ToSkip = 0;
@@ -1084,19 +1084,23 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
10841084
ToSkip = 2;
10851085
break;
10861086
case '1':
1087-
if (s[2] == '6') { // i16 suffix
1087+
if (s + 2 < ThisTokEnd && s[2] == '6') { // i16 suffix
10881088
Bits = 16;
10891089
ToSkip = 3;
1090+
} else if (s + 3 < ThisTokEnd && s[2] == '2' &&
1091+
s[3] == '8') { // i128 suffix
1092+
Bits = 128;
1093+
ToSkip = 4;
10901094
}
10911095
break;
10921096
case '3':
1093-
if (s[2] == '2') { // i32 suffix
1097+
if (s + 2 < ThisTokEnd && s[2] == '2') { // i32 suffix
10941098
Bits = 32;
10951099
ToSkip = 3;
10961100
}
10971101
break;
10981102
case '6':
1099-
if (s[2] == '4') { // i64 suffix
1103+
if (s + 2 < ThisTokEnd && s[2] == '4') { // i64 suffix
11001104
Bits = 64;
11011105
ToSkip = 3;
11021106
}

clang/lib/Sema/SemaExpr.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3924,10 +3924,18 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
39243924
// to get the integer value from an overly-wide APInt is *extremely*
39253925
// expensive, so the naive approach of assuming
39263926
// llvm::IntegerType::MAX_INT_BITS is a big performance hit.
3927-
unsigned BitsNeeded =
3928-
Literal.isBitInt ? llvm::APInt::getSufficientBitsNeeded(
3929-
Literal.getLiteralDigits(), Literal.getRadix())
3930-
: Context.getTargetInfo().getIntMaxTWidth();
3927+
unsigned BitsNeeded = Context.getTargetInfo().getIntMaxTWidth();
3928+
if (Literal.isBitInt)
3929+
BitsNeeded = llvm::APInt::getSufficientBitsNeeded(
3930+
Literal.getLiteralDigits(), Literal.getRadix());
3931+
if (Literal.MicrosoftInteger) {
3932+
if (Literal.MicrosoftInteger == 128 &&
3933+
!Context.getTargetInfo().hasInt128Type())
3934+
PP.Diag(Tok.getLocation(), diag::err_integer_literal_too_large)
3935+
<< Literal.isUnsigned;
3936+
BitsNeeded = Literal.MicrosoftInteger;
3937+
}
3938+
39313939
llvm::APInt ResultVal(BitsNeeded, 0);
39323940

39333941
if (Literal.GetIntegerValue(ResultVal)) {

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,14 +2468,14 @@ bool SemaOpenACC::CheckDeclareClause(SemaOpenACC::OpenACCParsedClause &Clause) {
24682468
// directives for a function, subroutine, program, or module.
24692469

24702470
if (CurDecl) {
2471-
auto Itr = DeclareVarReferences.find(CurDecl);
2472-
if (Itr != DeclareVarReferences.end()) {
2471+
auto [Itr, Inserted] = DeclareVarReferences.try_emplace(CurDecl);
2472+
if (!Inserted) {
24732473
Diag(VarExpr->getBeginLoc(), diag::err_acc_multiple_references)
24742474
<< Clause.getClauseKind();
24752475
Diag(Itr->second, diag::note_acc_previous_reference);
24762476
continue;
24772477
} else {
2478-
DeclareVarReferences[CurDecl] = VarExpr->getBeginLoc();
2478+
Itr->second = VarExpr->getBeginLoc();
24792479
}
24802480
}
24812481
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK-AIX,CHECK-AIX-OFF %s
2+
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK-AIX,CHECK-AIX-OFF %s
3+
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
4+
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
5+
6+
// RUN: %clang -target powerpc64-unknown-aix -maix-shared-lib-tls-model-opt -S -emit-llvm \
7+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK-AIX,CHECK-AIX-ON
8+
9+
// FIXME: Clang driver diagnostic not implemented.
10+
// RUN: true || not %clang -target powerpc-unknown-aix -maix-shared-lib-tls-model-opt \
11+
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
12+
// RUN: true || not %clang -target powerpc64le-unknown-linux-gnu -maix-shared-lib-tls-model-opt \
13+
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
14+
// RUN: true || not %clang -target powerpc64-unknown-linux-gnu -maix-shared-lib-tls-model-opt \
15+
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
16+
17+
int test(void) {
18+
return 0;
19+
}
20+
21+
// CHECK-AIX: test() #0 {
22+
// CHECK-AIX: attributes #0 = {
23+
// CHECK-AIX-OFF-SAME: -aix-shared-lib-tls-model-opt
24+
// CHECK-AIX-ON-SAME: +aix-shared-lib-tls-model-opt
25+
26+
// CHECK-LINUX-NOT: {{[-+]aix-shared-lib-tls-model-opt}}
27+
28+
// CHECK-UNSUPPORTED-TARGET: option '-maix-shared-lib-tls-model-opt' cannot be specified on this target

clang/test/Driver/aix-small-local-exec-dynamic-tls.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
2-
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
3-
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
4-
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
1+
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-AIX-DEFAULT %s
2+
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-AIX-DEFAULT %s
3+
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
4+
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
55

66
// RUN: %clang -target powerpc64-unknown-aix -maix-small-local-exec-tls -S -emit-llvm \
77
// RUN: %s -o - | FileCheck %s --check-prefix=CHECK-AIX_SMALL_LOCALEXEC_TLS
@@ -39,9 +39,10 @@ int test(void) {
3939
return 0;
4040
}
4141

42-
// CHECK: test() #0 {
43-
// CHECK: attributes #0 = {
44-
// CHECK-SAME: {{-aix-small-local-exec-tls,.*-aix-small-local-dynamic-tls|-aix-small-local-dynamic-tls,.*-aix-small-local-exec-tls}}
42+
// CHECK-AIX-DEFAULT: test() #0 {
43+
// CHECK-AIX-DEFAULT: attributes #0 = {
44+
// CHECK-AIX-DEFAULT-SAME: {{-aix-small-local-exec-tls,.*-aix-small-local-dynamic-tls|-aix-small-local-dynamic-tls,.*-aix-small-local-exec-tls}}
45+
// CHECK-LINUX-NOT: {{[-+]aix-small-local-exec-tls,.*[-+]aix-small-local-dynamic-tls|[-+]aix-small-local-dynamic-tls,.*[-+]aix-small-local-exec-tls}}
4546

4647
// CHECK-UNSUPPORTED-AIX32: option '-maix-small-local-[exec|dynamic]-tls' cannot be specified on this target
4748
// CHECK-UNSUPPORTED-LINUX: option '-maix-small-local-[exec|dynamic]-tls' cannot be specified on this target

0 commit comments

Comments
 (0)