Skip to content

Commit 66ddf60

Browse files
author
Nuri Amari
committed
Run ObjCContractPass in Distributed Thin-LTO Pipeline
Prior to this patch, when using -fthinlto-index= the ObjCARCContractPass isn't run prior to CodeGen, and instruction selection fails on IR containing arc intrinstics.
1 parent c00e012 commit 66ddf60

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,9 @@ static void runThinLTOBackend(
12891289
};
12901290
break;
12911291
default:
1292+
Conf.PreCodeGenPassesHook = [](legacy::PassManager &Pm) {
1293+
Pm.add(createObjCARCContractPass());
1294+
};
12921295
Conf.CGFileType = getCodeGenFileType(Action);
12931296
break;
12941297
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: opt -thinlto-bc -o %t.o %s
2+
3+
; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
4+
; RUN: -o %t2.index \
5+
; RUN: -r=%t.o,_use_arc,px
6+
7+
; RUN: %clang_cc1 -triple x86_64-apple-darwin \
8+
; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \
9+
; RUN: -o %t.native.o -x ir %t.o
10+
11+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
12+
target triple = "x86_64-apple-darwin"
13+
14+
define void @use_arc(ptr %a, ptr %b) {
15+
call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind
16+
ret void
17+
}
18+
19+
declare void @llvm.objc.clang.arc.use(...) nounwind

0 commit comments

Comments
 (0)