Skip to content

Commit 4744f12

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:56152fa377302fd8124e8be2a02dcb927a041f0a into amd-gfx:e18500ed5225
Local branch amd-gfx e18500e Merged main:73ef397fcba35b7b4239c00bf3e0b4e689ca0add into amd-gfx:fd70dbf23e48 Remote branch main 56152fa [Analysis] Guard logf128 cst folding (llvm#106543)
2 parents e18500e + 56152fa commit 4744f12

File tree

21 files changed

+2991
-849
lines changed

21 files changed

+2991
-849
lines changed

clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
203203
bool VisitUsingDecl(UsingDecl *UD) {
204204
for (const auto *Shadow : UD->shadows()) {
205205
auto *TD = Shadow->getTargetDecl();
206-
auto IsUsed = TD->isUsed() || TD->isReferenced();
206+
// For function-decls, we might have overloads brought in due to
207+
// transitive dependencies. Hence we only want to report explicit
208+
// references for those if they're used.
209+
// But for record decls, spelling of the type always refers to primary
210+
// decl non-ambiguously. Hence spelling is already a use.
211+
auto IsUsed = TD->isUsed() || TD->isReferenced() || !TD->getAsFunction();
207212
report(UD->getLocation(), TD,
208213
IsUsed ? RefType::Explicit : RefType::Ambiguous);
209214

clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ TEST(WalkAST, TemplateSpecializationsFromUsingDecl) {
255255
// Class templates
256256
testWalk(R"cpp(
257257
namespace ns {
258-
template<class T> class $ambiguous^Z {}; // primary template
258+
template<class T> class $explicit^Z {}; // primary template
259259
template<class T> class $ambiguous^Z<T*> {}; // partial specialization
260260
template<> class $ambiguous^Z<int> {}; // full specialization
261261
}
@@ -265,7 +265,7 @@ template<> class $ambiguous^Z<int> {}; // full specialization
265265
// Var templates
266266
testWalk(R"cpp(
267267
namespace ns {
268-
template<class T> T $ambiguous^foo; // primary template
268+
template<class T> T $explicit^foo; // primary template
269269
template<class T> T $ambiguous^foo<T*>; // partial specialization
270270
template<> int* $ambiguous^foo<int>; // full specialization
271271
}
@@ -335,7 +335,12 @@ TEST(WalkAST, Using) {
335335
testWalk(R"cpp(
336336
namespace ns {
337337
template<class T>
338-
class $ambiguous^Y {};
338+
class $explicit^Y {};
339+
})cpp",
340+
"using ns::^Y;");
341+
testWalk(R"cpp(
342+
namespace ns {
343+
class $explicit^Y {};
339344
})cpp",
340345
"using ns::^Y;");
341346
testWalk(R"cpp(

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,18 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
305305

306306
if (!Ptr.isLive()) {
307307
const auto &Src = S.Current->getSource(OpPC);
308-
bool IsTemp = Ptr.isTemporary();
309308

310-
S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
309+
if (Ptr.isDynamic()) {
310+
S.FFDiag(Src, diag::note_constexpr_access_deleted_object) << AK;
311+
} else {
312+
bool IsTemp = Ptr.isTemporary();
313+
S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
311314

312-
if (IsTemp)
313-
S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
314-
else
315-
S.Note(Ptr.getDeclLoc(), diag::note_declared_at);
315+
if (IsTemp)
316+
S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
317+
else
318+
S.Note(Ptr.getDeclLoc(), diag::note_declared_at);
319+
}
316320

317321
return false;
318322
}

clang/lib/AST/ByteCode/Interp.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2630,7 +2630,11 @@ inline bool Call(InterpState &S, CodePtr OpPC, const Function *Func,
26302630
if (!CheckCallable(S, OpPC, Func))
26312631
return false;
26322632

2633-
if (Func->hasThisPointer() && S.checkingPotentialConstantExpression())
2633+
// FIXME: The isConstructor() check here is not always right. The current
2634+
// constant evaluator is somewhat inconsistent in when it allows a function
2635+
// call when checking for a constant expression.
2636+
if (Func->hasThisPointer() && S.checkingPotentialConstantExpression() &&
2637+
!Func->isConstructor())
26342638
return false;
26352639

26362640
if (!CheckCallDepth(S, OpPC))

clang/lib/AST/ByteCode/InterpBlock.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
110110
Prev = nullptr;
111111
Root = this;
112112

113+
B.IsDynamic = Blk->IsDynamic;
114+
113115
// Transfer pointers.
114116
B.Pointers = Blk->Pointers;
115117
for (Pointer *P = Blk->Pointers; P; P = P->Next)

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,14 @@ class Pointer {
491491
}
492492
return false;
493493
}
494+
/// Checks if the storage has been dynamically allocated.
495+
bool isDynamic() const {
496+
if (isBlockPointer()) {
497+
assert(asBlockPointer().Pointee);
498+
return asBlockPointer().Pointee->isDynamic();
499+
}
500+
return false;
501+
}
494502
/// Checks if the storage is a static temporary.
495503
bool isStaticTemporary() const { return isStatic() && isTemporary(); }
496504

clang/test/AST/ByteCode/new-delete.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,13 @@ namespace CastedDelete {
579579
// expected-note {{in call to}}
580580
}
581581

582+
constexpr void use_after_free_2() { // both-error {{never produces a constant expression}}
583+
struct X { constexpr void f() {} };
584+
X *p = new X;
585+
delete p;
586+
p->f(); // both-note {{member call on heap allocated object that has been deleted}}
587+
}
588+
582589
#else
583590
/// Make sure we reject this prior to C++20
584591
constexpr int a() { // both-error {{never produces a constant expression}}

clang/test/AST/ByteCode/unions.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,15 @@ namespace DefaultInit {
8686

8787
#if __cplusplus >= 202002L
8888
namespace SimpleActivate {
89-
constexpr int foo() { // ref-error {{never produces a constant expression}}
89+
constexpr int foo() { // both-error {{never produces a constant expression}}
9090
union {
9191
int a;
9292
int b;
9393
} Z;
9494

9595
Z.a = 10;
9696
Z.b = 20;
97-
return Z.a; // both-note {{read of member 'a' of union with active member 'b'}} \
98-
// ref-note {{read of member 'a' of union with active member 'b}}
97+
return Z.a; // both-note 2{{read of member 'a' of union with active member 'b'}}
9998
}
10099
static_assert(foo() == 20); // both-error {{not an integral constant expression}} \
101100
// both-note {{in call to}}
@@ -212,11 +211,10 @@ namespace Nested {
212211
int y;
213212
};
214213

215-
constexpr int foo() { // ref-error {{constexpr function never produces a constant expression}}
214+
constexpr int foo() { // both-error {{constexpr function never produces a constant expression}}
216215
U2 u;
217216
u.u.a = 10;
218-
int a = u.y; // both-note {{read of member 'y' of union with active member 'u' is not allowed in a constant expression}} \
219-
// ref-note {{read of member 'y' of union with active member 'u' is not allowed in a constant expression}}
217+
int a = u.y; // both-note 2{{read of member 'y' of union with active member 'u' is not allowed in a constant expression}}
220218

221219
return 1;
222220
}
@@ -230,24 +228,22 @@ namespace Nested {
230228
}
231229
static_assert(foo2() == 10);
232230

233-
constexpr int foo3() { // ref-error {{constexpr function never produces a constant expression}}
231+
constexpr int foo3() { // both-error {{constexpr function never produces a constant expression}}
234232
U2 u;
235233
u.u.a = 10;
236-
int a = u.u.b; // both-note {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}} \
237-
// ref-note {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
234+
int a = u.u.b; // both-note 2{{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
238235

239236
return 1;
240237
}
241238
static_assert(foo3() == 1); // both-error {{not an integral constant expression}} \
242239
// both-note {{in call to}}
243240

244-
constexpr int foo4() { // ref-error {{constexpr function never produces a constant expression}}
241+
constexpr int foo4() { // both-error {{constexpr function never produces a constant expression}}
245242
U2 u;
246243

247244
u.x = 10;
248245

249-
return u.u.a;// both-note {{read of member 'u' of union with active member 'x' is not allowed in a constant expression}} \
250-
// ref-note {{read of member 'u' of union with active member 'x' is not allowed in a constant expression}}
246+
return u.u.a; // both-note 2{{read of member 'u' of union with active member 'x' is not allowed in a constant expression}}
251247
}
252248
static_assert(foo4() == 1); // both-error {{not an integral constant expression}} \
253249
// both-note {{in call to}}

lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class TestDAP_redirection_to_console(lldbdap_testcase.DAPTestCaseBase):
10-
@skipIfWindows
1110
def test(self):
1211
"""
1312
Without proper stderr and stdout redirection, the following code would throw an

lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase):
15-
@skipIfWindows
1615
@skipIfLLVMTargetMissing("X86")
1716
def test_core_file(self):
1817
current_dir = os.path.dirname(__file__)
@@ -58,7 +57,6 @@ def test_core_file(self):
5857
self.dap_server.request_next(threadId=32259)
5958
self.assertEqual(self.get_stackFrames(), expected_frames)
6059

61-
@skipIfWindows
6260
@skipIfLLVMTargetMissing("X86")
6361
def test_core_file_source_mapping(self):
6462
"""Test that sourceMap property is correctly applied when loading a core"""

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 510025
19+
#define LLVM_MAIN_REVISION 510035
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Analysis/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ add_llvm_component_library(LLVMAnalysis
163163
TargetParser
164164
)
165165

166-
include(CheckCXXSymbolExists)
167-
check_cxx_symbol_exists(logf128 math.h HAS_LOGF128)
168-
if(HAS_LOGF128)
169-
target_compile_definitions(LLVMAnalysis PRIVATE HAS_LOGF128)
166+
if(LLVM_HAS_LOGF128)
167+
target_compile_definitions(LLVMAnalysis PRIVATE HAS_LOGF128)
170168
endif()

llvm/lib/IR/BasicBlock.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,16 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
975975
if (ReadFromTail && Src->getMarker(Last)) {
976976
DbgMarker *FromLast = Src->getMarker(Last);
977977
if (LastIsEnd) {
978-
Dest->adoptDbgRecords(Src, Last, true);
979-
// adoptDbgRecords will release any trailers.
978+
if (Dest == end()) {
979+
// Abosrb the trailing markers from Src.
980+
assert(FromLast == Src->getTrailingDbgRecords());
981+
createMarker(Dest)->absorbDebugValues(*FromLast, true);
982+
FromLast->eraseFromParent();
983+
Src->deleteTrailingDbgRecords();
984+
} else {
985+
// adoptDbgRecords will release any trailers.
986+
Dest->adoptDbgRecords(Src, Last, true);
987+
}
980988
assert(!Src->getTrailingDbgRecords());
981989
} else {
982990
// FIXME: can we use adoptDbgRecords here to reduce allocations?

llvm/lib/Target/Sparc/SparcInstrAliases.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ def : InstAlias<"flush", (FLUSH), 0>;
601601
// unimp -> unimp 0
602602
def : InstAlias<"unimp", (UNIMP 0), 0>;
603603

604+
// Not in spec, but we follow Solaris behavior of having `illtrap`
605+
// interchangeable with `unimp` all the time.
606+
def : MnemonicAlias<"illtrap", "unimp">;
607+
604608
def : MnemonicAlias<"iflush", "flush">;
605609

606610
def : MnemonicAlias<"stub", "stb">;

0 commit comments

Comments
 (0)