@@ -350,15 +350,7 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
350
350
ConstantInt::get (Type::getInt32Ty (Cond->getContext ()), i),
351
351
" " , SI);
352
352
}
353
- #if JL_LLVM_VERSION >= 170000
354
353
assert (FalseElem->getType () == TrueElem->getType ());
355
- #else
356
- if (FalseElem->getType () != TrueElem->getType ()) {
357
- // Shouldn't get here when using opaque pointers, so the new BitCastInst is fine
358
- assert (FalseElem->getContext ().supportsTypedPointers ());
359
- FalseElem = new BitCastInst (FalseElem, TrueElem->getType (), " " , SI);
360
- }
361
- #endif
362
354
SelectInst *SelectBase = SelectInst::Create (Cond, TrueElem, FalseElem, " gclift" , SI);
363
355
int Number = ++S.MaxPtrNumber ;
364
356
S.AllPtrNumbering [SelectBase] = Number;
@@ -427,33 +419,7 @@ void LateLowerGCFrame::LiftPhi(State &S, PHINode *Phi) {
427
419
BaseElem = Base;
428
420
else
429
421
BaseElem = IncomingBases[i];
430
- #if JL_LLVM_VERSION >= 170000
431
422
assert (BaseElem->getType () == T_prjlvalue);
432
- #else
433
- if (BaseElem->getType () != T_prjlvalue) {
434
- // Shouldn't get here when using opaque pointers, so the new BitCastInst is fine
435
- assert (BaseElem->getContext ().supportsTypedPointers ());
436
- auto &remap = CastedRoots[i][BaseElem];
437
- if (!remap) {
438
- if (auto constant = dyn_cast<Constant>(BaseElem)) {
439
- remap = ConstantExpr::getBitCast (constant, T_prjlvalue, " " );
440
- } else {
441
- Instruction *InsertBefore;
442
- if (auto arg = dyn_cast<Argument>(BaseElem)) {
443
- InsertBefore = &*arg->getParent ()->getEntryBlock ().getFirstInsertionPt ();
444
- } else {
445
- assert (isa<Instruction>(BaseElem) && " Unknown value type detected!" );
446
- InsertBefore = cast<Instruction>(BaseElem)->getNextNonDebugInstruction ();
447
- }
448
- while (isa<PHINode>(InsertBefore)) {
449
- InsertBefore = InsertBefore->getNextNonDebugInstruction ();
450
- }
451
- remap = new BitCastInst (BaseElem, T_prjlvalue, " " , InsertBefore);
452
- }
453
- }
454
- BaseElem = remap;
455
- }
456
- #endif
457
423
lift->addIncoming (BaseElem, IncomingBB);
458
424
}
459
425
}
@@ -1528,14 +1494,11 @@ SmallVector<Value*, 0> ExtractTrackedValues(Value *Src, Type *STy, bool isptr, I
1528
1494
return Ptrs;
1529
1495
}
1530
1496
1531
- unsigned TrackWithShadow (Value *Src, Type *STy, bool isptr, Value *Dst, Type *DTy, IRBuilder<> &irbuilder) {
1497
+ unsigned TrackWithShadow (Value *Src, Type *STy, bool isptr, Value *Dst, IRBuilder<> &irbuilder) {
1532
1498
auto Ptrs = ExtractTrackedValues (Src, STy, isptr, irbuilder);
1533
1499
for (unsigned i = 0 ; i < Ptrs.size (); ++i) {
1534
- Value *Elem = Ptrs[i];// Dst has type `[n x {}*]*`
1535
- Value *Slot = irbuilder.CreateConstInBoundsGEP2_32 (DTy, Dst, 0 , i);
1536
- #if JL_LLVM_VERSION < 170000
1537
- assert (cast<PointerType>(Dst->getType ())->isOpaqueOrPointeeTypeMatches (DTy));
1538
- #endif
1500
+ Value *Elem = Ptrs[i];
1501
+ Value *Slot = irbuilder.CreateConstInBoundsGEP1_32 (irbuilder.getInt8Ty (), Dst, i * sizeof (void *));
1539
1502
StoreInst *shadowStore = irbuilder.CreateAlignedStore (Elem, Slot, Align (sizeof (void *)));
1540
1503
shadowStore->setOrdering (AtomicOrdering::NotAtomic);
1541
1504
// TODO: shadowStore->setMetadata(LLVMContext::MD_tbaa, tbaa_gcframe);
@@ -2133,7 +2096,7 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S, bool *CFGModified) {
2133
2096
// the type tag. (Note that if the size is not a constant, it will call
2134
2097
// gc_alloc_obj, and will redundantly set the tag.)
2135
2098
auto allocBytesIntrinsic = getOrDeclare (jl_intrinsics::GCAllocBytes);
2136
- auto ptls = get_current_ptls_from_task (builder, T_size, CI->getArgOperand (0 ), tbaa_gcframe);
2099
+ auto ptls = get_current_ptls_from_task (builder, CI->getArgOperand (0 ), tbaa_gcframe);
2137
2100
auto newI = builder.CreateCall (
2138
2101
allocBytesIntrinsic,
2139
2102
{
@@ -2319,15 +2282,7 @@ void LateLowerGCFrame::PlaceGCFrameStore(State &S, unsigned R, unsigned MinColor
2319
2282
// Pointee types don't have semantics, so the optimizer is
2320
2283
// free to rewrite them if convenient. We need to change
2321
2284
// it back here for the store.
2322
- #if JL_LLVM_VERSION >= 170000
2323
2285
assert (Val->getType () == T_prjlvalue);
2324
- #else
2325
- if (Val->getType () != T_prjlvalue) {
2326
- // Shouldn't get here when using opaque pointers, so the new BitCastInst is fine
2327
- assert (Val->getContext ().supportsTypedPointers ());
2328
- Val = new BitCastInst (Val, T_prjlvalue, " " , InsertBefore);
2329
- }
2330
- #endif
2331
2286
new StoreInst (Val, slotAddress, InsertBefore);
2332
2287
}
2333
2288
@@ -2407,18 +2362,7 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(SmallVectorImpl<int> &Colors, St
2407
2362
for (CallInst *II : ToDelete) {
2408
2363
II->eraseFromParent ();
2409
2364
}
2410
- #if JL_LLVM_VERSION >= 170000
2411
2365
assert (slotAddress->getType () == AI->getType ());
2412
- #else
2413
- if (slotAddress->getType () != AI->getType ()) {
2414
- // If we're replacing an ArrayAlloca, the pointer element type may need to be fixed up
2415
- // Shouldn't get here when using opaque pointers, so the new BitCastInst is fine
2416
- assert (slotAddress->getContext ().supportsTypedPointers ());
2417
- auto BCI = new BitCastInst (slotAddress, AI->getType ());
2418
- BCI->insertAfter (slotAddress);
2419
- slotAddress = BCI;
2420
- }
2421
- #endif
2422
2366
AI->replaceAllUsesWith (slotAddress);
2423
2367
AI->eraseFromParent ();
2424
2368
AI = NULL ;
@@ -2443,15 +2387,7 @@ void LateLowerGCFrame::PlaceRootsAndUpdateCalls(SmallVectorImpl<int> &Colors, St
2443
2387
slotAddress->insertAfter (gcframe);
2444
2388
auto ValExpr = std::make_pair (Base, isa<PointerType>(Base->getType ()) ? -1 : i);
2445
2389
auto Elem = MaybeExtractScalar (S, ValExpr, SI);
2446
- #if JL_LLVM_VERSION >= 170000
2447
2390
assert (Elem->getType () == T_prjlvalue);
2448
- #else
2449
- if (Elem->getType () != T_prjlvalue) {
2450
- // Shouldn't get here when using opaque pointers, so the new BitCastInst is fine
2451
- assert (Elem->getContext ().supportsTypedPointers ());
2452
- Elem = new BitCastInst (Elem, T_prjlvalue, " " , SI);
2453
- }
2454
- #endif
2455
2391
// auto Idxs = ArrayRef<unsigned>(Tracked[i]);
2456
2392
// Value *Elem = ExtractScalar(Base, true, Idxs, SI);
2457
2393
Value *shadowStore = new StoreInst (Elem, slotAddress, SI);
0 commit comments