@@ -2050,22 +2050,34 @@ ValuePacket Packetizer::Impl::packetizeCall(CallInst *CI) {
2050
2050
auto IntrID = Intrinsic::ID (Callee->getIntrinsicID ());
2051
2051
if (IntrID == llvm::Intrinsic::lifetime_end ||
2052
2052
IntrID == llvm::Intrinsic::lifetime_start) {
2053
- auto *ptr = CI->getOperand ( 1 );
2053
+ auto *ptr = CI->getArgOperand (CI-> arg_size () - 1 );
2054
2054
if (auto *const bcast = dyn_cast<BitCastInst>(ptr)) {
2055
2055
ptr = bcast->getOperand (0 );
2056
2056
}
2057
2057
2058
2058
if (auto *const alloca = dyn_cast<AllocaInst>(ptr)) {
2059
2059
if (!needsInstantiation (Ctx, *alloca)) {
2060
- // If it's an alloca we can widen, we can just change the size
2061
- const llvm::TypeSize allocSize =
2062
- Ctx.dataLayout ()->getTypeAllocSize (alloca->getAllocatedType ());
2063
- const auto lifeSize =
2064
- allocSize.isScalable () || SimdWidth.isScalable ()
2065
- ? -1
2066
- : allocSize.getKnownMinValue () * SimdWidth.getKnownMinValue ();
2067
- CI->setOperand (
2068
- 0 , ConstantInt::get (CI->getOperand (0 )->getType (), lifeSize));
2060
+ #if LLVM_VERSION_GREATER_EQUAL(23, 0)
2061
+ const bool HaveSizeArg = false ;
2062
+ #elif LLVM_VERSION_GREATER_EQUAL(22, 0)
2063
+ // TODO Remove runtime check when we no longer need to worry about
2064
+ // older LLVM 22 snapshots.
2065
+ const bool HaveSizeArg = CI->arg_size () == 2 ;
2066
+ #else
2067
+ const bool HaveSizeArg = true ;
2068
+ #endif
2069
+ if (HaveSizeArg) {
2070
+ // If it's an alloca we can widen, we can just change the size
2071
+ const llvm::TypeSize allocSize =
2072
+ Ctx.dataLayout ()->getTypeAllocSize (alloca->getAllocatedType ());
2073
+ const auto lifeSize =
2074
+ allocSize.isScalable () || SimdWidth.isScalable ()
2075
+ ? -1
2076
+ : allocSize.getKnownMinValue () *
2077
+ SimdWidth.getKnownMinValue ();
2078
+ CI->setOperand (
2079
+ 0 , ConstantInt::get (CI->getOperand (0 )->getType (), lifeSize));
2080
+ }
2069
2081
results.push_back (CI);
2070
2082
}
2071
2083
}
0 commit comments