Skip to content

Commit 5284972

Browse files
authored
Merge pull request llvm#170 from AMD-Lightning-Internal/upstream_merge_202501162308
merge main into amd-staging
2 parents 2ffefec + 46aa2d8 commit 5284972

File tree

280 files changed

+5403
-2303
lines changed

Some content is hidden

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

280 files changed

+5403
-2303
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,12 @@ class BinaryContext {
13631363
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
13641364
return *Size;
13651365

1366+
if (MIB->isPseudo(Inst))
1367+
return 0;
1368+
1369+
if (std::optional<uint32_t> Size = MIB->getInstructionSize(Inst))
1370+
return *Size;
1371+
13661372
if (!Emitter)
13671373
Emitter = this->MCE.get();
13681374
SmallString<256> Code;

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,11 @@ class MCPlusBuilder {
12041204
/// Get instruction size specified via annotation.
12051205
std::optional<uint32_t> getSize(const MCInst &Inst) const;
12061206

1207+
/// Get target-specific instruction size.
1208+
virtual std::optional<uint32_t> getInstructionSize(const MCInst &Inst) const {
1209+
return std::nullopt;
1210+
}
1211+
12071212
/// Set instruction size.
12081213
void setSize(MCInst &Inst, uint32_t Size) const;
12091214

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,11 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
17921792
}
17931793

17941794
uint16_t getMinFunctionAlignment() const override { return 4; }
1795+
1796+
std::optional<uint32_t>
1797+
getInstructionSize(const MCInst &Inst) const override {
1798+
return 4;
1799+
}
17951800
};
17961801

17971802
} // end anonymous namespace

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ Improvements to Clang's diagnostics
817817
scope.Unlock();
818818
require(scope); // Warning! Requires mu1.
819819
}
820+
- Diagnose invalid declarators in the declaration of constructors and destructors (#GH121706).
820821

821822
Improvements to Clang's time-trace
822823
----------------------------------

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,8 @@ def err_invalid_qualified_constructor : Error<
22042204
"'%0' qualifier is not allowed on a constructor">;
22052205
def err_ref_qualifier_constructor : Error<
22062206
"ref-qualifier '%select{&&|&}0' is not allowed on a constructor">;
2207+
def err_invalid_ctor_dtor_decl : Error<
2208+
"invalid %select{constructor|destructor}0 declaration">;
22072209

22082210
def err_constructor_return_type : Error<
22092211
"constructor cannot have a return type">;

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6805,6 +6805,7 @@ def fbinutils_version_EQ : Joined<["-"], "fbinutils-version=">,
68056805
def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group<f_Group>,
68066806
Flags<[LinkOption]>, Visibility<[ClangOption, FlangOption, CLOption]>;
68076807
def ld_path_EQ : Joined<["--"], "ld-path=">, Group<Link_Group>;
6808+
def fuse_lipo_EQ : Joined<["-"], "fuse-lipo=">, Group<f_clang_Group>, Flags<[LinkOption]>;
68086809

68096810
defm align_labels : BooleanFFlag<"align-labels">, Group<clang_ignored_gcc_optimization_f_Group>;
68106811
def falign_labels_EQ : Joined<["-"], "falign-labels=">, Group<clang_ignored_gcc_optimization_f_Group>;

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,18 +3607,15 @@ void CodeGenFunction::EmitCheck(
36073607
llvm::Value *RecoverableCond = nullptr;
36083608
llvm::Value *TrapCond = nullptr;
36093609
bool NoMerge = false;
3610-
for (int i = 0, n = Checked.size(); i < n; ++i) {
3611-
llvm::Value *Check = Checked[i].first;
3610+
for (auto &[Check, Ord] : Checked) {
36123611
// -fsanitize-trap= overrides -fsanitize-recover=.
3613-
llvm::Value *&Cond =
3614-
CGM.getCodeGenOpts().SanitizeTrap.has(Checked[i].second)
3615-
? TrapCond
3616-
: CGM.getCodeGenOpts().SanitizeRecover.has(Checked[i].second)
3617-
? RecoverableCond
3618-
: FatalCond;
3612+
llvm::Value *&Cond = CGM.getCodeGenOpts().SanitizeTrap.has(Ord) ? TrapCond
3613+
: CGM.getCodeGenOpts().SanitizeRecover.has(Ord)
3614+
? RecoverableCond
3615+
: FatalCond;
36193616
Cond = Cond ? Builder.CreateAnd(Cond, Check) : Check;
36203617

3621-
if (!CGM.getCodeGenOpts().SanitizeMergeHandlers.has(Checked[i].second))
3618+
if (!CGM.getCodeGenOpts().SanitizeMergeHandlers.has(Ord))
36223619
NoMerge = true;
36233620
}
36243621

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,21 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
659659
CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : ArchArgFPUKind;
660660
(void)llvm::ARM::getFPUFeatures(FPUKind, Features);
661661
} else {
662+
bool Generic = true;
662663
if (!ForAS) {
663664
std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple);
665+
if (CPU != "generic")
666+
Generic = false;
664667
llvm::ARM::ArchKind ArchKind =
665668
arm::getLLVMArchKindForARM(CPU, ArchName, Triple);
666669
FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind);
667670
(void)llvm::ARM::getFPUFeatures(FPUKind, Features);
668671
}
672+
if (Generic && (Triple.isOSWindows() || Triple.isOSDarwin()) &&
673+
getARMSubArchVersionNumber(Triple) >= 7) {
674+
FPUKind = llvm::ARM::parseFPU("neon");
675+
(void)llvm::ARM::getFPUFeatures(FPUKind, Features);
676+
}
669677
}
670678

671679
// Now we've finished accumulating features from arch, cpu and fpu,

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,9 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
910910
CmdArgs.push_back(II.getFilename());
911911
}
912912

913-
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo"));
913+
StringRef LipoName = Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo");
914+
const char *Exec =
915+
Args.MakeArgString(getToolChain().GetProgramPath(LipoName.data()));
914916
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
915917
Exec, CmdArgs, Inputs, Output));
916918
}

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10757,6 +10757,22 @@ static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID) {
1075710757
}
1075810758
}
1075910759

10760+
static void diagnoseInvalidDeclaratorChunks(Sema &S, Declarator &D,
10761+
unsigned Kind) {
10762+
if (D.isInvalidType() || D.getNumTypeObjects() <= 1)
10763+
return;
10764+
10765+
DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
10766+
if (Chunk.Kind == DeclaratorChunk::Paren ||
10767+
Chunk.Kind == DeclaratorChunk::Function)
10768+
return;
10769+
10770+
SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
10771+
S.Diag(PointerLoc, diag::err_invalid_ctor_dtor_decl)
10772+
<< Kind << Chunk.getSourceRange();
10773+
D.setInvalidType();
10774+
}
10775+
1076010776
QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
1076110777
StorageClass &SC) {
1076210778
bool isVirtual = D.getDeclSpec().isVirtualSpecified();
@@ -10792,6 +10808,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
1079210808
}
1079310809

1079410810
checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_constructor);
10811+
diagnoseInvalidDeclaratorChunks(*this, D, /*constructor*/ 0);
1079510812

1079610813
// C++0x [class.ctor]p4:
1079710814
// A constructor shall not be declared with a ref-qualifier.
@@ -10958,6 +10975,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R,
1095810975
}
1095910976

1096010977
checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_destructor);
10978+
diagnoseInvalidDeclaratorChunks(*this, D, /*destructor*/ 1);
1096110979

1096210980
// C++0x [class.dtor]p2:
1096310981
// A destructor shall not be declared with a ref-qualifier.

clang/test/Driver/arm-mfpu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,10 @@
356356
// CHECK-HF-DAG: "-target-cpu" "arm1176jzf-s"
357357

358358
// RUN: %clang -target armv7-apple-darwin -x assembler %s -### -c 2>&1 \
359-
// RUN: | FileCheck --check-prefix=ASM %s
360-
// ASM-NOT: -target-feature
359+
// RUN: | FileCheck --check-prefix=ASM-NEON %s
360+
// RUN: %clang -target armv7-windows -x assembler %s -### -c 2>&1 \
361+
// RUN: | FileCheck --check-prefix=ASM-NEON %s
362+
// ASM-NEON: "-target-feature" "+neon"
361363

362364
// RUN: %clang -target armv8-linux-gnueabi -mfloat-abi=soft -mfpu=none %s -### -c 2>&1 \
363365
// RUN: | FileCheck --check-prefix=CHECK-SOFT-ABI-FP %s

clang/test/Driver/fuse-lipo.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST1 %s
2+
// TEST1: llvm-lipo
3+
4+
// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 -fuse-lipo=nonexistant-lipo 2>&1 | FileCheck -check-prefix=TEST2 %s
5+
// TEST2: nonexistant-lipo
6+
7+
// RUN: %clang %s -### --target=arm64-apple-darwin -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST3 %s
8+
// TEST3: clang: warning: argument unused during compilation: '-fuse-lipo=llvm-lipo'
9+
10+
// RUN: %clang %s -### --target=arm64-apple-darwin -Wno-unused-command-line-argument -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST4 %s
11+
// TEST4-NOT: llvm-lipo
12+
13+
// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 2>&1 | FileCheck -check-prefix=TEST5 %s
14+
// TEST5: lipo
15+
// TEST5-NOT: llvm-lipo

clang/test/Preprocessor/arm-target-features.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@
132132
// CHECK-V7VE-DEFAULT-ABI-SOFT: #define __ARM_ARCH_EXT_IDIV__ 1
133133
// CHECK-V7VE-DEFAULT-ABI-SOFT: #define __ARM_FP 0xc
134134

135+
// RUN: %clang -target x86_64-apple-macosx10.10 -arch armv7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-DARWIN-V7 %s
136+
// CHECK-DARWIN-V7: #define __ARMEL__ 1
137+
// CHECK-DARWIN-V7: #define __ARM_ARCH 7
138+
// CHECK-DARWIN-V7: #define __ARM_ARCH_7A__ 1
139+
// CHECK-DARWIN-V7-NOT: __ARM_FEATURE_CRC32
140+
// CHECK-DARWIN-V7-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
141+
// CHECK-DARWIN-V7-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
142+
// CHECK-DARWIN-V7: #define __ARM_FP 0xc
143+
// CHECK-DARWIN-V7: #define __ARM_NEON 1
144+
// CHECK-DARWIN-V7: #define __ARM_NEON_FP 0x4
145+
// CHECK-DARWIN-V7: #define __ARM_NEON__ 1
146+
147+
// RUN: %clang -target armv7-windows -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-WINDOWS-V7 %s
148+
// CHECK-WINDOWS-V7: #define __ARMEL__ 1
149+
// CHECK-WINDOWS-V7: #define __ARM_ARCH 7
150+
// CHECK-WINDOWS-V7: #define __ARM_ARCH_7A__ 1
151+
// CHECK-WINDOWS-V7-NOT: __ARM_FEATURE_CRC32
152+
// CHECK-WINDOWS-V7-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
153+
// CHECK-WINDOWS-V7-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
154+
// CHECK-WINDOWS-V7: #define __ARM_FP 0xe
155+
// CHECK-WINDOWS-V7: #define __ARM_NEON 1
156+
// CHECK-WINDOWS-V7: #define __ARM_NEON_FP 0x6
157+
// CHECK-WINDOWS-V7: #define __ARM_NEON__ 1
158+
135159
// RUN: %clang -target x86_64-apple-macosx10.10 -arch armv7s -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V7S %s
136160
// CHECK-V7S: #define __ARMEL__ 1
137161
// CHECK-V7S: #define __ARM_ARCH 7
@@ -140,6 +164,9 @@
140164
// CHECK-V7S-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
141165
// CHECK-V7S-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
142166
// CHECK-V7S: #define __ARM_FP 0xe
167+
// CHECK-V7S: #define __ARM_NEON 1
168+
// CHECK-V7S: #define __ARM_NEON_FP 0x6
169+
// CHECK-V7S: #define __ARM_NEON__ 1
143170

144171
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=soft -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
145172
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=softfp -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s

clang/test/SemaCXX/constructor.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,80 @@ namespace PR38286 {
9696
template<typename> struct C; // expected-note {{non-type declaration found}}
9797
template<typename T> C<T>::~C() {} // expected-error {{identifier 'C' after '~' in destructor name does not name a type}}
9898
}
99+
100+
namespace GH121706 {
101+
102+
struct A {
103+
*&A(); // expected-error {{invalid constructor declaration}}
104+
};
105+
106+
struct B {
107+
*&&B(); // expected-error {{invalid constructor declaration}}
108+
};
109+
110+
struct C {
111+
*const C(); // expected-error {{invalid constructor declaration}}
112+
};
113+
114+
struct D {
115+
*const *D(); // expected-error {{invalid constructor declaration}}
116+
};
117+
118+
struct E {
119+
*E::*E(); // expected-error {{invalid constructor declaration}}
120+
};
121+
122+
struct F {
123+
*F::*const F(); // expected-error {{invalid constructor declaration}}
124+
};
125+
126+
struct G {
127+
****G(); // expected-error {{invalid constructor declaration}}
128+
};
129+
130+
struct H {
131+
**H(const H &); // expected-error {{invalid constructor declaration}}
132+
};
133+
134+
struct I {
135+
*I(I &&); // expected-error {{invalid constructor declaration}}
136+
};
137+
138+
struct J {
139+
*&(J)(); // expected-error {{invalid constructor declaration}}
140+
};
141+
142+
struct K {
143+
**&&(K)(); // expected-error {{invalid constructor declaration}}
144+
};
145+
146+
struct L {
147+
*L(L&& other); // expected-error {{invalid constructor declaration}}
148+
};
149+
150+
struct M {
151+
*M(M& other); // expected-error {{invalid constructor declaration}}
152+
};
153+
154+
struct N {
155+
int N(); // expected-error {{constructor cannot have a return type}}
156+
};
157+
158+
struct O {
159+
static O(); // expected-error {{constructor cannot be declared 'static'}}
160+
};
161+
162+
struct P {
163+
explicit P();
164+
};
165+
166+
struct Q {
167+
constexpr Q();
168+
};
169+
170+
struct R {
171+
R();
172+
friend R::R();
173+
};
174+
175+
}

clang/test/SemaCXX/conversion-function.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,10 @@ using Result = B<int>::Lookup<int>;
494494
using Result = int (A2<int>::*)();
495495
}
496496
#endif
497+
498+
namespace GH121706 {
499+
struct S {
500+
*operator int(); // expected-error {{cannot specify any part of a return type in the declaration of a conversion function; put the complete type after 'operator'}}
501+
**operator char(); // expected-error {{cannot specify any part of a return type in the declaration of a conversion function; put the complete type after 'operator'}}
502+
};
503+
}

clang/test/SemaCXX/destructor.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,50 @@ struct Y : X {} y1{ }; // expected-error {{call to implicitly-deleted default co
586586
// expected-note {{default constructor of 'Y' is implicitly deleted because base class 'X' has no destructor}}
587587
}
588588

589+
namespace GH121706 {
590+
struct A {
591+
*&~A(); // expected-error {{invalid destructor declaration}}
592+
};
593+
594+
struct B {
595+
*&&~B(); // expected-error {{invalid destructor declaration}}
596+
};
597+
598+
struct C {
599+
*const ~C(); // expected-error {{invalid destructor declaration}}
600+
};
601+
602+
struct D {
603+
*const * ~D(); // expected-error {{invalid destructor declaration}}
604+
};
605+
606+
struct E {
607+
*E::*~E(); // expected-error {{invalid destructor declaration}}
608+
};
609+
610+
struct F {
611+
*F::*const ~F(); // expected-error {{invalid destructor declaration}}
612+
};
613+
614+
struct G {
615+
****~G(); // expected-error {{invalid destructor declaration}}
616+
};
617+
618+
struct H {
619+
**~H(); // expected-error {{invalid destructor declaration}}
620+
};
621+
622+
struct I {
623+
*~I(); // expected-error {{invalid destructor declaration}}
624+
};
625+
626+
struct J {
627+
*&~J(); // expected-error {{invalid destructor declaration}}
628+
};
629+
630+
struct K {
631+
**&&~K(); // expected-error {{invalid destructor declaration}}
632+
};
633+
}
634+
589635
#endif // BE_THE_HEADER

flang/docs/OpenACC-descriptor-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ acc.attach.recipe @attach_ref :
348348
%offset : index,
349349
%size : index):
350350
fir.call _FortranAOpenACCAttachDescriptor(%aug_ptr, %base_addr_val, %offset, %size) :
351-
(!fir.ref<none>, !fir.ref<!fir.box<none>>, index, index) -> none
351+
(!fir.ref<none>, !fir.ref<!fir.box<none>>, index, index) -> ()
352352
acc.yield
353353
}
354354

0 commit comments

Comments
 (0)