]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Fix msan failure in printf lowering
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Tue, 13 Aug 2019 01:07:27 +0000 (01:07 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Tue, 13 Aug 2019 01:07:27 +0000 (01:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368645 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

index 85cf902a4edd3914c057bab83d16148c476a4884..022e8a060ed214c9bd3e7d573afd0013d3998da4 100644 (file)
@@ -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<Value *, 1> 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>(GetElementPtrInst::Create(
               nullptr, BufferIdx, BuffOffset, "PrintBuffNextPtr", Brnch));