Skip to content

Commit 62e1fc1

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2303)
2 parents 9945658 + 10e541a commit 62e1fc1

File tree

30 files changed

+814
-203
lines changed

30 files changed

+814
-203
lines changed

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class RootSignatureParser {
7373
/// Root Element parse methods:
7474
std::optional<llvm::hlsl::rootsig::RootFlags> parseRootFlags();
7575
std::optional<llvm::hlsl::rootsig::RootConstants> parseRootConstants();
76+
std::optional<llvm::hlsl::rootsig::RootDescriptor> parseRootDescriptor();
7677
std::optional<llvm::hlsl::rootsig::DescriptorTable> parseDescriptorTable();
7778
std::optional<llvm::hlsl::rootsig::DescriptorTableClause>
7879
parseDescriptorTableClause();

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ bool RootSignatureParser::parse() {
4747
return true;
4848
Elements.push_back(*Table);
4949
}
50+
51+
if (tryConsumeExpectedToken(
52+
{TokenKind::kw_CBV, TokenKind::kw_SRV, TokenKind::kw_UAV})) {
53+
auto Descriptor = parseRootDescriptor();
54+
if (!Descriptor.has_value())
55+
return true;
56+
Elements.push_back(*Descriptor);
57+
}
5058
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
5159

5260
return consumeExpectedToken(TokenKind::end_of_stream,
@@ -155,6 +163,41 @@ std::optional<RootConstants> RootSignatureParser::parseRootConstants() {
155163
return Constants;
156164
}
157165

166+
std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
167+
assert((CurToken.TokKind == TokenKind::kw_CBV ||
168+
CurToken.TokKind == TokenKind::kw_SRV ||
169+
CurToken.TokKind == TokenKind::kw_UAV) &&
170+
"Expects to only be invoked starting at given keyword");
171+
172+
TokenKind DescriptorKind = CurToken.TokKind;
173+
174+
if (consumeExpectedToken(TokenKind::pu_l_paren, diag::err_expected_after,
175+
CurToken.TokKind))
176+
return std::nullopt;
177+
178+
RootDescriptor Descriptor;
179+
switch (DescriptorKind) {
180+
default:
181+
llvm_unreachable("Switch for consumed token was not provided");
182+
case TokenKind::kw_CBV:
183+
Descriptor.Type = DescriptorType::CBuffer;
184+
break;
185+
case TokenKind::kw_SRV:
186+
Descriptor.Type = DescriptorType::SRV;
187+
break;
188+
case TokenKind::kw_UAV:
189+
Descriptor.Type = DescriptorType::UAV;
190+
break;
191+
}
192+
193+
if (consumeExpectedToken(TokenKind::pu_r_paren,
194+
diag::err_hlsl_unexpected_end_of_params,
195+
/*param of=*/TokenKind::kw_RootConstants))
196+
return std::nullopt;
197+
198+
return Descriptor;
199+
}
200+
158201
std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {
159202
assert(CurToken.TokKind == TokenKind::kw_DescriptorTable &&
160203
"Expects to only be invoked starting at given keyword");

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,43 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
344344
ASSERT_TRUE(Consumer->isSatisfied());
345345
}
346346

347+
TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
348+
const llvm::StringLiteral Source = R"cc(
349+
CBV(),
350+
SRV(),
351+
UAV()
352+
)cc";
353+
354+
TrivialModuleLoader ModLoader;
355+
auto PP = createPP(Source, ModLoader);
356+
auto TokLoc = SourceLocation();
357+
358+
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
359+
SmallVector<RootElement> Elements;
360+
hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
361+
362+
// Test no diagnostics produced
363+
Consumer->setNoDiag();
364+
365+
ASSERT_FALSE(Parser.parse());
366+
367+
ASSERT_EQ(Elements.size(), 3u);
368+
369+
RootElement Elem = Elements[0];
370+
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
371+
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::CBuffer);
372+
373+
Elem = Elements[1];
374+
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
375+
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::SRV);
376+
377+
Elem = Elements[2];
378+
ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
379+
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::UAV);
380+
381+
ASSERT_TRUE(Consumer->isSatisfied());
382+
}
383+
347384
TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
348385
// This test will checks we can handling trailing commas ','
349386
const llvm::StringLiteral Source = R"cc(

flang/lib/Lower/OpenMP/Utils.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,18 @@ mlir::Value createParentSymAndGenIntermediateMaps(
336336
clauseLocation, firOpBuilder.getRefType(memberTy), curValue,
337337
llvm::SmallVector<fir::IntOrValue, 1>{idxConst});
338338

339-
// Skip mapping and the subsequent load if we're the final member or not
340-
// a type with a descriptor such as a pointer/allocatable. If we're a
341-
// final member, the map will be generated by the processMap call that
342-
// invoked this function, and if we're not a type with a descriptor then
343-
// we have no need of generating an intermediate map for it, as we only
344-
// need to generate a map if a member is a descriptor type (and thus
345-
// obscures the members it contains via a pointer in which it's data needs
346-
// mapped)
347-
if ((currentIndicesIdx == indices.size() - 1) ||
348-
!fir::isTypeWithDescriptor(memberTy)) {
339+
// If we're a final member, the map will be generated by the processMap
340+
// call that invoked this function.
341+
if (currentIndicesIdx == indices.size() - 1)
342+
break;
343+
344+
// Skip mapping and the subsequent load if we're not
345+
// a type with a descriptor such as a pointer/allocatable. If we're not a
346+
// type with a descriptor then we have no need of generating an
347+
// intermediate map for it, as we only need to generate a map if a member
348+
// is a descriptor type (and thus obscures the members it contains via a
349+
// pointer in which it's data needs mapped).
350+
if (!fir::isTypeWithDescriptor(memberTy)) {
349351
currentIndicesIdx++;
350352
continue;
351353
}

lld/test/COFF/lto-cache-errors.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
; RUN: rm -Rf %t.cache && mkdir %t.cache
88
; RUN: chmod 444 %t.cache
99

10-
;; Check emit warnings when we can't create the cache dir
11-
; RUN: not --crash lld-link /lldltocache:%t.cache/nonexistant/ /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s
10+
;; Check fatal usage error emitted when the cache dir can't be created.
11+
; RUN: not lld-link /lldltocache:%t.cache/nonexistant/ /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s
1212
; CHECK: LLVM ERROR: can't create cache directory {{.*}}/nonexistant/: Permission denied
1313

1414
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

lld/test/ELF/lto/ltopasses-custom.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ define void @barrier() {
2424
; ATOMIC-NEXT: ret void
2525

2626
; Check that invalid passes are rejected gracefully.
27-
; RUN: env LLD_IN_TEST=1 not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
27+
; RUN: env LLD_IN_TEST=1 not ld.lld -m elf_x86_64 %t.o -o /dev/null \
2828
; RUN: --lto-newpm-passes=iamnotapass -shared 2>&1 | \
2929
; RUN: FileCheck %s --check-prefix=INVALID
3030
; INVALID: unable to parse pass pipeline description 'iamnotapass': unknown pass name 'iamnotapass'
3131

3232
; Check that invalid AA pipelines are rejected gracefully.
33-
; RUN: env LLD_IN_TEST=1 not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
33+
; RUN: env LLD_IN_TEST=1 not ld.lld -m elf_x86_64 %t.o -o /dev/null \
3434
; RUN: --lto-newpm-passes=globaldce --lto-aa-pipeline=patatino \
3535
; RUN: -shared 2>&1 | \
3636
; RUN: FileCheck %s --check-prefix=INVALIDAA

lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def continue_and_report_stop_reason(self, process, iter_str):
2222

2323
# debugserver only gained the ability to watch larger regions
2424
# with this patch.
25+
@skipIfOutOfTreeDebugserver
2526
def test_consecutive_watchpoints(self):
2627
"""Test watchpoint that covers a large region of memory."""
2728
self.build()

llvm/include/llvm/Analysis/MemoryProfileInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
#ifndef LLVM_ANALYSIS_MEMORYPROFILEINFO_H
1414
#define LLVM_ANALYSIS_MEMORYPROFILEINFO_H
1515

16-
#include "llvm/IR/InstrTypes.h"
1716
#include "llvm/IR/Metadata.h"
18-
#include "llvm/ProfileData/MemProfCommon.h"
17+
#include "llvm/IR/ModuleSummaryIndex.h"
1918
#include <map>
2019

2120
namespace llvm {

llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ struct RootConstants {
8585
ShaderVisibility Visibility = ShaderVisibility::All;
8686
};
8787

88+
using DescriptorType = llvm::dxil::ResourceClass;
89+
// Models RootDescriptor : CBV | SRV | UAV, by collecting like parameters
90+
struct RootDescriptor {
91+
DescriptorType Type;
92+
};
93+
8894
// Models the end of a descriptor table and stores its visibility
8995
struct DescriptorTable {
9096
ShaderVisibility Visibility = ShaderVisibility::All;
@@ -125,8 +131,8 @@ struct DescriptorTableClause {
125131
void dump(raw_ostream &OS) const;
126132
};
127133

128-
/// Models RootElement : RootFlags | RootConstants | DescriptorTable
129-
/// | DescriptorTableClause
134+
/// Models RootElement : RootFlags | RootConstants | RootDescriptor
135+
/// | DescriptorTable | DescriptorTableClause
130136
///
131137
/// A Root Signature is modeled in-memory by an array of RootElements. These
132138
/// aim to map closely to their DSL grammar reprsentation defined in the spec.
@@ -140,8 +146,8 @@ struct DescriptorTableClause {
140146
/// The DescriptorTable is modelled by having its Clauses as the previous
141147
/// RootElements in the array, and it holds a data member for the Visibility
142148
/// parameter.
143-
using RootElement = std::variant<RootFlags, RootConstants, DescriptorTable,
144-
DescriptorTableClause>;
149+
using RootElement = std::variant<RootFlags, RootConstants, RootDescriptor,
150+
DescriptorTable, DescriptorTableClause>;
145151

146152
void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements);
147153

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "llvm/IR/ConstantRange.h"
2828
#include "llvm/IR/GlobalValue.h"
2929
#include "llvm/IR/Module.h"
30-
#include "llvm/ProfileData/MemProfCommon.h"
3130
#include "llvm/Support/Allocator.h"
3231
#include "llvm/Support/Compiler.h"
3332
#include "llvm/Support/InterleavedRange.h"
@@ -307,6 +306,14 @@ template <> struct DenseMapInfo<ValueInfo> {
307306
static unsigned getHashValue(ValueInfo I) { return hash_value(I.getRef()); }
308307
};
309308

309+
// For optional hinted size reporting, holds a pair of the full stack id
310+
// (pre-trimming, from the full context in the profile), and the associated
311+
// total profiled size.
312+
struct ContextTotalSize {
313+
uint64_t FullStackId;
314+
uint64_t TotalSize;
315+
};
316+
310317
/// Summary of memprof callsite metadata.
311318
struct CallsiteInfo {
312319
// Actual callee function.
@@ -343,6 +350,19 @@ inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteInfo &SNI) {
343350
return OS;
344351
}
345352

353+
// Allocation type assigned to an allocation reached by a given context.
354+
// More can be added, now this is cold, notcold and hot.
355+
// Values should be powers of two so that they can be ORed, in particular to
356+
// track allocations that have different behavior with different calling
357+
// contexts.
358+
enum class AllocationType : uint8_t {
359+
None = 0,
360+
NotCold = 1,
361+
Cold = 2,
362+
Hot = 4,
363+
All = 7 // This should always be set to the OR of all values.
364+
};
365+
346366
/// Summary of a single MIB in a memprof metadata on allocations.
347367
struct MIBInfo {
348368
// The allocation type for this profiled context.

0 commit comments

Comments
 (0)