[llvm] 20b5310 - [OMPIRBuilder] Avoid use of ConstantExpr::getSizeOf() (#223323)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 01:46:50 PDT 2026


Author: Nikita Popov
Date: 2026-09-14T08:46:44Z
New Revision: 20b53106931742d2e5e64132f06994980fe94d7d

URL: https://github.com/llvm/llvm-project/commit/20b53106931742d2e5e64132f06994980fe94d7d
DIFF: https://github.com/llvm/llvm-project/commit/20b53106931742d2e5e64132f06994980fe94d7d.diff

LOG: [OMPIRBuilder] Avoid use of ConstantExpr::getSizeOf() (#223323)

This will not be supported in ptradd representation. Directly
create a constant with the type size instead.

Added: 
    

Modified: 
    llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index e7dad1829f383..a0e0033627cfb 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -5559,8 +5559,8 @@ Error OpenMPIRBuilder::emitScanBasedDirectiveDeclsIR(
         Builder.CreateAdd(ScanRedInfo->Span, Builder.getInt32(1));
     for (size_t i = 0; i < ScanVars.size(); i++) {
       Type *IntPtrTy = Builder.getInt32Ty();
-      Constant *Allocsize = ConstantExpr::getSizeOf(ScanVarsType[i]);
-      Allocsize = ConstantExpr::getTruncOrBitCast(Allocsize, IntPtrTy);
+      Value *Allocsize = Builder.CreateTypeSize(
+          IntPtrTy, M.getDataLayout().getTypeAllocSize(ScanVarsType[i]));
       Value *Buff =
           Builder.CreateMalloc(IntPtrTy, Allocsize, AllocSpan, nullptr, "arr");
       Builder.CreateStore(Buff, (*(ScanRedInfo->ScanBuffPtrs))[ScanVars[i]]);


        


More information about the llvm-commits mailing list