Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Qt Project
clang
llvm-project
Commits
32e813e4
Commit
32e813e4
authored
Aug 13, 2004
by
John Criswell
Browse files
Merged from mainline.
llvm-svn: 15723
parent
b6a9b36e
Changes
2
Hide whitespace changes
Inline
Side-by-side
llvm/lib/Transforms/Utils/CodeExtractor.cpp
View file @
32e813e4
...
...
@@ -622,7 +622,7 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
Function
*
oldFunction
=
header
->
getParent
();
// This takes place of the original loop
BasicBlock
*
codeReplacer
=
new
BasicBlock
(
"codeRepl"
,
oldFunction
);
BasicBlock
*
codeReplacer
=
new
BasicBlock
(
"codeRepl"
,
oldFunction
,
header
);
// The new function needs a root node because other nodes can branch to the
// head of the region, but the entry node of a function cannot have preds.
...
...
@@ -657,10 +657,19 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
succ_end
(
codeReplacer
));
for
(
unsigned
i
=
0
,
e
=
Succs
.
size
();
i
!=
e
;
++
i
)
for
(
BasicBlock
::
iterator
I
=
Succs
[
i
]
->
begin
();
PHINode
*
PN
=
dyn_cast
<
PHINode
>
(
I
);
++
I
)
PHINode
*
PN
=
dyn_cast
<
PHINode
>
(
I
);
++
I
)
{
std
::
set
<
BasicBlock
*>
ProcessedPreds
;
for
(
unsigned
i
=
0
,
e
=
PN
->
getNumIncomingValues
();
i
!=
e
;
++
i
)
if
(
BlocksToExtract
.
count
(
PN
->
getIncomingBlock
(
i
)))
PN
->
setIncomingBlock
(
i
,
codeReplacer
);
if
(
ProcessedPreds
.
insert
(
PN
->
getIncomingBlock
(
i
)).
second
)
PN
->
setIncomingBlock
(
i
,
codeReplacer
);
else
{
// There were multiple entries in the PHI for this block, now there
// is only one, so remove the duplicated entries.
PN
->
removeIncomingValue
(
i
,
false
);
--
i
;
--
e
;
}
}
//std::cerr << "NEW FUNCTION: " << *newFunction;
// verifyFunction(*newFunction);
...
...
llvm/lib/Transforms/Utils/ValueMapper.cpp
View file @
32e813e4
...
...
@@ -81,6 +81,11 @@ Value *llvm::MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
for
(
unsigned
i
=
1
,
e
=
CE
->
getNumOperands
();
i
!=
e
;
++
i
)
Idx
.
push_back
(
cast
<
Constant
>
(
MapValue
(
CE
->
getOperand
(
i
),
VM
)));
return
VMSlot
=
ConstantExpr
::
getGetElementPtr
(
MV
,
Idx
);
}
else
if
(
CE
->
getOpcode
()
==
Instruction
::
Select
)
{
Constant
*
MV1
=
cast
<
Constant
>
(
MapValue
(
CE
->
getOperand
(
0
),
VM
));
Constant
*
MV2
=
cast
<
Constant
>
(
MapValue
(
CE
->
getOperand
(
1
),
VM
));
Constant
*
MV3
=
cast
<
Constant
>
(
MapValue
(
CE
->
getOperand
(
2
),
VM
));
return
VMSlot
=
ConstantExpr
::
getSelect
(
MV1
,
MV2
,
MV3
);
}
else
{
assert
(
CE
->
getNumOperands
()
==
2
&&
"Must be binary operator?"
);
Constant
*
MV1
=
cast
<
Constant
>
(
MapValue
(
CE
->
getOperand
(
0
),
VM
));
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment