Skip to content

Commit e1655cc

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2295)
2 parents f79de5c + 0a525a9 commit e1655cc

File tree

294 files changed

+14473
-9153
lines changed

Some content is hidden

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

294 files changed

+14473
-9153
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ Bug Fixes in This Version
644644
- Fix crash due to unknown references and pointer implementation and handling of
645645
base classes. (GH139452)
646646
- Fixed an assertion failure in serialization of constexpr structs containing unions. (#GH140130)
647+
- Fixed duplicate entries in TableGen that caused the wrong attribute to be selected. (GH#140701)
647648

648649
Bug Fixes to Compiler Builtins
649650
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/Builtins.td

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4909,10 +4909,16 @@ def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
49094909
let Prototype = "void(...)";
49104910
}
49114911

4912-
def HLSLCross: LangBuiltin<"HLSL_LANG"> {
4913-
let Spellings = ["__builtin_hlsl_cross"];
4912+
def HLSLCrossFloat: LangBuiltin<"HLSL_LANG"> {
4913+
let Spellings = ["__builtin_hlsl_crossf32"];
49144914
let Attributes = [NoThrow, Const];
4915-
let Prototype = "void(...)";
4915+
let Prototype = "_ExtVector<3, float>(_ExtVector<3, float>, _ExtVector<3, float>)";
4916+
}
4917+
4918+
def HLSLCrossHalf: LangBuiltin<"HLSL_LANG"> {
4919+
let Spellings = ["__builtin_hlsl_crossf16"];
4920+
let Attributes = [NoThrow, Const];
4921+
let Prototype = "_ExtVector<3, __fp16>(_ExtVector<3, __fp16>, _ExtVector<3, __fp16>)";
49164922
}
49174923

49184924
def HLSLDegrees : LangBuiltin<"HLSL_LANG"> {
@@ -4971,7 +4977,7 @@ def HLSLLerp : LangBuiltin<"HLSL_LANG"> {
49714977

49724978
def HLSLMad : LangBuiltin<"HLSL_LANG"> {
49734979
let Spellings = ["__builtin_hlsl_mad"];
4974-
let Attributes = [NoThrow, Const];
4980+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49754981
let Prototype = "void(...)";
49764982
}
49774983

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12715,7 +12715,7 @@ def err_builtin_invalid_arg_type: Error<
1271512715
// An 'or' if non-empty second and third components are combined
1271612716
"%plural{0:|:%plural{0:|:or }2}3"
1271712717
// Third component: floating-point types
12718-
"%select{|floating-point}3"
12718+
"%select{|floating-point|16 or 32 bit floating-point}3"
1271912719
// A space after a non-empty third component
1272012720
"%plural{0:|: }3"
1272112721
"%plural{[0,3]:type|:types}1 (was %4)">;

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
1414
#include "clang/CIR/Dialect/IR/CIRDialect.h"
1515
#include "clang/CIR/Dialect/IR/CIRTypes.h"
16+
#include "clang/CIR/MissingFeatures.h"
1617
#include "llvm/ADT/STLForwardCompat.h"
1718
#include "llvm/Support/ErrorHandling.h"
1819

@@ -177,6 +178,12 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
177178
return create<cir::AllocaOp>(loc, addrType, type, name, alignment);
178179
}
179180

181+
mlir::Value createGetGlobal(mlir::Location loc, cir::GlobalOp global) {
182+
assert(!cir::MissingFeatures::addressSpace());
183+
return create<cir::GetGlobalOp>(loc, getPointerTo(global.getSymType()),
184+
global.getSymName());
185+
}
186+
180187
cir::LoadOp createLoad(mlir::Location loc, mlir::Value ptr,
181188
bool isVolatile = false, uint64_t alignment = 0) {
182189
mlir::IntegerAttr intAttr;

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct MissingFeatures {
3838
static bool opGlobalWeakRef() { return false; }
3939
static bool opGlobalLinkage() { return false; }
4040
static bool opGlobalSetVisitibility() { return false; }
41+
static bool opGlobalUnnamedAddr() { return false; }
4142

4243
static bool supportIFuncAttr() { return false; }
4344
static bool supportVisibility() { return false; }
@@ -127,7 +128,6 @@ struct MissingFeatures {
127128
static bool shouldReverseUnaryCondOnBoolExpr() { return false; }
128129

129130
// RecordType
130-
static bool recursiveRecordLayout() { return false; }
131131
static bool skippedLayout() { return false; }
132132
static bool astRecordDeclAttr() { return false; }
133133
static bool cxxSupport() { return false; }

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
2626
CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc)
2727
: CIRBaseBuilderTy(mlirContext), typeCache(tc) {}
2828

29+
/// Get a cir::ConstArrayAttr for a string literal.
30+
/// Note: This is different from what is returned by
31+
/// mlir::Builder::getStringAttr() which is an mlir::StringAttr.
32+
mlir::Attribute getString(llvm::StringRef str, mlir::Type eltTy,
33+
std::optional<size_t> size) {
34+
size_t finalSize = size.value_or(str.size());
35+
36+
size_t lastNonZeroPos = str.find_last_not_of('\0');
37+
// If the string is full of null bytes, emit a #cir.zero rather than
38+
// a #cir.const_array.
39+
if (lastNonZeroPos == llvm::StringRef::npos) {
40+
auto arrayTy = cir::ArrayType::get(eltTy, finalSize);
41+
return cir::ZeroAttr::get(arrayTy);
42+
}
43+
// We emit trailing zeros only if there are multiple trailing zeros.
44+
size_t trailingZerosNum = 0;
45+
if (finalSize > lastNonZeroPos + 2)
46+
trailingZerosNum = finalSize - lastNonZeroPos - 1;
47+
auto truncatedArrayTy =
48+
cir::ArrayType::get(eltTy, finalSize - trailingZerosNum);
49+
auto fullArrayTy = cir::ArrayType::get(eltTy, finalSize);
50+
return cir::ConstArrayAttr::get(
51+
fullArrayTy,
52+
mlir::StringAttr::get(str.drop_back(trailingZerosNum),
53+
truncatedArrayTy),
54+
trailingZerosNum);
55+
}
56+
2957
std::string getUniqueAnonRecordName() { return getUniqueRecordName("anon"); }
3058

3159
std::string getUniqueRecordName(const std::string &baseName) {

clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
115115
thisPtr = emitLValue(base);
116116
}
117117

118-
if (const CXXConstructorDecl *ctor = dyn_cast<CXXConstructorDecl>(md)) {
118+
if (isa<CXXConstructorDecl>(md)) {
119119
cgm.errorNYI(ce->getSourceRange(),
120120
"emitCXXMemberOrOperatorMemberCallExpr: constructor call");
121121
return RValue::get(nullptr);
@@ -129,29 +129,29 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
129129
cgm.errorNYI(ce->getSourceRange(),
130130
"emitCXXMemberOrOperatorMemberCallExpr: trivial assignment");
131131
return RValue::get(nullptr);
132-
} else {
133-
assert(md->getParent()->mayInsertExtraPadding() &&
134-
"unknown trivial member function");
135132
}
133+
134+
assert(md->getParent()->mayInsertExtraPadding() &&
135+
"unknown trivial member function");
136136
}
137137

138138
// Compute the function type we're calling
139139
const CXXMethodDecl *calleeDecl = md;
140140
const CIRGenFunctionInfo *fInfo = nullptr;
141-
if (const auto *dtor = dyn_cast<CXXDestructorDecl>(calleeDecl)) {
141+
if (isa<CXXDestructorDecl>(calleeDecl)) {
142142
cgm.errorNYI(ce->getSourceRange(),
143143
"emitCXXMemberOrOperatorMemberCallExpr: destructor call");
144144
return RValue::get(nullptr);
145-
} else {
146-
fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
147145
}
148146

147+
fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
148+
149149
mlir::Type ty = cgm.getTypes().getFunctionType(*fInfo);
150150

151151
assert(!cir::MissingFeatures::sanitizers());
152152
assert(!cir::MissingFeatures::emitTypeCheck());
153153

154-
if (const auto *dtor = dyn_cast<CXXDestructorDecl>(calleeDecl)) {
154+
if (isa<CXXDestructorDecl>(calleeDecl)) {
155155
cgm.errorNYI(ce->getSourceRange(),
156156
"emitCXXMemberOrOperatorMemberCallExpr: destructor call");
157157
return RValue::get(nullptr);

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,16 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) {
743743
return lv;
744744
}
745745

746+
LValue CIRGenFunction::emitStringLiteralLValue(const StringLiteral *e) {
747+
cir::GlobalOp globalOp = cgm.getGlobalForStringLiteral(e);
748+
assert(!cir::MissingFeatures::opGlobalAlignment());
749+
mlir::Value addr =
750+
builder.createGetGlobal(getLoc(e->getSourceRange()), globalOp);
751+
return makeAddrLValue(
752+
Address(addr, globalOp.getSymType(), CharUnits::fromQuantity(1)),
753+
e->getType(), AlignmentSource::Decl);
754+
}
755+
746756
/// Casts are never lvalues unless that cast is to a reference type. If the cast
747757
/// is to a reference, we can have the usual lvalue result, otherwise if a cast
748758
/// is needed by the code generator in an lvalue context, then it must mean that

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,8 @@ LValue CIRGenFunction::emitLValue(const Expr *e) {
531531
return emitArraySubscriptExpr(cast<ArraySubscriptExpr>(e));
532532
case Expr::UnaryOperatorClass:
533533
return emitUnaryOpLValue(cast<UnaryOperator>(e));
534+
case Expr::StringLiteralClass:
535+
return emitStringLiteralLValue(cast<StringLiteral>(e));
534536
case Expr::MemberExprClass:
535537
return emitMemberExpr(cast<MemberExpr>(e));
536538
case Expr::BinaryOperatorClass:

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ class CIRGenFunction : public CIRGenTypeCache {
695695

696696
mlir::Value emitStoreThroughBitfieldLValue(RValue src, LValue dstresult);
697697

698+
LValue emitStringLiteralLValue(const StringLiteral *e);
699+
698700
mlir::LogicalResult emitSwitchBody(const clang::Stmt *s);
699701
mlir::LogicalResult emitSwitchCase(const clang::SwitchCase &s,
700702
bool buildingTopLevelCase);

0 commit comments

Comments
 (0)