[PATCH] D111710: [AMDGPU][ASAN][OPENMP] Size Mismatch issue occurs when a global entry used in the target region is instrumented with ASAN specifically on AMDGPU occurs at Libomptarget level. There are trailing red zone for global variables mapped on the target...
Amit Kumar Pandey via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 22 04:01:17 PDT 2021
ampandey-AMD updated this revision to Diff 381502.
ampandey-AMD added a comment.
Removing unrelated white space changes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111710/new/
https://reviews.llvm.org/D111710
Files:
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2422,6 +2422,30 @@
for (auto &G : M.globals()) {
if (!AliasedGlobalExclusions.count(&G) && shouldInstrumentGlobal(&G))
GlobalsToChange.push_back(&G);
+ StringRef offload_str = G.getSection();
+ StringRef section_name = "omp_offloading_entries";
+ if(G.hasInitializer() && offload_str.compare(section_name)==0) {
+ Constant *OldInit = G.getInitializer();
+ if(OldInit->getType()->isStructTy()) {
+ StringRef GName = OldInit->getType()->getStructName();
+ const APInt &UI = OldInit->getAggregateElement(unsigned(2))->getUniqueInteger();
+ const uint64_t SizeInBytes = UI.getSExtValue();
+ if(SizeInBytes != 0) {
+ const uint64_t RightRedzoneSize = getRedzoneSizeForGlobal(SizeInBytes);
+ Constant *val = ConstantInt::get(IRB.getInt64Ty(),SizeInBytes+RightRedzoneSize,true);
+ StructType *sttype = StructType::getTypeByName(M.getContext(),GName);
+ SmallVector<Constant*,5> indices(5);
+ indices[0] = OldInit->getAggregateElement(unsigned(0));
+ indices[1] = OldInit->getAggregateElement(unsigned(1));
+ indices[2] = val;
+ indices[3] = OldInit->getAggregateElement(unsigned(3));
+ indices[4] = OldInit->getAggregateElement(unsigned(4));
+ Constant *NewInit = ConstantStruct::get(sttype,indices);
+ NewInit->takeName(G.getInitializer());
+ G.setInitializer(NewInit);
+ }
+ }
+ }
}
size_t n = GlobalsToChange.size();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111710.381502.patch
Type: text/x-patch
Size: 1665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211022/d8f375f8/attachment.bin>
More information about the llvm-commits
mailing list