Skip to content

Commit 5f19228

Browse files
committed
merge main into amd-staging
2 parents af81ade + aa2fe4e commit 5f19228

File tree

20 files changed

+407
-168
lines changed

20 files changed

+407
-168
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6745,6 +6745,22 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
67456745
// value.
67466746
bool IsReference = D->getType()->isReferenceType();
67476747

6748+
// Function parameters.
6749+
// Note that it's important to check them first since we might have a local
6750+
// variable created for a ParmVarDecl as well.
6751+
if (const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
6752+
if (Ctx.getLangOpts().CPlusPlus && !Ctx.getLangOpts().CPlusPlus11 &&
6753+
!D->getType()->isIntegralOrEnumerationType()) {
6754+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6755+
/*InitializerFailed=*/false, E);
6756+
}
6757+
if (auto It = this->Params.find(PVD); It != this->Params.end()) {
6758+
if (IsReference || !It->second.IsPtr)
6759+
return this->emitGetParam(classifyPrim(E), It->second.Offset, E);
6760+
6761+
return this->emitGetPtrParam(It->second.Offset, E);
6762+
}
6763+
}
67486764
// Local variables.
67496765
if (auto It = Locals.find(D); It != Locals.end()) {
67506766
const unsigned Offset = It->second.Offset;
@@ -6762,20 +6778,6 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
67626778

67636779
return this->emitGetPtrGlobal(*GlobalIndex, E);
67646780
}
6765-
// Function parameters.
6766-
if (const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
6767-
if (Ctx.getLangOpts().CPlusPlus && !Ctx.getLangOpts().CPlusPlus11 &&
6768-
!D->getType()->isIntegralOrEnumerationType()) {
6769-
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6770-
/*InitializerFailed=*/false, E);
6771-
}
6772-
if (auto It = this->Params.find(PVD); It != this->Params.end()) {
6773-
if (IsReference || !It->second.IsPtr)
6774-
return this->emitGetParam(classifyPrim(E), It->second.Offset, E);
6775-
6776-
return this->emitGetPtrParam(It->second.Offset, E);
6777-
}
6778-
}
67796781

67806782
// In case we need to re-visit a declaration.
67816783
auto revisit = [&](const VarDecl *VD) -> bool {

clang/test/AST/ByteCode/functions.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,3 +713,22 @@ namespace EnableIfWithTemporary {
713713
struct A { ~A(); };
714714
int &h() __attribute__((enable_if((A(), true), ""))); // both-warning {{clang extension}}
715715
}
716+
717+
namespace LocalVarForParmVarDecl {
718+
struct Iter {
719+
void *p;
720+
};
721+
constexpr bool bar2(Iter A) {
722+
return true;
723+
}
724+
constexpr bool bar(Iter A, bool b) {
725+
if (b)
726+
return true;
727+
728+
return bar(A, true);
729+
}
730+
constexpr int foo() {
731+
return bar(Iter(), false);
732+
}
733+
static_assert(foo(), "");
734+
}

llvm/benchmarks/CMakeLists.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,3 @@ add_benchmark(SandboxIRBench SandboxIRBench.cpp PARTIAL_SOURCES_INTENDED)
1414
add_benchmark(RuntimeLibcallsBench RuntimeLibcalls.cpp PARTIAL_SOURCES_INTENDED)
1515

1616

17-
if(TARGET llvm-nm)
18-
# Extract the list of symbols in a random utility as sample data.
19-
set(SYMBOL_TEST_DATA_FILE "sample_symbol_list.txt")
20-
set(SYMBOL_TEST_DATA_SOURCE_BINARY $<TARGET_FILE:llc>)
21-
22-
add_custom_command(OUTPUT ${SYMBOL_TEST_DATA_FILE}
23-
COMMAND $<TARGET_FILE:llvm-nm> --no-demangle --no-sort
24-
--format=just-symbols
25-
${SYMBOL_TEST_DATA_SOURCE_BINARY} > ${SYMBOL_TEST_DATA_FILE}
26-
DEPENDS "$<TARGET_FILE:llvm-nm>" "$<TARGET_FILE:llc>")
27-
28-
add_custom_target(generate-runtime-libcalls-sample-symbol-list
29-
DEPENDS ${SYMBOL_TEST_DATA_FILE})
30-
31-
add_dependencies(RuntimeLibcallsBench generate-runtime-libcalls-sample-symbol-list)
32-
target_compile_definitions(RuntimeLibcallsBench PRIVATE
33-
-DSYMBOL_TEST_DATA_FILE="${CMAKE_CURRENT_BINARY_DIR}/${SYMBOL_TEST_DATA_FILE}")
34-
endif()

llvm/docs/LangRef.rst

Lines changed: 51 additions & 51 deletions
Large diffs are not rendered by default.

llvm/include/llvm/ADT/SmallPtrSet.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ class SmallPtrSetImplBase : public DebugEpochBase {
160160
return make_range(CurArray, EndPointer());
161161
}
162162

163+
iterator_range<const void *const *> buckets() const {
164+
return make_range(CurArray, EndPointer());
165+
}
166+
163167
/// insert_imp - This returns true if the pointer was new to the set, false if
164168
/// it was already in the set. This is hidden from the client so that the
165169
/// derived class can check that the right type of pointer is passed in.

llvm/include/llvm/IR/Instruction.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,10 @@ class Instruction : public User,
584584
dropUBImplyingAttrsAndUnknownMetadata(ArrayRef<unsigned> KnownIDs = {});
585585

586586
/// Drop any attributes or metadata that can cause immediate undefined
587-
/// behavior. Retain other attributes/metadata on a best-effort basis.
588-
/// This should be used when speculating instructions.
589-
LLVM_ABI void dropUBImplyingAttrsAndMetadata();
587+
/// behavior. Retain other attributes/metadata on a best-effort basis, as well
588+
/// as those passed in `Keep`. This should be used when speculating
589+
/// instructions.
590+
LLVM_ABI void dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep = {});
590591

591592
/// Return true if this instruction has UB-implying attributes
592593
/// that can cause immediate undefined behavior.

llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class SSAUpdaterImpl {
366366
continue;
367367

368368
// Look for an existing PHI.
369-
FindExistingPHI(Info->BB, BlockList);
369+
FindExistingPHI(Info->BB);
370370
if (Info->AvailableVal)
371371
continue;
372372

@@ -412,19 +412,19 @@ class SSAUpdaterImpl {
412412

413413
/// FindExistingPHI - Look through the PHI nodes in a block to see if any of
414414
/// them match what is needed.
415-
void FindExistingPHI(BlkT *BB, BlockListTy *BlockList) {
415+
void FindExistingPHI(BlkT *BB) {
416416
SmallVector<BBInfo *, 20> TaggedBlocks;
417417
for (auto &SomePHI : BB->phis()) {
418418
if (CheckIfPHIMatches(&SomePHI, TaggedBlocks)) {
419-
RecordMatchingPHIs(BlockList);
419+
RecordMatchingPHIs(TaggedBlocks);
420420
break;
421421
}
422422
}
423423
}
424424

425425
/// CheckIfPHIMatches - Check if a PHI node matches the placement and values
426426
/// in the BBMap.
427-
bool CheckIfPHIMatches(PhiT *PHI, SmallVectorImpl<BBInfo *> &TaggedBlocks) {
427+
bool CheckIfPHIMatches(PhiT *PHI, BlockListTy &TaggedBlocks) {
428428
// Match failed: clear all the PHITag values. Only need to clear visited
429429
// blocks.
430430
auto Cleanup = make_scope_exit([&]() {
@@ -484,15 +484,15 @@ class SSAUpdaterImpl {
484484

485485
/// RecordMatchingPHIs - For each PHI node that matches, record it in both
486486
/// the BBMap and the AvailableVals mapping.
487-
void RecordMatchingPHIs(BlockListTy *BlockList) {
488-
for (typename BlockListTy::iterator I = BlockList->begin(),
489-
E = BlockList->end(); I != E; ++I)
490-
if (PhiT *PHI = (*I)->PHITag) {
491-
BlkT *BB = PHI->getParent();
492-
ValT PHIVal = Traits::GetPHIValue(PHI);
493-
(*AvailableVals)[BB] = PHIVal;
494-
BBMap[BB]->AvailableVal = PHIVal;
495-
}
487+
void RecordMatchingPHIs(BlockListTy &TaggedBlocks) {
488+
for (BBInfo *Block : TaggedBlocks) {
489+
PhiT *PHI = Block->PHITag;
490+
assert(PHI && "PHITag didn't set?");
491+
BlkT *BB = PHI->getParent();
492+
ValT PHIVal = Traits::GetPHIValue(PHI);
493+
(*AvailableVals)[BB] = PHIVal;
494+
BBMap[BB]->AvailableVal = PHIVal;
495+
}
496496
}
497497
};
498498

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,10 @@ bool RuntimeDyldELF::resolveLoongArch64ShortBranch(
654654
if (Loc == GlobalSymbolTable.end())
655655
return false;
656656
const auto &SymInfo = Loc->second;
657-
Address =
658-
uint64_t(Sections[SymInfo.getSectionID()].getLoadAddressWithOffset(
659-
SymInfo.getOffset()));
657+
Address = Sections[SymInfo.getSectionID()].getLoadAddressWithOffset(
658+
SymInfo.getOffset());
660659
} else {
661-
Address = uint64_t(Sections[Value.SectionID].getLoadAddress());
660+
Address = Sections[Value.SectionID].getLoadAddress();
662661
}
663662
uint64_t Offset = RelI->getOffset();
664663
uint64_t SourceAddress = Sections[SectionID].getLoadAddressWithOffset(Offset);

llvm/lib/IR/Instruction.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,19 @@ void Instruction::dropUBImplyingAttrsAndUnknownMetadata(
552552
CB->removeRetAttrs(UBImplyingAttributes);
553553
}
554554

555-
void Instruction::dropUBImplyingAttrsAndMetadata() {
555+
void Instruction::dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep) {
556556
// !annotation metadata does not impact semantics.
557557
// !range, !nonnull and !align produce poison, so they are safe to speculate.
558558
// !noundef and various AA metadata must be dropped, as it generally produces
559559
// immediate undefined behavior.
560-
unsigned KnownIDs[] = {LLVMContext::MD_annotation, LLVMContext::MD_range,
561-
LLVMContext::MD_nonnull, LLVMContext::MD_align};
562-
dropUBImplyingAttrsAndUnknownMetadata(KnownIDs);
560+
static const unsigned KnownIDs[] = {
561+
LLVMContext::MD_annotation, LLVMContext::MD_range,
562+
LLVMContext::MD_nonnull, LLVMContext::MD_align};
563+
SmallVector<unsigned> KeepIDs;
564+
KeepIDs.reserve(Keep.size() + std::size(KnownIDs));
565+
append_range(KeepIDs, KnownIDs);
566+
append_range(KeepIDs, Keep);
567+
dropUBImplyingAttrsAndUnknownMetadata(KeepIDs);
563568
}
564569

565570
bool Instruction::hasUBImplyingAttrs() const {

llvm/lib/Support/SmallPtrSet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "llvm/ADT/SmallPtrSet.h"
1515
#include "llvm/ADT/DenseMapInfo.h"
16+
#include "llvm/ADT/STLExtras.h"
1617
#include "llvm/Support/MathExtras.h"
1718
#include "llvm/Support/MemAlloc.h"
1819
#include <algorithm>
@@ -190,7 +191,7 @@ void SmallPtrSetImplBase::copyHelper(const SmallPtrSetImplBase &RHS) {
190191
CurArraySize = RHS.CurArraySize;
191192

192193
// Copy over the contents from the other set
193-
std::copy(RHS.CurArray, RHS.EndPointer(), CurArray);
194+
llvm::copy(RHS.buckets(), CurArray);
194195

195196
NumEntries = RHS.NumEntries;
196197
NumTombstones = RHS.NumTombstones;
@@ -214,7 +215,7 @@ void SmallPtrSetImplBase::moveHelper(const void **SmallStorage,
214215
if (RHS.isSmall()) {
215216
// Copy a small RHS rather than moving.
216217
CurArray = SmallStorage;
217-
std::copy(RHS.CurArray, RHS.CurArray + RHS.NumEntries, CurArray);
218+
llvm::copy(RHS.small_buckets(), CurArray);
218219
} else {
219220
CurArray = RHS.CurArray;
220221
RHS.CurArray = RHSSmallStorage;
@@ -252,7 +253,7 @@ void SmallPtrSetImplBase::swap(const void **SmallStorage,
252253
// If only RHS is small, copy the small elements into LHS and move the pointer
253254
// from LHS to RHS.
254255
if (!this->isSmall() && RHS.isSmall()) {
255-
std::copy(RHS.CurArray, RHS.CurArray + RHS.NumEntries, SmallStorage);
256+
llvm::copy(RHS.small_buckets(), SmallStorage);
256257
std::swap(RHS.CurArraySize, this->CurArraySize);
257258
std::swap(this->NumEntries, RHS.NumEntries);
258259
std::swap(this->NumTombstones, RHS.NumTombstones);
@@ -266,8 +267,7 @@ void SmallPtrSetImplBase::swap(const void **SmallStorage,
266267
// If only LHS is small, copy the small elements into RHS and move the pointer
267268
// from RHS to LHS.
268269
if (this->isSmall() && !RHS.isSmall()) {
269-
std::copy(this->CurArray, this->CurArray + this->NumEntries,
270-
RHSSmallStorage);
270+
llvm::copy(this->small_buckets(), RHSSmallStorage);
271271
std::swap(RHS.CurArraySize, this->CurArraySize);
272272
std::swap(RHS.NumEntries, this->NumEntries);
273273
std::swap(RHS.NumTombstones, this->NumTombstones);

0 commit comments

Comments
 (0)