[llvm] [IR] Remove some uses of StructType::setBody. NFC. (PR #113685)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 25 06:10:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Jay Foad (jayfoad)
<details>
<summary>Changes</summary>
It is simple to create the struct body up front, now that we have
transitioned to opaque pointers.
---
Full diff: https://github.com/llvm/llvm-project/pull/113685.diff
3 Files Affected:
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+3-4)
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+2-4)
- (modified) llvm/lib/Transforms/Coroutines/CoroEarly.cpp (+1-2)
``````````diff
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 =
``````````
</details>
https://github.com/llvm/llvm-project/pull/113685
More information about the llvm-commits
mailing list