aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Lex/Preprocessor.h7
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp7
-rw-r--r--clang/lib/Basic/Targets/AArch64.cpp5
-rw-r--r--clang/lib/CodeGen/CGStmtOpenMP.cpp13
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h7
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp15
-rw-r--r--clang/lib/Driver/ToolChains/Cuda.cpp4
-rw-r--r--clang/lib/Headers/cpuid.h1
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp55
-rw-r--r--clang/lib/Sema/SemaExpr.cpp2
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp2
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp3
-rw-r--r--clang/utils/TableGen/SveEmitter.cpp2
-rw-r--r--libcxx/include/regex2
-rw-r--r--libcxx/include/span7
-rw-r--r--lld/COFF/Driver.cpp15
-rw-r--r--lld/docs/ReleaseNotes.rst11
-rw-r--r--llvm/include/llvm/Analysis/LoopAccessAnalysis.h2
-rw-r--r--llvm/include/llvm/MC/MCContext.h6
-rw-r--r--llvm/include/llvm/MC/MCDwarf.h6
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp3
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp51
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp5
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp10
-rw-r--r--llvm/lib/MC/MCContext.cpp39
-rw-r--r--llvm/lib/MC/MCDwarf.cpp14
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp3
-rw-r--r--llvm/lib/Support/Host.cpp1
-rw-r--r--llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp4
-rw-r--r--llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp8
-rw-r--r--llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp1
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp49
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp5
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp12
-rw-r--r--llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp18
36 files changed, 275 insertions, 124 deletions
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 79454b5addea..7c5df05069ed 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -178,6 +178,8 @@ class Preprocessor {
IdentifierInfo *Ident__is_target_vendor; // __is_target_vendor
IdentifierInfo *Ident__is_target_os; // __is_target_os
IdentifierInfo *Ident__is_target_environment; // __is_target_environment
+ IdentifierInfo *Ident__is_target_variant_os;
+ IdentifierInfo *Ident__is_target_variant_environment;
IdentifierInfo *Ident__FLT_EVAL_METHOD__; // __FLT_EVAL_METHOD
// Weak, only valid (and set) while InMacroArgs is true.
@@ -1353,6 +1355,11 @@ public:
StringRef getLastMacroWithSpelling(SourceLocation Loc,
ArrayRef<TokenValue> Tokens) const;
+ /// Get the predefines for this processor.
+ /// Used by some third-party tools to inspect and add predefines (see
+ /// https://github.com/llvm/llvm-project/issues/57483).
+ const std::string &getPredefines() const { return Predefines; }
+
/// Set the predefines for this Preprocessor.
///
/// These predefines are automatically injected when parsing the main file.
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 6f3ede2ce42a..5ddd95e2ecca 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1889,12 +1889,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
UnfilledBitsInLastUnit = 0;
LastBitfieldStorageUnitSize = 0;
- llvm::Triple Target = Context.getTargetInfo().getTriple();
- bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
- Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver14 ||
- Target.isPS() || Target.isOSDarwin())) ||
- D->hasAttr<PackedAttr>();
+ bool FieldPacked = Packed || D->hasAttr<PackedAttr>();
AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
CharUnits FieldSize;
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 60ef52ac3f0d..8d8972c1613a 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -489,9 +489,12 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__FP_FAST_FMA", "1");
Builder.defineMacro("__FP_FAST_FMAF", "1");
+ // C/C++ operators work on both VLS and VLA SVE types
+ if (FPU & SveMode)
+ Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS", "2");
+
if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) {
Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128));
- Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS");
}
}
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index aa55cdaca5dc..570424dae7fc 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2582,8 +2582,9 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const OMPLoopDirective &S,
CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_simd);
emitPostUpdateForReductionClause(CGF, S,
[](CodeGenFunction &) { return nullptr; });
+ LoopScope.restoreMap();
+ CGF.EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
}
- CGF.EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
// Emit: if (PreCond) - end.
if (ContBlock) {
CGF.EmitBranch(ContBlock);
@@ -3426,11 +3427,12 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
EmitOMPLastprivateClauseFinal(
S, isOpenMPSimdDirective(S.getDirectiveKind()),
Builder.CreateIsNotNull(EmitLoadOfScalar(IL, S.getBeginLoc())));
+ LoopScope.restoreMap();
+ EmitOMPLinearClauseFinal(S, [IL, &S](CodeGenFunction &CGF) {
+ return CGF.Builder.CreateIsNotNull(
+ CGF.EmitLoadOfScalar(IL, S.getBeginLoc()));
+ });
}
- EmitOMPLinearClauseFinal(S, [IL, &S](CodeGenFunction &CGF) {
- return CGF.Builder.CreateIsNotNull(
- CGF.EmitLoadOfScalar(IL, S.getBeginLoc()));
- });
DoacrossCleanupScope.ForceCleanup();
// We're now done with the loop, so jump to the continuation block.
if (ContBlock) {
@@ -7658,6 +7660,7 @@ void CodeGenFunction::EmitOMPTaskLoopBasedDirective(const OMPLoopDirective &S) {
CGF.GetAddrOfLocalVar(*LIP), /*Volatile=*/false,
(*LIP)->getType(), S.getBeginLoc())));
}
+ LoopScope.restoreMap();
CGF.EmitOMPLinearClauseFinal(S, [LIP, &S](CodeGenFunction &CGF) {
return CGF.Builder.CreateIsNotNull(
CGF.EmitLoadOfScalar(CGF.GetAddrOfLocalVar(*LIP), /*Volatile=*/false,
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index fe0890f433e8..672acd844525 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1094,7 +1094,7 @@ public:
void ForceCleanup() {
RunCleanupsScope::ForceCleanup();
- MappedVars.restore(CGF);
+ restoreMap();
}
/// Exit scope - all the mapped variables are restored.
@@ -1108,6 +1108,11 @@ public:
VD = VD->getCanonicalDecl();
return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0;
}
+
+ /// Restore all mapped variables w/o clean up. This is usefully when we want
+ /// to reference the original variables but don't want the clean up because
+ /// that could emit lifetime end too early, causing backend issue #56913.
+ void restoreMap() { MappedVars.restore(CGF); }
};
/// Save/restore original map of previously emitted local vars in case when we
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 195ad8cdc13e..36e10e4df4c1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -11002,9 +11002,22 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
// Unions aren't eligible unless they're empty (which is caught above).
if (RD->isUnion())
return false;
+ const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
+ // If this is a C++ record, check the bases first.
+ if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
+ for (const CXXBaseSpecifier &B : CXXRD->bases()) {
+ const auto *BDecl =
+ cast<CXXRecordDecl>(B.getType()->castAs<RecordType>()->getDecl());
+ CharUnits BaseOff = Layout.getBaseClassOffset(BDecl);
+ bool Ret = detectFPCCEligibleStructHelper(B.getType(), CurOff + BaseOff,
+ Field1Ty, Field1Off, Field2Ty,
+ Field2Off);
+ if (!Ret)
+ return false;
+ }
+ }
int ZeroWidthBitFieldCount = 0;
for (const FieldDecl *FD : RD->fields()) {
- const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
uint64_t FieldOffInBits = Layout.getFieldOffset(FD->getFieldIndex());
QualType QTy = FD->getType();
if (FD->isBitField()) {
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index 5e59677947e6..7ad990dda467 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -693,8 +693,8 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
// Only object files are changed, for example assembly files keep their .s
- // extensions.
- if (Input.getType() != types::TY_Object)
+ // extensions. If the user requested device-only compilation don't change it.
+ if (Input.getType() != types::TY_Object || getDriver().offloadDeviceOnly())
return ToolChain::getInputFilename(Input);
// Replace extension for object files with cubin because nvlink relies on
diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 5d262a60735f..caa0069c2e1f 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -232,6 +232,7 @@
/* Features in %ebx for leaf 0x80000008 */
#define bit_CLZERO 0x00000001
+#define bit_RDPRU 0x00000010
#define bit_WBNOINVD 0x00000200
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index f3be2107f985..c56f41c4495e 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -387,6 +387,10 @@ void Preprocessor::RegisterBuiltinMacros() {
Ident__is_target_os = RegisterBuiltinMacro(*this, "__is_target_os");
Ident__is_target_environment =
RegisterBuiltinMacro(*this, "__is_target_environment");
+ Ident__is_target_variant_os =
+ RegisterBuiltinMacro(*this, "__is_target_variant_os");
+ Ident__is_target_variant_environment =
+ RegisterBuiltinMacro(*this, "__is_target_variant_environment");
// Modules.
Ident__building_module = RegisterBuiltinMacro(*this, "__building_module");
@@ -1431,6 +1435,39 @@ static bool isTargetEnvironment(const TargetInfo &TI,
return TI.getTriple().getEnvironment() == Env.getEnvironment();
}
+/// Implements the __is_target_variant_os builtin macro.
+static bool isTargetVariantOS(const TargetInfo &TI, const IdentifierInfo *II) {
+ if (TI.getTriple().isOSDarwin()) {
+ const llvm::Triple *VariantTriple = TI.getDarwinTargetVariantTriple();
+ if (!VariantTriple)
+ return false;
+
+ std::string OSName =
+ (llvm::Twine("unknown-unknown-") + II->getName().lower()).str();
+ llvm::Triple OS(OSName);
+ if (OS.getOS() == llvm::Triple::Darwin) {
+ // Darwin matches macos, ios, etc.
+ return VariantTriple->isOSDarwin();
+ }
+ return VariantTriple->getOS() == OS.getOS();
+ }
+ return false;
+}
+
+/// Implements the __is_target_variant_environment builtin macro.
+static bool isTargetVariantEnvironment(const TargetInfo &TI,
+ const IdentifierInfo *II) {
+ if (TI.getTriple().isOSDarwin()) {
+ const llvm::Triple *VariantTriple = TI.getDarwinTargetVariantTriple();
+ if (!VariantTriple)
+ return false;
+ std::string EnvName = (llvm::Twine("---") + II->getName().lower()).str();
+ llvm::Triple Env(EnvName);
+ return VariantTriple->getEnvironment() == Env.getEnvironment();
+ }
+ return false;
+}
+
/// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
/// as a builtin macro, handle it and return the next token as 'Tok'.
void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
@@ -1677,6 +1714,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
.Case("__is_target_vendor", true)
.Case("__is_target_os", true)
.Case("__is_target_environment", true)
+ .Case("__is_target_variant_os", true)
+ .Case("__is_target_variant_environment", true)
.Default(false);
}
});
@@ -1877,6 +1916,22 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
Tok, *this, diag::err_feature_check_malformed);
return II && isTargetEnvironment(getTargetInfo(), II);
});
+ } else if (II == Ident__is_target_variant_os) {
+ EvaluateFeatureLikeBuiltinMacro(
+ OS, Tok, II, *this, false,
+ [this](Token &Tok, bool &HasLexedNextToken) -> int {
+ IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+ Tok, *this, diag::err_feature_check_malformed);
+ return II && isTargetVariantOS(getTargetInfo(), II);
+ });
+ } else if (II == Ident__is_target_variant_environment) {
+ EvaluateFeatureLikeBuiltinMacro(
+ OS, Tok, II, *this, false,
+ [this](Token &Tok, bool &HasLexedNextToken) -> int {
+ IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+ Tok, *this, diag::err_feature_check_malformed);
+ return II && isTargetVariantEnvironment(getTargetInfo(), II);
+ });
} else {
llvm_unreachable("Unknown identifier!");
}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0f79978b0911..0e24237faae5 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15603,6 +15603,8 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
resultType->castAs<VectorType>()->getVectorKind() !=
VectorType::AltiVecBool))
break;
+ else if (resultType->isVLSTBuiltinType()) // SVE vectors allow + and -
+ break;
else if (getLangOpts().CPlusPlus && // C++ [expr.unary.op]p6
Opc == UO_Plus &&
resultType->isPointerType())
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5331193de863..6f9e025283f5 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5412,6 +5412,8 @@ void DiagnoseBuiltinDeprecation(Sema& S, TypeTrait Kind,
Replacement = BTT_IsTriviallyAssignable;
break;
case UTT_HasTrivialCopy:
+ Replacement = UTT_IsTriviallyCopyable;
+ break;
case UTT_HasTrivialDefaultConstructor:
case UTT_HasTrivialMoveConstructor:
Replacement = TT_IsTriviallyConstructible;
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index dc1470bf7a9d..a92fec6a0232 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2270,6 +2270,9 @@ bool Sema::isInOpenMPTargetExecutionDirective() const {
}
bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) {
+ // Only rebuild for Field.
+ if (!dyn_cast<FieldDecl>(D))
+ return false;
DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(
D,
[](OpenMPClauseKind C, bool AppliedToPointee,
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index b2f6ede56522..e1e1c078ccbf 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -1282,6 +1282,8 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
OS << "#ifdef __cplusplus\n";
OS << "} // extern \"C\"\n";
OS << "#endif\n\n";
+ OS << "#undef __ai\n\n";
+ OS << "#undef __aio\n\n";
OS << "#endif /*__ARM_FEATURE_SVE */\n\n";
OS << "#endif /* __ARM_SVE_H */\n";
}
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 850fe099df1e..26887e84bf28 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1355,7 +1355,7 @@ inline _LIBCPP_INLINE_VISIBILITY
unsigned char __to_lower(unsigned char __c)
{
#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
- return c & 0xBF;
+ return __c & 0xBF;
#else
return __c | 0x20;
#endif
diff --git a/libcxx/include/span b/libcxx/include/span
index 00793a210cbe..67d2ac241ff2 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -453,9 +453,10 @@ public:
: __data{_VSTD::to_address(__first)}, __size{__count} {}
template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
- _LIBCPP_INLINE_VISIBILITY
- constexpr span(_It __first, _End __last)
- : __data(_VSTD::to_address(__first)), __size(__last - __first) {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last)
+ : __data(_VSTD::to_address(__first)), __size(__last - __first) {
+ _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)");
+ }
template <size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 680f89b79b95..5b21337bb45e 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2228,15 +2228,14 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
// Windows specific -- if __load_config_used can be resolved, resolve it.
if (ctx.symtab.findUnderscore("_load_config_used"))
addUndefined(mangle("_load_config_used"));
- } while (run());
- if (args.hasArg(OPT_include_optional)) {
- // Handle /includeoptional
- for (auto *arg : args.filtered(OPT_include_optional))
- if (isa_and_nonnull<LazyArchive>(ctx.symtab.find(arg->getValue())))
- addUndefined(arg->getValue());
- while (run());
- }
+ if (args.hasArg(OPT_include_optional)) {
+ // Handle /includeoptional
+ for (auto *arg : args.filtered(OPT_include_optional))
+ if (isa_and_nonnull<LazyArchive>(ctx.symtab.find(arg->getValue())))
+ addUndefined(arg->getValue());
+ }
+ } while (run());
// Create wrapped symbols for -wrap option.
std::vector<WrappedSymbol> wrapped = addWrappedSymbols(ctx, args);
diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 5819d67d3297..db0b66a3807c 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -5,13 +5,6 @@ lld |release| Release Notes
.. contents::
:local:
-.. only:: PreRelease
-
- .. warning::
- These are in-progress notes for the upcoming LLVM |release| release.
- Release notes for previous releases can be found on
- `the Download Page <https://releases.llvm.org/download.html>`_.
-
Introduction
============
@@ -98,7 +91,7 @@ MachO Improvements
* We now support proper relocation and pruning of EH frames. **Note:** this
comes at some performance overhead on x86_64 builds, and we recommend adding
- the ``-femit-compact-unwind=no-compact-unwind`` compile flag to avoid it.
+ the ``-femit-dwarf-unwind=no-compact-unwind`` compile flag to avoid it.
(`D129540 <https://reviews.llvm.org/D129540>`_,
`D122258 <https://reviews.llvm.org/D122258>`_)
@@ -212,6 +205,8 @@ Fixes
errors. (`D122624 <https://reviews.llvm.org/D122624>`_)
* Fixed handling of relocatable object files within frameworks.
(`D114841 <https://reviews.llvm.org/D114841>`_)
+* Fixed the PPC64R2SaveStub to only use non-pc-relative code.
+ (`D129580 <https://reviews.llvm.org/D129580>`_)
WebAssembly Improvements
------------------------
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index 8f71ce9e96c0..af8e8d22269e 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -253,6 +253,8 @@ public:
return {};
}
+ const Loop *getInnermostLoop() const { return InnermostLoop; }
+
private:
/// A wrapper around ScalarEvolution, used to add runtime SCEV checks, and
/// applies dynamic knowledge to simplify SCEV expressions and convert them
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index 61520c4f29bf..c20ce79ee4d0 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -190,7 +190,8 @@ private:
SmallString<128> CompilationDir;
/// Prefix replacement map for source file information.
- std::map<const std::string, const std::string> DebugPrefixMap;
+ std::map<std::string, const std::string, std::greater<std::string>>
+ DebugPrefixMap;
/// The main file name if passed in explicitly.
std::string MainFileName;
@@ -698,6 +699,9 @@ public:
/// Add an entry to the debug prefix map.
void addDebugPrefixMapEntry(const std::string &From, const std::string &To);
+ /// Remap one path in-place as per the debug prefix map.
+ void remapDebugPath(SmallVectorImpl<char> &Path);
+
// Remaps all debug directory paths in-place as per the debug prefix map.
void RemapDebugPaths();
diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h
index 8b2ae84749b4..557c713575e4 100644
--- a/llvm/include/llvm/MC/MCDwarf.h
+++ b/llvm/include/llvm/MC/MCDwarf.h
@@ -22,6 +22,7 @@
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MD5.h"
+#include "llvm/Support/StringSaver.h"
#include <cassert>
#include <cstdint>
#include <string>
@@ -48,6 +49,8 @@ MCSymbol *emitListsTableHeaderStart(MCStreamer &S);
/// Manage the .debug_line_str section contents, if we use it.
class MCDwarfLineStr {
+ BumpPtrAllocator Alloc;
+ StringSaver Saver{Alloc};
MCSymbol *LineStrLabel = nullptr;
StringTableBuilder LineStrings{StringTableBuilder::DWARF};
bool UseRelocs = false;
@@ -57,6 +60,8 @@ public:
/// v5 line table).
explicit MCDwarfLineStr(MCContext &Ctx);
+ StringSaver &getSaver() { return Saver; }
+
/// Emit a reference to the string.
void emitRef(MCStreamer *MCOS, StringRef Path);
@@ -382,6 +387,7 @@ public:
bool hasRootFile() const { return !Header.RootFile.Name.empty(); }
+ MCDwarfFile &getRootFile() { return Header.RootFile; }
const MCDwarfFile &getRootFile() const { return Header.RootFile; }
// Report whether MD5 usage has been consistent (all-or-none).
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index aa35f253bc5f..8311b480ab09 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -280,7 +280,8 @@ void RuntimePointerChecking::tryToCreateDiffCheck(
auto *SrcAR = dyn_cast<SCEVAddRecExpr>(Src->Expr);
auto *SinkAR = dyn_cast<SCEVAddRecExpr>(Sink->Expr);
- if (!SrcAR || !SinkAR) {
+ if (!SrcAR || !SinkAR || SrcAR->getLoop() != DC.getInnermostLoop() ||
+ SinkAR->getLoop() != DC.getInnermostLoop()) {
CanUseDiffCheck = false;
return;
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 8d465b9520de..42a141e8876b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6360,7 +6360,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
SDValue Extendee = Ext->getOperand(0);
unsigned ScalarWidth = Extendee.getValueType().getScalarSizeInBits();
- if (N1C->getAPIntValue().isMask(ScalarWidth)) {
+ if (N1C->getAPIntValue().isMask(ScalarWidth) &&
+ (!LegalOperations || TLI.isOperationLegal(ISD::ZERO_EXTEND, ExtVT))) {
// (and (extract_subvector (zext|anyext|sext v) _) iN_mask)
// => (extract_subvector (iN_zeroext v))
SDValue ZeroExtExtendee =
@@ -7573,6 +7574,10 @@ SDValue DAGCombiner::MatchRotate(SDValue LHS, SDValue RHS, const SDLoc &DL) {
std::swap(LHSMask, RHSMask);
}
+ // Something has gone wrong - we've lost the shl/srl pair - bail.
+ if (LHSShift.getOpcode() != ISD::SHL || RHSShift.getOpcode() != ISD::SRL)
+ return SDValue();
+
unsigned EltSizeInBits = VT.getScalarSizeInBits();
SDValue LHSShiftArg = LHSShift.getOperand(0);
SDValue LHSShiftAmt = LHSShift.getOperand(1);
@@ -22729,25 +22734,31 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
SDLoc DL(N);
EVT IntVT = VT.changeVectorElementTypeToInteger();
EVT IntSVT = VT.getVectorElementType().changeTypeToInteger();
- IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT);
- SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT);
- SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT);
- SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT));
- for (int I = 0; I != (int)NumElts; ++I)
- if (0 <= Mask[I])
- AndMask[I] = Mask[I] == I ? AllOnesElt : ZeroElt;
-
- // See if a clear mask is legal instead of going via
- // XformToShuffleWithZero which loses UNDEF mask elements.
- if (TLI.isVectorClearMaskLegal(ClearMask, IntVT))
- return DAG.getBitcast(
- VT, DAG.getVectorShuffle(IntVT, DL, DAG.getBitcast(IntVT, N0),
- DAG.getConstant(0, DL, IntVT), ClearMask));
-
- if (TLI.isOperationLegalOrCustom(ISD::AND, IntVT))
- return DAG.getBitcast(
- VT, DAG.getNode(ISD::AND, DL, IntVT, DAG.getBitcast(IntVT, N0),
- DAG.getBuildVector(IntVT, DL, AndMask)));
+ // Transform the type to a legal type so that the buildvector constant
+ // elements are not illegal. Make sure that the result is larger than the
+ // original type, incase the value is split into two (eg i64->i32).
+ if (!TLI.isTypeLegal(IntSVT) && LegalTypes)
+ IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT);
+ if (IntSVT.getSizeInBits() >= IntVT.getScalarSizeInBits()) {
+ SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT);
+ SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT);
+ SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT));
+ for (int I = 0; I != (int)NumElts; ++I)
+ if (0 <= Mask[I])
+ AndMask[I] = Mask[I] == I ? AllOnesElt : ZeroElt;
+
+ // See if a clear mask is legal instead of going via
+ // XformToShuffleWithZero which loses UNDEF mask elements.
+ if (TLI.isVectorClearMaskLegal(ClearMask, IntVT))
+ return DAG.getBitcast(
+ VT, DAG.getVectorShuffle(IntVT, DL, DAG.getBitcast(IntVT, N0),
+ DAG.getConstant(0, DL, IntVT), ClearMask));
+
+ if (TLI.isOperationLegalOrCustom(ISD::AND, IntVT))
+ return DAG.getBitcast(
+ VT, DAG.getNode(ISD::AND, DL, IntVT, DAG.getBitcast(IntVT, N0),
+ DAG.getBuildVector(IntVT, DL, AndMask)));
+ }
}
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index 228d4a43ccde..e2173879c218 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -4428,7 +4428,10 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N,
else if (VT == MVT::i128)
LC = RTLIB::MULO_I128;
- if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
+ // If we don't have the libcall or if the function we are compiling is the
+ // implementation of the expected libcall (avoid inf-loop), expand inline.
+ if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC) ||
+ TLI.getLibcallName(LC) == DAG.getMachineFunction().getName()) {
// FIXME: This is not an optimal expansion, but better than crashing.
EVT WideVT =
EVT::getIntegerVT(*DAG.getContext(), VT.getScalarSizeInBits() * 2);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index d2ed4fe018b5..5ea4c4cded7f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1382,10 +1382,12 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
IncludeDir = dwarf::toStringRef(IncludeDirectories[Entry.DirIdx - 1]);
}
- // For absolute paths only, include the compilation directory of compile unit.
- // We know that FileName is not absolute, the only way to have an absolute
- // path at this point would be if IncludeDir is absolute.
- if (Kind == FileLineInfoKind::AbsoluteFilePath && !CompDir.empty() &&
+ // For absolute paths only, include the compilation directory of compile unit,
+ // unless v5 DirIdx == 0 (IncludeDir indicates the compilation directory). We
+ // know that FileName is not absolute, the only way to have an absolute path
+ // at this point would be if IncludeDir is absolute.
+ if (Kind == FileLineInfoKind::AbsoluteFilePath &&
+ (getVersion() < 5 || Entry.DirIdx != 0) && !CompDir.empty() &&
!isPathAbsoluteOnWindowsOrPosix(IncludeDir))
sys::path::append(FilePath, Style, CompDir);
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 322ed8e23eb6..062246f9c7ee 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -855,30 +855,35 @@ void MCContext::addDebugPrefixMapEntry(const std::string &From,
DebugPrefixMap.insert(std::make_pair(From, To));
}
+void MCContext::remapDebugPath(SmallVectorImpl<char> &Path) {
+ for (const auto &V : DebugPrefixMap)
+ if (llvm::sys::path::replace_path_prefix(Path, V.first, V.second))
+ break;
+}
+
void MCContext::RemapDebugPaths() {
const auto &DebugPrefixMap = this->DebugPrefixMap;
if (DebugPrefixMap.empty())
return;
- const auto RemapDebugPath = [&DebugPrefixMap](std::string &Path) {
- SmallString<256> P(Path);
- for (const auto &Entry : DebugPrefixMap) {
- if (llvm::sys::path::replace_path_prefix(P, Entry.first, Entry.second)) {
- Path = P.str().str();
- break;
- }
+ // Remap compilation directory.
+ remapDebugPath(CompilationDir);
+
+ // Remap MCDwarfDirs and RootFile.Name in all compilation units.
+ SmallString<256> P;
+ for (auto &CUIDTablePair : MCDwarfLineTablesCUMap) {
+ for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs()) {
+ P = Dir;
+ remapDebugPath(P);
+ Dir = std::string(P);
}
- };
- // Remap compilation directory.
- std::string CompDir = std::string(CompilationDir.str());
- RemapDebugPath(CompDir);
- CompilationDir = CompDir;
-
- // Remap MCDwarfDirs in all compilation units.
- for (auto &CUIDTablePair : MCDwarfLineTablesCUMap)
- for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs())
- RemapDebugPath(Dir);
+ // Used by DW_TAG_compile_unit's DT_AT_name and DW_TAG_label's
+ // DW_AT_decl_file for DWARF v5 generated for assembly source.
+ P = CUIDTablePair.second.getRootFile().Name;
+ remapDebugPath(P);
+ CUIDTablePair.second.getRootFile().Name = std::string(P);
+ }
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 4cbb9981fde2..cc1a662da87e 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -266,7 +266,7 @@ void MCDwarfLineTable::emit(MCStreamer *MCOS, MCDwarfLineTableParams Params) {
// In a v5 non-split line table, put the strings in a separate section.
Optional<MCDwarfLineStr> LineStr;
if (context.getDwarfVersion() >= 5)
- LineStr = MCDwarfLineStr(context);
+ LineStr.emplace(context);
// Switch to the section where the table will be emitted into.
MCOS->switchSection(context.getObjectFileInfo()->getDwarfLineSection());
@@ -416,9 +416,15 @@ void MCDwarfLineTableHeader::emitV5FileDirTables(
: dwarf::DW_FORM_string);
MCOS->emitULEB128IntValue(MCDwarfDirs.size() + 1);
// Try not to emit an empty compilation directory.
- const StringRef CompDir = CompilationDir.empty()
- ? MCOS->getContext().getCompilationDir()
- : StringRef(CompilationDir);
+ SmallString<256> Dir;
+ StringRef CompDir = MCOS->getContext().getCompilationDir();
+ if (!CompilationDir.empty()) {
+ Dir = CompilationDir;
+ MCOS->getContext().remapDebugPath(Dir);
+ CompDir = Dir.str();
+ if (LineStr)
+ CompDir = LineStr->getSaver().save(CompDir);
+ }
if (LineStr) {
// Record path strings, emit references here.
LineStr->emitRef(MCOS, CompDir);
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 563d3487ef50..38977b7641a0 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -566,8 +566,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
}
if (getLexer().isNot(AsmToken::String)) {
- if (!getContext().getAsmInfo()->usesSunStyleELFSectionSwitchSyntax()
- || getLexer().isNot(AsmToken::Hash))
+ if (getLexer().isNot(AsmToken::Hash))
return TokError("expected string in directive");
extraFlags = parseSunStyleSectionFlags();
} else {
diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index c97f273b0739..94a1536f4690 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -1734,6 +1734,7 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
bool HasExtLeaf8 = MaxExtLevel >= 0x80000008 &&
!getX86CpuIDAndInfo(0x80000008, &EAX, &EBX, &ECX, &EDX);
Features["clzero"] = HasExtLeaf8 && ((EBX >> 0) & 1);
+ Features["rdpru"] = HasExtLeaf8 && ((EBX >> 4) & 1);
Features["wbnoinvd"] = HasExtLeaf8 && ((EBX >> 9) & 1);
bool HasLeaf7 =
diff --git a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
index a19253da440e..1b5bd4c00089 100644
--- a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
+++ b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
@@ -71,7 +71,7 @@ bool RISCVCodeGenPrepare::optimizeZExt(ZExtInst *ZExt) {
// This often occurs with widened induction variables.
if (isImpliedByDomCondition(ICmpInst::ICMP_SGE, Src,
Constant::getNullValue(Src->getType()), ZExt,
- *DL)) {
+ *DL).value_or(false)) {
auto *SExt = new SExtInst(Src, ZExt->getType(), "", ZExt);
SExt->takeName(ZExt);
SExt->setDebugLoc(ZExt->getDebugLoc());
@@ -140,7 +140,7 @@ bool RISCVCodeGenPrepare::optimizeAndExt(BinaryOperator *BO) {
// And mask constant.
if (!isImpliedByDomCondition(ICmpInst::ICMP_SGE, LHSSrc,
Constant::getNullValue(LHSSrc->getType()),
- LHS, *DL))
+ LHS, *DL).value_or(false))
return false;
// Sign extend the constant and replace the And operand.
diff --git a/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp b/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
index 27d1326d5f6c..7b63b060dd9c 100644
--- a/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
+++ b/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
@@ -21,8 +21,8 @@ Target &llvm::getTheRISCV64Target() {
}
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetInfo() {
- RegisterTarget<Triple::riscv32> X(getTheRISCV32Target(), "riscv32",
- "32-bit RISC-V", "RISCV");
- RegisterTarget<Triple::riscv64> Y(getTheRISCV64Target(), "riscv64",
- "64-bit RISC-V", "RISCV");
+ RegisterTarget<Triple::riscv32, /*HasJIT=*/true> X(
+ getTheRISCV32Target(), "riscv32", "32-bit RISC-V", "RISCV");
+ RegisterTarget<Triple::riscv64, /*HasJIT=*/true> Y(
+ getTheRISCV64Target(), "riscv64", "64-bit RISC-V", "RISCV");
}
diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
index c5cc2ea34bb7..c4545ff56f74 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
@@ -40,7 +40,6 @@ SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Triple &TheTriple) {
ExceptionsType = ExceptionHandling::DwarfCFI;
- SunStyleELFSectionSwitchSyntax = true;
UsesELFSectionDirectiveForBSS = true;
}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 7d0fc4e8a8c6..cd45c48259bb 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -1362,6 +1362,8 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setOperationAction(ISD::SINT_TO_FP, MVT::v8i32, Custom);
setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v8i32, Custom);
+ setOperationAction(ISD::FP_EXTEND, MVT::v8f32, Expand);
+ setOperationAction(ISD::FP_ROUND, MVT::v8f16, Expand);
setOperationAction(ISD::FP_EXTEND, MVT::v4f64, Custom);
setOperationAction(ISD::STRICT_FP_EXTEND, MVT::v4f64, Custom);
@@ -1519,7 +1521,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
// Extract subvector is special because the value type
// (result) is 128-bit but the source is 256-bit wide.
for (auto VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64,
- MVT::v4f32, MVT::v2f64 }) {
+ MVT::v8f16, MVT::v4f32, MVT::v2f64 }) {
setOperationAction(ISD::EXTRACT_SUBVECTOR, VT, Legal);
}
@@ -1859,7 +1861,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
// (result) is 256-bit but the source is 512-bit wide.
// 128-bit was made Legal under AVX1.
for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64,
- MVT::v8f32, MVT::v4f64 })
+ MVT::v16f16, MVT::v8f32, MVT::v4f64 })
setOperationAction(ISD::EXTRACT_SUBVECTOR, VT, Legal);
for (auto VT : { MVT::v64i8, MVT::v32i16, MVT::v16i32, MVT::v8i64,
@@ -16120,16 +16122,18 @@ static SDValue lowerV8F16Shuffle(const SDLoc &DL, ArrayRef<int> Mask,
assert(Mask.size() == 8 && "Unexpected mask size for v8 shuffle!");
int NumV2Elements = count_if(Mask, [](int M) { return M >= 8; });
- if (NumV2Elements == 0) {
- // Check for being able to broadcast a single element.
- if (SDValue Broadcast = lowerShuffleAsBroadcast(DL, MVT::v8f16, V1, V2,
- Mask, Subtarget, DAG))
- return Broadcast;
+ if (Subtarget.hasFP16()) {
+ if (NumV2Elements == 0) {
+ // Check for being able to broadcast a single element.
+ if (SDValue Broadcast = lowerShuffleAsBroadcast(DL, MVT::v8f16, V1, V2,
+ Mask, Subtarget, DAG))
+ return Broadcast;
+ }
+ if (NumV2Elements == 1 && Mask[0] >= 8)
+ if (SDValue V = lowerShuffleAsElementInsertion(
+ DL, MVT::v8f16, V1, V2, Mask, Zeroable, Subtarget, DAG))
+ return V;
}
- if (NumV2Elements == 1 && Mask[0] >= 8)
- if (SDValue V = lowerShuffleAsElementInsertion(DL, MVT::v8f16, V1, V2, Mask,
- Zeroable, Subtarget, DAG))
- return V;
V1 = DAG.getBitcast(MVT::v8i16, V1);
V2 = DAG.getBitcast(MVT::v8i16, V2);
@@ -32701,8 +32705,29 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
N->getOpcode() == ISD::STRICT_FP_TO_SINT;
EVT VT = N->getValueType(0);
SDValue Src = N->getOperand(IsStrict ? 1 : 0);
+ SDValue Chain = IsStrict ? N->getOperand(0) : SDValue();
EVT SrcVT = Src.getValueType();
+ SDValue Res;
+ if (isSoftFP16(SrcVT)) {
+ EVT NVT = VT.isVector() ? VT.changeVectorElementType(MVT::f32) : MVT::f32;
+ if (IsStrict) {
+ Res =
+ DAG.getNode(N->getOpcode(), dl, {VT, MVT::Other},
+ {Chain, DAG.getNode(ISD::STRICT_FP_EXTEND, dl,
+ {NVT, MVT::Other}, {Chain, Src})});
+ Chain = Res.getValue(1);
+ } else {
+ Res = DAG.getNode(N->getOpcode(), dl, VT,
+ DAG.getNode(ISD::FP_EXTEND, dl, NVT, Src));
+ }
+ Results.push_back(Res);
+ if (IsStrict)
+ Results.push_back(Chain);
+
+ return;
+ }
+
if (VT.isVector() && Subtarget.hasFP16() &&
SrcVT.getVectorElementType() == MVT::f16) {
EVT EleVT = VT.getVectorElementType();
@@ -32716,7 +32741,6 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
Src = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v8f16, Ops);
}
- SDValue Res, Chain;
if (IsStrict) {
unsigned Opc =
IsSigned ? X86ISD::STRICT_CVTTP2SI : X86ISD::STRICT_CVTTP2UI;
@@ -32908,7 +32932,6 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
return;
}
- SDValue Chain;
if (SDValue V = FP_TO_INTHelper(SDValue(N, 0), DAG, IsSigned, Chain)) {
Results.push_back(V);
if (IsStrict)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 158d2e8289e0..edbd4091d1d2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2040,9 +2040,7 @@ Instruction *InstCombinerImpl::foldICmpMulConstant(ICmpInst &Cmp,
NewC = ConstantInt::get(
Mul->getType(),
APIntOps::RoundingSDiv(C, *MulC, APInt::Rounding::DOWN));
- }
-
- if (Mul->hasNoUnsignedWrap()) {
+ } else if (Mul->hasNoUnsignedWrap()) {
if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)
NewC = ConstantInt::get(
Mul->getType(),
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 349063dd5e89..bbba76a5c5ef 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1394,7 +1394,10 @@ int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI,
// and next SCEV may errneously get smaller cost.
// Collect all the candidate PHINodes to be rewritten.
- RewritePhiSet.emplace_back(PN, i, ExitValue, Inst, HighCost);
+ Instruction *InsertPt =
+ (isa<PHINode>(Inst) || isa<LandingPadInst>(Inst)) ?
+ &*Inst->getParent()->getFirstInsertionPt() : Inst;
+ RewritePhiSet.emplace_back(PN, i, ExitValue, InsertPt, HighCost);
}
}
}
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 03087d8370d5..245f2d4e442a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -89,10 +89,12 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr,
// Fail for an invalid base (required by POSIX).
return nullptr;
+ // Current offset into the original string to reflect in EndPtr.
+ size_t Offset = 0;
// Strip leading whitespace.
- for (unsigned i = 0; i != Str.size(); ++i)
- if (!isSpace((unsigned char)Str[i])) {
- Str = Str.substr(i);
+ for ( ; Offset != Str.size(); ++Offset)
+ if (!isSpace((unsigned char)Str[Offset])) {
+ Str = Str.substr(Offset);
break;
}
@@ -108,6 +110,7 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr,
if (Str.empty())
// Fail for a sign with nothing after it.
return nullptr;
+ ++Offset;
}
// Set Max to the absolute value of the minimum (for signed), or
@@ -127,6 +130,7 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr,
return nullptr;
Str = Str.drop_front(2);
+ Offset += 2;
Base = 16;
}
else if (Base == 0)
@@ -167,7 +171,7 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr,
if (EndPtr) {
// Store the pointer to the end.
- Value *Off = B.getInt64(Str.size());
+ Value *Off = B.getInt64(Offset + Str.size());
Value *StrBeg = CI->getArgOperand(0);
Value *StrEnd = B.CreateInBoundsGEP(B.getInt8Ty(), StrBeg, Off, "endptr");
B.CreateStore(StrEnd, EndPtr);
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d69d1e3d19f3..53c11c58f73d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4696,10 +4696,12 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
};
SmallVector<unsigned> SortedIndices;
BasicBlock *BB = nullptr;
+ bool IsScatterVectorizeUserTE =
+ UserTreeIdx.UserTE &&
+ UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize;
bool AreAllSameInsts =
(S.getOpcode() && allSameBlock(VL)) ||
- (S.OpValue->getType()->isPointerTy() && UserTreeIdx.UserTE &&
- UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize &&
+ (S.OpValue->getType()->isPointerTy() && IsScatterVectorizeUserTE &&
VL.size() > 2 &&
all_of(VL,
[&BB](Value *V) {
@@ -4760,10 +4762,9 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
// Check that none of the instructions in the bundle are already in the tree.
for (Value *V : VL) {
- auto *I = dyn_cast<Instruction>(V);
- if (!I)
+ if (!IsScatterVectorizeUserTE && !isa<Instruction>(V))
continue;
- if (getTreeEntry(I)) {
+ if (getTreeEntry(V)) {
LLVM_DEBUG(dbgs() << "SLP: The instruction (" << *V
<< ") is already in tree.\n");
if (TryToFindDuplicates(S))
@@ -5213,9 +5214,6 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
}
- bool IsScatterUser =
- UserTreeIdx.UserTE &&
- UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize;
// We don't combine GEPs with non-constant indexes.
Type *Ty1 = VL0->getOperand(1)->getType();
for (Value *V : VL) {
@@ -5223,9 +5221,9 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
if (!I)
continue;
auto *Op = I->getOperand(1);
- if ((!IsScatterUser && !isa<ConstantInt>(Op)) ||
+ if ((!IsScatterVectorizeUserTE && !isa<ConstantInt>(Op)) ||
(Op->getType() != Ty1 &&
- ((IsScatterUser && !isa<ConstantInt>(Op)) ||
+ ((IsScatterVectorizeUserTE && !isa<ConstantInt>(Op)) ||
Op->getType()->getScalarSizeInBits() >
DL->getIndexSizeInBits(
V->getType()->getPointerAddressSpace())))) {