Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions llvm/lib/CodeGen/ShadowStackGCLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,12 @@ bool ShadowStackGCLoweringImpl::doInitialization(Module &M) {
// void *Roots[]; // Stack roots (in-place array, so we pretend).
// };

StackEntryTy = StructType::create(M.getContext(), "gc_stackentry");
PointerType *StackEntryPtrTy = PointerType::getUnqual(M.getContext());

EltTys.clear();
EltTys.push_back(PointerType::getUnqual(StackEntryTy));
EltTys.push_back(StackEntryPtrTy);
EltTys.push_back(FrameMapPtrTy);
StackEntryTy->setBody(EltTys);
PointerType *StackEntryPtrTy = PointerType::getUnqual(StackEntryTy);
StackEntryTy = StructType::create(EltTys, "gc_stackentry");

// Get the root chain if it already exists.
Head = M.getGlobalVariable("llvm_gc_root_chain");
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Target/X86/X86WinEHState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,11 @@ Type *WinEHStatePass::getEHLinkRegistrationType() {
if (EHLinkRegistrationTy)
return EHLinkRegistrationTy;
LLVMContext &Context = TheModule->getContext();
EHLinkRegistrationTy = StructType::create(Context, "EHRegistrationNode");
Type *FieldTys[] = {
PointerType::getUnqual(
EHLinkRegistrationTy->getContext()), // EHRegistrationNode *Next
PointerType::getUnqual(Context) // EXCEPTION_DISPOSITION (*Handler)(...)
PointerType::getUnqual(Context), // EHRegistrationNode *Next
PointerType::getUnqual(Context) // EXCEPTION_DISPOSITION (*Handler)(...)
};
EHLinkRegistrationTy->setBody(FieldTys, false);
EHLinkRegistrationTy = StructType::create(FieldTys, "EHRegistrationNode");
return EHLinkRegistrationTy;
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Coroutines/CoroEarly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ void Lowerer::lowerCoroNoop(IntrinsicInst *II) {
Module &M = *II->getModule();

// Create a noop.frame struct type.
StructType *FrameTy = StructType::create(C, "NoopCoro.Frame");
auto *FnTy = FunctionType::get(Type::getVoidTy(C), Builder.getPtrTy(0),
/*isVarArg=*/false);
auto *FnPtrTy = Builder.getPtrTy(0);
FrameTy->setBody({FnPtrTy, FnPtrTy});
StructType *FrameTy =
StructType::create({FnPtrTy, FnPtrTy}, "NoopCoro.Frame");

// Create a Noop function that does nothing.
Function *NoopFn =
Expand Down
22 changes: 12 additions & 10 deletions llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ class FrameTypeBuilder {
return Fields.size() - 1;
}

/// Finish the layout and set the body on the given type.
void finish(StructType *Ty);
/// Finish the layout and create the struct type with the given name.
StructType *finish(StringRef Name);

uint64_t getStructSize() const {
assert(IsFinished && "not yet finished!");
Expand Down Expand Up @@ -464,7 +464,7 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
});
}

void FrameTypeBuilder::finish(StructType *Ty) {
StructType *FrameTypeBuilder::finish(StringRef Name) {
assert(!IsFinished && "already finished!");

// Prepare the optimal-layout field array.
Expand Down Expand Up @@ -526,7 +526,7 @@ void FrameTypeBuilder::finish(StructType *Ty) {
LastOffset = Offset + F.Size;
}

Ty->setBody(FieldTypes, Packed);
StructType *Ty = StructType::create(Context, FieldTypes, Name, Packed);

#ifndef NDEBUG
// Check that the IR layout matches the offsets we expect.
Expand All @@ -538,6 +538,8 @@ void FrameTypeBuilder::finish(StructType *Ty) {
#endif

IsFinished = true;

return Ty;
}

static void cacheDIVar(FrameDataInfo &FrameData,
Expand Down Expand Up @@ -866,11 +868,6 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
bool OptimizeFrame) {
LLVMContext &C = F.getContext();
const DataLayout &DL = F.getDataLayout();
StructType *FrameTy = [&] {
SmallString<32> Name(F.getName());
Name.append(".Frame");
return StructType::create(C, Name);
}();

// We will use this value to cap the alignment of spilled values.
std::optional<Align> MaxFrameAlignment;
Expand Down Expand Up @@ -931,7 +928,12 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
FrameData.setFieldIndex(S.first, Id);
}

B.finish(FrameTy);
StructType *FrameTy = [&] {
SmallString<32> Name(F.getName());
Name.append(".Frame");
return B.finish(Name);
}();

FrameData.updateLayoutIndex(B);
Shape.FrameAlign = B.getStructAlign();
Shape.FrameSize = B.getStructSize();
Expand Down
Loading