-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[IR] Remove some uses of StructType::setBody. NFC. #113685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It is simple to create the struct body up front, now that we have transitioned to opaque pointers.
|
@llvm/pr-subscribers-coroutines @llvm/pr-subscribers-backend-x86 Author: Jay Foad (jayfoad) ChangesIt is simple to create the struct body up front, now that we have Full diff: https://github.com/llvm/llvm-project/pull/113685.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
index 232e5e2bb886df..f8ab44124b3ae8 100644
--- a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
+++ b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
@@ -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");
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index bc9fd801f94b22..6f697ceea6034f 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -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), // EHRegistrationNode *Next
PointerType::getUnqual(Context) // EXCEPTION_DISPOSITION (*Handler)(...)
};
- EHLinkRegistrationTy->setBody(FieldTys, false);
+ EHLinkRegistrationTy = StructType::create(FieldTys, "EHRegistrationNode");
return EHLinkRegistrationTy;
}
diff --git a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
index a3674306f3e10e..6d9012b881b8c3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
@@ -123,11 +123,10 @@ 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 =
|
|
@llvm/pr-subscribers-llvm-transforms Author: Jay Foad (jayfoad) ChangesIt is simple to create the struct body up front, now that we have Full diff: https://github.com/llvm/llvm-project/pull/113685.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
index 232e5e2bb886df..f8ab44124b3ae8 100644
--- a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
+++ b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
@@ -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");
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index bc9fd801f94b22..6f697ceea6034f 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -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), // EHRegistrationNode *Next
PointerType::getUnqual(Context) // EXCEPTION_DISPOSITION (*Handler)(...)
};
- EHLinkRegistrationTy->setBody(FieldTys, false);
+ EHLinkRegistrationTy = StructType::create(FieldTys, "EHRegistrationNode");
return EHLinkRegistrationTy;
}
diff --git a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
index a3674306f3e10e..6d9012b881b8c3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
@@ -123,11 +123,10 @@ 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 =
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
It is simple to create the struct body up front, now that we have transitioned to opaque pointers.
It is simple to create the struct body up front, now that we have
transitioned to opaque pointers.