From: Stanislav Mekhanoshin Date: Tue, 13 Aug 2019 01:07:27 +0000 (+0000) Subject: [AMDGPU] Fix msan failure in printf lowering X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae4f6e8d53e0ccf6458dfb4959ff2af8005cc93d;p=llvm [AMDGPU] Fix msan failure in printf lowering git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368645 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp index 85cf902a4ed..022e8a060ed 100644 --- a/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp +++ b/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp @@ -537,8 +537,8 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(Module &M) { } else { WhatToStore.push_back(Arg); } - for (auto W : WhatToStore) { - Value *TheBtCast = W; + for (unsigned I = 0, E = WhatToStore.size(); I != E; ++I) { + Value *TheBtCast = WhatToStore[I]; unsigned ArgSize = TD->getTypeAllocSizeInBits(TheBtCast->getType()) / 8; SmallVector BuffOffset; @@ -551,9 +551,7 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(Module &M) { LLVM_DEBUG(dbgs() << "inserting store to printf buffer:\n" << *StBuff << '\n'); (void)StBuff; - ++W; - if (W == *WhatToStore.end() && - ArgCount + 1 == CI->getNumArgOperands()) + if (I + 1 == E && ArgCount + 1 == CI->getNumArgOperands()) break; BufferIdx = dyn_cast(GetElementPtrInst::Create( nullptr, BufferIdx, BuffOffset, "PrintBuffNextPtr", Brnch));