[llvm] Reland [AMDGPU] Add AMDGPU specific variadic operation MCExprs (PR #84562)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 08:12:38 PDT 2024
================
@@ -20,7 +20,13 @@ using namespace llvm;
const AMDGPUVariadicMCExpr *
AMDGPUVariadicMCExpr::create(VariadicKind Kind, ArrayRef<const MCExpr *> Args,
MCContext &Ctx) {
- return new (Ctx) AMDGPUVariadicMCExpr(Kind, Args);
+ // Storage for the argument's 'const MCExpr*' allocated through MCContext new placement which means that AMDGPUVariadicMCExpr objects and all of its contents will now be allocated through MCContext new placement.
+ //
+ // Will result in an asan failure if allocated on the heap (e.g., through SmallVector's grow).
+ const MCExpr **CtxArgs = new (Ctx) const MCExpr*[Args.size()];
+ for (size_t i = 0; i < Args.size(); ++i)
+ CtxArgs[i] = Args[i];
----------------
arsenm wrote:
Can you just use a regular old array, plus Ctx.allocate?
https://github.com/llvm/llvm-project/pull/84562
More information about the llvm-commits
mailing list