Skip to content

Commit 39301a4

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/shift-of-zero
2 parents 49d0e0d + 21ded66 commit 39301a4

File tree

23 files changed

+375
-157
lines changed

23 files changed

+375
-157
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,20 +548,18 @@ class ASTWriter : public ASTDeserializationListener,
548548
void WriteSubStmt(Stmt *S);
549549

550550
void WriteBlockInfoBlock();
551-
void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
552-
StringRef isysroot);
551+
void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
553552

554553
/// Write out the signature and diagnostic options, and return the signature.
555-
void writeUnhashedControlBlock(Preprocessor &PP, ASTContext &Context);
554+
void writeUnhashedControlBlock(Preprocessor &PP);
556555
ASTFileSignature backpatchSignature();
557556

558557
/// Calculate hash of the pcm content.
559558
std::pair<ASTFileSignature, ASTFileSignature> createSignature() const;
560559
ASTFileSignature createSignatureForNamedModule() const;
561560

562561
void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);
563-
void WriteSourceManagerBlock(SourceManager &SourceMgr,
564-
const Preprocessor &PP);
562+
void WriteSourceManagerBlock(SourceManager &SourceMgr);
565563
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
566564
void WriteHeaderSearch(const HeaderSearch &HS);
567565
void WritePreprocessorDetail(PreprocessingRecord &PPRec,

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,7 @@ ASTFileSignature ASTWriter::backpatchSignature() {
12691269
return Signature;
12701270
}
12711271

1272-
void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
1273-
ASTContext &Context) {
1272+
void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
12741273
using namespace llvm;
12751274

12761275
// Flush first to prepare the PCM hash (signature).
@@ -1323,7 +1322,7 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
13231322
const auto &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
13241323

13251324
// Diagnostic options.
1326-
const auto &Diags = Context.getDiagnostics();
1325+
const auto &Diags = PP.getDiagnostics();
13271326
const DiagnosticOptions &DiagOpts = Diags.getDiagnosticOptions();
13281327
if (!HSOpts.ModulesSkipDiagnosticOptions) {
13291328
#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
@@ -1403,10 +1402,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
14031402
}
14041403

14051404
/// Write the control block.
1406-
void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1407-
StringRef isysroot) {
1405+
void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
14081406
using namespace llvm;
14091407

1408+
SourceManager &SourceMgr = PP.getSourceManager();
1409+
FileManager &FileMgr = PP.getFileManager();
1410+
14101411
Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
14111412
RecordData Record;
14121413

@@ -1454,14 +1455,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14541455
SmallString<128> BaseDir;
14551456
if (PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) {
14561457
// Use the current working directory as the base path for all inputs.
1457-
auto CWD =
1458-
Context.getSourceManager().getFileManager().getOptionalDirectoryRef(
1459-
".");
1458+
auto CWD = FileMgr.getOptionalDirectoryRef(".");
14601459
BaseDir.assign(CWD->getName());
14611460
} else {
14621461
BaseDir.assign(WritingModule->Directory->getName());
14631462
}
1464-
cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
1463+
cleanPathForOutput(FileMgr, BaseDir);
14651464

14661465
// If the home of the module is the current working directory, then we
14671466
// want to pick up the cwd of the build process loading the module, not
@@ -1554,7 +1553,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15541553

15551554
// Language options.
15561555
Record.clear();
1557-
const LangOptions &LangOpts = Context.getLangOpts();
1556+
const LangOptions &LangOpts = PP.getLangOpts();
15581557
#define LANGOPT(Name, Bits, Default, Description) \
15591558
Record.push_back(LangOpts.Name);
15601559
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
@@ -1591,7 +1590,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15911590

15921591
// Target options.
15931592
Record.clear();
1594-
const TargetInfo &Target = Context.getTargetInfo();
1593+
const TargetInfo &Target = PP.getTargetInfo();
15951594
const TargetOptions &TargetOpts = Target.getTargetOpts();
15961595
AddString(TargetOpts.Triple, Record);
15971596
AddString(TargetOpts.CPU, Record);
@@ -1609,8 +1608,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16091608

16101609
// File system options.
16111610
Record.clear();
1612-
const FileSystemOptions &FSOpts =
1613-
Context.getSourceManager().getFileManager().getFileSystemOpts();
1611+
const FileSystemOptions &FSOpts = FileMgr.getFileSystemOpts();
16141612
AddString(FSOpts.WorkingDir, Record);
16151613
Stream.EmitRecord(FILE_SYSTEM_OPTIONS, Record);
16161614

@@ -1675,8 +1673,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16751673
Stream.ExitBlock();
16761674

16771675
// Original file name and file ID
1678-
SourceManager &SM = Context.getSourceManager();
1679-
if (auto MainFile = SM.getFileEntryRefForID(SM.getMainFileID())) {
1676+
if (auto MainFile =
1677+
SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID())) {
16801678
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
16811679
FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
16821680
FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
@@ -1685,16 +1683,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16851683

16861684
Record.clear();
16871685
Record.push_back(ORIGINAL_FILE);
1688-
AddFileID(SM.getMainFileID(), Record);
1686+
AddFileID(SourceMgr.getMainFileID(), Record);
16891687
EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
16901688
}
16911689

16921690
Record.clear();
1693-
AddFileID(SM.getMainFileID(), Record);
1691+
AddFileID(SourceMgr.getMainFileID(), Record);
16941692
Stream.EmitRecord(ORIGINAL_FILE_ID, Record);
16951693

1696-
WriteInputFiles(Context.SourceMgr,
1697-
PP.getHeaderSearchInfo().getHeaderSearchOpts());
1694+
WriteInputFiles(SourceMgr, PP.getHeaderSearchInfo().getHeaderSearchOpts());
16981695
Stream.ExitBlock();
16991696
}
17001697

@@ -2234,8 +2231,7 @@ static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
22342231
/// entries for files that we actually need. In the common case (no
22352232
/// errors), we probably won't have to create file entries for any of
22362233
/// the files in the AST.
2237-
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
2238-
const Preprocessor &PP) {
2234+
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
22392235
RecordData Record;
22402236

22412237
// Enter the source manager block.
@@ -2323,8 +2319,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23232319
// We add one to the size so that we capture the trailing NULL
23242320
// that is required by llvm::MemoryBuffer::getMemBuffer (on
23252321
// the reader side).
2326-
std::optional<llvm::MemoryBufferRef> Buffer =
2327-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2322+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2323+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23282324
StringRef Name = Buffer ? Buffer->getBufferIdentifier() : "";
23292325
Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
23302326
StringRef(Name.data(), Name.size() + 1));
@@ -2334,8 +2330,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23342330
if (EmitBlob) {
23352331
// Include the implicit terminating null character in the on-disk buffer
23362332
// if we're writing it uncompressed.
2337-
std::optional<llvm::MemoryBufferRef> Buffer =
2338-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2333+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2334+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23392335
if (!Buffer)
23402336
Buffer = llvm::MemoryBufferRef("<<<INVALID BUFFER>>>", "");
23412337
StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
@@ -5371,7 +5367,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
53715367
// SourceLocations or FileIDs depends on it.
53725368
computeNonAffectingInputFiles();
53735369

5374-
writeUnhashedControlBlock(PP, Context);
5370+
writeUnhashedControlBlock(PP);
53755371

53765372
// Don't reuse type ID and Identifier ID from readers for C++ standard named
53775373
// modules since we want to support no-transitive-change model for named
@@ -5433,7 +5429,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
54335429
PrepareWritingSpecialDecls(SemaRef);
54345430

54355431
// Write the control block
5436-
WriteControlBlock(PP, Context, isysroot);
5432+
WriteControlBlock(PP, isysroot);
54375433

54385434
// Write the remaining AST contents.
54395435
Stream.FlushToWord();
@@ -5526,7 +5522,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
55265522
WriteDeclAndTypes(Context);
55275523

55285524
WriteFileDeclIDsMap();
5529-
WriteSourceManagerBlock(Context.getSourceManager(), PP);
5525+
WriteSourceManagerBlock(PP.getSourceManager());
55305526
WriteComments();
55315527
WritePreprocessor(PP, isModule);
55325528
WriteHeaderSearch(PP.getHeaderSearchInfo());

flang/lib/Semantics/check-declarations.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,9 @@ void CheckHelper::CheckObjectEntity(
928928
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
929929
common::CUDADataAttr::Device &&
930930
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
931-
common::CUDADataAttr::Managed) {
931+
common::CUDADataAttr::Managed &&
932+
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
933+
common::CUDADataAttr::Shared) {
932934
Warn(common::UsageWarning::CUDAUsage,
933935
"Dummy argument '%s' may not have ATTRIBUTES(%s) in a device subprogram"_warn_en_US,
934936
symbol.name(),

flang/test/Semantics/cuf03.cuf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ module m
5555
real, unified :: um
5656

5757
contains
58-
attributes(device) subroutine devsubr(n,da)
58+
attributes(device) subroutine devsubr(n,da,rs)
5959
integer, intent(in) :: n
6060
real, device :: da(*) ! ok
6161
real, managed :: ma(n) ! ok
6262
!WARNING: Pointer 'dp' may not be associated in a device subprogram
6363
real, device, pointer :: dp
6464
real, constant :: rc ! ok
65+
real, shared :: rs ! ok
6566
!ERROR: Object 'u' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram
6667
real, unified :: u
6768
end subroutine

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ class DependencyGraph {
345345
Interval<Instruction> extend(ArrayRef<Instruction *> Instrs);
346346
/// \Returns the range of instructions included in the DAG.
347347
Interval<Instruction> getInterval() const { return DAGInterval; }
348+
/// Called by the scheduler when a new instruction \p I has been created.
349+
void notifyCreateInstr(Instruction *I) {
350+
getOrCreateNode(I);
351+
// TODO: Update the dependencies for the new node.
352+
}
348353
#ifndef NDEBUG
349354
void print(raw_ostream &OS) const;
350355
LLVM_DUMP_METHOD void dump() const;

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ class LegalityAnalysis {
162162
const DataLayout &DL;
163163

164164
public:
165-
LegalityAnalysis(AAResults &AA, ScalarEvolution &SE, const DataLayout &DL)
166-
: Sched(AA), SE(SE), DL(DL) {}
165+
LegalityAnalysis(AAResults &AA, ScalarEvolution &SE, const DataLayout &DL,
166+
Context &Ctx)
167+
: Sched(AA, Ctx), SE(SE), DL(DL) {}
167168
/// A LegalityResult factory.
168169
template <typename ResultT, typename... ArgsT>
169170
ResultT &createLegalityResult(ArgsT... Args) {

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/Analysis/AliasAnalysis.h"
1414
#include "llvm/Analysis/ScalarEvolution.h"
1515
#include "llvm/IR/PassManager.h"
16+
#include "llvm/SandboxIR/Context.h"
1617
#include "llvm/SandboxIR/PassManager.h"
1718

1819
namespace llvm {
@@ -24,6 +25,8 @@ class SandboxVectorizerPass : public PassInfoMixin<SandboxVectorizerPass> {
2425
AAResults *AA = nullptr;
2526
ScalarEvolution *SE = nullptr;
2627

28+
std::unique_ptr<sandboxir::Context> Ctx;
29+
2730
// A pipeline of SandboxIR function passes run by the vectorizer.
2831
sandboxir::FunctionPassManager FPM;
2932

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class Scheduler {
9595
DependencyGraph DAG;
9696
std::optional<BasicBlock::iterator> ScheduleTopItOpt;
9797
SmallVector<std::unique_ptr<SchedBundle>> Bndls;
98+
Context &Ctx;
99+
Context::CallbackID CreateInstrCB;
98100

99101
/// \Returns a scheduling bundle containing \p Instrs.
100102
SchedBundle *createBundle(ArrayRef<Instruction *> Instrs);
@@ -110,8 +112,11 @@ class Scheduler {
110112
Scheduler &operator=(const Scheduler &) = delete;
111113

112114
public:
113-
Scheduler(AAResults &AA) : DAG(AA) {}
114-
~Scheduler() {}
115+
Scheduler(AAResults &AA, Context &Ctx) : DAG(AA), Ctx(Ctx) {
116+
CreateInstrCB = Ctx.registerCreateInstrCallback(
117+
[this](Instruction *I) { DAG.notifyCreateInstr(I); });
118+
}
119+
~Scheduler() { Ctx.unregisterCreateInstrCallback(CreateInstrCB); }
115120

116121
bool trySchedule(ArrayRef<Instruction *> Instrs);
117122

llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,
103103

104104
unsigned Offset;
105105
if (GV.getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
106-
if (TargetExtType *TTy = AMDGPU::isNamedBarrier(GV)) {
106+
if (AMDGPU::isNamedBarrier(GV)) {
107107
std::optional<unsigned> BarAddr = getLDSAbsoluteAddress(GV);
108108
if (!BarAddr)
109109
llvm_unreachable("named barrier should have an assigned address");

llvm/lib/Target/RISCV/RISCVGISel.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def gi_zexti32 : GIComplexOperandMatcher<s64, "selectZExtBits<32>">,
100100
GIComplexPatternEquiv<zexti32>;
101101
def gi_zexti16 : GIComplexOperandMatcher<s32, "selectZExtBits<16>">,
102102
GIComplexPatternEquiv<zexti16>;
103+
def gi_zexti8 : GIComplexOperandMatcher<s32, "selectZExtBits<8>">,
104+
GIComplexPatternEquiv<zexti8>;
103105

104106
// FIXME: Canonicalize (sub X, C) -> (add X, -C) earlier.
105107
def : Pat<(XLenVT (sub GPR:$rs1, simm12Plus1:$imm)),

0 commit comments

Comments
 (0)