Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -525,6 +525,7 @@ ShadowMapping Mapping; SmallVector AllocaVec; + SmallVector NonInstrumentedAllocaVec; SmallVector RetVec; unsigned StackAlignment; @@ -625,7 +626,10 @@ /// \brief Collect Alloca instructions we want (and can) handle. void visitAllocaInst(AllocaInst &AI) { - if (!ASan.isInterestingAlloca(AI)) return; + if (!ASan.isInterestingAlloca(AI)) { + if (AI.isStaticAlloca()) NonInstrumentedAllocaVec.push_back(&AI); + return; + } StackAlignment = std::max(StackAlignment, AI.getAlignment()); if (ASan.isDynamicAlloca(AI)) @@ -1734,6 +1738,10 @@ IRBuilder<> IRB(InsBefore); IRB.SetCurrentDebugLocation(EntryDebugLocation); + for (auto *AI : NonInstrumentedAllocaVec) { + AI->moveBefore(AllocaVec[0]); + } + SmallVector SVD; SVD.reserve(AllocaVec.size()); for (AllocaInst *AI : AllocaVec) {