Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LLVM bpEVL
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Lorenzo Albano
LLVM bpEVL
Commits
23289c38
Commit
23289c38
authored
14 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
fix PR9015, a crash linking recursive metadata.
llvm-svn: 124099
parent
d8d75434
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
llvm/lib/Transforms/Utils/ValueMapper.cpp
+11
-6
11 additions, 6 deletions
llvm/lib/Transforms/Utils/ValueMapper.cpp
llvm/test/Linker/linkmdnode.ll
+1
-0
1 addition, 0 deletions
llvm/test/Linker/linkmdnode.ll
llvm/test/Linker/linkmdnode2.ll
+10
-0
10 additions, 0 deletions
llvm/test/Linker/linkmdnode2.ll
with
22 additions
and
6 deletions
llvm/lib/Transforms/Utils/ValueMapper.cpp
+
11
−
6
View file @
23289c38
...
...
@@ -38,15 +38,16 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM,
if
(
!
MD
->
isFunctionLocal
()
&&
(
Flags
&
RF_NoModuleLevelChanges
))
return
VM
[
V
]
=
const_cast
<
Value
*>
(
V
);
// Create a dummy node in case we have a metadata cycle.
MDNode
*
Dummy
=
MDNode
::
getTemporary
(
V
->
getContext
(),
0
,
0
);
VM
[
V
]
=
Dummy
;
// Check all operands to see if any need to be remapped.
for
(
unsigned
i
=
0
,
e
=
MD
->
getNumOperands
();
i
!=
e
;
++
i
)
{
Value
*
OP
=
MD
->
getOperand
(
i
);
if
(
OP
==
0
||
MapValue
(
OP
,
VM
,
Flags
)
==
OP
)
continue
;
// Ok, at least one operand needs remapping. Create a dummy node in case
// we have a metadata cycle.
MDNode
*
Dummy
=
MDNode
::
getTemporary
(
V
->
getContext
(),
0
,
0
);
VM
[
V
]
=
Dummy
;
// Ok, at least one operand needs remapping.
SmallVector
<
Value
*
,
4
>
Elts
;
Elts
.
reserve
(
MD
->
getNumOperands
());
for
(
i
=
0
;
i
!=
e
;
++
i
)
{
...
...
@@ -55,12 +56,16 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM,
}
MDNode
*
NewMD
=
MDNode
::
get
(
V
->
getContext
(),
Elts
.
data
(),
Elts
.
size
());
Dummy
->
replaceAllUsesWith
(
NewMD
);
VM
[
V
]
=
NewMD
;
MDNode
::
deleteTemporary
(
Dummy
);
return
VM
[
V
]
=
NewMD
;
return
NewMD
;
}
VM
[
V
]
=
const_cast
<
Value
*>
(
V
);
MDNode
::
deleteTemporary
(
Dummy
);
// No operands needed remapping. Use an identity mapping.
return
VM
[
V
]
=
const_cast
<
Value
*>
(
V
);
return
const_cast
<
Value
*>
(
V
);
}
// Okay, this either must be a constant (which may or may not be mappable) or
...
...
This diff is collapsed.
Click to expand it.
llvm/test/Linker/linkmdnode.ll
+
1
−
0
View file @
23289c38
...
...
@@ -10,3 +10,4 @@ define void @foo() {
%x
=
call
i8
@llvm.something
(
metadata
!21
)
ret
void
}
This diff is collapsed.
Click to expand it.
llvm/test/Linker/linkmdnode2.ll
+
10
−
0
View file @
23289c38
...
...
@@ -10,3 +10,13 @@ define void @foo1() {
%x
=
call
i8
@llvm.something
(
metadata
!22
)
ret
void
}
; PR9015
define
void
@test
()
{
ret
void
,
!abc
!0
}
!0
=
metadata
!{
metadata
!0
,
i32
42
}
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