Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
8f1077cb
Commit
8f1077cb
authored
Feb 24, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pretty-print things inside invokes
Maybe this was the issue I was running into earlier
parent
a9832bf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
31 deletions
+39
-31
src/codegen/irgen/util.cpp
src/codegen/irgen/util.cpp
+39
-31
No files found.
src/codegen/irgen/util.cpp
View file @
8f1077cb
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "codegen/codegen.h"
#include "codegen/codegen.h"
...
@@ -205,9 +206,40 @@ public:
...
@@ -205,9 +206,40 @@ public:
}
}
};
};
template
<
typename
I
>
void
remapPatchpoint
(
I
*
ii
)
{
int
pp_id
=
-
1
;
for
(
int
i
=
0
;
i
<
ii
->
getNumArgOperands
();
i
++
)
{
llvm
::
Value
*
op
=
ii
->
getArgOperand
(
i
);
if
(
i
==
0
)
{
llvm
::
ConstantInt
*
l_pp_id
=
llvm
::
cast
<
llvm
::
ConstantInt
>
(
op
);
pp_id
=
l_pp_id
->
getSExtValue
();
}
else
if
(
i
==
2
)
{
assert
(
pp_id
!=
-
1
);
void
*
addr
=
PatchpointInfo
::
getSlowpathAddr
(
pp_id
);
bool
lookup_success
=
true
;
std
::
string
name
;
if
(
addr
==
(
void
*
)
None
)
{
name
=
"None"
;
}
else
{
name
=
g
.
func_addr_registry
.
getFuncNameAtAddress
(
addr
,
true
,
&
lookup_success
);
}
if
(
!
lookup_success
)
{
llvm
::
Constant
*
int_val
=
llvm
::
ConstantInt
::
get
(
g
.
i64
,
reinterpret_cast
<
uintptr_t
>
(
addr
),
false
);
llvm
::
Constant
*
ptr_val
=
llvm
::
ConstantExpr
::
getIntToPtr
(
int_val
,
g
.
i8_ptr
);
ii
->
setArgOperand
(
i
,
ptr_val
);
continue
;
}
else
{
ii
->
setArgOperand
(
i
,
ii
->
getParent
()
->
getParent
()
->
getParent
()
->
getOrInsertGlobal
(
name
,
g
.
i8
));
}
}
}
}
void
dumpPrettyIR
(
llvm
::
Function
*
f
)
{
void
dumpPrettyIR
(
llvm
::
Function
*
f
)
{
//f->getParent()->dump();
//
f->getParent()->dump();
//return;
//
return;
std
::
unique_ptr
<
llvm
::
Module
>
tmp_module
(
llvm
::
CloneModule
(
f
->
getParent
()));
std
::
unique_ptr
<
llvm
::
Module
>
tmp_module
(
llvm
::
CloneModule
(
f
->
getParent
()));
// std::unique_ptr<llvm::Module> tmp_module(new llvm::Module("tmp", g.context));
// std::unique_ptr<llvm::Module> tmp_module(new llvm::Module("tmp", g.context));
...
@@ -228,35 +260,11 @@ void dumpPrettyIR(llvm::Function* f) {
...
@@ -228,35 +260,11 @@ void dumpPrettyIR(llvm::Function* f) {
if
(
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_i64
if
(
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_i64
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_void
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_void
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_double
)
{
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_double
)
{
int
pp_id
=
-
1
;
remapPatchpoint
(
ii
);
for
(
int
i
=
0
;
i
<
ii
->
getNumArgOperands
();
i
++
)
{
}
llvm
::
Value
*
op
=
ii
->
getArgOperand
(
i
);
}
else
if
(
llvm
::
InvokeInst
*
ii
=
llvm
::
dyn_cast
<
llvm
::
InvokeInst
>
(
&*
it
))
{
if
(
i
==
0
)
{
if
(
ii
->
getCalledFunction
()
->
isIntrinsic
())
{
llvm
::
ConstantInt
*
l_pp_id
=
llvm
::
cast
<
llvm
::
ConstantInt
>
(
op
);
remapPatchpoint
(
ii
);
pp_id
=
l_pp_id
->
getSExtValue
();
}
else
if
(
i
==
2
)
{
assert
(
pp_id
!=
-
1
);
void
*
addr
=
PatchpointInfo
::
getSlowpathAddr
(
pp_id
);
bool
lookup_success
=
true
;
std
::
string
name
;
if
(
addr
==
(
void
*
)
None
)
{
name
=
"None"
;
}
else
{
name
=
g
.
func_addr_registry
.
getFuncNameAtAddress
(
addr
,
true
,
&
lookup_success
);
}
if
(
!
lookup_success
)
{
llvm
::
Constant
*
int_val
=
llvm
::
ConstantInt
::
get
(
g
.
i64
,
reinterpret_cast
<
uintptr_t
>
(
addr
),
false
);
llvm
::
Constant
*
ptr_val
=
llvm
::
ConstantExpr
::
getIntToPtr
(
int_val
,
g
.
i8_ptr
);
ii
->
setArgOperand
(
i
,
ptr_val
);
continue
;
}
else
{
ii
->
setArgOperand
(
i
,
tmp_module
->
getOrInsertGlobal
(
name
,
g
.
i8
));
}
}
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment