<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62468>62468</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion failed: (checkVariableImport(Index, ImportLists, ExportLists)), function ComputeCrossModuleImport
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld:MachO,
lld:ELF,
LTO
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
int3
</td>
</tr>
</table>
<pre>
I ran into this assertion error in LTO code while working on `ld64.lld`. I was able to repro it on `ld.lld` too, so it seems like a general LTO issue. I am not super familiar with how LTO's FunctionImport is supposed to work, so I would appreciate help here. I've gotten it down to a simple repro (https://github.com/llvm/llvm-project/files/11362003/assert.repro.tar.gz) of two files:
#### foo.ll
```
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
@qux = linkonce_odr hidden global i32 0
define linkonce_odr hidden void @foo() {
call void @bar()
ret void
}
declare hidden void @bar()
```
#### bar.ll
```
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
@qux = linkonce_odr hidden global i32 0
define hidden void @bar() {
%1 = load i32, i32* @qux, align 8
ret void
}
```
`@qux` is marked read-only, and it is only present in the ExportLists but not the ImportLists, triggering the assertion. Disabling the assertion doesn't seem to result in any runtime issues though. Perhaps the assertion itself isn't correct? cc @eleviant and @teresajohnson -- it was introduced in https://reviews.llvm.org/D70128.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVcFu4zYQ_Rr6MrAgUbIsH3TwxisgwC62QIteC0ocS7OhOCpJxZt-fUHJcRM3RdFjASJCZsj3hs8zj8p76i1iLXafxO60UXMY2NVkQ75pWb_Uj-CUBbKBIQzkQXmPLhBbQOfYAVn48ss36FgjXAYyCBd2T2R7YAuiTI0ui8QYLco0gUe4KA-qNQiBweHkGCjcdl73QWAW8gH8kvSIowdDTwgKerTolFkoyfsZI6YawXIAP0_o4KxGMqQ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