[llvm] [InstCombine] Combine ptrauth intrin. callee into same-key bundle. (PR #94707)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 06:49:28 PDT 2024


================
@@ -3665,6 +3665,78 @@ static IntrinsicInst *findInitTrampoline(Value *Callee) {
   return nullptr;
 }
 
+Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) {
+  Value *Callee = Call.getCalledOperand();
+  auto *IPC = dyn_cast<IntToPtrInst>(Callee);
+  if (!IPC || !IPC->isNoopCast(DL))
+    return nullptr;
+
+  IntrinsicInst *II = dyn_cast<IntrinsicInst>(IPC->getOperand(0));
+  if (!II)
+    return nullptr;
+
----------------
kovdan01 wrote:

I'd probably add smth like this here to return early:

```
  Intrinsic::ID IIID = II->getIntrinsicID();
  if (IIID != Intrinsic::ptrauth_resign && IIID != Intrinsic::ptrauth_sign)
    return nullptr;
```

In switch below, you can use smth like `llvm_unreachable` for default label.

https://github.com/llvm/llvm-project/pull/94707


More information about the llvm-commits mailing list