@@ -534,11 +534,21 @@ void CodeGenFunction::EmitMessageHook(llvm::CallInst *_class,
534
534
" MSHookMessageEx" );
535
535
536
536
cast<llvm::Function>(msHookMsgExFn.getCallee ())->setLinkage (llvm::Function::ExternalWeakLinkage);
537
-
538
537
llvm::Value *msHookMsgExArgs[4 ];
538
+
539
+ llvm::Value *targetValue = Builder.CreateBitCast (hook, Int8PtrTy);
540
+ if (auto &schema =
541
+ CGM.getCodeGenOpts ().PointerAuth .FunctionPointers )
542
+ {
543
+ auto authInfo = EmitPointerAuthInfo (schema, targetValue,
544
+ GlobalDecl (), QualType ());
545
+ msHookMsgExArgs[2 ] = EmitPointerAuthSign (authInfo, targetValue);
546
+ }
547
+ else
548
+ msHookMsgExArgs[2 ] = Builder.CreateBitCast (hook, Int8PtrTy);
549
+
539
550
msHookMsgExArgs[0 ] = Builder.CreateBitCast (_class, Int8PtrTy);
540
551
msHookMsgExArgs[1 ] = Builder.CreateBitCast (message, Int8PtrTy);
541
- msHookMsgExArgs[2 ] = Builder.CreateBitCast (hook, Int8PtrTy);
542
552
msHookMsgExArgs[3 ] = Builder.CreateBitCast (old, Int8PtrTy);
543
553
544
554
EmitRuntimeCallOrInvoke (msHookMsgExFn, msHookMsgExArgs);
@@ -843,7 +853,13 @@ llvm::Value* CodeGenFunction::EmitObjCOrigExpr(const ObjCOrigExpr *E) {
843
853
844
854
// Emit self, _cmd
845
855
Args.add (RValue::get (LoadObjCSelf ()), getContext ().getObjCIdType ());
846
- Args.add (RValue::get (Runtime.GetSelector (*this , OMD->getSelector ())),
856
+
857
+ // instead of re-emitting the method decl, we can just pass through the existing arg we got
858
+ VarDecl *Sel = cast<ObjCMethodDecl>(CurFuncDecl)->getCmdDecl ();
859
+ DeclRefExpr DRE (getContext (), Sel,
860
+ /* is enclosing local*/ (CurFuncDecl != CurCodeDecl),
861
+ getContext ().getObjCSelType (), VK_LValue, SourceLocation ());
862
+ Args.add (RValue::get (EmitLoadOfScalar (EmitDeclRefLValue (&DRE), SourceLocation ())),
847
863
getContext ().getObjCSelType ());
848
864
849
865
// Emit arguments
@@ -869,7 +885,13 @@ llvm::Value* CodeGenFunction::EmitObjCOrigExpr(const ObjCOrigExpr *E) {
869
885
870
886
llvm::Value *Fn = Builder.CreateAlignedLoad (VoidPtrTy, OHD->GetOrigPointer (OMD), getPointerAlign ());
871
887
llvm::Value* FnV = Builder.CreateBitCast (Fn, MSI.MessengerType );
872
- CGCallee Callee = CGCallee (CGCalleeInfo (), FnV, CGPointerAuthInfo ());
888
+
889
+ CGPointerAuthInfo pointerAuth = CGPointerAuthInfo ();
890
+ if (auto &schema =
891
+ CGM.getCodeGenOpts ().PointerAuth .FunctionPointers ) {
892
+ pointerAuth = EmitPointerAuthInfo (schema, FnV,GlobalDecl (), QualType ());
893
+ }
894
+ CGCallee Callee = CGCallee (CGCalleeInfo (), FnV, pointerAuth);
873
895
874
896
RValue rvalue = EmitCall (MSI.CallInfo , Callee, ReturnValueSlot (), Args);
875
897
0 commit comments