|
1 | 1 | // This file is a part of Julia. License is MIT: https://julialang.org/license |
2 | 2 |
|
3 | 3 | #include "llvm-gc-interface-passes.h" |
| 4 | +#include "llvm/IR/Intrinsics.h" |
4 | 5 |
|
5 | 6 | #define DEBUG_TYPE "late_lower_gcroot" |
6 | 7 |
|
@@ -204,7 +205,17 @@ static std::pair<Value*,int> FindBaseValue(const State &S, Value *V, bool UseCac |
204 | 205 | } |
205 | 206 | // In general a load terminates a walk |
206 | 207 | break; |
207 | | - } |
| 208 | + } else if (II->getIntrinsicID() == Intrinsic::vector_extract) { |
| 209 | + if (auto VTy = dyn_cast<VectorType>(II->getType())) { |
| 210 | + if (hasLoadedTy(VTy->getElementType())) { |
| 211 | + // TODO: For now, only support constant index. |
| 212 | + auto IdxOp = cast<ConstantInt>(II->getOperand(1)); |
| 213 | + fld_idx = IdxOp->getLimitedValue(INT_MAX); |
| 214 | + CurrentV = II->getOperand(0); |
| 215 | + } |
| 216 | + } |
| 217 | + } else |
| 218 | + break; |
208 | 219 | } |
209 | 220 | else if (auto CI = dyn_cast<CallInst>(CurrentV)) { |
210 | 221 | auto callee = CI->getCalledFunction(); |
@@ -518,6 +529,16 @@ SmallVector<int, 0> LateLowerGCFrame::NumberAllBase(State &S, Value *CurrentV) { |
518 | 529 | Numbers = NumberAll(S, IEI->getOperand(0)); |
519 | 530 | int ElNumber = Number(S, IEI->getOperand(1)); |
520 | 531 | Numbers[idx] = ElNumber; |
| 532 | + } else if (auto * VII = dyn_cast<IntrinsicInst>(CurrentV)) { |
| 533 | + if (VII->getIntrinsicID() == Intrinsic::vector_insert) { |
| 534 | + Numbers = NumberAll(S, VII->getOperand(0)); |
| 535 | + int first_idx = cast<ConstantInt>(VII->getOperand(2))->getZExtValue(); |
| 536 | + SmallVector<int, 0> Numbers2 = NumberAll(S, VII->getOperand(1)); |
| 537 | + for (unsigned i = 0; i < Numbers2.size(); ++i) { |
| 538 | + dbgs() << Numbers2[i] << " "<< first_idx + i << "\n"; |
| 539 | + Numbers[first_idx + i] = Numbers2[i]; |
| 540 | + } |
| 541 | + } |
521 | 542 | } else if (auto *IVI = dyn_cast<InsertValueInst>(CurrentV)) { |
522 | 543 | Numbers = NumberAll(S, IVI->getAggregateOperand()); |
523 | 544 | auto Tracked = TrackCompositeType(IVI->getType()); |
@@ -1143,6 +1164,10 @@ State LateLowerGCFrame::LocalScan(Function &F) { |
1143 | 1164 | } |
1144 | 1165 | } |
1145 | 1166 | } |
| 1167 | + if (II->getIntrinsicID() == Intrinsic::vector_extract || II->getIntrinsicID() == Intrinsic::vector_insert) { |
| 1168 | + // These are not real defs |
| 1169 | + continue; |
| 1170 | + } |
1146 | 1171 | } |
1147 | 1172 | auto callee = CI->getCalledFunction(); |
1148 | 1173 | if (callee && callee == typeof_func) { |
|
0 commit comments