Skip to content

Commit ada1fc7

Browse files
committed
Merged main:9ad4ebd82b60 into amd-gfx:5feec07126dd
Local branch amd-gfx 5feec07 Merged main:f3549814f8a2 into amd-gfx:681f277691b2 Remote branch main 9ad4ebd [mlir][OpenMP][NFC] break out priv var init into helper (llvm#125303) Change-Id: Iaab6369bc4c75c936271600caef96625ecc7394c
2 parents 5feec07 + 9ad4ebd commit ada1fc7

File tree

408 files changed

+10251
-8652
lines changed

Some content is hidden

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

408 files changed

+10251
-8652
lines changed

.github/workflows/premerge.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ jobs:
139139
group: ${{ github.workflow }}-macos-${{ github.event.pull_request.number || github.sha }}
140140
cancel-in-progress: true
141141
if: >-
142+
github.repository_owner == 'llvm' &&
142143
(startswith(github.ref_name, 'release/') ||
143-
startswith(github.base_ref, 'refs/heads/release/'))
144+
startswith(github.base_ref, 'release/'))
144145
steps:
145146
- name: Checkout LLVM
146147
uses: actions/checkout@v4

bolt/test/X86/dynamic-relocs-on-entry.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
# RUN: %clang %cflags -fPIC -pie %s -o %t.exe -nostdlib -Wl,-q
66
# RUN: llvm-bolt %t.exe -o %t.bolt > %t.out.txt
7-
# RUN: readelf -r %t.bolt >> %t.out.txt
7+
# RUN: llvm-readelf -r %t.bolt >> %t.out.txt
88
# RUN: llvm-objdump --disassemble-symbols=chain %t.bolt >> %t.out.txt
99
# RUN: FileCheck %s --input-file=%t.out.txt
1010

1111
## Check if the new address in `chain` is correctly updated by BOLT
12-
# CHECK: Relocation section '.rela.dyn' at offset 0x{{.*}} contains 1 entry:
12+
# CHECK: Relocation section '.rela.dyn' at offset 0x{{.*}} contains 1 entries:
1313
# CHECK: {{.*}} R_X86_64_RELATIVE [[#%x,ADDR:]]
1414
# CHECK: [[#ADDR]]: c3 retq
1515
.text
@@ -29,4 +29,4 @@ _start:
2929

3030
.data
3131
.Lfoo:
32-
.quad Label
32+
.quad Label

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ Code Completion
219219
Static Analyzer
220220
---------------
221221

222+
- Clang currently support extending lifetime of object bound to
223+
reference members of aggregates in CFG and ExprEngine, that are
224+
created from default member initializer.
225+
222226
New features
223227
^^^^^^^^^^^^
224228

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5040,7 +5040,7 @@ class CXXParenListInitExpr final
50405040
}
50415041

50425042
const FieldDecl *getInitializedFieldInUnion() const {
5043-
return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5043+
return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
50445044
}
50455045

50465046
child_range children() {

clang/include/clang/Driver/Options.td

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7302,6 +7302,9 @@ let Visibility = [CC1Option, FC1Option] in {
73027302
def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">,
73037303
HelpText<"Link and internalize needed symbols from the given bitcode file "
73047304
"before performing optimizations.">;
7305+
def mlink_bitcode_file
7306+
: Separate<["-"], "mlink-bitcode-file">,
7307+
HelpText<"Link the given bitcode file before performing optimizations.">;
73057308
} // let Visibility = [CC1Option, FC1Option]
73067309

73077310
let Visibility = [CC1Option] in {
@@ -7405,14 +7408,13 @@ def msmall_data_limit : Separate<["-"], "msmall-data-limit">,
74057408
def funwind_tables_EQ : Joined<["-"], "funwind-tables=">,
74067409
HelpText<"Generate unwinding tables for all functions">,
74077410
MarshallingInfoInt<CodeGenOpts<"UnwindTables">>;
7408-
defm constructor_aliases : BoolMOption<"constructor-aliases",
7409-
CodeGenOpts<"CXXCtorDtorAliases">, DefaultFalse,
7410-
PosFlag<SetTrue, [], [ClangOption], "Enable">,
7411-
NegFlag<SetFalse, [], [ClangOption], "Disable">,
7412-
BothFlags<[], [ClangOption, CC1Option],
7413-
" emitting complete constructors and destructors as aliases when possible">>;
7414-
def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">,
7415-
HelpText<"Link the given bitcode file before performing optimizations.">;
7411+
defm constructor_aliases
7412+
: BoolMOption<"constructor-aliases", CodeGenOpts<"CXXCtorDtorAliases">,
7413+
DefaultFalse, PosFlag<SetTrue, [], [ClangOption], "Enable">,
7414+
NegFlag<SetFalse, [], [ClangOption], "Disable">,
7415+
BothFlags<[], [ClangOption, CC1Option],
7416+
" emitting complete constructors and destructors "
7417+
"as aliases when possible">>;
74167418
defm link_builtin_bitcode_postopt: BoolMOption<"link-builtin-bitcode-postopt",
74177419
CodeGenOpts<"LinkBitcodePostopt">, DefaultFalse,
74187420
PosFlag<SetTrue, [], [ClangOption], "Link builtin bitcodes after the "

clang/include/clang/Lex/Preprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ class Preprocessor {
933933
}
934934

935935
ArrayRef<ModuleMacro*> getOverriddenMacros() const {
936-
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
936+
if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
937937
return Info->OverriddenMacros;
938938
return {};
939939
}

clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,8 @@ class BugReporterContext {
748748
/// It can be valuable to produce tags with some bits of information and later
749749
/// reuse them for a better diagnostic.
750750
///
751-
/// Please make sure that derived class' constuctor is private and that the user
752-
/// can only create objects using DataTag::Factory. This also means that
751+
/// Please make sure that derived class' constructor is private and that the
752+
/// user can only create objects using DataTag::Factory. This also means that
753753
/// DataTag::Factory should be friend for every derived class.
754754
class DataTag : public ProgramPointTag {
755755
public:

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ class SMTConstraintManager : public clang::ento::SimpleConstraintManager {
353353
addStateConstraints(NewState);
354354

355355
std::optional<bool> res = Solver->check();
356-
if (!res)
357-
Cached[hash] = ConditionTruthVal();
358-
else
359-
Cached[hash] = ConditionTruthVal(*res);
360-
361-
return Cached[hash];
356+
return Cached[hash] = res ? ConditionTruthVal(*res) : ConditionTruthVal();
362357
}
363358

364359
// Cache the result of an SMT query (true, false, unknown). The key is the

clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
135135
// Create a handle over the emitted code.
136136
Function *Func = P.getFunction(FuncDecl);
137137
if (!Func) {
138-
unsigned BuiltinID = FuncDecl->getBuiltinID();
139-
Func =
140-
P.createFunction(FuncDecl, ParamOffset, std::move(ParamTypes),
141-
std::move(ParamDescriptors), std::move(ParamOffsets),
142-
HasThisPointer, HasRVO, BuiltinID);
138+
Func = P.createFunction(FuncDecl, ParamOffset, std::move(ParamTypes),
139+
std::move(ParamDescriptors),
140+
std::move(ParamOffsets), HasThisPointer, HasRVO);
143141
}
144142

145143
assert(Func);
@@ -212,8 +210,7 @@ Function *ByteCodeEmitter::compileObjCBlock(const BlockExpr *BE) {
212210
Function *Func =
213211
P.createFunction(BE, ParamOffset, std::move(ParamTypes),
214212
std::move(ParamDescriptors), std::move(ParamOffsets),
215-
/*HasThisPointer=*/false, /*HasRVO=*/false,
216-
/*IsUnevaluatedBuiltin=*/false);
213+
/*HasThisPointer=*/false, /*HasRVO=*/false);
217214

218215
assert(Func);
219216
Func->setDefined(true);

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,8 +4991,8 @@ bool Compiler<Emitter>::visitCompoundStmt(const CompoundStmt *S) {
49914991
template <class Emitter>
49924992
bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
49934993
for (const auto *D : DS->decls()) {
4994-
if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl, UsingEnumDecl,
4995-
FunctionDecl>(D))
4994+
if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl, BaseUsingDecl,
4995+
FunctionDecl, NamespaceAliasDecl>(D))
49964996
continue;
49974997

49984998
const auto *VD = dyn_cast<VarDecl>(D);

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,11 @@ const llvm::fltSemantics &Context::getFloatSemantics(QualType T) const {
212212
bool Context::Run(State &Parent, const Function *Func) {
213213

214214
{
215-
InterpState State(Parent, *P, Stk, *this);
216-
State.Current = new InterpFrame(State, Func, /*Caller=*/nullptr, CodePtr(),
217-
Func->getArgSize());
215+
InterpState State(Parent, *P, Stk, *this, Func);
218216
if (Interpret(State)) {
219217
assert(Stk.empty());
220218
return true;
221219
}
222-
223220
// State gets destroyed here, so the Stk.clear() below doesn't accidentally
224221
// remove values the State's destructor might access.
225222
}

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ using namespace clang::interp;
1717

1818
EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State &Parent,
1919
InterpStack &Stk)
20-
: Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx),
21-
BottomFrame(S) {
22-
S.Current = &BottomFrame;
23-
}
20+
: Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {}
2421

2522
EvalEmitter::~EvalEmitter() {
2623
for (auto &[K, V] : Locals) {

clang/lib/AST/ByteCode/EvalEmitter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ class EvalEmitter : public SourceMapper {
122122
/// Active block which should be executed.
123123
LabelTy ActiveLabel = 0;
124124

125-
InterpFrame BottomFrame;
126-
127125
protected:
128126
#define GET_EVAL_PROTO
129127
#include "Opcodes.inc"

clang/lib/AST/ByteCode/Function.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,28 @@ Function::Function(Program &P, FunctionDeclTy Source, unsigned ArgSize,
1919
llvm::SmallVectorImpl<PrimType> &&ParamTypes,
2020
llvm::DenseMap<unsigned, ParamDescriptor> &&Params,
2121
llvm::SmallVectorImpl<unsigned> &&ParamOffsets,
22-
bool HasThisPointer, bool HasRVO, unsigned BuiltinID)
23-
: P(P), Source(Source), ArgSize(ArgSize), ParamTypes(std::move(ParamTypes)),
24-
Params(std::move(Params)), ParamOffsets(std::move(ParamOffsets)),
25-
HasThisPointer(HasThisPointer), HasRVO(HasRVO), BuiltinID(BuiltinID) {
26-
if (const auto *F = Source.dyn_cast<const FunctionDecl *>())
22+
bool HasThisPointer, bool HasRVO)
23+
: P(P), Kind(FunctionKind::Normal), Source(Source), ArgSize(ArgSize),
24+
ParamTypes(std::move(ParamTypes)), Params(std::move(Params)),
25+
ParamOffsets(std::move(ParamOffsets)), HasThisPointer(HasThisPointer),
26+
HasRVO(HasRVO) {
27+
if (const auto *F = dyn_cast<const FunctionDecl *>(Source)) {
2728
Variadic = F->isVariadic();
29+
BuiltinID = F->getBuiltinID();
30+
if (const auto *CD = dyn_cast<CXXConstructorDecl>(F)) {
31+
Virtual = CD->isVirtual();
32+
Kind = FunctionKind::Ctor;
33+
} else if (const auto *CD = dyn_cast<CXXDestructorDecl>(F)) {
34+
Virtual = CD->isVirtual();
35+
Kind = FunctionKind::Dtor;
36+
} else if (const auto *MD = dyn_cast<CXXMethodDecl>(F)) {
37+
Virtual = MD->isVirtual();
38+
if (MD->isLambdaStaticInvoker())
39+
Kind = FunctionKind::LambdaStaticInvoker;
40+
else if (clang::isLambdaCallOperator(F))
41+
Kind = FunctionKind::LambdaCallOperator;
42+
}
43+
}
2844
}
2945

3046
Function::ParamDescriptor Function::getParamDescriptor(unsigned Offset) const {
@@ -45,13 +61,6 @@ SourceInfo Function::getSource(CodePtr PC) const {
4561
return It->second;
4662
}
4763

48-
bool Function::isVirtual() const {
49-
if (const auto *M = dyn_cast_if_present<CXXMethodDecl>(
50-
Source.dyn_cast<const FunctionDecl *>()))
51-
return M->isVirtual();
52-
return false;
53-
}
54-
5564
/// Unevaluated builtins don't get their arguments put on the stack
5665
/// automatically. They instead operate on the AST of their Call
5766
/// Expression.

clang/lib/AST/ByteCode/Function.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ using FunctionDeclTy =
8080
///
8181
class Function final {
8282
public:
83+
enum class FunctionKind {
84+
Normal,
85+
Ctor,
86+
Dtor,
87+
LambdaStaticInvoker,
88+
LambdaCallOperator,
89+
};
8390
using ParamDescriptor = std::pair<PrimType, Descriptor *>;
8491

8592
/// Returns the size of the function's local stack.
@@ -141,43 +148,31 @@ class Function final {
141148
bool isConstexpr() const { return IsValid || isLambdaStaticInvoker(); }
142149

143150
/// Checks if the function is virtual.
144-
bool isVirtual() const;
151+
bool isVirtual() const { return Virtual; };
145152

146153
/// Checks if the function is a constructor.
147-
bool isConstructor() const {
148-
return isa_and_nonnull<CXXConstructorDecl>(
149-
dyn_cast<const FunctionDecl *>(Source));
150-
}
154+
bool isConstructor() const { return Kind == FunctionKind::Ctor; }
151155
/// Checks if the function is a destructor.
152-
bool isDestructor() const {
153-
return isa_and_nonnull<CXXDestructorDecl>(
154-
dyn_cast<const FunctionDecl *>(Source));
155-
}
156-
157-
/// Returns the parent record decl, if any.
158-
const CXXRecordDecl *getParentDecl() const {
159-
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
160-
dyn_cast<const FunctionDecl *>(Source)))
161-
return MD->getParent();
162-
return nullptr;
163-
}
156+
bool isDestructor() const { return Kind == FunctionKind::Dtor; }
164157

165158
/// Returns whether this function is a lambda static invoker,
166159
/// which we generate custom byte code for.
167160
bool isLambdaStaticInvoker() const {
168-
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
169-
dyn_cast<const FunctionDecl *>(Source)))
170-
return MD->isLambdaStaticInvoker();
171-
return false;
161+
return Kind == FunctionKind::LambdaStaticInvoker;
172162
}
173163

174164
/// Returns whether this function is the call operator
175165
/// of a lambda record decl.
176166
bool isLambdaCallOperator() const {
167+
return Kind == FunctionKind::LambdaCallOperator;
168+
}
169+
170+
/// Returns the parent record decl, if any.
171+
const CXXRecordDecl *getParentDecl() const {
177172
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
178173
dyn_cast<const FunctionDecl *>(Source)))
179-
return clang::isLambdaCallOperator(MD);
180-
return false;
174+
return MD->getParent();
175+
return nullptr;
181176
}
182177

183178
/// Checks if the function is fully done compiling.
@@ -213,7 +208,7 @@ class Function final {
213208

214209
bool isThisPointerExplicit() const {
215210
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
216-
Source.dyn_cast<const FunctionDecl *>()))
211+
dyn_cast<const FunctionDecl *>(Source)))
217212
return MD->isExplicitObjectMemberFunction();
218213
return false;
219214
}
@@ -232,7 +227,7 @@ class Function final {
232227
llvm::SmallVectorImpl<PrimType> &&ParamTypes,
233228
llvm::DenseMap<unsigned, ParamDescriptor> &&Params,
234229
llvm::SmallVectorImpl<unsigned> &&ParamOffsets, bool HasThisPointer,
235-
bool HasRVO, unsigned BuiltinID);
230+
bool HasRVO);
236231

237232
/// Sets the code of a function.
238233
void setCode(unsigned NewFrameSize, std::vector<std::byte> &&NewCode,
@@ -255,6 +250,8 @@ class Function final {
255250

256251
/// Program reference.
257252
Program &P;
253+
/// Function Kind.
254+
FunctionKind Kind;
258255
/// Declaration this function was compiled from.
259256
FunctionDeclTy Source;
260257
/// Local area size: storage + metadata.
@@ -289,6 +286,7 @@ class Function final {
289286
bool HasBody = false;
290287
bool Defined = false;
291288
bool Variadic = false;
289+
bool Virtual = false;
292290
unsigned BuiltinID = 0;
293291

294292
public:

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
6565
const ValueDecl *VD);
6666
static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
6767
const ValueDecl *D) {
68-
const SourceInfo &E = S.Current->getSource(OpPC);
6968

7069
if (isa<ParmVarDecl>(D)) {
7170
if (D->getType()->isReferenceType())
7271
return false;
7372

73+
const SourceInfo &Loc = S.Current->getSource(OpPC);
7474
if (S.getLangOpts().CPlusPlus11) {
75-
S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
75+
S.FFDiag(Loc, diag::note_constexpr_function_param_value_unknown) << D;
7676
S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
7777
} else {
78-
S.FFDiag(E);
78+
S.FFDiag(Loc);
7979
}
8080
return false;
8181
}

0 commit comments

Comments
 (0)