Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions llvm/lib/SYCLLowerIR/LowerWGScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static constexpr char PFWI_MD[] = "parallel_for_work_item";
static cl::opt<int> Debug("sycl-lower-wg-debug", llvm::cl::Optional,
llvm::cl::Hidden,
llvm::cl::desc("Debug SYCL work group code lowering"),
llvm::cl::init(10));
llvm::cl::init(1));

namespace {
class SYCLLowerWGScopeLegacyPass : public FunctionPass {
Expand Down Expand Up @@ -375,25 +375,29 @@ using LocalsSet = SmallPtrSet<AllocaInst *, 4>;

static void copyBetweenPrivateAndShadow(Value *L, GlobalVariable *Shadow,
IRBuilder<> &Builder, bool Loc2Shadow) {
assert(isa<PointerType>(L->getType()));
Type *T = nullptr;
MaybeAlign LocAlign(0);

if (const auto *AI = dyn_cast<AllocaInst>(L)) {
T = AI->getAllocatedType();
LocAlign = MaybeAlign(AI->getAlignment());
} else {
if (cast<Argument>(L)->hasByValAttr()) {
T = cast<Argument>(L)->getParamByValType();
LocAlign = MaybeAlign(cast<Argument>(L)->getParamAlignment());
auto Arg = cast<Argument>(L);
if (Arg->hasByValAttr()) {
T = Arg->getParamByValType();
LocAlign = MaybeAlign(Arg->getParamAlignment());
} else {
Type *Ty = cast<Argument>(L)->getType();
Type *Ty = Arg->getType();
Module &M = *Shadow->getParent();
LocAlign = M.getDataLayout().getValueOrABITypeAlignment(
MaybeAlign(cast<Argument>(L)->getParamAlignment()), Ty);
T = cast<Argument>(L)->getType()->getPointerElementType();
MaybeAlign(Arg->getParamAlignment()), Ty);
T = Arg->getType()->getPointerElementType();
}
}

assert(T && "Unexpected type");

if (T->isAggregateType()) {
// TODO: we should use methods which directly return MaybeAlign once such
// are added to LLVM for AllocaInst and GlobalVariable
Expand Down