Jeroen Dobbelaere 90a6bb30fa [remangleIntrinsicFunction] Detect and resolve name clash
It is possible that the remangled name for an intrinsic already exists with a different (and wrong) prototype within the module.
As the bitcode reader keeps both versions of all remangled intrinsics around for a longer time, this can result in a
crash, as can be seen in https://bugs.llvm.org/show_bug.cgi?id=50923

This patch makes 'remangleIntrinsicFunction' aware of this situation. When it is detected, it moves the version with the wrong prototype to a different name. That version will be removed anyway once the module is completely loaded.

With thanks to @asbirlea for reporting this issue when trying out an lto build with the full restrict patches, and @efriedma for suggesting a sane resolution mechanism.

Reviewed By: apilipenko

Differential Revision: https://reviews.llvm.org/D105118
2021-07-13 11:21:12 +02:00

28 lines
1.1 KiB
LLVM

# RUN: llvm-as %S/Inputs/remangle1.ll -o %t.remangle1.bc
# RUN: llvm-as %S/Inputs/remangle2.ll -o %t.remangle2.bc
# RUN: llvm-link %t.remangle1.bc %t.remangle2.bc -o %t.remangle.linked.bc
# RUN: llvm-dis %t.remangle.linked.bc -o - | FileCheck %s
; CHECK-DAG: %fum.1 = type { %aab.0, i8, [7 x i8] }
; CHECK-DAG: %aab.0 = type { %aba }
; CHECK-DAG: %aba = type { [8 x i8] }
; CHECK-DAG: %fum.1.2 = type { %abb, i8, [7 x i8] }
; CHECK-DAG: %abb = type { %abc }
; CHECK-DAG: %abc = type { [4 x i8] }
; CHECK-LABEL: define void @foo1(%fum.1** %a, %fum.1.2** %b) {
; CHECK-NEXT: %b.copy = call %fum.1.2** @llvm.ssa.copy.p0p0s_fum.1.2s(%fum.1.2** %b)
; CHECK-NEXT: %a.copy = call %fum.1** @llvm.ssa.copy.p0p0s_fum.1s(%fum.1** %a)
; CHECK-NEXT: ret void
; CHECK: declare %fum.1.2** @llvm.ssa.copy.p0p0s_fum.1.2s(%fum.1.2** returned)
; CHECK: declare %fum.1** @llvm.ssa.copy.p0p0s_fum.1s(%fum.1** returned)
; CHECK-LABEL: define void @foo2(%fum.1.2** %b, %fum.1** %a) {
; CHECK-NEXT: %a.copy = call %fum.1** @llvm.ssa.copy.p0p0s_fum.1s(%fum.1** %a)
; CHECK-NEXT: %b.copy = call %fum.1.2** @llvm.ssa.copy.p0p0s_fum.1.2s(%fum.1.2** %b)
; CHECK-NEXT: ret void