How to get objc-arc related function call in LLVM IR file (original) (raw)
i have a objective-c file
@implementation IRTest
-(id)methodb{
NSObject *obj =[[NSObject alloc] init];// for arc rules, the compiler will generate objc_autorelease for the obj
return obj;
}
@end
i compile it to llvm ir use
clang -emit-llvm -S -c -O2 -x objective-c -c IRTest.m
i got the IR
define internal ptr @"\01-[IRTest methodb]"(ptr nocapture readnone %0, ptr nocapture readnone %1) #1 {
%3 = load ptr, ptr @"OBJC_CLASSLIST_REFERENCES_$_", align 8
%4 = tail call ptr @objc_alloc_init(ptr %3)
ret ptr %4
}
then, i compile it to mach o binary, i got
mov x1, x0
ldr x0, [sp, #0x8]
str x1, [sp, #0x10]
mov x1, #0x0
bl 0x100003ed4 ; symbol stub for: objc_storeStrong
ldr x0, [sp, #0x10]
ldp x29, x30, [sp, #0x30]
add sp, sp, #0x40
b 0x100003eb0 ; symbol stub for: objc_autoreleaseReturnValue
where is the objc_storeStrong & objc_autoreleaseReturnValue call going ??
This seems like a codegen question.
I can’t comment on this from the Static Analyzer’s side.
dqjk May 20, 2024, 4:05am 3
thank you for reply, I find the problem and have resovle it.
it’s the compile args, I retrive the compile args from xcode, i can got the arc methods in ir code.