Skip to content

Commit 5856ee5

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:8e5b43c8effc0a01745bb7c53ca21fb6c8384c51 into amd-gfx:3cfe7da32635
Local branch amd-gfx 3cfe7da Merged main:b6a4ab5a12c9ced0642769e4b2d8f77859541ba8 into amd-gfx:6ab9923b43c0 Remote branch main 8e5b43c [AMDGPU][NewPM] Have consistent property changes in GCNDPPCombine (llvm#106520)
2 parents 3cfe7da + 8e5b43c commit 5856ee5

File tree

102 files changed

+1541
-1124
lines changed

Some content is hidden

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

102 files changed

+1541
-1124
lines changed

clang/docs/Multilib.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ For a more comprehensive example see
200200
# to be a match.
201201
Flags: [--target=thumbv7m-none-eabi, -mfpu=fpv4-sp-d16]
202202
203+
# If there is no multilib available for a particular set of flags, and the
204+
# other multilibs are not adequate fallbacks, then you can define a variant
205+
# record with a FatalError key in place of the Dir key.
206+
- FatalError: this multilib collection has no hard-float ABI support
207+
Flags: [--target=thumbv7m-none-eabi, -mfloat-abi=hard]
208+
203209
204210
# The second section of the file is a list of regular expressions that are
205211
# used to map from flags generated from command line options to custom flags.

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ Improvements to Clang's diagnostics
266266
compilation speed with modules. This warning is disabled by default and it needs
267267
to be explicitly enabled or by ``-Weverything``.
268268

269+
- Improved diagnostic when trying to overload a function in an ``extern "C"`` context. (#GH80235)
270+
269271
Improvements to Clang's time-trace
270272
----------------------------------
271273

clang/include/clang/AST/ASTContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,9 +2722,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
27222722
const ObjCMethodDecl *MethodImp);
27232723

27242724
bool UnwrapSimilarTypes(QualType &T1, QualType &T2,
2725-
bool AllowPiMismatch = true);
2725+
bool AllowPiMismatch = true) const;
27262726
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2,
2727-
bool AllowPiMismatch = true);
2727+
bool AllowPiMismatch = true) const;
27282728

27292729
/// Determine if two types are similar, according to the C++ rules. That is,
27302730
/// determine if they are the same other than qualifiers on the initial
@@ -2733,7 +2733,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
27332733
///
27342734
/// Clang offers a number of qualifiers in addition to the C++ qualifiers;
27352735
/// those qualifiers are also ignored in the 'similarity' check.
2736-
bool hasSimilarType(QualType T1, QualType T2);
2736+
bool hasSimilarType(QualType T1, QualType T2) const;
27372737

27382738
/// Determine if two types are similar, ignoring only CVR qualifiers.
27392739
bool hasCvrSimilarType(QualType T1, QualType T2);

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,8 @@ def warn_drv_missing_multilib : Warning<
810810
InGroup<DiagGroup<"missing-multilib">>;
811811
def note_drv_available_multilibs : Note<
812812
"available multilibs are:%0">;
813+
def err_drv_multilib_custom_error : Error<
814+
"multilib configuration error: %0">;
813815

814816
def err_drv_experimental_crel : Error<
815817
"-Wa,--allow-experimental-crel must be specified to use -Wa,--crel. "

clang/include/clang/CodeGen/CodeGenAction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CodeGenAction : public ASTFrontendAction {
5757
bool loadLinkModules(CompilerInstance &CI);
5858

5959
protected:
60-
bool BeginInvocation(CompilerInstance &CI) override;
60+
bool BeginSourceFileAction(CompilerInstance &CI) override;
6161

6262
/// Create a new code generation action. If the optional \p _VMContext
6363
/// parameter is supplied, the action uses it without taking ownership,

clang/include/clang/Driver/Multilib.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
#include "llvm/Support/SourceMgr.h"
1919
#include <cassert>
2020
#include <functional>
21+
#include <optional>
2122
#include <string>
2223
#include <utility>
2324
#include <vector>
2425

2526
namespace clang {
2627
namespace driver {
2728

29+
class Driver;
30+
2831
/// This corresponds to a single GCC Multilib, or a segment of one controlled
2932
/// by a command line flag.
3033
/// See also MultilibBuilder for building a multilib by mutating it
@@ -48,13 +51,19 @@ class Multilib {
4851
// directory is not mutually exclusive with anything else.
4952
std::string ExclusiveGroup;
5053

54+
// Some Multilib objects don't actually represent library directories you can
55+
// select. Instead, they represent failures of multilib selection, of the
56+
// form 'Sorry, we don't have any library compatible with these constraints'.
57+
std::optional<std::string> FatalError;
58+
5159
public:
5260
/// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
5361
/// sysroot string so they must either be empty or begin with a '/' character.
5462
/// This is enforced with an assert in the constructor.
5563
Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
5664
StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(),
57-
StringRef ExclusiveGroup = {});
65+
StringRef ExclusiveGroup = {},
66+
std::optional<StringRef> FatalError = std::nullopt);
5867

5968
/// Get the detected GCC installation path suffix for the multi-arch
6069
/// target variant. Always starts with a '/', unless empty
@@ -84,6 +93,10 @@ class Multilib {
8493
{ return GCCSuffix.empty() && OSSuffix.empty() && IncludeSuffix.empty(); }
8594

8695
bool operator==(const Multilib &Other) const;
96+
97+
bool isFatalError() const { return FatalError.has_value(); }
98+
99+
const std::string &getFatalError() const { return FatalError.value(); }
87100
};
88101

89102
raw_ostream &operator<<(raw_ostream &OS, const Multilib &M);
@@ -129,7 +142,7 @@ class MultilibSet {
129142
const_iterator end() const { return Multilibs.end(); }
130143

131144
/// Select compatible variants, \returns false if none are compatible
132-
bool select(const Multilib::flags_list &Flags,
145+
bool select(const Driver &D, const Multilib::flags_list &Flags,
133146
llvm::SmallVectorImpl<Multilib> &) const;
134147

135148
unsigned size() const { return Multilibs.size(); }

clang/include/clang/Frontend/FrontendActions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
152152
CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
153153
};
154154

155-
bool BeginInvocationForModules(CompilerInstance &CI);
156-
157155
/// Generates full BMI (which contains full information to generate the object
158156
/// files) for C++20 Named Modules.
159157
class GenerateModuleInterfaceAction : public GenerateModuleAction {
160158
protected:
161-
bool BeginInvocation(CompilerInstance &CI) override;
159+
bool BeginSourceFileAction(CompilerInstance &CI) override;
162160

163161
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
164162
StringRef InFile) override;

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class InputFile {
8888

8989
InputFile(FileEntryRef File, bool isOverridden = false,
9090
bool isOutOfDate = false) {
91+
assert(!(isOverridden && isOutOfDate) &&
92+
"an overridden cannot be out-of-date");
9193
unsigned intVal = 0;
92-
// Make isOutOfDate with higher priority than isOverridden.
93-
// It is possible if the recorded hash value mismatches.
94-
if (isOutOfDate)
95-
intVal = OutOfDate;
96-
else if (isOverridden)
94+
if (isOverridden)
9795
intVal = Overridden;
96+
else if (isOutOfDate)
97+
intVal = OutOfDate;
9898
Val.setPointerAndInt(&File.getMapEntry(), intVal);
9999
}
100100

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6581,7 +6581,7 @@ QualType ASTContext::getUnqualifiedArrayType(QualType type,
65816581
/// \param AllowPiMismatch Allow the Pi1 and Pi2 to differ as described in
65826582
/// C++20 [conv.qual], if permitted by the current language mode.
65836583
void ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2,
6584-
bool AllowPiMismatch) {
6584+
bool AllowPiMismatch) const {
65856585
while (true) {
65866586
auto *AT1 = getAsArrayType(T1);
65876587
if (!AT1)
@@ -6632,7 +6632,7 @@ void ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2,
66326632
/// \return \c true if a pointer type was unwrapped, \c false if we reached a
66336633
/// pair of types that can't be unwrapped further.
66346634
bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2,
6635-
bool AllowPiMismatch) {
6635+
bool AllowPiMismatch) const {
66366636
UnwrapSimilarArrayTypes(T1, T2, AllowPiMismatch);
66376637

66386638
const auto *T1PtrType = T1->getAs<PointerType>();
@@ -6668,7 +6668,7 @@ bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2,
66686668
return false;
66696669
}
66706670

6671-
bool ASTContext::hasSimilarType(QualType T1, QualType T2) {
6671+
bool ASTContext::hasSimilarType(QualType T1, QualType T2) const {
66726672
while (true) {
66736673
Qualifiers Quals;
66746674
T1 = getUnqualifiedArrayType(T1, Quals);

clang/lib/Basic/OpenMPKinds.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,6 @@ void clang::getOpenMPCaptureRegions(
799799
case OMPD_dispatch:
800800
case OMPD_distribute:
801801
case OMPD_for:
802-
case OMPD_masked:
803-
case OMPD_master:
804802
case OMPD_ordered:
805803
case OMPD_scope:
806804
case OMPD_sections:
@@ -813,6 +811,9 @@ void clang::getOpenMPCaptureRegions(
813811
// leafs from that directive have specific regions, then these directives
814812
// add no additional regions.
815813
return true;
814+
case OMPD_masked:
815+
case OMPD_master:
816+
return false;
816817
default:
817818
llvm::errs() << getOpenMPDirectiveName(LKind) << '\n';
818819
llvm_unreachable("Unexpected directive");

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,9 @@ CodeGenerator *CodeGenAction::getCodeGenerator() const {
969969
return BEConsumer->getCodeGenerator();
970970
}
971971

972-
bool CodeGenAction::BeginInvocation(CompilerInstance &CI) {
972+
bool CodeGenAction::BeginSourceFileAction(CompilerInstance &CI) {
973973
if (CI.getFrontendOpts().GenReducedBMI)
974-
return BeginInvocationForModules(CI);
975-
974+
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
976975
return true;
977976
}
978977

clang/lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,8 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
22962296

22972297
if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
22982298
for (const Multilib &Multilib : TC.getMultilibs())
2299-
llvm::outs() << Multilib << "\n";
2299+
if (!Multilib.isFatalError())
2300+
llvm::outs() << Multilib << "\n";
23002301
return false;
23012302
}
23022303

clang/lib/Driver/Multilib.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "clang/Driver/Multilib.h"
1010
#include "clang/Basic/LLVM.h"
1111
#include "clang/Basic/Version.h"
12+
#include "clang/Driver/Driver.h"
1213
#include "llvm/ADT/DenseSet.h"
1314
#include "llvm/ADT/SmallString.h"
1415
#include "llvm/ADT/StringRef.h"
@@ -31,9 +32,10 @@ using namespace llvm::sys;
3132

3233
Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
3334
StringRef IncludeSuffix, const flags_list &Flags,
34-
StringRef ExclusiveGroup)
35+
StringRef ExclusiveGroup,
36+
std::optional<StringRef> FatalError)
3537
: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
36-
Flags(Flags), ExclusiveGroup(ExclusiveGroup) {
38+
Flags(Flags), ExclusiveGroup(ExclusiveGroup), FatalError(FatalError) {
3739
assert(GCCSuffix.empty() ||
3840
(StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
3941
assert(OSSuffix.empty() ||
@@ -94,7 +96,7 @@ MultilibSet &MultilibSet::FilterOut(FilterCallback F) {
9496

9597
void MultilibSet::push_back(const Multilib &M) { Multilibs.push_back(M); }
9698

97-
bool MultilibSet::select(const Multilib::flags_list &Flags,
99+
bool MultilibSet::select(const Driver &D, const Multilib::flags_list &Flags,
98100
llvm::SmallVectorImpl<Multilib> &Selected) const {
99101
llvm::StringSet<> FlagSet(expandFlags(Flags));
100102
Selected.clear();
@@ -121,6 +123,14 @@ bool MultilibSet::select(const Multilib::flags_list &Flags,
121123
continue;
122124
}
123125

126+
// If this multilib is actually a placeholder containing a fatal
127+
// error message written by the multilib.yaml author, display that
128+
// error message, and return failure.
129+
if (M.isFatalError()) {
130+
D.Diag(clang::diag::err_drv_multilib_custom_error) << M.getFatalError();
131+
return false;
132+
}
133+
124134
// Select this multilib.
125135
Selected.push_back(M);
126136
}
@@ -162,7 +172,8 @@ namespace {
162172
static const VersionTuple MultilibVersionCurrent(1, 0);
163173

164174
struct MultilibSerialization {
165-
std::string Dir;
175+
std::string Dir; // if this record successfully selects a library dir
176+
std::string FatalError; // if this record reports a fatal error message
166177
std::vector<std::string> Flags;
167178
std::string Group;
168179
};
@@ -205,11 +216,16 @@ struct MultilibSetSerialization {
205216

206217
template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
207218
static void mapping(llvm::yaml::IO &io, MultilibSerialization &V) {
208-
io.mapRequired("Dir", V.Dir);
219+
io.mapOptional("Dir", V.Dir);
220+
io.mapOptional("FatalError", V.FatalError);
209221
io.mapRequired("Flags", V.Flags);
210222
io.mapOptional("Group", V.Group);
211223
}
212224
static std::string validate(IO &io, MultilibSerialization &V) {
225+
if (V.Dir.empty() && V.FatalError.empty())
226+
return "one of the 'Dir' and 'FatalError' keys must be specified";
227+
if (!V.Dir.empty() && !V.FatalError.empty())
228+
return "the 'Dir' and 'FatalError' keys may not both be specified";
213229
if (StringRef(V.Dir).starts_with("/"))
214230
return "paths must be relative but \"" + V.Dir + "\" starts with \"/\"";
215231
return std::string{};
@@ -295,14 +311,18 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
295311
multilib_list Multilibs;
296312
Multilibs.reserve(MS.Multilibs.size());
297313
for (const auto &M : MS.Multilibs) {
298-
std::string Dir;
299-
if (M.Dir != ".")
300-
Dir = "/" + M.Dir;
301-
// We transfer M.Group straight into the ExclusiveGroup parameter for the
302-
// Multilib constructor. If we later support more than one type of group,
303-
// we'll have to look up the group name in MS.Groups, check its type, and
304-
// decide what to do here.
305-
Multilibs.emplace_back(Dir, Dir, Dir, M.Flags, M.Group);
314+
if (!M.FatalError.empty()) {
315+
Multilibs.emplace_back("", "", "", M.Flags, M.Group, M.FatalError);
316+
} else {
317+
std::string Dir;
318+
if (M.Dir != ".")
319+
Dir = "/" + M.Dir;
320+
// We transfer M.Group straight into the ExclusiveGroup parameter for the
321+
// Multilib constructor. If we later support more than one type of group,
322+
// we'll have to look up the group name in MS.Groups, check its type, and
323+
// decide what to do here.
324+
Multilibs.emplace_back(Dir, Dir, Dir, M.Flags, M.Group);
325+
}
306326
}
307327

308328
return MultilibSet(std::move(Multilibs), std::move(MS.FlagMatchers));

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static bool findRISCVMultilibs(const Driver &D,
5858

5959
Result.Multilibs =
6060
MultilibSetBuilder().Either(Imac, Imafdc).makeMultilibSet();
61-
return Result.Multilibs.select(Flags, Result.SelectedMultilibs);
61+
return Result.Multilibs.select(D, Flags, Result.SelectedMultilibs);
6262
}
6363
if (TargetTriple.isRISCV32()) {
6464
MultilibBuilder Imac =
@@ -92,7 +92,7 @@ static bool findRISCVMultilibs(const Driver &D,
9292

9393
Result.Multilibs =
9494
MultilibSetBuilder().Either(I, Im, Iac, Imac, Imafc).makeMultilibSet();
95-
return Result.Multilibs.select(Flags, Result.SelectedMultilibs);
95+
return Result.Multilibs.select(D, Flags, Result.SelectedMultilibs);
9696
}
9797
return false;
9898
}
@@ -182,12 +182,13 @@ static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
182182
if (ErrorOrMultilibSet.getError())
183183
return;
184184
Result.Multilibs = ErrorOrMultilibSet.get();
185-
if (Result.Multilibs.select(Flags, Result.SelectedMultilibs))
185+
if (Result.Multilibs.select(D, Flags, Result.SelectedMultilibs))
186186
return;
187187
D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
188188
std::stringstream ss;
189189
for (const Multilib &Multilib : Result.Multilibs)
190-
ss << "\n" << llvm::join(Multilib.flags(), " ");
190+
if (!Multilib.isFatalError())
191+
ss << "\n" << llvm::join(Multilib.flags(), " ");
191192
D.Diag(clang::diag::note_drv_available_multilibs) << ss.str();
192193
}
193194

clang/lib/Driver/ToolChains/Fuchsia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
324324

325325
Multilibs.setFilePathsCallback(FilePaths);
326326

327-
if (Multilibs.select(Flags, SelectedMultilibs)) {
327+
if (Multilibs.select(D, Flags, SelectedMultilibs)) {
328328
// Ensure that -print-multi-directory only outputs one multilib directory.
329329
Multilib LastSelected = SelectedMultilibs.back();
330330
SelectedMultilibs = {LastSelected};

0 commit comments

Comments
 (0)