<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64907>64907</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [ORC] Missing definition for inlining function after optimizations in IRTRansformLayer 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          lucasreis1
      </td>
    </tr>
</table>

<pre>
    Faced this issue while dealing with an optimization pipeline that focuses on inlining. 

If a function has the `always_inline` attribute and `linkonce_odr` linkage, it is registered as a symbol for materialization by the MU. After optimization, passes discard the definition in IR and no symbol is generated. The symbol request is then left dangling by the MU.

Quick module to reproduce:
```
; ModuleID = 'main.cpp'
source_filename = "main.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

$_Z7testFoov = comdat any

@.str = private unnamed_addr constant [8 x i8] c"hello!\0A\00", align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @_Z7testFoov()
 ret i32 0
}

; Function Attrs: alwaysinline mustprogress uwtable
define linkonce_odr dso_local void @_Z7testFoov() #1 comdat {
 %1 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)"}
```

I have not done in-depth testing, but I'm pretty sure any standard optimization pipeline done by opt would trigger this, as the function is marked as `always_inline`. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV0tv67wR_TX0ZiBDop5eeJFHAwT4Ltreft10E9DkSGJDkSpJxfb36wtSkh_35jboug0CmQLPGc4cjcgj5pzsNOKelI-kfN6wyffG7tXEmbMoXbY5GHHevzCOAnwvHUjnJoRjLxWCQKak7uAofQ9Mgxm9HOQfzEujYZQjKqkRfM88tIZPDh0YDVIrqaXutkDSZ5I-zNfXFhi0k-aR3DMHvkcgVcrUkZ3dW2QhqVJg3lt5mDwC0yIglNTvRnN8M8IGQLhnHRL6BNKDdGCxk86jRQHMAQN3Hg5GQWssDMyjlUytWR_Ocd1vf9_CQ-vR3tUUIo7MhTqEdJxZEcECW6llpEsNr99jXtqsy0gHHWq0zKPYwu89rhMW_zWhixn6HjUobD0Iprso6jWTW5n-Okn-DoMRk0LwBiyO1oiJI8kXBKnS5X--zR_hW4S_PgPJn4HQemBSb_k4ElrPIGcmy_GtlQo1G3DB0SuOzjjPbIchR88UO5vJr0hMBpI_YDLSOiX5Q07jJdxm97dhVBXxksh10DaBlNEm0U0YVCunKpK_ZbT5cX1v5aguWZ6a6q0qkkm_a3PUiZJ6OiWdni6s5UqLt3_UHp1_MeYjkrkZBPPA9PkOWKRb521EjFZ-MI8w6aCLeG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