Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/clang-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
- macOS-latest
steps:
- name: Install Ninja
uses: llvm/actions/install-ninja@master
uses: llvm/actions/install-ninja@main
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Test clang
uses: llvm/actions/build-test-llvm-project@master
uses: llvm/actions/build-test-llvm-project@main
with:
cmake_args: -G Ninja -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE=Release
build_target: check-clang
4 changes: 2 additions & 2 deletions .github/workflows/llvm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
- macOS-latest
steps:
- name: Install Ninja
uses: llvm/actions/install-ninja@master
uses: llvm/actions/install-ninja@main
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Test llvm
uses: llvm/actions/build-test-llvm-project@master
uses: llvm/actions/build-test-llvm-project@main
with:
cmake_args: -G Ninja -DCMAKE_BUILD_TYPE=Release
13 changes: 12 additions & 1 deletion llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4859,7 +4859,14 @@ DIExpression that describes how to get from an object's address to the actual
raw data, if they aren't equivalent. This is only supported for array types,
particularly to describe Fortran arrays, which have an array descriptor in
addition to the array data. Alternatively it can also be DIVariable which
has the address of the actual raw data.
has the address of the actual raw data. The Fortran language supports pointer
arrays which can be attached to actual arrays, this attachement between pointer
and pointee is called association. The optional ``associated`` is a
DIExpression that describes whether the pointer array is currently associated.
The optional ``allocated`` is a DIExpression that describes whether the
allocatable array is currently allocated. The optional ``rank`` is a
DIExpression that describes the rank (number of dimensions) of fortran assumed
rank array (rank is known at runtime).

For ``DW_TAG_enumeration_type``, the ``elements:`` should be :ref:`enumerator
descriptors <DIEnumerator>`, each representing the definition of an enumeration
Expand Down Expand Up @@ -5156,6 +5163,10 @@ The current supported opcode vocabulary is limited:
- ``DW_OP_push_object_address`` pushes the address of the object which can then
serve as a descriptor in subsequent calculation. This opcode can be used to
calculate bounds of fortran allocatable array which has array descriptors.
- ``DW_OP_over`` duplicates the entry currently second in the stack at the top
of the stack. This opcode can be used to calculate bounds of fortran assumed
rank array which has rank known at run time and current dimension number is
implicitly first element of the stack.

DWARF specifies three kinds of simple location descriptions: Register, memory,
and implicit location descriptions. Note that a location description is
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ enum {
LLVMDIStringTypeMetadataKind,
LLVMDIFortranArrayTypeMetadataKind,
LLVMDIFortranSubrangeMetadataKind,
LLVMDICommonBlockMetadataKind
LLVMDICommonBlockMetadataKind,
LLVMDIGenericSubrangeMetadataKind
};
typedef unsigned LLVMMetadataKind;

Expand Down
67 changes: 64 additions & 3 deletions llvm/include/llvm/BinaryFormat/Dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ enum SourceLanguage {
};

inline bool isCPlusPlus(SourceLanguage S) {
bool result = false;
// Deliberately enumerate all the language options so we get a warning when
// new language options are added (-Wswitch) that'll hopefully help keep this
// switch up-to-date when new C++ versions are added.
Expand All @@ -191,7 +192,8 @@ inline bool isCPlusPlus(SourceLanguage S) {
case DW_LANG_C_plus_plus_03:
case DW_LANG_C_plus_plus_11:
case DW_LANG_C_plus_plus_14:
return true;
result = true;
break;
case DW_LANG_C89:
case DW_LANG_C:
case DW_LANG_Ada83:
Expand Down Expand Up @@ -230,9 +232,68 @@ inline bool isCPlusPlus(SourceLanguage S) {
case DW_LANG_BORLAND_Delphi:
case DW_LANG_lo_user:
case DW_LANG_hi_user:
return false;
result = false;
break;
}

return result;
}

inline bool isFortran(SourceLanguage S) {
bool result = false;
// Deliberately enumerate all the language options so we get a warning when
// new language options are added (-Wswitch) that'll hopefully help keep this
// switch up-to-date when new Fortran versions are added.
switch (S) {
case DW_LANG_Fortran77:
case DW_LANG_Fortran90:
case DW_LANG_Fortran95:
case DW_LANG_Fortran03:
case DW_LANG_Fortran08:
result = true;
break;
case DW_LANG_C89:
case DW_LANG_C:
case DW_LANG_Ada83:
case DW_LANG_C_plus_plus:
case DW_LANG_Cobol74:
case DW_LANG_Cobol85:
case DW_LANG_Pascal83:
case DW_LANG_Modula2:
case DW_LANG_Java:
case DW_LANG_C99:
case DW_LANG_Ada95:
case DW_LANG_PLI:
case DW_LANG_ObjC:
case DW_LANG_ObjC_plus_plus:
case DW_LANG_UPC:
case DW_LANG_D:
case DW_LANG_Python:
case DW_LANG_OpenCL:
case DW_LANG_Go:
case DW_LANG_Modula3:
case DW_LANG_Haskell:
case DW_LANG_C_plus_plus_03:
case DW_LANG_C_plus_plus_11:
case DW_LANG_OCaml:
case DW_LANG_Rust:
case DW_LANG_C11:
case DW_LANG_Swift:
case DW_LANG_Julia:
case DW_LANG_Dylan:
case DW_LANG_C_plus_plus_14:
case DW_LANG_RenderScript:
case DW_LANG_BLISS:
case DW_LANG_Mips_Assembler:
case DW_LANG_GOOGLE_RenderScript:
case DW_LANG_BORLAND_Delphi:
case DW_LANG_lo_user:
case DW_LANG_hi_user:
result = false;
break;
}
llvm_unreachable("Invalid source language");

return result;
}

enum CaseSensitivity {
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Bitcode/LLVMBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ enum MetadataCodes {
METADATA_FORTRAN_ARRAY_TYPE = 42, // [distinct, name, [bounds ...], ...]
METADATA_FORTRAN_SUBRANGE = 43, // [distinct, lbound, lbnde, ubound, ubnde]
METADATA_COMMON_BLOCK = 44, // [distinct, scope, name, variable,...]
METADATA_GENERIC_SUBRANGE = 45 // [distinct, count, lo, up, stride]
};

// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/IR/DIBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ namespace llvm {
int64_t CLBound, int64_t CUBound, bool NoUBound, Metadata *Lbound,
Metadata * Lbndexp, Metadata *Ubound, Metadata * Ubndexp);

DIGenericSubrange *
getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count,
DIGenericSubrange::BoundType LowerBound,
DIGenericSubrange::BoundType UpperBound,
DIGenericSubrange::BoundType Stride);

/// Create a new descriptor for the specified variable.
/// \param Context Variable scope.
/// \param Name Name of the variable.
Expand Down
107 changes: 94 additions & 13 deletions llvm/include/llvm/IR/DebugInfoMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class DINode : public MDNode {
case DIObjCPropertyKind:
case DIImportedEntityKind:
case DIModuleKind:
case DIGenericSubrangeKind:
return true;
}
}
Expand Down Expand Up @@ -418,6 +419,52 @@ class DIFortranSubrange : public DINode {
}
};

class DIGenericSubrange : public DINode {
friend class LLVMContextImpl;
friend class MDNode;

DIGenericSubrange(LLVMContext &C, StorageType Storage,
ArrayRef<Metadata *> Ops)
: DINode(C, DIGenericSubrangeKind, Storage,
dwarf::DW_TAG_generic_subrange, Ops) {}

~DIGenericSubrange() = default;

static DIGenericSubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
Metadata *LowerBound, Metadata *UpperBound,
Metadata *Stride, StorageType Storage,
bool ShouldCreate = true);

TempDIGenericSubrange cloneImpl() const {
return getTemporary(getContext(), getRawCountNode(), getRawLowerBound(),
getRawUpperBound(), getRawStride());
}

public:
DEFINE_MDNODE_GET(DIGenericSubrange,
(Metadata * CountNode, Metadata *LowerBound,
Metadata *UpperBound, Metadata *Stride),
(CountNode, LowerBound, UpperBound, Stride))

TempDIGenericSubrange clone() const { return cloneImpl(); }

Metadata *getRawCountNode() const { return getOperand(0).get(); }
Metadata *getRawLowerBound() const { return getOperand(1).get(); }
Metadata *getRawUpperBound() const { return getOperand(2).get(); }
Metadata *getRawStride() const { return getOperand(3).get(); }

using BoundType = PointerUnion<DIVariable *, DIExpression *>;

BoundType getCount() const;
BoundType getLowerBound() const;
BoundType getUpperBound() const;
BoundType getStride() const;

static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIGenericSubrangeKind;
}
};

/// Enumeration value.
///
/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
Expand Down Expand Up @@ -1113,13 +1160,14 @@ class DICompositeType : public DIType {
DINodeArray Elements, unsigned RuntimeLang, DIType *VTableHolder,
DITemplateParameterArray TemplateParams, StringRef Identifier,
DIDerivedType *Discriminator, Metadata *DataLocation,
Metadata *Associated, Metadata *Allocated, Metadata *Rank,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
Flags, Elements.get(), RuntimeLang, VTableHolder,
TemplateParams.get(),
getCanonicalMDString(Context, Identifier), Discriminator,
DataLocation, Storage, ShouldCreate);
return getImpl(
Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
RuntimeLang, VTableHolder, TemplateParams.get(),
getCanonicalMDString(Context, Identifier), Discriminator, DataLocation,
Associated, Allocated, Rank, Storage, ShouldCreate);
}
static DICompositeType *
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
Expand All @@ -1128,6 +1176,7 @@ class DICompositeType : public DIType {
DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams,
MDString *Identifier, Metadata *Discriminator, Metadata *DataLocation,
Metadata *Associated, Metadata *Allocated, Metadata *Rank,
StorageType Storage, bool ShouldCreate = true);

TempDICompositeType cloneImpl() const {
Expand All @@ -1136,7 +1185,8 @@ class DICompositeType : public DIType {
getAlignInBits(), getOffsetInBits(), getFlags(),
getElements(), getRuntimeLang(), getVTableHolder(),
getTemplateParams(), getIdentifier(),
getDiscriminator(), getRawDataLocation());
getDiscriminator(), getRawDataLocation(),
getRawAssociated(), getRawAllocated(), getRawRank());
}

public:
Expand All @@ -1148,21 +1198,24 @@ class DICompositeType : public DIType {
DINodeArray Elements, unsigned RuntimeLang, DIType *VTableHolder,
DITemplateParameterArray TemplateParams = nullptr,
StringRef Identifier = "", DIDerivedType *Discriminator = nullptr,
Metadata *DataLocation = nullptr),
Metadata *DataLocation = nullptr, Metadata *Associated = nullptr,
Metadata *Allocated = nullptr, Metadata *Rank = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator, DataLocation))
Identifier, Discriminator, DataLocation, Associated, Allocated, Rank))
DEFINE_MDNODE_GET(
DICompositeType,
(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams = nullptr, MDString *Identifier = nullptr,
Metadata *Discriminator = nullptr, Metadata *DataLocation = nullptr),
Metadata *Discriminator = nullptr, Metadata *DataLocation = nullptr,
Metadata *Associated = nullptr, Metadata *Allocated = nullptr,
Metadata *Rank = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator, DataLocation))
Identifier, Discriminator, DataLocation, Associated, Allocated, Rank))

TempDICompositeType clone() const { return cloneImpl(); }

Expand All @@ -1180,7 +1233,8 @@ class DICompositeType : public DIType {
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, Metadata *Discriminator,
Metadata *DataLocation);
Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
Metadata *Rank);
static DICompositeType *getODRTypeIfExists(LLVMContext &Context,
MDString &Identifier);

Expand All @@ -1200,7 +1254,8 @@ class DICompositeType : public DIType {
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, Metadata *Discriminator,
Metadata *DataLocation);
Metadata *DataLocation, Metadata *Associated,
Metadata *Allocated, Metadata *Rank);

DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
DINodeArray getElements() const {
Expand Down Expand Up @@ -1229,6 +1284,29 @@ class DICompositeType : public DIType {
DIExpression *getDataLocationExp() const {
return dyn_cast_or_null<DIExpression>(getRawDataLocation());
}
Metadata *getRawAssociated() const { return getOperand(10); }
DIVariable *getAssociated() const {
return dyn_cast_or_null<DIVariable>(getRawAssociated());
}
DIExpression *getAssociatedExp() const {
return dyn_cast_or_null<DIExpression>(getRawAssociated());
}
Metadata *getRawAllocated() const { return getOperand(11); }
DIVariable *getAllocated() const {
return dyn_cast_or_null<DIVariable>(getRawAllocated());
}
DIExpression *getAllocatedExp() const {
return dyn_cast_or_null<DIExpression>(getRawAllocated());
}
Metadata *getRawRank() const { return getOperand(12); }
ConstantInt *getRankConst() const {
if (auto *MD = dyn_cast_or_null<ConstantAsMetadata>(getRawRank()))
return dyn_cast_or_null<ConstantInt>(MD->getValue());
return nullptr;
}
DIExpression *getRankExp() const {
return dyn_cast_or_null<DIExpression>(getRawRank());
}

/// Replace operands.
///
Expand Down Expand Up @@ -2664,6 +2742,9 @@ class DIExpression : public MDNode {
/// Determine whether this represents a standalone constant value.
bool isConstant() const;

/// Determine whether this represents a standalone signed constant value.
bool isSignedConstant() const;

using element_iterator = ArrayRef<uint64_t>::iterator;

element_iterator elements_begin() const { return getElements().begin(); }
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/Metadata.def
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIStringType)
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIFortranArrayType)
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIFortranSubrange)
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DICommonBlock)
HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIGenericSubrange)

#undef HANDLE_METADATA
#undef HANDLE_METADATA_LEAF
Expand Down
Loading