From f6605ee4658b8a2d69fb056932b5b64eab32f7ad Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 10 Dec 2011 13:33:28 -0800 Subject: [PATCH] Small cleanup: allocate storage for the full mask in the FunctionEmitContext constructor --- ctx.cpp | 11 +++++++---- ctx.h | 6 +++--- func.cpp | 7 +++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ctx.cpp b/ctx.cpp index eeb500cd..4aea7fdc 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -171,8 +171,11 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, internalMaskPointer = AllocaInst(LLVMTypes::MaskType, "internal_mask_memory"); StoreInst(LLVMMaskAllOn, internalMaskPointer); + functionMaskValue = LLVMMaskAllOn; - fullMaskPointer = NULL; + + fullMaskPointer = AllocaInst(LLVMTypes::MaskType, "full_mask_memory"); + StoreInst(LLVMMaskAllOn, fullMaskPointer); loopMask = NULL; breakLanesPtr = continueLanesPtr = NULL; @@ -286,9 +289,9 @@ FunctionEmitContext::GetFullMask() { } -void -FunctionEmitContext::SetMaskPointer(llvm::Value *p) { - fullMaskPointer = p; +llvm::Value * +FunctionEmitContext::GetFullMaskPointer() { + return fullMaskPointer; } diff --git a/ctx.h b/ctx.h index e5c94550..e573a8ca 100644 --- a/ctx.h +++ b/ctx.h @@ -98,9 +98,9 @@ public: the function entry mask and the internal mask. */ llvm::Value *GetFullMask(); - /** Provides the alloca'd pointer to memory to store the full function - mask. This is only used to wire up the __mask builtin variable. */ - void SetMaskPointer(llvm::Value *p); + /** Returns a pointer to storage in memory that stores the current full + mask. */ + llvm::Value *GetFullMaskPointer(); /** Provides the value of the mask at function entry */ void SetFunctionMask(llvm::Value *val); diff --git a/func.cpp b/func.cpp index 2bef5bb9..170beec1 100644 --- a/func.cpp +++ b/func.cpp @@ -189,10 +189,9 @@ lCopyInTaskParameter(int i, llvm::Value *structArgPtr, const std::vectorAllocaInst(LLVMTypes::MaskType, "mask_memory"); - ctx->StoreInst(LLVMMaskAllOn, maskPtr); - maskSymbol->storagePtr = maskPtr; - ctx->SetMaskPointer(maskPtr); + // Connect the __mask builtin to the location in memory that stores its + // value + maskSymbol->storagePtr = ctx->GetFullMaskPointer(); // add debugging info for __mask, programIndex, ... maskSymbol->pos = firstStmtPos;