Skip to content

Commit acd784e

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:162fa4dd25d631d0ab7816ec6081bcaff951a23c into amd-gfx:7ab2a1875722
Local branch amd-gfx 7ab2a18 Merged main:73185854a3fc469b7d3e21d0b5d2ecb5ee15d201 into amd-gfx:e849a3027d34 Remote branch main 162fa4d Module::getOrInsertFunction: set debug info format (llvm#82505)
2 parents 7ab2a18 + 162fa4d commit acd784e

File tree

27 files changed

+3884
-424
lines changed

27 files changed

+3884
-424
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
335335
return discard(SubExpr);
336336

337337
default:
338-
assert(false && "Cast not implemented");
338+
return this->emitInvalid(CE);
339339
}
340340
llvm_unreachable("Unhandled clang::CastKind enum");
341341
}
@@ -1403,12 +1403,11 @@ bool ByteCodeExprGen<Emitter>::VisitPointerCompoundAssignOperator(
14031403

14041404
if (!LT || !RT)
14051405
return false;
1406-
assert(*LT == PT_Ptr);
14071406

14081407
if (!visit(LHS))
14091408
return false;
14101409

1411-
if (!this->emitLoadPtr(LHS))
1410+
if (!this->emitLoad(*LT, LHS))
14121411
return false;
14131412

14141413
if (!visit(RHS))
@@ -2828,7 +2827,7 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
28282827
if (!this->visit(SubExpr))
28292828
return false;
28302829

2831-
if (T == PT_Ptr) {
2830+
if (T == PT_Ptr || T == PT_FnPtr) {
28322831
if (!this->emitIncPtr(E))
28332832
return false;
28342833

@@ -2846,7 +2845,7 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
28462845
if (!this->visit(SubExpr))
28472846
return false;
28482847

2849-
if (T == PT_Ptr) {
2848+
if (T == PT_Ptr || T == PT_FnPtr) {
28502849
if (!this->emitDecPtr(E))
28512850
return false;
28522851

@@ -2864,7 +2863,7 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
28642863
if (!this->visit(SubExpr))
28652864
return false;
28662865

2867-
if (T == PT_Ptr) {
2866+
if (T == PT_Ptr || T == PT_FnPtr) {
28682867
if (!this->emitLoadPtr(E))
28692868
return false;
28702869
if (!this->emitConstUint8(1, E))
@@ -2903,7 +2902,7 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
29032902
if (!this->visit(SubExpr))
29042903
return false;
29052904

2906-
if (T == PT_Ptr) {
2905+
if (T == PT_Ptr || T == PT_FnPtr) {
29072906
if (!this->emitLoadPtr(E))
29082907
return false;
29092908
if (!this->emitConstUint8(1, E))
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_cc1 %s -fsyntax-only -verify=gnu,expected -pedantic -Wextra -std=c11 -fexperimental-new-constant-interpreter
2+
// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify=gnu,expected -pedantic -Wextra -std=c11 -fexperimental-new-constant-interpreter
3+
// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify=gnu,expected -pedantic -Wextra -std=c11 -fexperimental-new-constant-interpreter
4+
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -Wno-gnu -std=c11 -fexperimental-new-constant-interpreter
5+
6+
typedef __INTPTR_TYPE__ intptr_t;
7+
typedef struct S S; // expected-note 4 {{forward declaration of 'struct S'}}
8+
extern _Atomic(S*) e;
9+
void a(S* b, void* c) {
10+
void (*fp)(int) = 0;
11+
b++; // expected-error {{arithmetic on a pointer to an incomplete type}}
12+
b += 1; // expected-error {{arithmetic on a pointer to an incomplete type}}
13+
c++; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
14+
c += 1; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
15+
c--; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
16+
c -= 1; // gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
17+
(void) c[1]; // gnu-warning {{subscript of a pointer to void is a GNU extension}}
18+
b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
19+
/* The next couple tests are only pedantic warnings in gcc */
20+
void (*d)(S*,void*) = a;
21+
d += 1; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
22+
d++; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
23+
d--; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
24+
d -= 1; // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
25+
(void)(1 + d); // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
26+
e++; // expected-error {{arithmetic on a pointer to an incomplete type}}
27+
intptr_t i = (intptr_t)b;
28+
char *f = (char*)0 + i; // gnu-warning {{arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension}}
29+
// Cases that don't match the GNU inttoptr idiom get a different warning.
30+
f = (char*)0 - i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
31+
int *g = (int*)0 + i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
32+
}

llvm/include/llvm/BinaryFormat/Dwarf.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,25 @@ enum AcceleratorTable {
613613
DW_hash_function_djb = 0u
614614
};
615615

616+
// Uniquify the string hashes and calculate the bucket count for the
617+
// DWARF v5 Accelerator Table. NOTE: This function effectively consumes the
618+
// 'hashes' input parameter.
619+
inline uint32_t getDebugNamesBucketCount(MutableArrayRef<uint32_t> hashes,
620+
uint32_t &uniqueHashCount) {
621+
uint32_t BucketCount = 0;
622+
623+
sort(hashes);
624+
uniqueHashCount = llvm::unique(hashes) - hashes.begin();
625+
if (uniqueHashCount > 1024)
626+
BucketCount = uniqueHashCount / 4;
627+
else if (uniqueHashCount > 16)
628+
BucketCount = uniqueHashCount / 2;
629+
else
630+
BucketCount = std::max<uint32_t>(uniqueHashCount, 1);
631+
632+
return BucketCount;
633+
}
634+
616635
// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
617636
enum GDBIndexEntryKind {
618637
GIEK_NONE,

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 490369
19+
#define LLVM_MAIN_REVISION 490385
2020

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

llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,12 @@ using namespace llvm;
3333

3434
void AccelTableBase::computeBucketCount() {
3535
// First get the number of unique hashes.
36-
std::vector<uint32_t> Uniques;
36+
SmallVector<uint32_t, 0> Uniques;
3737
Uniques.reserve(Entries.size());
3838
for (const auto &E : Entries)
3939
Uniques.push_back(E.second.HashValue);
40-
array_pod_sort(Uniques.begin(), Uniques.end());
41-
std::vector<uint32_t>::iterator P =
42-
std::unique(Uniques.begin(), Uniques.end());
4340

44-
UniqueHashCount = std::distance(Uniques.begin(), P);
45-
46-
if (UniqueHashCount > 1024)
47-
BucketCount = UniqueHashCount / 4;
48-
else if (UniqueHashCount > 16)
49-
BucketCount = UniqueHashCount / 2;
50-
else
51-
BucketCount = std::max<uint32_t>(UniqueHashCount, 1);
41+
BucketCount = llvm::dwarf::getDebugNamesBucketCount(Uniques, UniqueHashCount);
5242
}
5343

5444
void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {

llvm/lib/Frontend/Offloading/Utility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void offloading::emitOffloadingEntry(Module &M, Constant *Addr, StringRef Name,
7070
getOffloadingEntryInitializer(M, Addr, Name, Size, Flags, Data);
7171

7272
StringRef Prefix =
73-
Triple.isNVPTX() ? "$omp_offloading$entry." : ".omp_offloading.entry.";
73+
Triple.isNVPTX() ? "$omp_offloading$entry$" : ".omp_offloading.entry.";
7474
auto *Entry = new GlobalVariable(
7575
M, getEntryTy(M),
7676
/*isConstant=*/true, GlobalValue::WeakAnyLinkage, EntryInitializer,

llvm/lib/IR/Module.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty,
149149
if (!F) {
150150
// Nope, add it
151151
Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage,
152-
DL.getProgramAddressSpace(), Name);
152+
DL.getProgramAddressSpace(), Name, this);
153153
if (!New->isIntrinsic()) // Intrinsics get attrs set on construction
154154
New->setAttributes(AttributeList);
155-
FunctionList.push_back(New);
156155
return {Ty, New}; // Return the new prototype.
157156
}
158157

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,22 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
436436
if (Index == 0)
437437
return TTI::TCC_Free;
438438

439+
// If we're extracting a subvector of at most m1 size at a sub-register
440+
// boundary - which unfortunately we need exact vlen to identify - this is
441+
// a subregister extract at worst and thus won't require a vslidedown.
442+
// TODO: Extend for aligned m2, m4 subvector extracts
443+
// TODO: Extend for misalgined (but contained) extracts
444+
// TODO: Extend for scalable subvector types
445+
if (std::pair<InstructionCost, MVT> SubLT = getTypeLegalizationCost(SubTp);
446+
SubLT.second.isValid() && SubLT.second.isFixedLengthVector()) {
447+
const unsigned MinVLen = ST->getRealMinVLen();
448+
const unsigned MaxVLen = ST->getRealMaxVLen();
449+
if (MinVLen == MaxVLen &&
450+
SubLT.second.getScalarSizeInBits() * Index % MinVLen == 0 &&
451+
SubLT.second.getSizeInBits() <= MinVLen)
452+
return TTI::TCC_Free;
453+
}
454+
439455
// Example sequence:
440456
// vsetivli zero, 4, e8, mf2, tu, ma (ignored)
441457
// vslidedown.vi v8, v9, 2

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
19231923
unsigned N = getNumRegistersForCallingConv(Ctx, CLI.CallConv, OrigArgVT);
19241924
SlotVT = EVT::getIntegerVT(Ctx, PartVT.getSizeInBits() * N);
19251925
} else {
1926-
SlotVT = Outs[I].ArgVT;
1926+
SlotVT = Outs[I].VT;
19271927
}
19281928
SDValue SpillSlot = DAG.CreateStackTemporary(SlotVT);
19291929
int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,6 +3090,7 @@ InstructionCost X86TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
30903090
InstructionCost ExtraCost = 0;
30913091
if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
30923092
// Some vector comparison predicates cost extra instructions.
3093+
// TODO: Adjust ExtraCost based on CostKind?
30933094
// TODO: Should we invert this and assume worst case cmp costs
30943095
// and reduce for particular predicates?
30953096
if (MTy.isVector() &&
@@ -3102,21 +3103,25 @@ InstructionCost X86TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
31023103
Pred == CmpInst::BAD_FCMP_PREDICATE))
31033104
Pred = cast<CmpInst>(I)->getPredicate();
31043105

3106+
bool CmpWithConstant = false;
3107+
if (auto *CmpInstr = dyn_cast_or_null<CmpInst>(I))
3108+
CmpWithConstant = isa<Constant>(CmpInstr->getOperand(1));
3109+
31053110
switch (Pred) {
31063111
case CmpInst::Predicate::ICMP_NE:
31073112
// xor(cmpeq(x,y),-1)
3108-
ExtraCost = 1;
3113+
ExtraCost = CmpWithConstant ? 0 : 1;
31093114
break;
31103115
case CmpInst::Predicate::ICMP_SGE:
31113116
case CmpInst::Predicate::ICMP_SLE:
31123117
// xor(cmpgt(x,y),-1)
3113-
ExtraCost = 1;
3118+
ExtraCost = CmpWithConstant ? 0 : 1;
31143119
break;
31153120
case CmpInst::Predicate::ICMP_ULT:
31163121
case CmpInst::Predicate::ICMP_UGT:
31173122
// cmpgt(xor(x,signbit),xor(y,signbit))
31183123
// xor(cmpeq(pmaxu(x,y),x),-1)
3119-
ExtraCost = 2;
3124+
ExtraCost = CmpWithConstant ? 1 : 2;
31203125
break;
31213126
case CmpInst::Predicate::ICMP_ULE:
31223127
case CmpInst::Predicate::ICMP_UGE:
@@ -3127,7 +3132,7 @@ InstructionCost X86TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
31273132
ExtraCost = 1;
31283133
} else {
31293134
// xor(cmpgt(xor(x,signbit),xor(y,signbit)),-1)
3130-
ExtraCost = 3;
3135+
ExtraCost = CmpWithConstant ? 2 : 3;
31313136
}
31323137
break;
31333138
case CmpInst::Predicate::FCMP_ONE:

0 commit comments

Comments
 (0)