Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: Ia3220e1c036f2c4f57a020e2e62924073b3626c7
  • Loading branch information
ronlieb committed Aug 25, 2024
2 parents c828e74 + 33e7cd6 commit ada98bb
Show file tree
Hide file tree
Showing 17 changed files with 223 additions and 31 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/ADT/StringRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ namespace llvm {
size_t Idx = find(Separator);
if (Idx == npos)
return std::make_pair(*this, StringRef());
return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
return std::make_pair(slice(0, Idx), substr(Idx + Separator.size()));
}

/// Split into two substrings around the last occurrence of a separator
Expand All @@ -731,7 +731,7 @@ namespace llvm {
size_t Idx = rfind(Separator);
if (Idx == npos)
return std::make_pair(*this, StringRef());
return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
return std::make_pair(slice(0, Idx), substr(Idx + Separator.size()));
}

/// Split into substrings around the occurrences of a separator string.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/MIRParser/MIParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ MIParser::MIParser(PerFunctionMIParsingState &PFS, SMDiagnostic &Error,

void MIParser::lex(unsigned SkipChar) {
CurrentSource = lexMIToken(
CurrentSource.slice(SkipChar, StringRef::npos), Token,
CurrentSource.substr(SkipChar), Token,
[this](StringRef::iterator Loc, const Twine &Msg) { error(Loc, Msg); });
}

Expand Down Expand Up @@ -2308,7 +2308,7 @@ bool MIParser::parseDIExpression(MDNode *&Expr) {
Expr = llvm::parseDIExpressionBodyAtBeginning(
CurrentSource, Read, Error, *PFS.MF.getFunction().getParent(),
&PFS.IRSlots);
CurrentSource = CurrentSource.slice(Read, StringRef::npos);
CurrentSource = CurrentSource.substr(Read);
lex();
if (!Expr)
return error(Error.getMessage());
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void MCAsmStreamer::addExplicitComment(const Twine &T) {
ExplicitCommentToEmit.append("\t");
ExplicitCommentToEmit.append(MAI->getCommentString());
// drop //
ExplicitCommentToEmit.append(c.slice(2, c.size()).str());
ExplicitCommentToEmit.append(c.substr(2).str());
} else if (c.starts_with(StringRef("/*"))) {
size_t p = 2, len = c.size() - 2;
// emit each line in comment as separate newline.
Expand All @@ -527,7 +527,7 @@ void MCAsmStreamer::addExplicitComment(const Twine &T) {

ExplicitCommentToEmit.append("\t");
ExplicitCommentToEmit.append(MAI->getCommentString());
ExplicitCommentToEmit.append(c.slice(1, c.size()).str());
ExplicitCommentToEmit.append(c.substr(1).str());
} else
assert(false && "Unexpected Assembly Comment");
// full line comments immediately output
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Object/MachOObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2436,12 +2436,12 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name,
a = Name.rfind('/');
if (a == Name.npos || a == 0)
goto guess_library;
Foo = Name.slice(a+1, Name.npos);
Foo = Name.substr(a + 1);

// Look for a suffix starting with a '_'
Idx = Foo.rfind('_');
if (Idx != Foo.npos && Foo.size() >= 2) {
Suffix = Foo.slice(Idx, Foo.npos);
Suffix = Foo.substr(Idx);
if (Suffix != "_debug" && Suffix != "_profile")
Suffix = StringRef();
else
Expand All @@ -2468,7 +2468,7 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name,
c = Name.rfind('/', b);
if (c == Name.npos || c == 0)
goto guess_library;
V = Name.slice(c+1, Name.npos);
V = Name.substr(c + 1);
if (!V.starts_with("Versions/"))
goto guess_library;
d = Name.rfind('/', c);
Expand All @@ -2489,7 +2489,7 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name,
a = Name.rfind('.');
if (a == Name.npos || a == 0)
return StringRef();
Dylib = Name.slice(a, Name.npos);
Dylib = Name.substr(a);
if (Dylib != ".dylib")
goto guess_qtx;

Expand Down Expand Up @@ -2527,7 +2527,7 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name,
return Lib;

guess_qtx:
Qtx = Name.slice(a, Name.npos);
Qtx = Name.substr(a);
if (Qtx != ".qtx")
return StringRef();
b = Name.rfind('/', a);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Support/StringRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void StringRef::split(SmallVectorImpl<StringRef> &A,
A.push_back(S.slice(0, Idx));

// Jump forward.
S = S.slice(Idx + Separator.size(), npos);
S = S.substr(Idx + Separator.size());
}

// Push the tail.
Expand All @@ -354,7 +354,7 @@ void StringRef::split(SmallVectorImpl<StringRef> &A, char Separator,
A.push_back(S.slice(0, Idx));

// Jump forward.
S = S.slice(Idx + 1, npos);
S = S.substr(Idx + 1);
}

// Push the tail.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Support/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,7 @@ bool JSONWriter::containedIn(StringRef Parent, StringRef Path) {
StringRef JSONWriter::containedPart(StringRef Parent, StringRef Path) {
assert(!Parent.empty());
assert(containedIn(Parent, Path));
return Path.slice(Parent.size() + 1, StringRef::npos);
return Path.substr(Parent.size() + 1);
}

void JSONWriter::startDirectory(StringRef Path) {
Expand Down Expand Up @@ -2846,7 +2846,7 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
if (UseOverlayRelative) {
assert(RPath.starts_with(OverlayDir) &&
"Overlay dir must be contained in RPath");
RPath = RPath.slice(OverlayDir.size(), RPath.size());
RPath = RPath.substr(OverlayDir.size());
}

bool IsCurrentDirEmpty = true;
Expand Down Expand Up @@ -2879,7 +2879,7 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
if (UseOverlayRelative) {
assert(RPath.starts_with(OverlayDir) &&
"Overlay dir must be contained in RPath");
RPath = RPath.slice(OverlayDir.size(), RPath.size());
RPath = RPath.substr(OverlayDir.size());
}
if (!Entry.IsDirectory) {
writeEntry(path::filename(Entry.VPath), RPath);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4183,7 +4183,7 @@ ParseStatus AArch64AsmParser::tryParseVectorRegister(MCRegister &Reg,

if (RegNum) {
if (Next != StringRef::npos) {
Kind = Name.slice(Next, StringRef::npos);
Kind = Name.substr(Next);
if (!isValidVectorKind(Kind, MatchKind))
return TokError("invalid vector kind qualifier");
}
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,10 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,

Attributor A(Functions, InfoCache, AC);

LLVM_DEBUG(dbgs() << "Module " << M.getName() << " is "
<< (AC.IsClosedWorldModule ? "" : "not ")
<< "assumed to be a closed world.\n");

for (Function &F : M) {
if (F.isIntrinsic())
continue;
Expand Down
8 changes: 6 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,12 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
// module is partitioned for codegen.
if (EnableLowerModuleLDS)
PM.addPass(AMDGPULowerModuleLDSPass(*this));
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
PM.addPass(AMDGPUAttributorPass(*this));

if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0) {
AMDGPUAttributorOptions Opts;
Opts.IsClosedWorld = true;
PM.addPass(AMDGPUAttributorPass(*this, Opts));
}
});

PB.registerRegClassFilterParsingCallback(
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5251,7 +5251,7 @@ ParseStatus ARMAsmParser::parseMSRMaskOperand(OperandVector &Operands) {
StringRef Flags = "";
std::string SpecReg = Mask.slice(Start, Next).lower();
if (Next != StringRef::npos)
Flags = Mask.slice(Next+1, Mask.size());
Flags = Mask.substr(Next + 1);

// FlagsVal contains the complete mask:
// 3-0: Mask
Expand Down Expand Up @@ -6648,15 +6648,15 @@ StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic, StringRef ExtraToken,

// The "it" instruction has the condition mask on the end of the mnemonic.
if (Mnemonic.starts_with("it")) {
ITMask = Mnemonic.slice(2, Mnemonic.size());
ITMask = Mnemonic.substr(2);
Mnemonic = Mnemonic.slice(0, 2);
}

if (Mnemonic.starts_with("vpst")) {
ITMask = Mnemonic.slice(4, Mnemonic.size());
ITMask = Mnemonic.substr(4);
Mnemonic = Mnemonic.slice(0, 4);
} else if (Mnemonic.starts_with("vpt")) {
ITMask = Mnemonic.slice(3, Mnemonic.size());
ITMask = Mnemonic.substr(3);
Mnemonic = Mnemonic.slice(0, 3);
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ bool PPCAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
Operands.push_back(PPCOperand::CreateToken(Mnemonic, NameLoc, isPPC64()));
if (Dot != StringRef::npos) {
SMLoc DotLoc = SMLoc::getFromPointer(NameLoc.getPointer() + Dot);
StringRef DotStr = Name.slice(Dot, StringRef::npos);
StringRef DotStr = Name.substr(Dot);
if (!NewOpcode.empty()) // Underlying memory for Name is volatile.
Operands.push_back(
PPCOperand::CreateTokenWithStringCopy(DotStr, DotLoc, isPPC64()));
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
consumeToken();
StringRef LHS = Identifier.slice(0, DotOffset);
StringRef Dot = Identifier.slice(DotOffset, DotOffset + 1);
StringRef RHS = Identifier.slice(DotOffset + 1, StringRef::npos);
StringRef RHS = Identifier.substr(DotOffset + 1);
if (!RHS.empty()) {
getLexer().UnLex(AsmToken(AsmToken::Identifier, RHS));
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/TargetParser/RISCVISAInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {

size_t Idx = Arch.find('_');
StringRef Ext = Arch.slice(0, Idx);
Arch = Arch.slice(Idx, StringRef::npos);
Arch = Arch.substr(Idx);

StringRef Prefix, MinorVersionStr;
std::tie(Prefix, MinorVersionStr) = Ext.rsplit('p');
Expand All @@ -533,7 +533,7 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
return getError("missing extension name");

StringRef ExtName = Prefix.slice(0, VersionStart);
StringRef MajorVersionStr = Prefix.slice(VersionStart, StringRef::npos);
StringRef MajorVersionStr = Prefix.substr(VersionStart);
if (MajorVersionStr.getAsInteger(10, MajorVersion))
return getError("failed to parse major version number");

Expand Down Expand Up @@ -662,7 +662,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,

size_t Idx = Arch.find('_');
StringRef Ext = Arch.slice(0, Idx);
Arch = Arch.slice(Idx, StringRef::npos);
Arch = Arch.substr(Idx);

do {
StringRef Name, Vers, Desc;
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; RUN: opt -O3 -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=PRE-LINK
; RUN: opt -passes="lto<O3>" -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=POST-LINK

target triple = "amdgcn-amd-amdhsa"

; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
; POST-LINK: Module {{.*}} is assumed to be a closed world.
define hidden noundef i32 @_Z3foov() {
ret i32 1
}
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,14 @@ parseTwoOperandConstraint(StringRef S, ArrayRef<SMLoc> Loc) {
size_t start = Ops.first.find_first_of('$');
if (start == std::string::npos)
PrintFatalError(Loc, "expected '$' prefix on asm operand name");
Ops.first = Ops.first.slice(start + 1, std::string::npos);
Ops.first = Ops.first.substr(start + 1);
size_t end = Ops.first.find_last_of(" \t");
Ops.first = Ops.first.slice(0, end);
// Now the second operand.
start = Ops.second.find_first_of('$');
if (start == std::string::npos)
PrintFatalError(Loc, "expected '$' prefix on asm operand name");
Ops.second = Ops.second.slice(start + 1, std::string::npos);
Ops.second = Ops.second.substr(start + 1);
end = Ops.second.find_last_of(" \t");
Ops.first = Ops.first.slice(0, end);
return Ops;
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/OptParserEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static MarshallingInfo createMarshallingInfo(const Record &R) {
break;
if (Idx > 0)
Ret.Values.push_back(ValuesStr.slice(0, Idx));
ValuesStr = ValuesStr.slice(Idx + 1, StringRef::npos);
ValuesStr = ValuesStr.substr(Idx + 1);
}
if (!ValuesStr.empty())
Ret.Values.push_back(ValuesStr);
Expand Down
Loading

0 comments on commit ada98bb

Please sign in to comment.