Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
66f84e7a
Commit
66f84e7a
authored
16 years ago
by
Devang Patel
Browse files
Options
Downloads
Patches
Plain Diff
Add helper pass to remove llvm.dbg.declare intrinsics.
llvm-svn: 66454
parent
e201f8ff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/include/llvm/Transforms/IPO.h
+7
-2
7 additions, 2 deletions
llvm/include/llvm/Transforms/IPO.h
llvm/lib/Transforms/IPO/StripSymbols.cpp
+62
-0
62 additions, 0 deletions
llvm/lib/Transforms/IPO/StripSymbols.cpp
with
69 additions
and
2 deletions
llvm/include/llvm/Transforms/IPO.h
+
7
−
2
View file @
66f84e7a
...
@@ -35,11 +35,16 @@ ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
...
@@ -35,11 +35,16 @@ ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
//
//
// These functions
remove
s symbols from functions and modules.
// These functions
strip
s symbols from functions and modules.
// Only debugging information is not
remov
ed.
// Only debugging information is not
stripp
ed.
//
//
ModulePass
*
createStripNonDebugSymbolsPass
();
ModulePass
*
createStripNonDebugSymbolsPass
();
//===----------------------------------------------------------------------===//
//
// These pass removes llvm.dbg.declare intrinsics.
ModulePass
*
createStripDebugDeclarePass
();
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
/// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
/// createLowerSetJmpPass - This function lowers the setjmp/longjmp intrinsics
/// to invoke/unwind instructions. This should really be part of the C/C++
/// to invoke/unwind instructions. This should really be part of the C/C++
...
...
This diff is collapsed.
Click to expand it.
llvm/lib/Transforms/IPO/StripSymbols.cpp
+
62
−
0
View file @
66f84e7a
...
@@ -60,6 +60,19 @@ namespace {
...
@@ -60,6 +60,19 @@ namespace {
AU
.
setPreservesAll
();
AU
.
setPreservesAll
();
}
}
};
};
class
VISIBILITY_HIDDEN
StripDebugDeclare
:
public
ModulePass
{
public:
static
char
ID
;
// Pass identification, replacement for typeid
explicit
StripDebugDeclare
()
:
ModulePass
(
&
ID
)
{}
virtual
bool
runOnModule
(
Module
&
M
);
virtual
void
getAnalysisUsage
(
AnalysisUsage
&
AU
)
const
{
AU
.
setPreservesAll
();
}
};
}
}
char
StripSymbols
::
ID
=
0
;
char
StripSymbols
::
ID
=
0
;
...
@@ -78,6 +91,14 @@ ModulePass *llvm::createStripNonDebugSymbolsPass() {
...
@@ -78,6 +91,14 @@ ModulePass *llvm::createStripNonDebugSymbolsPass() {
return
new
StripNonDebugSymbols
();
return
new
StripNonDebugSymbols
();
}
}
char
StripDebugDeclare
::
ID
=
0
;
static
RegisterPass
<
StripDebugDeclare
>
Z
(
"strip-debug-declare"
,
"Strip all llvm.dbg.declare intrinsics"
);
ModulePass
*
llvm
::
createStripDebugDeclarePass
()
{
return
new
StripDebugDeclare
();
}
/// OnlyUsedBy - Return true if V is only used by Usr.
/// OnlyUsedBy - Return true if V is only used by Usr.
static
bool
OnlyUsedBy
(
Value
*
V
,
Value
*
Usr
)
{
static
bool
OnlyUsedBy
(
Value
*
V
,
Value
*
Usr
)
{
for
(
Value
::
use_iterator
I
=
V
->
use_begin
(),
E
=
V
->
use_end
();
I
!=
E
;
++
I
)
{
for
(
Value
::
use_iterator
I
=
V
->
use_begin
(),
E
=
V
->
use_end
();
I
!=
E
;
++
I
)
{
...
@@ -343,3 +364,44 @@ bool StripSymbols::runOnModule(Module &M) {
...
@@ -343,3 +364,44 @@ bool StripSymbols::runOnModule(Module &M) {
bool
StripNonDebugSymbols
::
runOnModule
(
Module
&
M
)
{
bool
StripNonDebugSymbols
::
runOnModule
(
Module
&
M
)
{
return
StripSymbolNames
(
M
,
true
);
return
StripSymbolNames
(
M
,
true
);
}
}
bool
StripDebugDeclare
::
runOnModule
(
Module
&
M
)
{
Function
*
Declare
=
M
.
getFunction
(
"llvm.dbg.declare"
);
if
(
!
Declare
)
return
false
;
std
::
vector
<
Constant
*>
DeadConstants
;
while
(
!
Declare
->
use_empty
())
{
CallInst
*
CI
=
cast
<
CallInst
>
(
Declare
->
use_back
());
Value
*
Arg1
=
CI
->
getOperand
(
1
);
Value
*
Arg2
=
CI
->
getOperand
(
2
);
assert
(
CI
->
use_empty
()
&&
"llvm.dbg intrinsic should have void result"
);
CI
->
eraseFromParent
();
if
(
Arg1
->
use_empty
())
{
if
(
Constant
*
C
=
dyn_cast
<
Constant
>
(
Arg1
))
DeadConstants
.
push_back
(
C
);
else
RecursivelyDeleteTriviallyDeadInstructions
(
Arg1
,
NULL
);
}
if
(
Arg2
->
use_empty
())
if
(
Constant
*
C
=
dyn_cast
<
Constant
>
(
Arg2
))
DeadConstants
.
push_back
(
C
);
}
Declare
->
eraseFromParent
();
while
(
!
DeadConstants
.
empty
())
{
Constant
*
C
=
DeadConstants
.
back
();
DeadConstants
.
pop_back
();
if
(
GlobalVariable
*
GV
=
dyn_cast
<
GlobalVariable
>
(
C
))
{
if
(
GV
->
hasLocalLinkage
())
RemoveDeadConstant
(
GV
);
}
else
RemoveDeadConstant
(
C
);
}
return
true
;
}
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