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
Show 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 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "codegen/codegen.h"
...
...
@@ -205,29 +206,7 @@ public:
}
};
void
dumpPrettyIR
(
llvm
::
Function
*
f
)
{
//f->getParent()->dump();
//return;
std
::
unique_ptr
<
llvm
::
Module
>
tmp_module
(
llvm
::
CloneModule
(
f
->
getParent
()));
// std::unique_ptr<llvm::Module> tmp_module(new llvm::Module("tmp", g.context));
llvm
::
Function
*
new_f
=
tmp_module
->
begin
();
llvm
::
ValueToValueMapTy
VMap
;
llvm
::
RemapFlags
flags
=
llvm
::
RF_None
;
llvm
::
ValueMapTypeRemapper
*
type_remapper
=
NULL
;
PrettifyingMaterializer
materializer
(
tmp_module
.
get
(),
VMap
,
flags
,
type_remapper
);
for
(
llvm
::
Function
::
iterator
I
=
new_f
->
begin
(),
E
=
new_f
->
end
();
I
!=
E
;
++
I
)
{
VMap
[
I
]
=
I
;
}
for
(
llvm
::
inst_iterator
it
=
inst_begin
(
new_f
),
end
=
inst_end
(
new_f
);
it
!=
end
;
++
it
)
{
llvm
::
RemapInstruction
(
&*
it
,
VMap
,
flags
,
type_remapper
,
&
materializer
);
if
(
llvm
::
IntrinsicInst
*
ii
=
llvm
::
dyn_cast
<
llvm
::
IntrinsicInst
>
(
&*
it
))
{
if
(
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_i64
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_void
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_double
)
{
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
);
...
...
@@ -247,16 +226,45 @@ void dumpPrettyIR(llvm::Function* f) {
}
if
(
!
lookup_success
)
{
llvm
::
Constant
*
int_val
=
llvm
::
ConstantInt
::
get
(
g
.
i64
,
reinterpret_cast
<
uintptr_t
>
(
addr
),
false
);
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
));
ii
->
setArgOperand
(
i
,
ii
->
getParent
()
->
getParent
()
->
getParent
()
->
getOrInsertGlobal
(
name
,
g
.
i8
));
}
}
}
}
void
dumpPrettyIR
(
llvm
::
Function
*
f
)
{
// f->getParent()->dump();
// return;
std
::
unique_ptr
<
llvm
::
Module
>
tmp_module
(
llvm
::
CloneModule
(
f
->
getParent
()));
// std::unique_ptr<llvm::Module> tmp_module(new llvm::Module("tmp", g.context));
llvm
::
Function
*
new_f
=
tmp_module
->
begin
();
llvm
::
ValueToValueMapTy
VMap
;
llvm
::
RemapFlags
flags
=
llvm
::
RF_None
;
llvm
::
ValueMapTypeRemapper
*
type_remapper
=
NULL
;
PrettifyingMaterializer
materializer
(
tmp_module
.
get
(),
VMap
,
flags
,
type_remapper
);
for
(
llvm
::
Function
::
iterator
I
=
new_f
->
begin
(),
E
=
new_f
->
end
();
I
!=
E
;
++
I
)
{
VMap
[
I
]
=
I
;
}
for
(
llvm
::
inst_iterator
it
=
inst_begin
(
new_f
),
end
=
inst_end
(
new_f
);
it
!=
end
;
++
it
)
{
llvm
::
RemapInstruction
(
&*
it
,
VMap
,
flags
,
type_remapper
,
&
materializer
);
if
(
llvm
::
IntrinsicInst
*
ii
=
llvm
::
dyn_cast
<
llvm
::
IntrinsicInst
>
(
&*
it
))
{
if
(
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_i64
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_void
||
ii
->
getIntrinsicID
()
==
llvm
::
Intrinsic
::
experimental_patchpoint_double
)
{
remapPatchpoint
(
ii
);
}
}
else
if
(
llvm
::
InvokeInst
*
ii
=
llvm
::
dyn_cast
<
llvm
::
InvokeInst
>
(
&*
it
))
{
if
(
ii
->
getCalledFunction
()
->
isIntrinsic
())
{
remapPatchpoint
(
ii
);
}
}
}
...
...
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