Commit bfcf9799 authored by Jon Chesterfield's avatar Jon Chesterfield
Browse files

Revert "[openmp] Fix 51647, corrupt bitcode on amdgpu"

This reverts commit d5c049a3.
Going to re-commit it in pieces for easier application to 13
parent 6fec6552
Loading
Loading
Loading
Loading
+4 −19
Original line number Diff line number Diff line
@@ -2041,8 +2041,7 @@ bool OpenMPOpt::rewriteDeviceCodeStateMachine() {
        UndefValue::get(Int8Ty), F->getName() + ".ID");

    for (Use *U : ToBeReplacedStateMachineUses)
      U->set(ConstantExpr::getPointerBitCastOrAddrSpaceCast(
          ID, U->get()->getType()));
      U->set(ConstantExpr::getBitCast(ID, U->get()->getType()));

    ++NumOpenMPParallelRegionsReplacedInGPUStateMachine;

@@ -3456,14 +3455,10 @@ struct AAKernelInfoFunction : AAKernelInfo {
    IsWorker->setDebugLoc(DLoc);
    BranchInst::Create(StateMachineBeginBB, UserCodeEntryBB, IsWorker, InitBB);

    Module &M = *Kernel->getParent();

    // Create local storage for the work function pointer.
    const DataLayout &DL = M.getDataLayout();
    Type *VoidPtrTy = Type::getInt8PtrTy(Ctx);
    Instruction *WorkFnAI =
        new AllocaInst(VoidPtrTy, DL.getAllocaAddrSpace(), nullptr,
                       "worker.work_fn.addr", &Kernel->getEntryBlock().front());
    AllocaInst *WorkFnAI = new AllocaInst(VoidPtrTy, 0, "worker.work_fn.addr",
                                          &Kernel->getEntryBlock().front());
    WorkFnAI->setDebugLoc(DLoc);

    auto &OMPInfoCache = static_cast<OMPInformationCache &>(A.getInfoCache());
@@ -3476,23 +3471,13 @@ struct AAKernelInfoFunction : AAKernelInfo {
    Value *Ident = KernelInitCB->getArgOperand(0);
    Value *GTid = KernelInitCB;

    Module &M = *Kernel->getParent();
    FunctionCallee BarrierFn =
        OMPInfoCache.OMPBuilder.getOrCreateRuntimeFunction(
            M, OMPRTL___kmpc_barrier_simple_spmd);
    CallInst::Create(BarrierFn, {Ident, GTid}, "", StateMachineBeginBB)
        ->setDebugLoc(DLoc);

    if (WorkFnAI->getType()->getPointerAddressSpace() !=
        (unsigned int)AddressSpace::Generic) {
      WorkFnAI = new AddrSpaceCastInst(
          WorkFnAI,
          PointerType::getWithSamePointeeType(
              cast<PointerType>(WorkFnAI->getType()),
              (unsigned int)AddressSpace::Generic),
          WorkFnAI->getName() + ".generic", StateMachineBeginBB);
      WorkFnAI->setDebugLoc(DLoc);
    }

    FunctionCallee KernelParallelFn =
        OMPInfoCache.OMPBuilder.getOrCreateRuntimeFunction(
            M, OMPRTL___kmpc_kernel_parallel);
+1696 −3397

File changed.

Preview size limit exceeded, changes collapsed.

+884 −1831

File changed.

Preview size limit exceeded, changes collapsed.