<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146847>146847</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][OpenMP][debug] Build failure with duplicate variable mapping
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
abidh
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
abidh
</td>
</tr>
</table>
<pre>
Please see the following program
```
PROGRAM test
implicit none
integer i
type :: t1
integer :: i1
end type t1
type(t1), dimension(10) :: v2
call fn()
CONTAINS
subroutine fn()
!$omp target map(alloc: v2(:))
v2(5)%i1 = 5
!$omp end target
end subroutine
end program test
```
When compiled with
flang -fc1 -emit-llvm -debug-info-kind=standalone -fopenmp
it fails with the following error:
```
conflicting debug info for argument
#dbg_declare(ptr %1, !41, !DIExpression(), !40)
!39 = !DILocalVariable(name: "v2", arg: 2, scope: !35, file: !4, line: 22, type: !9)
!41 = !DILocalVariable(name: "v2", arg: 2, scope: !35, file: !4, line: 23, type: !9)
error: failed to create the LLVM module
```
The reason seems to be that variable v2 is mapped twice and get 2 DeclareOp (and 2 local variables) in the outlined function for target region. This eventually maps to same location and cause this verification failure.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE1v4zYQ_TX0ZWBDoiRbPujgrJtigWQTbIPtsaDEkTwtRQok5TT_vhhKTra7PRcQIPLxzefjUIVAg0VsRHUnpFQt6YuQUlTnjZrjxfkmQZvW6bfm2aAKCAER4gWhd8a4V7IDTN4NXo0iO_G3z9YvOz1_ffr16-kRIoYoshMAjZOhjiJYZ3FBbMQBPVDaxbcJQRQnUZwg5gn6oKw4LThavdBXHq-FrGMu5FHIT6BpRBvIWSHrPBPyeLO_ysTvlDHQ8ykbLJEAIK0-PX15OX3-8tuyC3Pr3RzJ4o98IXMhSzdOEJUfMMKoJiFrZYzr1lCy5rCc0ndBloMqwRXlIIozVD_5TBUmv-8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