[llvm] r277265 - [AMDGPU] Fix lifetime of SmallVector temporaries.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 30 04:31:17 PDT 2016
Author: d0k
Date: Sat Jul 30 06:31:16 2016
New Revision: 277265
URL: http://llvm.org/viewvc/llvm-project?rev=277265&view=rev
Log:
[AMDGPU] Fix lifetime of SmallVector temporaries.
Found by asan -fsanitize-address-use-after-scope.
Modified:
llvm/trunk/lib/Target/AMDGPU/R600InstrInfo.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/R600InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/R600InstrInfo.cpp?rev=277265&r1=277264&r2=277265&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/R600InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/R600InstrInfo.cpp Sat Jul 30 06:31:16 2016
@@ -320,12 +320,12 @@ R600InstrInfo::ExtractSrcs(MachineInstr
const DenseMap<unsigned, unsigned> &PV,
unsigned &ConstCount) const {
ConstCount = 0;
- ArrayRef<std::pair<MachineOperand *, int64_t>> Srcs = getSrcs(MI);
const std::pair<int, unsigned> DummyPair(-1, 0);
std::vector<std::pair<int, unsigned> > Result;
unsigned i = 0;
- for (unsigned n = Srcs.size(); i < n; ++i) {
- unsigned Reg = Srcs[i].first->getReg();
+ for (const auto &Src : getSrcs(MI)) {
+ ++i;
+ unsigned Reg = Src.first->getReg();
int Index = RI.getEncodingValue(Reg) & 0xff;
if (Reg == AMDGPU::OQAP) {
Result.push_back(std::make_pair(Index, 0U));
@@ -592,9 +592,7 @@ R600InstrInfo::fitsConstReadLimitations(
if (!isALUInstr(MI.getOpcode()))
continue;
- ArrayRef<std::pair<MachineOperand *, int64_t>> Srcs = getSrcs(MI);
-
- for (const auto &Src:Srcs) {
+ for (const auto &Src : getSrcs(MI)) {
if (Src.first->getReg() == AMDGPU::ALU_LITERAL_X)
Literals.insert(Src.second);
if (Literals.size() > 4)
More information about the llvm-commits
mailing list