[llvm] [CodeExtractor] Add align metadata to extracted pointers (PR #131131)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 13 07:50:41 PDT 2025


================
@@ -1604,8 +1604,26 @@ void CodeExtractor::emitFunctionBody(
       Idx[1] = ConstantInt::get(Type::getInt32Ty(header->getContext()), aggIdx);
       GetElementPtrInst *GEP = GetElementPtrInst::Create(
           StructArgTy, AggArg, Idx, "gep_" + inputs[i]->getName(), newFuncRoot);
-      RewriteVal = new LoadInst(StructArgTy->getElementType(aggIdx), GEP,
-                                "loadgep_" + inputs[i]->getName(), newFuncRoot);
+      LoadInst *LoadGEP =
+          new LoadInst(StructArgTy->getElementType(aggIdx), GEP,
+                       "loadgep_" + inputs[i]->getName(), newFuncRoot);
+      PointerType *ItemType =
+          dyn_cast<PointerType>(StructArgTy->getElementType(aggIdx));
+      if (ItemType && !LoadGEP->getMetadata(LLVMContext::MD_align)) {
----------------
Meinersbur wrote:

Is the `!LoadGEP->getMetadata()` condition superfluous? How can there be metadata if we just created the instruction?

https://github.com/llvm/llvm-project/pull/131131


More information about the llvm-commits mailing list