Skip to content

Commit 33fa1f9

Browse files
authored
Merge branch 'main' into dag-fold-constant-buildvector
2 parents 14bfeb6 + 8740ff8 commit 33fa1f9

File tree

138 files changed

+3548
-1200
lines changed

Some content is hidden

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

138 files changed

+3548
-1200
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ Bug Fixes to C++ Support
899899
- Fixed a crash when constant evaluating some explicit object member assignment operators. (#GH142835)
900900
- Fixed an access checking bug when substituting into concepts (#GH115838)
901901
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
902+
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
902903

903904
Bug Fixes to AST Handling
904905
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace hlsl {
2727

2828
class RootSignatureParser {
2929
public:
30-
RootSignatureParser(SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
30+
RootSignatureParser(llvm::dxbc::RootSignatureVersion Version,
31+
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
3132
RootSignatureLexer &Lexer, clang::Preprocessor &PP);
3233

3334
/// Consumes tokens from the Lexer and constructs the in-memory
@@ -187,6 +188,7 @@ class RootSignatureParser {
187188
bool tryConsumeExpectedToken(ArrayRef<RootSignatureToken::Kind> Expected);
188189

189190
private:
191+
llvm::dxbc::RootSignatureVersion Version;
190192
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements;
191193
RootSignatureLexer &Lexer;
192194

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7723,12 +7723,12 @@ class Sema final : public SemaBase {
77237723

77247724
class ConditionResult {
77257725
Decl *ConditionVar;
7726-
FullExprArg Condition;
7726+
ExprResult Condition;
77277727
bool Invalid;
77287728
std::optional<bool> KnownValue;
77297729

77307730
friend class Sema;
7731-
ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
7731+
ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
77327732
bool IsConstexpr)
77337733
: ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
77347734
if (IsConstexpr && Condition.get()) {
@@ -7739,7 +7739,7 @@ class Sema final : public SemaBase {
77397739
}
77407740
}
77417741
explicit ConditionResult(bool Invalid)
7742-
: ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
7742+
: ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
77437743
KnownValue(std::nullopt) {}
77447744

77457745
public:

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5836,6 +5836,8 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
58365836
return false;
58375837

58385838
if (R->isUnion() && Ctor->isCopyOrMoveConstructor()) {
5839+
if (R->getNumFields() == 0)
5840+
return this->emitRetVoid(Ctor);
58395841
// union copy and move ctors are special.
58405842
assert(cast<CompoundStmt>(Ctor->getBody())->body_empty());
58415843
if (!this->emitThis(Ctor))

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "clang/Basic/Specifiers.h"
2525
#include "clang/Basic/TypeTraits.h"
2626
#include "llvm/ADT/StringExtras.h"
27-
#include "llvm/Frontend/HLSL/HLSLRootSignatureUtils.h"
27+
#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
2828

2929
#include <algorithm>
3030
#include <utility>

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "clang/AST/Type.h"
2424
#include "clang/Basic/TargetOptions.h"
2525
#include "llvm/ADT/SmallVector.h"
26-
#include "llvm/Frontend/HLSL/HLSLRootSignatureUtils.h"
26+
#include "llvm/Frontend/HLSL/RootSignatureMetadata.h"
2727
#include "llvm/IR/Constants.h"
2828
#include "llvm/IR/DerivedTypes.h"
2929
#include "llvm/IR/GlobalVariable.h"

clang/lib/CodeGen/TargetBuiltins/ARM.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,8 @@ static const ARMVectorIntrinsicInfo ARMSIMDIntrinsicMap [] = {
845845
NEONMAP0(vrndiq_v),
846846
NEONMAP1(vrndm_v, floor, Add1ArgType),
847847
NEONMAP1(vrndmq_v, floor, Add1ArgType),
848-
NEONMAP1(vrndn_v, arm_neon_vrintn, Add1ArgType),
849-
NEONMAP1(vrndnq_v, arm_neon_vrintn, Add1ArgType),
848+
NEONMAP1(vrndn_v, roundeven, Add1ArgType),
849+
NEONMAP1(vrndnq_v, roundeven, Add1ArgType),
850850
NEONMAP1(vrndp_v, ceil, Add1ArgType),
851851
NEONMAP1(vrndpq_v, ceil, Add1ArgType),
852852
NEONMAP1(vrndq_v, trunc, Add1ArgType),
@@ -3132,7 +3132,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
31323132
case NEON::BI__builtin_neon_vrndns_f32: {
31333133
Value *Arg = EmitScalarExpr(E->getArg(0));
31343134
llvm::Type *Tys[] = {Arg->getType()};
3135-
Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
3135+
Function *F = CGM.getIntrinsic(Intrinsic::roundeven, Tys);
31363136
return Builder.CreateCall(F, {Arg}, "vrndn"); }
31373137

31383138
case NEON::BI__builtin_neon_vset_lane_i8:

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4956,7 +4956,8 @@ void Parser::ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
49564956
// Invoke the root signature parser to construct the in-memory constructs
49574957
hlsl::RootSignatureLexer Lexer(Signature, SignatureLoc);
49584958
SmallVector<llvm::hlsl::rootsig::RootElement> RootElements;
4959-
hlsl::RootSignatureParser Parser(RootElements, Lexer, PP);
4959+
hlsl::RootSignatureParser Parser(getLangOpts().HLSLRootSigVer, RootElements,
4960+
Lexer, PP);
49604961
if (Parser.parse()) {
49614962
T.consumeClose();
49624963
return;

clang/lib/Parse/ParseExprCXX.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,15 +1931,13 @@ Parser::ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc,
19311931
return ParseCXXCondition(nullptr, Loc, CK, MissingOK);
19321932
}
19331933

1934-
ExprResult Expr = [&] {
1935-
EnterExpressionEvaluationContext Eval(
1936-
Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
1937-
/*LambdaContextDecl=*/nullptr,
1938-
/*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other,
1939-
/*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf);
1940-
// Parse the expression.
1941-
return ParseExpression(); // expression
1942-
}();
1934+
EnterExpressionEvaluationContext Eval(
1935+
Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
1936+
/*LambdaContextDecl=*/nullptr,
1937+
/*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other,
1938+
/*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf);
1939+
1940+
ExprResult Expr = ParseExpression();
19431941

19441942
if (Expr.isInvalid())
19451943
return Sema::ConditionError();

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ namespace hlsl {
1717

1818
using TokenKind = RootSignatureToken::Kind;
1919

20-
RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
21-
RootSignatureLexer &Lexer,
22-
Preprocessor &PP)
23-
: Elements(Elements), Lexer(Lexer), PP(PP), CurToken(SourceLocation()) {}
20+
RootSignatureParser::RootSignatureParser(
21+
llvm::dxbc::RootSignatureVersion Version,
22+
SmallVector<RootElement> &Elements, RootSignatureLexer &Lexer,
23+
Preprocessor &PP)
24+
: Version(Version), Elements(Elements), Lexer(Lexer), PP(PP),
25+
CurToken(SourceLocation()) {}
2426

2527
bool RootSignatureParser::parse() {
2628
// Iterate as many RootElements as possible
@@ -199,7 +201,7 @@ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
199201
ExpectedReg = TokenKind::uReg;
200202
break;
201203
}
202-
Descriptor.setDefaultFlags();
204+
Descriptor.setDefaultFlags(Version);
203205

204206
auto Params = parseRootDescriptorParams(ExpectedReg);
205207
if (!Params.has_value())
@@ -318,7 +320,7 @@ RootSignatureParser::parseDescriptorTableClause() {
318320
ExpectedReg = TokenKind::sReg;
319321
break;
320322
}
321-
Clause.setDefaultFlags();
323+
Clause.setDefaultFlags(Version);
322324

323325
auto Params = parseDescriptorTableClauseParams(ExpectedReg);
324326
if (!Params.has_value())

0 commit comments

Comments
 (0)