diff options
author | James Y Knight <jyknight@google.com> | 2019-02-01 20:44:47 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2019-02-01 20:44:47 +0000 |
commit | 7716075a1729ead67844574fdb34579894122992 (patch) | |
tree | 1a3b91f53223202ab65c910dbc26979f5f05201c /llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | |
parent | 14359ef1b6a0610ac91df5f5a91c88a0b51c187c (diff) | |
download | bcm5719-llvm-7716075a1729ead67844574fdb34579894122992.tar.gz bcm5719-llvm-7716075a1729ead67844574fdb34579894122992.zip |
[opaque pointer types] Pass value type to GetElementPtr creation.
This cleans up all GetElementPtr creation in LLVM to explicitly pass a
value type rather than deriving it from the pointer's element-type.
Differential Revision: https://reviews.llvm.org/D57173
llvm-svn: 352913
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 75c82229309..71ce65774ae 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -557,6 +557,7 @@ private: FunctionCallee MemmoveFn, MemcpyFn, MemsetFn; /// KMSAN callback for task-local function argument shadow. + StructType *MsanContextStateTy; FunctionCallee MsanGetContextStateFn; /// Functions for poisoning/unpoisoning local variables @@ -677,18 +678,15 @@ void MemorySanitizer::createKernelApi(Module &M) { IRB.getInt32Ty()); // Requests the per-task context state (kmsan_context_state*) from the // runtime library. + MsanContextStateTy = StructType::get( + ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), + ArrayType::get(IRB.getInt64Ty(), kRetvalTLSSize / 8), + ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), + ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), /* va_arg_origin */ + IRB.getInt64Ty(), ArrayType::get(OriginTy, kParamTLSSize / 4), OriginTy, + OriginTy); MsanGetContextStateFn = M.getOrInsertFunction( - "__msan_get_context_state", - PointerType::get( - StructType::get(ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), - ArrayType::get(IRB.getInt64Ty(), kRetvalTLSSize / 8), - ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), - ArrayType::get(IRB.getInt64Ty(), - kParamTLSSize / 8), /* va_arg_origin */ - IRB.getInt64Ty(), - ArrayType::get(OriginTy, kParamTLSSize / 4), OriginTy, - OriginTy), - 0)); + "__msan_get_context_state", PointerType::get(MsanContextStateTy, 0)); Type *RetTy = StructType::get(PointerType::get(IRB.getInt8Ty(), 0), PointerType::get(IRB.getInt32Ty(), 0)); @@ -1096,7 +1094,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { for (unsigned i = Ofs; i < (Size + kOriginSize - 1) / kOriginSize; ++i) { Value *GEP = - i ? IRB.CreateConstGEP1_32(nullptr, OriginPtr, i) : OriginPtr; + i ? IRB.CreateConstGEP1_32(MS.OriginTy, OriginPtr, i) : OriginPtr; IRB.CreateAlignedStore(Origin, GEP, CurrentAlignment); CurrentAlignment = kMinOriginAlignment; } @@ -1241,20 +1239,22 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { IRBuilder<> IRB(F.getEntryBlock().getFirstNonPHI()); Value *ContextState = IRB.CreateCall(MS.MsanGetContextStateFn, {}); Constant *Zero = IRB.getInt32(0); - MS.ParamTLS = - IRB.CreateGEP(ContextState, {Zero, IRB.getInt32(0)}, "param_shadow"); - MS.RetvalTLS = - IRB.CreateGEP(ContextState, {Zero, IRB.getInt32(1)}, "retval_shadow"); - MS.VAArgTLS = - IRB.CreateGEP(ContextState, {Zero, IRB.getInt32(2)}, "va_arg_shadow"); - MS.VAArgOriginTLS = - IRB.CreateGEP(ContextState, {Zero, IRB.getInt32(3)}, "va_arg_origin"); - MS.VAArgOverflowSizeTLS = IRB.CreateGEP( - ContextState, {Zero, IRB.getInt32(4)}, "va_arg_overflow_size"); - MS.ParamOriginTLS = - IRB.CreateGEP(ContextState, {Zero, IRB.getInt32(5)}, "param_origin"); + MS.ParamTLS = IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(0)}, "param_shadow"); + MS.RetvalTLS = IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(1)}, "retval_shadow"); + MS.VAArgTLS = IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(2)}, "va_arg_shadow"); + MS.VAArgOriginTLS = IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(3)}, "va_arg_origin"); + MS.VAArgOverflowSizeTLS = + IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(4)}, "va_arg_overflow_size"); + MS.ParamOriginTLS = IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(5)}, "param_origin"); MS.RetvalOriginTLS = - IRB.CreateGEP(ContextState, {Zero, IRB.getInt32(6)}, "retval_origin"); + IRB.CreateGEP(MS.MsanContextStateTy, ContextState, + {Zero, IRB.getInt32(6)}, "retval_origin"); return ret; } |