Skip to content

Commit ac6784f

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:fef1bec39642 into amd-gfx:b13841aa3970
Local branch amd-gfx b13841a Merged main:11fbbcb3106a into amd-gfx:2fc17a552619 Remote branch main fef1bec [X86]Remove X86-specific dead code in ScheduleDAGRRList.cpp (llvm#67629)
2 parents b13841a + fef1bec commit ac6784f

File tree

5 files changed

+45
-12
lines changed

5 files changed

+45
-12
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,8 @@ bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) {
881881

882882
// If the initializer string is too long, a diagnostic has already been
883883
// emitted. Read only the array length from the string literal.
884-
unsigned N =
885-
std::min(unsigned(CAT->getSize().getZExtValue()), E->getLength());
884+
unsigned ArraySize = CAT->getSize().getZExtValue();
885+
unsigned N = std::min(ArraySize, E->getLength());
886886
size_t CharWidth = E->getCharByteWidth();
887887

888888
for (unsigned I = 0; I != N; ++I) {
@@ -901,6 +901,23 @@ bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) {
901901
llvm_unreachable("unsupported character width");
902902
}
903903
}
904+
905+
// Fill up the rest of the char array with NUL bytes.
906+
for (unsigned I = N; I != ArraySize; ++I) {
907+
if (CharWidth == 1) {
908+
this->emitConstSint8(0, E);
909+
this->emitInitElemSint8(I, E);
910+
} else if (CharWidth == 2) {
911+
this->emitConstUint16(0, E);
912+
this->emitInitElemUint16(I, E);
913+
} else if (CharWidth == 4) {
914+
this->emitConstUint32(0, E);
915+
this->emitInitElemUint32(I, E);
916+
} else {
917+
llvm_unreachable("unsupported character width");
918+
}
919+
}
920+
904921
return true;
905922
}
906923

clang/test/AST/Interp/arrays.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,24 @@ namespace ArrayInitLoop {
369369
static_assert(g() == 6); // expected-error {{failed}} \
370370
// expected-note {{15 == 6}}
371371
}
372+
373+
namespace StringZeroFill {
374+
struct A {
375+
char c[6];
376+
};
377+
constexpr A a = { "abc" };
378+
static_assert(a.c[0] == 'a', "");
379+
static_assert(a.c[1] == 'b', "");
380+
static_assert(a.c[2] == 'c', "");
381+
static_assert(a.c[3] == '\0', "");
382+
static_assert(a.c[4] == '\0', "");
383+
static_assert(a.c[5] == '\0', "");
384+
385+
constexpr char b[6] = "foo";
386+
static_assert(b[0] == 'f', "");
387+
static_assert(b[1] == 'o', "");
388+
static_assert(b[2] == 'o', "");
389+
static_assert(b[3] == '\0', "");
390+
static_assert(b[4] == '\0', "");
391+
static_assert(b[5] == '\0', "");
392+
}

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 476444
19+
#define LLVM_MAIN_REVISION 476447
2020

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

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,6 @@ SUnit *ScheduleDAGRRList::TryUnfoldSU(SUnit *SU) {
986986
if (!TII->unfoldMemoryOperand(*DAG, N, NewNodes))
987987
return nullptr;
988988

989-
// unfolding an x86 DEC64m operation results in store, dec, load which
990-
// can't be handled here so quit
991-
if (NewNodes.size() == 3)
992-
return nullptr;
993-
994989
assert(NewNodes.size() == 2 && "Expected a load folding node!");
995990

996991
N = NewNodes[1];

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,19 +702,19 @@ static SmallString<32> getIRFileDisplayName(Any IR) {
702702
stable_hash NameHash = stable_hash_combine_string(M->getName());
703703
unsigned int MaxHashWidth = sizeof(stable_hash) * 8 / 4;
704704
write_hex(ResultStream, NameHash, HexPrintStyle::Lower, MaxHashWidth);
705-
if (any_cast<const Module *>(&IR)) {
705+
if (llvm::any_cast<const Module *>(&IR)) {
706706
ResultStream << "-module";
707-
} else if (const Function **F = any_cast<const Function *>(&IR)) {
707+
} else if (const Function **F = llvm::any_cast<const Function *>(&IR)) {
708708
ResultStream << "-function-";
709709
stable_hash FunctionNameHash = stable_hash_combine_string((*F)->getName());
710710
write_hex(ResultStream, FunctionNameHash, HexPrintStyle::Lower,
711711
MaxHashWidth);
712712
} else if (const LazyCallGraph::SCC **C =
713-
any_cast<const LazyCallGraph::SCC *>(&IR)) {
713+
llvm::any_cast<const LazyCallGraph::SCC *>(&IR)) {
714714
ResultStream << "-scc-";
715715
stable_hash SCCNameHash = stable_hash_combine_string((*C)->getName());
716716
write_hex(ResultStream, SCCNameHash, HexPrintStyle::Lower, MaxHashWidth);
717-
} else if (const Loop **L = any_cast<const Loop *>(&IR)) {
717+
} else if (const Loop **L = llvm::any_cast<const Loop *>(&IR)) {
718718
ResultStream << "-loop-";
719719
stable_hash LoopNameHash = stable_hash_combine_string((*L)->getName());
720720
write_hex(ResultStream, LoopNameHash, HexPrintStyle::Lower, MaxHashWidth);

0 commit comments

Comments
 (0)