[llvm] 4de5148 - Revert "[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend"
Argyrios Kyrtzidis via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 31 12:12:07 PST 2023
Author: Argyrios Kyrtzidis
Date: 2023-01-31T12:11:57-08:00
New Revision: 4de51483ef5ffbae85142bd75e406b7e59f451b4
URL: https://github.com/llvm/llvm-project/commit/4de51483ef5ffbae85142bd75e406b7e59f451b4
DIFF: https://github.com/llvm/llvm-project/commit/4de51483ef5ffbae85142bd75e406b7e59f451b4.diff
LOG: Revert "[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend"
Causes clang build failures, see https://reviews.llvm.org/D141910#4089465 for details.
This reverts commit ca446037af019d1aa01b1352a30a18df33038359.
Added:
Modified:
clang/include/clang/Basic/TargetInfo.h
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index b30368aa822f5..bb2a453f46573 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -225,6 +225,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
bool HasStrictFP;
unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
+ unsigned short SimdDefaultAlign;
std::string DataLayoutString;
const char *UserLabelPrefix;
const char *MCountName;
@@ -793,6 +794,10 @@ class TargetInfo : public virtual TransferrableTargetInfo,
/// Return the maximum vector alignment supported for the given target.
unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
+ /// Return default simd alignment for the given target. Generally, this
+ /// value is type-specific, but this alignment can be used for most of the
+ /// types for the given target.
+ unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; }
unsigned getMaxOpenCLWorkGroupSize() const { return MaxOpenCLWorkGroupSize; }
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a6dfbd48d0d4d..432a9cba4de21 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -78,7 +78,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
-#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/Support/Capacity.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
@@ -2552,8 +2551,7 @@ unsigned ASTContext::getTypeUnadjustedAlign(const Type *T) const {
}
unsigned ASTContext::getOpenMPDefaultSimdAlign(QualType T) const {
- unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
- getTargetInfo().getTriple(), Target->getTargetOpts().FeatureMap);
+ unsigned SimdAlign = getTargetInfo().getSimdDefaultAlign();
return SimdAlign;
}
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index fa5e568d599d0..8ee43261fc1d3 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -119,6 +119,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
MaxVectorAlign = 0;
MaxTLSAlign = 0;
+ SimdDefaultAlign = 0;
SizeType = UnsignedLong;
PtrDiffType = SignedLong;
IntMaxType = SignedLongLong;
diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 4c02183feb4c1..cc185fdadfcbc 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -87,6 +87,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
: TargetInfo(Triple) {
SuitableAlign = 128;
+ SimdDefaultAlign = 128;
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
HasStrictFP = true;
diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h
index 1f0bb08665347..1e73450fdd0c3 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -49,6 +49,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
SuitableAlign = 128;
LargeArrayMinWidth = 128;
LargeArrayAlign = 128;
+ SimdDefaultAlign = 128;
SigAtomicType = SignedLong;
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad();
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 980249c6cb526..cb31712275301 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -400,6 +400,9 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
return false;
}
+ SimdDefaultAlign =
+ hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
+
// FIXME: We should allow long double type on 32-bits to match with GCC.
// This requires backend to be able to lower f80 without x87 first.
if (!HasX87 && LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index c22d5827ebbef..58e81fb1cd745 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -500,6 +500,8 @@ ClangExpressionParser::ClangExpressionParser(
auto target_info = TargetInfo::CreateTargetInfo(
m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts);
if (log) {
+ LLDB_LOGF(log, "Using SIMD alignment: %d",
+ target_info->getSimdDefaultAlign());
LLDB_LOGF(log, "Target datalayout string: '%s'",
target_info->getDataLayoutString());
LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str());
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 1dfa858421d93..84c062978a32e 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -502,13 +502,6 @@ class OpenMPIRBuilder {
ArrayRef<CanonicalLoopInfo *> Loops,
InsertPointTy ComputeIP);
- /// Get the default alignment value for given target
- ///
- /// \param TargetTriple Target triple
- /// \param Features StringMap which describes extra CPU features
- static unsigned getOpenMPDefaultSimdAlign(const Triple &TargetTriple,
- const StringMap<bool> &Features);
-
private:
/// Modifies the canonical loop to be a statically-scheduled workshare loop.
///
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index b21a9a7eeb0d1..8a4ed30628dc8 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3053,23 +3053,6 @@ void OpenMPIRBuilder::createIfVersion(CanonicalLoopInfo *CanonicalLoop,
Builder.CreateBr(NewBlocks.front());
}
-unsigned
-OpenMPIRBuilder::getOpenMPDefaultSimdAlign(const Triple &TargetTriple,
- const StringMap<bool> &Features) {
- if (TargetTriple.isX86()) {
- if (Features.lookup("avx512f"))
- return 512;
- else if (Features.lookup("avx"))
- return 256;
- return 128;
- }
- if (TargetTriple.isPPC())
- return 128;
- if (TargetTriple.isWasm())
- return 128;
- return 0;
-}
-
void OpenMPIRBuilder::applySimd(CanonicalLoopInfo *CanonicalLoop,
MapVector<Value *, Value *> AlignedVars,
Value *IfCond, OrderKind Order,
More information about the llvm-commits
mailing list