1042 lines
45 KiB
Diff
1042 lines
45 KiB
Diff
From d6d17d8f0362ac47100be32f0d9cb31fd66a1060 Mon Sep 17 00:00:00 2001
|
|
From: luofeng14 <luofeng13@huawei.com>
|
|
Date: Wed, 17 Apr 2024 14:26:07 +0800
|
|
Subject: [PATCH] Fix declaration definition mismatch for classic flang
|
|
|
|
---
|
|
llvm/cmake/modules/TableGen.cmake | 4 +
|
|
llvm/include/llvm-c/DebugInfo.h | 11 ++-
|
|
.../include/llvm/Analysis/TargetLibraryInfo.h | 5 +
|
|
llvm/include/llvm/Analysis/VecFuncs.def | 8 ++
|
|
llvm/include/llvm/IR/DebugInfoMetadata.h | 65 ++++++++++---
|
|
llvm/lib/Analysis/TargetLibraryInfo.cpp | 24 +++++
|
|
llvm/lib/AsmParser/LLParser.cpp | 6 +-
|
|
llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 44 ++++++---
|
|
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 6 ++
|
|
llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h | 4 +
|
|
.../CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 4 +-
|
|
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 8 +-
|
|
llvm/lib/IR/AsmWriter.cpp | 2 +
|
|
llvm/lib/IR/DIBuilder.cpp | 21 +++-
|
|
llvm/lib/IR/DebugInfo.cpp | 22 ++++-
|
|
llvm/lib/IR/DebugInfoMetadata.cpp | 19 +++-
|
|
llvm/lib/IR/LLVMContextImpl.h | 22 ++++-
|
|
.../Instrumentation/InstrProfiling.cpp | 5 +-
|
|
llvm/tools/llvm-c-test/debuginfo.c | 12 ++-
|
|
llvm/unittests/IR/MetadataTest.cpp | 97 +++++++++++++++----
|
|
llvm/utils/lit/lit/llvm/config.py | 17 ++--
|
|
21 files changed, 321 insertions(+), 85 deletions(-)
|
|
|
|
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
|
|
index 7fd6628ef55d..d4d2c06c051b 100644
|
|
--- a/llvm/cmake/modules/TableGen.cmake
|
|
+++ b/llvm/cmake/modules/TableGen.cmake
|
|
@@ -76,6 +76,10 @@ function(tablegen project ofn)
|
|
set(tblgen_change_flag "--write-if-changed")
|
|
endif()
|
|
|
|
+ if (LLVM_ENABLE_CLASSIC_FLANG)
|
|
+ list(APPEND tblgen_change_flag "-DENABLE_CLASSIC_FLANG")
|
|
+ endif()
|
|
+
|
|
if (NOT LLVM_ENABLE_WARNINGS)
|
|
list(APPEND LLVM_TABLEGEN_FLAGS "-no-warn-on-unused-template-args")
|
|
endif()
|
|
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
|
|
index 09d584c24711..0201bac4349d 100644
|
|
--- a/llvm/include/llvm-c/DebugInfo.h
|
|
+++ b/llvm/include/llvm-c/DebugInfo.h
|
|
@@ -1148,7 +1148,10 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
|
|
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
|
size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
|
|
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
|
|
- LLVMMetadataRef Expr, LLVMMetadataRef Decl, LLVMDIFlags Flags,
|
|
+ LLVMMetadataRef Expr, LLVMMetadataRef Decl,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ LLVMDIFlags Flags,
|
|
+#endif
|
|
uint32_t AlignInBits);
|
|
|
|
|
|
@@ -1247,7 +1250,11 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
|
|
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
|
size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File,
|
|
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
|
|
- LLVMMetadataRef Decl, LLVMDIFlags Flags, uint32_t AlignInBits);
|
|
+ LLVMMetadataRef Decl,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ LLVMDIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits);
|
|
|
|
/**
|
|
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
|
|
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
|
|
index 490252cd018a..6805c6535189 100644
|
|
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
|
|
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
|
|
@@ -22,6 +22,9 @@ namespace llvm {
|
|
template <typename T> class ArrayRef;
|
|
class Function;
|
|
class Module;
|
|
+#ifndef ENABLE_CLASSIC_FLANG
|
|
+class Triple;
|
|
+#endif
|
|
|
|
/// Describes a possible vectorization of a function.
|
|
/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
|
|
@@ -80,7 +83,9 @@ class TargetLibraryInfoImpl {
|
|
bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F,
|
|
const Module &M) const;
|
|
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
Triple T;
|
|
+#endif
|
|
|
|
public:
|
|
/// List of known vector-functions libraries.
|
|
diff --git a/llvm/include/llvm/Analysis/VecFuncs.def b/llvm/include/llvm/Analysis/VecFuncs.def
|
|
index d1712d158423..679e28057d6e 100644
|
|
--- a/llvm/include/llvm/Analysis/VecFuncs.def
|
|
+++ b/llvm/include/llvm/Analysis/VecFuncs.def
|
|
@@ -910,6 +910,8 @@ TLI_DEFINE_VECFUNC("tgamma", "armpl_svtgamma_f64_x", SCALABLE(2), MASKED)
|
|
TLI_DEFINE_VECFUNC("tgammaf", "armpl_svtgamma_f32_x", SCALABLE(4), MASKED)
|
|
|
|
#elif defined(TLI_DEFINE_PGMATH_AARCH64_VECFUNCS)
|
|
+
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
// Classic flang libpgmath library's Vector Functions for AArch64
|
|
|
|
TLI_DEFINE_VECFUNC("__fd_sin_1", "__fd_sin_2", FIXED(2))
|
|
@@ -1079,8 +1081,11 @@ TLI_DEFINE_VECFUNC("__ps_exp_1", "__ps_exp_4", FIXED(4))
|
|
|
|
TLI_DEFINE_VECFUNC("__rd_exp_1", "__rd_exp_2", FIXED(2))
|
|
TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_4", FIXED(4))
|
|
+#endif
|
|
|
|
#elif defined(TLI_DEFINE_PGMATH_X86_VECFUNCS)
|
|
+
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
// Classic flang libpgmath library's Vector Functions for X86
|
|
|
|
TLI_DEFINE_VECFUNC("__fd_sin_1", "__fd_sin_2", FIXED(2))
|
|
@@ -1498,6 +1503,7 @@ TLI_DEFINE_VECFUNC("__rd_exp_1", "__rd_exp_8", FIXED(8))
|
|
TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_4", FIXED(4))
|
|
TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_8", FIXED(8))
|
|
TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_16", FIXED(16))
|
|
+#endif
|
|
|
|
#else
|
|
#error "Must choose which vector library functions are to be defined."
|
|
@@ -1519,5 +1525,7 @@ TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_16", FIXED(16))
|
|
#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
|
|
#undef TLI_DEFINE_MASSV_VECFUNCS_NAMES
|
|
#undef TLI_DEFINE_ARMPL_VECFUNCS
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
#undef TLI_DEFINE_PGMATH_AARCH64_VECFUNCS
|
|
#undef TLI_DEFINE_PGMATH_X86_VECFUNCS
|
|
+#endif
|
|
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
|
|
index 9bd86172a4c0..277c2ddd4dd9 100644
|
|
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
|
|
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
|
|
@@ -3062,14 +3062,23 @@ class DIGlobalVariable : public DIVariable {
|
|
|
|
bool IsLocalToUnit;
|
|
bool IsDefinition;
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
DIFlags Flags;
|
|
+#endif
|
|
|
|
DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
|
|
- bool IsLocalToUnit, bool IsDefinition, DIFlags Flags,
|
|
+ bool IsLocalToUnit, bool IsDefinition,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DIFlags Flags,
|
|
+#endif
|
|
uint32_t AlignInBits, ArrayRef<Metadata *> Ops)
|
|
: DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
|
|
- IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition),
|
|
- Flags(Flags) {}
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition), Flags(Flags) {}
|
|
+#else
|
|
+ IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
|
|
+#endif
|
|
+
|
|
~DIGlobalVariable() = default;
|
|
|
|
static DIGlobalVariable *
|
|
@@ -3077,28 +3086,40 @@ class DIGlobalVariable : public DIVariable {
|
|
StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
|
|
bool IsLocalToUnit, bool IsDefinition,
|
|
DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
|
|
- DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits, DINodeArray Annotations,
|
|
StorageType Storage, bool ShouldCreate = true) {
|
|
return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
|
|
getCanonicalMDString(Context, LinkageName), File, Line, Type,
|
|
IsLocalToUnit, IsDefinition, StaticDataMemberDeclaration,
|
|
- cast_or_null<Metadata>(TemplateParams), Flags, AlignInBits,
|
|
- Annotations.get(), Storage, ShouldCreate);
|
|
+ cast_or_null<Metadata>(TemplateParams),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, Annotations.get(), Storage, ShouldCreate);
|
|
}
|
|
static DIGlobalVariable *
|
|
getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
|
|
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
|
|
bool IsLocalToUnit, bool IsDefinition,
|
|
Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
|
|
- DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits, Metadata *Annotations,
|
|
StorageType Storage, bool ShouldCreate = true);
|
|
|
|
TempDIGlobalVariable cloneImpl() const {
|
|
return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
|
|
getFile(), getLine(), getType(), isLocalToUnit(),
|
|
isDefinition(), getStaticDataMemberDeclaration(),
|
|
- getTemplateParams(), getFlags(), getAlignInBits(),
|
|
- getAnnotations());
|
|
+ getTemplateParams(),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ getFlags(),
|
|
+#endif
|
|
+ getAlignInBits(), getAnnotations());
|
|
}
|
|
|
|
public:
|
|
@@ -3107,26 +3128,40 @@ public:
|
|
(DIScope * Scope, StringRef Name, StringRef LinkageName, DIFile *File,
|
|
unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition,
|
|
DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
|
|
- DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits, DINodeArray Annotations),
|
|
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
|
|
- StaticDataMemberDeclaration, TemplateParams, Flags, AlignInBits,
|
|
- Annotations))
|
|
+ StaticDataMemberDeclaration, TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, Annotations))
|
|
DEFINE_MDNODE_GET(
|
|
DIGlobalVariable,
|
|
(Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
|
|
unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
|
|
Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
|
|
- DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits, Metadata *Annotations),
|
|
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
|
|
- StaticDataMemberDeclaration, TemplateParams, Flags, AlignInBits,
|
|
- Annotations))
|
|
+ StaticDataMemberDeclaration, TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, Annotations))
|
|
|
|
TempDIGlobalVariable clone() const { return cloneImpl(); }
|
|
|
|
bool isLocalToUnit() const { return IsLocalToUnit; }
|
|
bool isDefinition() const { return IsDefinition; }
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
DIFlags getFlags() const { return Flags; }
|
|
bool isArtificial() const { return getFlags() & FlagArtificial; }
|
|
+#endif
|
|
StringRef getDisplayName() const { return getStringOperand(4); }
|
|
StringRef getLinkageName() const { return getStringOperand(5); }
|
|
DIDerivedType *getStaticDataMemberDeclaration() const {
|
|
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
|
|
index a6593f6b3757..a9d69af5373c 100644
|
|
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
|
|
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
|
|
@@ -871,14 +871,26 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
|
|
TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary, T);
|
|
}
|
|
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
TargetLibraryInfoImpl::TargetLibraryInfoImpl() : T(Triple()) {
|
|
+#else
|
|
+TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
|
|
+#endif
|
|
// Default to everything being available.
|
|
memset(AvailableArray, -1, sizeof(AvailableArray));
|
|
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
initialize(*this, T, StandardNames);
|
|
+#else
|
|
+ initialize(*this, Triple(), StandardNames);
|
|
+#endif
|
|
}
|
|
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) : T(T) {
|
|
+#else
|
|
+TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
|
|
+#endif
|
|
// Default to everything being available.
|
|
memset(AvailableArray, -1, sizeof(AvailableArray));
|
|
|
|
@@ -890,7 +902,11 @@ TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
|
|
ShouldExtI32Return(TLI.ShouldExtI32Return),
|
|
ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
|
|
ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
SizeOfInt(TLI.SizeOfInt), T(TLI.T) {
|
|
+#else
|
|
+ SizeOfInt(TLI.SizeOfInt) {
|
|
+#endif
|
|
memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
|
|
VectorDescs = TLI.VectorDescs;
|
|
ScalarDescs = TLI.ScalarDescs;
|
|
@@ -902,7 +918,11 @@ TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
|
|
ShouldExtI32Return(TLI.ShouldExtI32Return),
|
|
ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
|
|
ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
SizeOfInt(TLI.SizeOfInt), T(TLI.T) {
|
|
+#else
|
|
+ SizeOfInt(TLI.SizeOfInt) {
|
|
+#endif
|
|
std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
|
|
AvailableArray);
|
|
VectorDescs = TLI.VectorDescs;
|
|
@@ -916,7 +936,9 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoI
|
|
ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
|
|
ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
|
|
SizeOfInt = TLI.SizeOfInt;
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
T = TLI.T;
|
|
+#endif
|
|
memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
|
|
return *this;
|
|
}
|
|
@@ -928,7 +950,9 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
|
|
ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
|
|
ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
|
|
SizeOfInt = TLI.SizeOfInt;
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
T = TLI.T;
|
|
+#endif
|
|
std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
|
|
AvailableArray);
|
|
return *this;
|
|
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
|
|
index d7eb34e3d148..0a7166bd50b7 100644
|
|
--- a/llvm/lib/AsmParser/LLParser.cpp
|
|
+++ b/llvm/lib/AsmParser/LLParser.cpp
|
|
@@ -5432,7 +5432,6 @@ bool LLParser::parseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
|
|
OPTIONAL(isDefinition, MDBoolField, (true)); \
|
|
OPTIONAL(templateParams, MDField, ); \
|
|
OPTIONAL(declaration, MDField, ); \
|
|
- OPTIONAL(flags, DIFlagField, ); \
|
|
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
|
|
OPTIONAL(annotations, MDField, );
|
|
#endif
|
|
@@ -5443,7 +5442,10 @@ bool LLParser::parseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
|
|
GET_OR_DISTINCT(DIGlobalVariable,
|
|
(Context, scope.Val, name.Val, linkageName.Val, file.Val,
|
|
line.Val, type.Val, isLocal.Val, isDefinition.Val,
|
|
- declaration.Val, templateParams.Val, flags.Val,
|
|
+ declaration.Val, templateParams.Val,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ flags.Val,
|
|
+#endif
|
|
align.Val, annotations.Val));
|
|
return false;
|
|
}
|
|
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
|
|
index c21e5e5dba97..a33a0587d1c0 100644
|
|
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
|
|
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
|
|
@@ -1979,12 +1979,16 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|
break;
|
|
}
|
|
case bitc::METADATA_GLOBAL_VAR: {
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
if (Record.size() < 11 || Record.size() > 14)
|
|
+#else
|
|
+ if (Record.size() < 11 || Record.size() > 13)
|
|
+#endif
|
|
return error("Invalid record");
|
|
|
|
IsDistinct = Record[0] & 1;
|
|
unsigned Version = Record[0] >> 1;
|
|
-
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
if (Version == 3) {
|
|
// Add support for DIFlags
|
|
Metadata *Annotations = nullptr;
|
|
@@ -1998,24 +2002,30 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|
getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
|
|
getDITypeRefOrNull(Record[6]), Record[7], Record[8],
|
|
getMDOrNull(Record[9]), getMDOrNull(Record[10]),
|
|
- static_cast<DINode::DIFlags>(Record[11]), Record[12],
|
|
- Annotations)),
|
|
+ static_cast<DINode::DIFlags>(Record[11]),
|
|
+ Record[12], Annotations)),
|
|
NextMetadataNo);
|
|
|
|
NextMetadataNo++;
|
|
} else if (Version == 2) {
|
|
+#else
|
|
+ if (Version == 2) {
|
|
+#endif
|
|
Metadata *Annotations = nullptr;
|
|
if (Record.size() > 12)
|
|
Annotations = getMDOrNull(Record[12]);
|
|
|
|
MetadataList.assignValue(
|
|
- GET_OR_DISTINCT(
|
|
- DIGlobalVariable,
|
|
- (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
|
|
- getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
|
|
- getDITypeRefOrNull(Record[6]), Record[7], Record[8],
|
|
- getMDOrNull(Record[9]), getMDOrNull(Record[10]),
|
|
- DINode::FlagZero, Record[11], Annotations)),
|
|
+ GET_OR_DISTINCT(DIGlobalVariable,
|
|
+ (Context, getMDOrNull(Record[1]),
|
|
+ getMDString(Record[2]), getMDString(Record[3]),
|
|
+ getMDOrNull(Record[4]), Record[5],
|
|
+ getDITypeRefOrNull(Record[6]), Record[7], Record[8],
|
|
+ getMDOrNull(Record[9]), getMDOrNull(Record[10]),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DINode::FlagZero,
|
|
+#endif
|
|
+ Record[11], Annotations)),
|
|
NextMetadataNo);
|
|
|
|
NextMetadataNo++;
|
|
@@ -2028,8 +2038,11 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|
(Context, getMDOrNull(Record[1]), getMDString(Record[2]),
|
|
getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
|
|
getDITypeRefOrNull(Record[6]), Record[7], Record[8],
|
|
- getMDOrNull(Record[10]), nullptr, DINode::FlagZero, Record[11],
|
|
- nullptr)),
|
|
+ getMDOrNull(Record[10]), nullptr,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DINode::FlagZero,
|
|
+#endif
|
|
+ Record[11], nullptr)),
|
|
NextMetadataNo);
|
|
|
|
NextMetadataNo++;
|
|
@@ -2062,8 +2075,11 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|
(Context, getMDOrNull(Record[1]), getMDString(Record[2]),
|
|
getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
|
|
getDITypeRefOrNull(Record[6]), Record[7], Record[8],
|
|
- getMDOrNull(Record[10]), nullptr, DINode::FlagZero, AlignInBits,
|
|
- nullptr));
|
|
+ getMDOrNull(Record[10]), nullptr,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DINode::FlagZero,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
|
|
DIGlobalVariableExpression *DGVE = nullptr;
|
|
if (Attach || Expr)
|
|
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
|
|
index 013e7ce2d425..d5bcd327a9b7 100644
|
|
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
|
|
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
|
|
@@ -2014,7 +2014,11 @@ void ModuleBitcodeWriter::writeDITemplateValueParameter(
|
|
void ModuleBitcodeWriter::writeDIGlobalVariable(
|
|
const DIGlobalVariable *N, SmallVectorImpl<uint64_t> &Record,
|
|
unsigned Abbrev) {
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
const uint64_t Version = 3 << 1;
|
|
+#else
|
|
+ const uint64_t Version = 2 << 1;
|
|
+#endif
|
|
Record.push_back((uint64_t)N->isDistinct() | Version);
|
|
Record.push_back(VE.getMetadataOrNullID(N->getScope()));
|
|
Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
|
|
@@ -2026,7 +2030,9 @@ void ModuleBitcodeWriter::writeDIGlobalVariable(
|
|
Record.push_back(N->isDefinition());
|
|
Record.push_back(VE.getMetadataOrNullID(N->getStaticDataMemberDeclaration()));
|
|
Record.push_back(VE.getMetadataOrNullID(N->getTemplateParams()));
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
Record.push_back(N->getFlags());
|
|
+#endif
|
|
Record.push_back(N->getAlignInBits());
|
|
Record.push_back(VE.getMetadataOrNullID(N->getAnnotations().get()));
|
|
|
|
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
|
|
index ee8be3921ab7..b4fe2295d0b1 100644
|
|
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
|
|
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
|
|
@@ -115,6 +115,7 @@ class DbgValueLoc {
|
|
SmallVector<DbgValueLocEntry, 2> ValueLocEntries;
|
|
|
|
bool IsVariadic;
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
/// Type of entry that this represents.
|
|
enum EntryType {
|
|
E_Location,
|
|
@@ -138,6 +139,7 @@ class DbgValueLoc {
|
|
/// Or a location from target specific location.
|
|
TargetIndexLocation TIL;
|
|
};
|
|
+#endif
|
|
|
|
public:
|
|
DbgValueLoc(const DIExpression *Expr, ArrayRef<DbgValueLocEntry> Locs)
|
|
@@ -162,6 +164,7 @@ public:
|
|
assert(((Expr && Expr->isValid()) || !Loc.isLocation()) &&
|
|
"DBG_VALUE with a machine location must have a valid expression.");
|
|
}
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
DbgValueLoc(const DIExpression *Expr, int64_t i)
|
|
: Expression(Expr), EntryKind(E_Integer) {
|
|
Constant.Int = i;
|
|
@@ -193,6 +196,7 @@ public:
|
|
const ConstantInt *getConstantInt() const { return Constant.CIP; }
|
|
MachineLocation getLoc() const { return Loc; }
|
|
TargetIndexLocation getTargetIndexLocation() const { return TIL; }
|
|
+#endif
|
|
|
|
bool isFragment() const { return getExpression()->isFragment(); }
|
|
bool isEntryVal() const { return getExpression()->isEntryValue(); }
|
|
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
|
|
index 78ff0d351492..4a70d1f07d6e 100644
|
|
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
|
|
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
|
|
@@ -184,10 +184,10 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
|
addFlag(*VariableDIE, dwarf::DW_AT_declaration);
|
|
else
|
|
addGlobalName(GV->getName(), *VariableDIE, DeclContext);
|
|
-
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
if (GV->isArtificial())
|
|
addFlag(*VariableDIE, dwarf::DW_AT_artificial);
|
|
-
|
|
+#endif
|
|
addAnnotation(*VariableDIE, GV->getAnnotations());
|
|
|
|
if (uint32_t AlignInBytes = GV->getAlignInBytes())
|
|
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
|
|
index e526614792c7..1f7fe5c382e9 100644
|
|
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
|
|
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
|
|
@@ -283,9 +283,9 @@ struct SymbolCU {
|
|
const MCSymbol *Sym;
|
|
DwarfCompileUnit *CU;
|
|
};
|
|
-
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
class DummyDwarfExpression;
|
|
-
|
|
+#endif
|
|
/// The kind of accelerator tables we should emit.
|
|
enum class AccelTableKind {
|
|
Default, ///< Platform default.
|
|
@@ -438,9 +438,9 @@ private:
|
|
|
|
/// Map for tracking Fortran deferred CHARACTER lengths.
|
|
DenseMap<const DIStringType *, unsigned> StringTypeLocMap;
|
|
-
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
DenseMap<const DIVariable*,const DIType*> VariableInDependentType;
|
|
-
|
|
+#endif
|
|
AddressPool AddrPool;
|
|
|
|
/// Accelerator tables.
|
|
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
|
|
index c47dd4664ea6..df753b91ff90 100644
|
|
--- a/llvm/lib/IR/AsmWriter.cpp
|
|
+++ b/llvm/lib/IR/AsmWriter.cpp
|
|
@@ -2281,7 +2281,9 @@ static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N,
|
|
Printer.printBool("isDefinition", N->isDefinition());
|
|
Printer.printMetadata("declaration", N->getRawStaticDataMemberDeclaration());
|
|
Printer.printMetadata("templateParams", N->getRawTemplateParams());
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
Printer.printDIFlags("flags", N->getFlags());
|
|
+#endif
|
|
Printer.printInt("align", N->getAlignInBits());
|
|
Printer.printMetadata("annotations", N->getRawAnnotations());
|
|
Out << ")";
|
|
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
|
|
index af6ebf702165..41b2acd8661f 100644
|
|
--- a/llvm/lib/IR/DIBuilder.cpp
|
|
+++ b/llvm/lib/IR/DIBuilder.cpp
|
|
@@ -725,13 +725,19 @@ DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression(
|
|
DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
|
|
unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined,
|
|
DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams,
|
|
- DINode::DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations) {
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DINode::DIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits, DINodeArray Annotations) {
|
|
checkGlobalVariableScope(Context);
|
|
|
|
auto *GV = DIGlobalVariable::getDistinct(
|
|
VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
|
|
LineNumber, Ty, IsLocalToUnit, isDefined,
|
|
- cast_or_null<DIDerivedType>(Decl), TemplateParams, Flags,
|
|
+ cast_or_null<DIDerivedType>(Decl), TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
AlignInBits, Annotations);
|
|
if (!Expr)
|
|
Expr = createExpression();
|
|
@@ -743,13 +749,20 @@ DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression(
|
|
DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl(
|
|
DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
|
|
unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, MDNode *Decl,
|
|
- MDTuple *TemplateParams, DINode::DIFlags Flags, uint32_t AlignInBits) {
|
|
+ MDTuple *TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DINode::DIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits) {
|
|
checkGlobalVariableScope(Context);
|
|
|
|
return DIGlobalVariable::getTemporary(
|
|
VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
|
|
LineNumber, Ty, IsLocalToUnit, false,
|
|
- cast_or_null<DIDerivedType>(Decl), TemplateParams, Flags,
|
|
+ cast_or_null<DIDerivedType>(Decl), TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
AlignInBits, nullptr)
|
|
.release();
|
|
}
|
|
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
|
|
index 3696beccdd0c..f21a8f6e3c10 100644
|
|
--- a/llvm/lib/IR/DebugInfo.cpp
|
|
+++ b/llvm/lib/IR/DebugInfo.cpp
|
|
@@ -1547,13 +1547,20 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
|
|
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
|
size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
|
|
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
|
|
- LLVMMetadataRef Expr, LLVMMetadataRef Decl, LLVMDIFlags Flags,
|
|
+ LLVMMetadataRef Expr, LLVMMetadataRef Decl,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ LLVMDIFlags Flags,
|
|
+#endif
|
|
uint32_t AlignInBits) {
|
|
return wrap(unwrap(Builder)->createGlobalVariableExpression(
|
|
unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LinkLen},
|
|
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
|
|
true, unwrap<DIExpression>(Expr), unwrapDI<MDNode>(Decl),
|
|
- nullptr, map_from_llvmDIFlags(Flags), AlignInBits));
|
|
+ nullptr,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ map_from_llvmDIFlags(Flags),
|
|
+#endif
|
|
+ AlignInBits));
|
|
}
|
|
|
|
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE) {
|
|
@@ -1598,11 +1605,18 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
|
|
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
|
|
size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File,
|
|
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
|
|
- LLVMMetadataRef Decl, LLVMDIFlags Flags, uint32_t AlignInBits) {
|
|
+ LLVMMetadataRef Decl,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ LLVMDIFlags Flags,
|
|
+#endif
|
|
+ uint32_t AlignInBits) {
|
|
return wrap(unwrap(Builder)->createTempGlobalVariableFwdDecl(
|
|
unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LnkLen},
|
|
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
|
|
- unwrapDI<MDNode>(Decl), nullptr, map_from_llvmDIFlags(Flags),
|
|
+ unwrapDI<MDNode>(Decl), nullptr,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ map_from_llvmDIFlags(Flags),
|
|
+#endif
|
|
AlignInBits));
|
|
}
|
|
|
|
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
|
|
index d599896ee456..074529f6e1c6 100644
|
|
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
|
|
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
|
|
@@ -1258,7 +1258,10 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
|
|
MDString *LinkageName, Metadata *File, unsigned Line,
|
|
Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
|
|
Metadata *StaticDataMemberDeclaration,
|
|
- Metadata *TemplateParams, DIFlags Flags,
|
|
+ Metadata *TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ DIFlags Flags,
|
|
+#endif
|
|
uint32_t AlignInBits, Metadata *Annotations,
|
|
StorageType Storage, bool ShouldCreate) {
|
|
assert(isCanonical(Name) && "Expected canonical MDString");
|
|
@@ -1266,8 +1269,11 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
|
|
DEFINE_GETIMPL_LOOKUP(
|
|
DIGlobalVariable,
|
|
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
|
|
- StaticDataMemberDeclaration, TemplateParams, Flags, AlignInBits,
|
|
- Annotations));
|
|
+ StaticDataMemberDeclaration, TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, Annotations));
|
|
Metadata *Ops[] = {Scope,
|
|
Name,
|
|
File,
|
|
@@ -1278,8 +1284,11 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
|
|
TemplateParams,
|
|
Annotations};
|
|
DEFINE_GETIMPL_STORE(DIGlobalVariable,
|
|
- (Line, IsLocalToUnit, IsDefinition, Flags, AlignInBits),
|
|
- Ops);
|
|
+ (Line, IsLocalToUnit, IsDefinition,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits), Ops);
|
|
}
|
|
|
|
DILocalVariable *
|
|
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
|
|
index 8a621725f55e..01faec286b7d 100644
|
|
--- a/llvm/lib/IR/LLVMContextImpl.h
|
|
+++ b/llvm/lib/IR/LLVMContextImpl.h
|
|
@@ -1055,7 +1055,9 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
|
|
bool IsDefinition;
|
|
Metadata *StaticDataMemberDeclaration;
|
|
Metadata *TemplateParams;
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
unsigned Flags;
|
|
+#endif
|
|
uint32_t AlignInBits;
|
|
Metadata *Annotations;
|
|
|
|
@@ -1063,13 +1065,18 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
|
|
Metadata *File, unsigned Line, Metadata *Type,
|
|
bool IsLocalToUnit, bool IsDefinition,
|
|
Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
unsigned Flags,
|
|
+#endif
|
|
uint32_t AlignInBits, Metadata *Annotations)
|
|
: Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
|
|
Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
|
|
IsDefinition(IsDefinition),
|
|
StaticDataMemberDeclaration(StaticDataMemberDeclaration),
|
|
- TemplateParams(TemplateParams), Flags(Flags),
|
|
+ TemplateParams(TemplateParams),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags(Flags),
|
|
+#endif
|
|
AlignInBits(AlignInBits), Annotations(Annotations) {}
|
|
MDNodeKeyImpl(const DIGlobalVariable *N)
|
|
: Scope(N->getRawScope()), Name(N->getRawName()),
|
|
@@ -1077,7 +1084,10 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
|
|
Line(N->getLine()), Type(N->getRawType()),
|
|
IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
|
|
StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
|
|
- TemplateParams(N->getRawTemplateParams()), Flags(N->getFlags()),
|
|
+ TemplateParams(N->getRawTemplateParams()),
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags(N->getFlags()),
|
|
+#endif
|
|
AlignInBits(N->getAlignInBits()), Annotations(N->getRawAnnotations()) {}
|
|
|
|
bool isKeyOf(const DIGlobalVariable *RHS) const {
|
|
@@ -1089,7 +1099,9 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
|
|
StaticDataMemberDeclaration ==
|
|
RHS->getRawStaticDataMemberDeclaration() &&
|
|
TemplateParams == RHS->getRawTemplateParams() &&
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
Flags == RHS->getFlags() &&
|
|
+#endif
|
|
AlignInBits == RHS->getAlignInBits() &&
|
|
Annotations == RHS->getRawAnnotations();
|
|
}
|
|
@@ -1104,7 +1116,11 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
|
|
// TODO: make hashing work fine with such situations
|
|
return hash_combine(Scope, Name, LinkageName, File, Line, Type,
|
|
IsLocalToUnit, IsDefinition, /* AlignInBits, */
|
|
- StaticDataMemberDeclaration, Flags, Annotations);
|
|
+ StaticDataMemberDeclaration,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ Annotations);
|
|
}
|
|
};
|
|
|
|
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
|
|
index 136132d7e65a..343554241da3 100644
|
|
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
|
|
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
|
|
@@ -1053,7 +1053,10 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfInstBase *Inc) {
|
|
/*LineNo=*/0, DB.createUnspecifiedType("Profile Data Type"),
|
|
CounterPtr->hasLocalLinkage(), /*IsDefined=*/true, /*Expr=*/nullptr,
|
|
/*Decl=*/nullptr, /*TemplateParams=*/nullptr,
|
|
- /*Flags=*/DINode::FlagZero, /*AlignInBits=*/0, Annotations);
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ /*Flags=*/DINode::FlagZero,
|
|
+#endif
|
|
+ /*AlignInBits=*/0, Annotations);
|
|
CounterPtr->addDebugInfo(DICounter);
|
|
DB.finalize();
|
|
} else {
|
|
diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c
|
|
index 906c96f1c24b..e1866443e762 100644
|
|
--- a/llvm/tools/llvm-c-test/debuginfo.c
|
|
+++ b/llvm/tools/llvm-c-test/debuginfo.c
|
|
@@ -64,7 +64,11 @@ int llvm_test_dibuilder(void) {
|
|
LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
|
|
LLVMDIBuilderCreateGlobalVariableExpression(
|
|
DIB, Module, "globalClass", 11, "", 0, File, 1, ClassTy, true,
|
|
- GlobalClassValueExpr, NULL, LLVMDIFlagZero, 0);
|
|
+ GlobalClassValueExpr, NULL,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ LLVMDIFlagZero,
|
|
+#endif
|
|
+ 0);
|
|
|
|
LLVMMetadataRef Int64Ty =
|
|
LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
|
|
@@ -75,7 +79,11 @@ int llvm_test_dibuilder(void) {
|
|
LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
|
|
LLVMDIBuilderCreateGlobalVariableExpression(
|
|
DIB, Module, "global", 6, "", 0, File, 1, Int64TypeDef, true,
|
|
- GlobalVarValueExpr, NULL, LLVMDIFlagZero, 0);
|
|
+ GlobalVarValueExpr, NULL,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ LLVMDIFlagZero,
|
|
+#endif
|
|
+ 0);
|
|
|
|
LLVMMetadataRef NameSpace =
|
|
LLVMDIBuilderCreateNameSpace(DIB, Module, "NameSpace", 9, false);
|
|
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
|
|
index 4bce26851d2f..788d514ad366 100644
|
|
--- a/llvm/unittests/IR/MetadataTest.cpp
|
|
+++ b/llvm/unittests/IR/MetadataTest.cpp
|
|
@@ -2895,13 +2895,17 @@ TEST_F(DIGlobalVariableTest, get) {
|
|
MDTuple *templateParams = getTuple();
|
|
DIDerivedType *StaticDataMemberDeclaration =
|
|
cast<DIDerivedType>(getDerivedType());
|
|
-
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
|
|
+#endif
|
|
uint32_t AlignInBits = 8;
|
|
|
|
auto *N = DIGlobalVariable::get(
|
|
Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
|
|
- IsDefinition, StaticDataMemberDeclaration, templateParams, Flags,
|
|
+ IsDefinition, StaticDataMemberDeclaration, templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
AlignInBits, nullptr);
|
|
|
|
EXPECT_EQ(dwarf::DW_TAG_variable, N->getTag());
|
|
@@ -2915,67 +2919,114 @@ TEST_F(DIGlobalVariableTest, get) {
|
|
EXPECT_EQ(IsDefinition, N->isDefinition());
|
|
EXPECT_EQ(StaticDataMemberDeclaration, N->getStaticDataMemberDeclaration());
|
|
EXPECT_EQ(templateParams, N->getTemplateParams());
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
EXPECT_EQ(Flags, N->getFlags());
|
|
+#endif
|
|
EXPECT_EQ(AlignInBits, N->getAlignInBits());
|
|
EXPECT_EQ(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits,
|
|
- nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
|
|
EXPECT_NE(N, DIGlobalVariable::get(
|
|
Context, getSubprogram(), Name, LinkageName, File, Line,
|
|
Type, IsLocalToUnit, IsDefinition,
|
|
- StaticDataMemberDeclaration, templateParams, Flags,
|
|
+ StaticDataMemberDeclaration, templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, "other", LinkageName, File,
|
|
Line, Type, IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits,
|
|
- nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, "other", File, Line,
|
|
Type, IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName,
|
|
getFile(), Line, Type, IsLocalToUnit,
|
|
IsDefinition, StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line + 1, Type, IsLocalToUnit,
|
|
IsDefinition, StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, getDerivedType(), IsLocalToUnit,
|
|
IsDefinition, StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, !IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, IsLocalToUnit, !IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, IsLocalToUnit, IsDefinition,
|
|
cast<DIDerivedType>(getDerivedType()),
|
|
- templateParams, Flags, AlignInBits, nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration, nullptr,
|
|
- Flags, AlignInBits, nullptr));
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ AlignInBits, nullptr));
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
templateParams,
|
|
static_cast<DINode::DIFlags>(Flags + 1),
|
|
AlignInBits, nullptr));
|
|
+#endif
|
|
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
|
|
Line, Type, IsLocalToUnit, IsDefinition,
|
|
StaticDataMemberDeclaration,
|
|
- templateParams, Flags, (AlignInBits << 1),
|
|
- nullptr));
|
|
+ templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
+ (AlignInBits << 1), nullptr));
|
|
|
|
TempDIGlobalVariable Temp = N->clone();
|
|
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
|
|
@@ -2997,16 +3048,24 @@ TEST_F(DIGlobalVariableExpressionTest, get) {
|
|
auto *Expr2 = DIExpression::get(Context, {1, 2, 3});
|
|
DIDerivedType *StaticDataMemberDeclaration =
|
|
cast<DIDerivedType>(getDerivedType());
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
|
|
+#endif
|
|
uint32_t AlignInBits = 8;
|
|
|
|
auto *Var = DIGlobalVariable::get(
|
|
Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
|
|
- IsDefinition, StaticDataMemberDeclaration, templateParams, Flags,
|
|
+ IsDefinition, StaticDataMemberDeclaration, templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
AlignInBits, nullptr);
|
|
auto *Var2 = DIGlobalVariable::get(
|
|
Context, Scope, "other", LinkageName, File, Line, Type, IsLocalToUnit,
|
|
- IsDefinition, StaticDataMemberDeclaration, templateParams, Flags,
|
|
+ IsDefinition, StaticDataMemberDeclaration, templateParams,
|
|
+#ifdef ENABLE_CLASSIC_FLANG
|
|
+ Flags,
|
|
+#endif
|
|
AlignInBits, nullptr);
|
|
auto *N = DIGlobalVariableExpression::get(Context, Var, Expr);
|
|
|
|
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
|
|
index d8dec6160071..69ede49dadc5 100644
|
|
--- a/llvm/utils/lit/lit/llvm/config.py
|
|
+++ b/llvm/utils/lit/lit/llvm/config.py
|
|
@@ -632,14 +632,15 @@ class LLVMConfig(object):
|
|
]
|
|
self.add_tool_substitutions(tool_substitutions)
|
|
self.config.substitutions.append(("%resource_dir", builtin_include_dir))
|
|
-
|
|
- self.config.flang = self.use_llvm_tool(
|
|
- 'flang', search_env='FLANG', required=required)
|
|
- if self.config.flang:
|
|
- tool_substitutions = [
|
|
- ToolSubst('%flang', command=self.config.flang)
|
|
- ]
|
|
- self.add_tool_substitutions(tool_substitutions)
|
|
+ use_classic_flang = getattr(self.config, "use_classic_flang", None)
|
|
+ if use_classic_flang and use_classic_flang != "@LLVM_ENABLE_CLASSIC_FLANG@":
|
|
+ self.config.flang = self.use_llvm_tool(
|
|
+ 'flang', search_env='FLANG', required=required)
|
|
+ if self.config.flang:
|
|
+ tool_substitutions = [
|
|
+ ToolSubst('%flang', command=self.config.flang)
|
|
+ ]
|
|
+ self.add_tool_substitutions(tool_substitutions)
|
|
|
|
self.config.substitutions.append(
|
|
(
|
|
--
|
|
2.24.3 (Apple Git-128)
|
|
|