diff options
author | Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com> | 2020-08-20 16:11:22 +0530 |
---|---|---|
committer | Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com> | 2020-08-22 10:13:40 +0530 |
commit | f91d18eaa946b2d2ea5a9334fb099c3e409ad2d1 (patch) | |
tree | a31a2a613b62d9467e17152a42714d9de50a130f /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 86fc1933099d8818c7d7559ae41e5903a1daf9bd (diff) | |
download | llvm-f91d18eaa946b2d2ea5a9334fb099c3e409ad2d1.zip llvm-f91d18eaa946b2d2ea5a9334fb099c3e409ad2d1.tar.gz llvm-f91d18eaa946b2d2ea5a9334fb099c3e409ad2d1.tar.bz2 |
[DebugInfo][flang]Added support for representing Fortran assumed length strings
This patch adds support for representing Fortran `character(n)`.
Primarily patch is based out of D54114 with appropriate modifications.
Test case IR is generated using our downstream classic-flang. We're in process
of upstreaming flang PR's but classic-flang has dependencies on llvm, so
this has to get in first.
Patch includes functional test case for both IR and corresponding
dwarf, furthermore it has been manually tested as well using GDB.
Source snippet:
```
program assumedLength
call sub('Hello')
call sub('Goodbye')
contains
subroutine sub(string)
implicit none
character(len=*), intent(in) :: string
print *, string
end subroutine sub
end program assumedLength
```
GDB:
```
(gdb) ptype string
type = character (5)
(gdb) p string
$1 = 'Hello'
```
Reviewed By: aprantl, schweitz
Differential Revision: https://reviews.llvm.org/D86305
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 777a0e2..329cbe4 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -301,6 +301,8 @@ private: SmallVectorImpl<uint64_t> &Record, unsigned Abbrev); void writeDIBasicType(const DIBasicType *N, SmallVectorImpl<uint64_t> &Record, unsigned Abbrev); + void writeDIStringType(const DIStringType *N, + SmallVectorImpl<uint64_t> &Record, unsigned Abbrev); void writeDIDerivedType(const DIDerivedType *N, SmallVectorImpl<uint64_t> &Record, unsigned Abbrev); void writeDICompositeType(const DICompositeType *N, @@ -1590,6 +1592,22 @@ void ModuleBitcodeWriter::writeDIBasicType(const DIBasicType *N, Record.clear(); } +void ModuleBitcodeWriter::writeDIStringType(const DIStringType *N, + SmallVectorImpl<uint64_t> &Record, + unsigned Abbrev) { + Record.push_back(N->isDistinct()); + Record.push_back(N->getTag()); + Record.push_back(VE.getMetadataOrNullID(N->getRawName())); + Record.push_back(VE.getMetadataOrNullID(N->getStringLength())); + Record.push_back(VE.getMetadataOrNullID(N->getStringLengthExp())); + Record.push_back(N->getSizeInBits()); + Record.push_back(N->getAlignInBits()); + Record.push_back(N->getEncoding()); + + Stream.EmitRecord(bitc::METADATA_STRING_TYPE, Record, Abbrev); + Record.clear(); +} + void ModuleBitcodeWriter::writeDIDerivedType(const DIDerivedType *N, SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) { |