Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
llvm
hpvm-release
Commits
886c149b
Commit
886c149b
authored
9 years ago
by
Prakalp Srivastava
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug: For internal df nodes with void return types, the genvisc pass was
not producing empty struct as return type. Fixed it
parent
13c6539b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/lib/Transforms/GenVISC/GenVISC.cpp
+33
-0
33 additions, 0 deletions
llvm/lib/Transforms/GenVISC/GenVISC.cpp
with
33 additions
and
0 deletions
llvm/lib/Transforms/GenVISC/GenVISC.cpp
+
33
−
0
View file @
886c149b
...
...
@@ -33,6 +33,7 @@ namespace genvisc {
// Helper Functions
static
inline
ConstantInt
*
getTimerID
(
Module
&
,
enum
visc_TimerID
);
static
void
transformReturnTypeToStruct
(
Function
*
F
);
// Check if the dummy function call is a __visc__node call
#define IS_VISC_CALL(callName) \
...
...
@@ -870,6 +871,7 @@ bool GenVISC::runOnModule(Module &M) {
DEBUG
(
errs
()
<<
*
LaunchF
<<
"
\n
"
);
// Get i8* cast to function pointer
Function
*
graphFunc
=
cast
<
Function
>
(
CI
->
getArgOperand
(
1
));
transformReturnTypeToStruct
(
graphFunc
);
Constant
*
F
=
ConstantExpr
::
getPointerCast
(
graphFunc
,
Type
::
getInt8PtrTy
(
Ctx
));
ConstantInt
*
Op
=
cast
<
ConstantInt
>
(
CI
->
getArgOperand
(
0
));
...
...
@@ -916,6 +918,7 @@ bool GenVISC::runOnModule(Module &M) {
// Get i8* cast to function pointer
Function
*
graphFunc
=
cast
<
Function
>
(
CI
->
getArgOperand
(
0
));
transformReturnTypeToStruct
(
graphFunc
);
Constant
*
F
=
ConstantExpr
::
getPointerCast
(
graphFunc
,
Type
::
getInt8PtrTy
(
Ctx
));
CallInst
*
CreateNodeInst
=
CallInst
::
Create
(
CreateNodeF
,
...
...
@@ -933,6 +936,7 @@ bool GenVISC::runOnModule(Module &M) {
// Get i8* cast to function pointer
Function
*
graphFunc
=
cast
<
Function
>
(
CI
->
getArgOperand
(
0
));
transformReturnTypeToStruct
(
graphFunc
);
Constant
*
F
=
ConstantExpr
::
getPointerCast
(
graphFunc
,
Type
::
getInt8PtrTy
(
Ctx
));
Value
*
CreateNode1DArgs
[]
=
{
F
,
CI
->
getArgOperand
(
1
)};
...
...
@@ -950,6 +954,7 @@ bool GenVISC::runOnModule(Module &M) {
// Get i8* cast to function pointer
Function
*
graphFunc
=
cast
<
Function
>
(
CI
->
getArgOperand
(
0
));
transformReturnTypeToStruct
(
graphFunc
);
Constant
*
F
=
ConstantExpr
::
getPointerCast
(
graphFunc
,
Type
::
getInt8PtrTy
(
Ctx
));
Value
*
CreateNode2DArgs
[]
=
{
F
,
CI
->
getArgOperand
(
1
),
CI
->
getArgOperand
(
2
)};
...
...
@@ -967,6 +972,7 @@ bool GenVISC::runOnModule(Module &M) {
// Get i8* cast to function pointer
Function
*
graphFunc
=
cast
<
Function
>
(
CI
->
getArgOperand
(
0
));
transformReturnTypeToStruct
(
graphFunc
);
Constant
*
F
=
ConstantExpr
::
getPointerCast
(
graphFunc
,
Type
::
getInt8PtrTy
(
Ctx
));
Value
*
CreateNode3DArgs
[]
=
{
F
,
CI
->
getArgOperand
(
1
),
...
...
@@ -1476,6 +1482,33 @@ static inline ConstantInt* getTimerID(Module& M, enum visc_TimerID timer) {
return
ConstantInt
::
get
(
Type
::
getInt32Ty
(
M
.
getContext
()),
timer
);
}
static
void
transformReturnTypeToStruct
(
Function
*
F
)
{
// Currently only works for void return types
errs
()
<<
"Transforming return type of function to Struct: "
<<
F
->
getName
()
<<
"
\n
"
;
if
(
!
F
->
getReturnType
()
->
isVoidTy
())
{
errs
()
<<
"Warning: Unhandled case - Only void return type handled
\n
"
;
return
;
}
// Create the argument type list with added argument types
std
::
vector
<
Type
*>
ArgTypes
;
for
(
Function
::
const_arg_iterator
ai
=
F
->
arg_begin
(),
ae
=
F
->
arg_end
();
ai
!=
ae
;
++
ai
)
{
ArgTypes
.
push_back
(
ai
->
getType
());
}
StructType
*
RetTy
=
StructType
::
create
(
F
->
getContext
(),
None
,
"emptyStruct"
,
true
);
FunctionType
*
FTy
=
FunctionType
::
get
(
RetTy
,
ArgTypes
,
F
->
isVarArg
());
PointerType
*
PTy
=
FTy
->
getPointerTo
();
F
->
mutateType
(
PTy
);
// Replace ret void instruction with ret %RetTy undef
for
(
auto
&
BB
:
F
->
getBasicBlockList
())
{
if
(
ReturnInst
*
RI
=
dyn_cast
<
ReturnInst
>
(
BB
.
getTerminator
()))
{
DEBUG
(
errs
()
<<
"Found return inst: "
<<
*
RI
<<
"
\n
"
);
ReturnInst
*
newRI
=
ReturnInst
::
Create
(
F
->
getContext
(),
UndefValue
::
get
(
RetTy
));
ReplaceInstWithInst
(
RI
,
newRI
);
}
}
}
char
GenVISC
::
ID
=
0
;
static
RegisterPass
<
GenVISC
>
X
(
"genvisc"
,
"Pass to generate VISC IR from LLVM IR (with dummy function calls)"
,
false
,
false
);
...
...
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