Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LLVM bpEVL
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Albano
LLVM bpEVL
Commits
ccaa448d
Commit
ccaa448d
authored
17 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
Read global symtab
llvm-svn: 36378
parent
1e93f5b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+56
-3
56 additions, 3 deletions
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.h
+3
-0
3 additions, 0 deletions
llvm/lib/Bitcode/Reader/BitcodeReader.h
with
59 additions
and
3 deletions
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+
56
−
3
View file @
ccaa448d
...
@@ -15,12 +15,14 @@
...
@@ -15,12 +15,14 @@
#include
"llvm/Bitcode/BitstreamReader.h"
#include
"llvm/Bitcode/BitstreamReader.h"
#include
"llvm/DerivedTypes.h"
#include
"llvm/DerivedTypes.h"
#include
"llvm/Module.h"
#include
"llvm/Module.h"
#include
"llvm/ADT/SmallString.h"
using
namespace
llvm
;
using
namespace
llvm
;
/// ConvertToString - Convert a string from a record into an std::string, return
/// ConvertToString - Convert a string from a record into an std::string, return
/// true on failure.
/// true on failure.
template
<
typename
StrTy
>
static
bool
ConvertToString
(
SmallVector
<
uint64_t
,
64
>
&
Record
,
unsigned
Idx
,
static
bool
ConvertToString
(
SmallVector
<
uint64_t
,
64
>
&
Record
,
unsigned
Idx
,
std
::
string
&
Result
)
{
StrTy
&
Result
)
{
if
(
Record
.
size
()
<
Idx
+
1
||
Record
.
size
()
<
Record
[
Idx
]
+
Idx
+
1
)
if
(
Record
.
size
()
<
Idx
+
1
||
Record
.
size
()
<
Record
[
Idx
]
+
Idx
+
1
)
return
true
;
return
true
;
...
@@ -255,6 +257,52 @@ bool BitcodeReader::ParseTypeSymbolTable(BitstreamReader &Stream) {
...
@@ -255,6 +257,52 @@ bool BitcodeReader::ParseTypeSymbolTable(BitstreamReader &Stream) {
}
}
}
}
bool
BitcodeReader
::
ParseValueSymbolTable
(
BitstreamReader
&
Stream
)
{
if
(
Stream
.
EnterSubBlock
())
return
Error
(
"Malformed block record"
);
SmallVector
<
uint64_t
,
64
>
Record
;
// Read all the records for this value table.
SmallString
<
128
>
ValueName
;
while
(
1
)
{
unsigned
Code
=
Stream
.
ReadCode
();
if
(
Code
==
bitc
::
END_BLOCK
)
return
Stream
.
ReadBlockEnd
();
if
(
Code
==
bitc
::
ENTER_SUBBLOCK
)
{
// No known subblocks, always skip them.
Stream
.
ReadSubBlockID
();
if
(
Stream
.
SkipBlock
())
return
Error
(
"Malformed block record"
);
continue
;
}
if
(
Code
==
bitc
::
DEFINE_ABBREV
)
{
Stream
.
ReadAbbrevRecord
();
continue
;
}
// Read a record.
Record
.
clear
();
switch
(
Stream
.
ReadRecord
(
Code
,
Record
))
{
default:
// Default behavior: unknown type.
break
;
case
bitc
::
VST_ENTRY_CODE
:
// VST_ENTRY: [valueid, namelen, namechar x N]
if
(
ConvertToString
(
Record
,
1
,
ValueName
))
return
Error
(
"Invalid TST_ENTRY record"
);
unsigned
ValueID
=
Record
[
0
];
if
(
ValueID
>=
ValueList
.
size
())
return
Error
(
"Invalid Value ID in VST_ENTRY record"
);
Value
*
V
=
ValueList
[
ValueID
];
V
->
setName
(
&
ValueName
[
0
],
ValueName
.
size
());
ValueName
.
clear
();
break
;
}
}
}
bool
BitcodeReader
::
ParseModule
(
BitstreamReader
&
Stream
,
bool
BitcodeReader
::
ParseModule
(
BitstreamReader
&
Stream
,
const
std
::
string
&
ModuleID
)
{
const
std
::
string
&
ModuleID
)
{
...
@@ -291,6 +339,10 @@ bool BitcodeReader::ParseModule(BitstreamReader &Stream,
...
@@ -291,6 +339,10 @@ bool BitcodeReader::ParseModule(BitstreamReader &Stream,
if
(
ParseTypeSymbolTable
(
Stream
))
if
(
ParseTypeSymbolTable
(
Stream
))
return
true
;
return
true
;
break
;
break
;
case
bitc
::
VALUE_SYMTAB_BLOCK_ID
:
if
(
ParseValueSymbolTable
(
Stream
))
return
true
;
break
;
}
}
continue
;
continue
;
}
}
...
@@ -377,7 +429,8 @@ bool BitcodeReader::ParseModule(BitstreamReader &Stream,
...
@@ -377,7 +429,8 @@ bool BitcodeReader::ParseModule(BitstreamReader &Stream,
NewGV
->
setVisibility
(
Visibility
);
NewGV
->
setVisibility
(
Visibility
);
NewGV
->
setThreadLocal
(
isThreadLocal
);
NewGV
->
setThreadLocal
(
isThreadLocal
);
// TODO: Add to value table.
ValueList
.
push_back
(
NewGV
);
// TODO: remember initializer/global pair for later substitution.
// TODO: remember initializer/global pair for later substitution.
break
;
break
;
}
}
...
@@ -407,7 +460,7 @@ bool BitcodeReader::ParseModule(BitstreamReader &Stream,
...
@@ -407,7 +460,7 @@ bool BitcodeReader::ParseModule(BitstreamReader &Stream,
}
}
Func
->
setVisibility
(
GetDecodedVisibility
(
Record
[
6
]));
Func
->
setVisibility
(
GetDecodedVisibility
(
Record
[
6
]));
// TODO: Add to value table.
ValueList
.
push_back
(
Func
);
// TODO: remember initializer/global pair for later substitution.
// TODO: remember initializer/global pair for later substitution.
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
llvm/lib/Bitcode/Reader/BitcodeReader.h
+
3
−
0
View file @
ccaa448d
...
@@ -21,11 +21,13 @@
...
@@ -21,11 +21,13 @@
namespace
llvm
{
namespace
llvm
{
class
BitstreamReader
;
class
BitstreamReader
;
class
Value
;
class
BitcodeReader
:
public
ModuleProvider
{
class
BitcodeReader
:
public
ModuleProvider
{
const
char
*
ErrorString
;
const
char
*
ErrorString
;
std
::
vector
<
PATypeHolder
>
TypeList
;
std
::
vector
<
PATypeHolder
>
TypeList
;
std
::
vector
<
Value
*>
ValueList
;
public:
public:
virtual
~
BitcodeReader
()
{}
virtual
~
BitcodeReader
()
{}
...
@@ -59,6 +61,7 @@ private:
...
@@ -59,6 +61,7 @@ private:
bool
ParseModule
(
BitstreamReader
&
Stream
,
const
std
::
string
&
ModuleID
);
bool
ParseModule
(
BitstreamReader
&
Stream
,
const
std
::
string
&
ModuleID
);
bool
ParseTypeTable
(
BitstreamReader
&
Stream
);
bool
ParseTypeTable
(
BitstreamReader
&
Stream
);
bool
ParseTypeSymbolTable
(
BitstreamReader
&
Stream
);
bool
ParseTypeSymbolTable
(
BitstreamReader
&
Stream
);
bool
ParseValueSymbolTable
(
BitstreamReader
&
Stream
);
};
};
}
// End llvm namespace
}
// End llvm namespace
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment