From 438315bf69c7dae68edd5c99f9672fffdc442a79 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Tue, 13 Aug 2019 01:07:27 +0000 Subject: [PATCH] [AMDGPU] Fix msan failure in printf lowering llvm-svn: 368645 --- llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp index 85cf902..022e8a0 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp +++ b/llvm/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)); -- 2.7.4