Skip to content

Commit 5ea8571

Browse files
committed
fix non-deterministic IR generation
1 parent 607a3e0 commit 5ea8571

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mlir/lib/Target/LLVMIR/Dialect/Ptr/PtrToLLVMIRTranslation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,10 @@ convertPtrDiffOp(PtrDiffOp ptrDiffOp, llvm::IRBuilderBase &builder,
371371

372372
// Convert both pointers to integers using ptrtoaddr, and compute the
373373
// difference: lhs - rhs
374+
llvm::Value *llLhs = builder.CreatePtrToAddr(lhs);
375+
llvm::Value *llRhs = builder.CreatePtrToAddr(rhs);
374376
llvm::Value *result = builder.CreateSub(
375-
builder.CreatePtrToAddr(lhs), builder.CreatePtrToAddr(rhs), /*Name=*/"",
377+
llLhs, llRhs, /*Name=*/"",
376378
/*HasNUW=*/(flags & PtrDiffFlags::nuw) == PtrDiffFlags::nuw,
377379
/*HasNSW=*/(flags & PtrDiffFlags::nsw) == PtrDiffFlags::nsw);
378380

0 commit comments

Comments
 (0)