[PATCH] D80285: [mlir] make the bitwidth of device side index computations configurable
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 23 09:37:38 PDT 2020
mehdi_amini added inline comments.
================
Comment at: mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h:385
+ /*indexBitwidth=*/kDeriveIndexBitwidthFromDataLayout,
+ /*useAlignedAlloc=*/false},
PatternBenefit benefit = 1);
----------------
jeanPerier wrote:
> gysit wrote:
> > ftynse wrote:
> > > gysit wrote:
> > > > ftynse wrote:
> > > > > gysit wrote:
> > > > > > mehdi_amini wrote:
> > > > > > > I am puzzled how is this working?
> > > > > > >
> > > > > > > This default value for this parameter is mapped to a reference member, how isn't it gonna lead to "use-after-free"?
> > > > > > >
> > > > > > You are right this should not work (the lifetime of the default argument is limited to the body of the constructor -- I believe). I will submit a patch to fix this problem.
> > > > > Hmm, why wouldn't it? The lifetime of the temporary is that of the constructor body. The reference will be used to copy-construct the member struct at the beginning of the constructor implementation, at which point the temporary is guaranteed to be live. Then we will only use the member. It would have been a problem if ConvertToLLVMPattern kept a reference to the temporary.
> > > > > It would have been a problem if ConvertToLLVMPattern kept a reference to the temporary.
> > > >
> > > > The options member is unfortunately a const reference.
> > > >
> > > >
> > > My bad, I looked elsewhere. The reference capture semantics should be documented somewhere. Or in a more hacky way, this can accept a non-const reference that would effectively disallow passing in temporaries.
> > should we just make the options a non-reference member of ConvertToLLVMPattern? At the moment to struct is super small and copying the options should not harm performance.
> + 1, this broke our flang builds with some compilers (they randomly emitted C interface).
Duplicating the option in every single pattern instance inheriting from ConvertToLLVMPattern seems a bit suboptimal to me.
================
Comment at: mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h:30
+ /// Use aligned_alloc for heap allocations.
+ bool useAlignedAlloc = false;
+};
----------------
If you reorder the bool before the unsigned, the struct would be smaller I think (on most platform)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80285/new/
https://reviews.llvm.org/D80285
More information about the llvm-commits
mailing list