Skip to content

Commit 5a43b4d

Browse files
Merge pull request #42116 from aschwaighofer/swift_llvm_merge_funcs_objc_msgSend
LLVMMergeFunctions: Must not merge function calls to `objc_sendMsg$...`
2 parents 0ded798 + 7e298df commit 5a43b4d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/LLVMPasses/LLVMMergeFunctions.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,16 @@ static bool isCalleeOperand(const CallInst *CI, unsigned opIdx) {
120120
static bool canParameterizeCallOperand(const CallInst *CI, unsigned opIdx) {
121121
if (CI->isInlineAsm())
122122
return false;
123-
if (Function *Callee = CI->getCalledFunction()) {
123+
124+
Function *Callee = CI->getCalledOperand() ?
125+
dyn_cast_or_null<Function>(CI->getCalledOperand()->stripPointerCasts()) :
126+
nullptr;
127+
if (Callee) {
124128
if (Callee->isIntrinsic())
125129
return false;
130+
// objc_msgSend stubs must be called, and can't have their address taken.
131+
if (Callee->getName().startswith("objc_msgSend$"))
132+
return false;
126133
}
127134
if (isCalleeOperand(CI, opIdx) &&
128135
CI->getOperandBundle(LLVMContext::OB_ptrauth).hasValue()) {

0 commit comments

Comments
 (0)