mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Improve debug info generated with enabled AddressSanitizer.
When ASan replaces <alloca instruction> with <offset into a common large alloca>, it should also patch llvm.dbg.declare calls and replace debug info descriptors to mark that we've replaced alloca with a value that stores an address of the user variable, not the user variable itself. See PR11818 for more context. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/DataLayout.h"
|
||||
#include "llvm/DIBuilder.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/IRBuilder.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
@@ -38,6 +39,7 @@
|
||||
#include "llvm/Support/system_error.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
||||
#include "llvm/Type.h"
|
||||
#include <algorithm>
|
||||
@@ -1158,6 +1160,7 @@ bool AddressSanitizer::poisonStackInFunction(Function &F) {
|
||||
SmallVector<Instruction*, 8> RetVec;
|
||||
uint64_t TotalSize = 0;
|
||||
bool HavePoisonedAllocas = false;
|
||||
DIBuilder DIB(*F.getParent());
|
||||
|
||||
// Filter out Alloca instructions we want (and can) handle.
|
||||
// Collect Ret instructions.
|
||||
@@ -1228,6 +1231,7 @@ bool AddressSanitizer::poisonStackInFunction(Function &F) {
|
||||
Value *NewAllocaPtr = IRB.CreateIntToPtr(
|
||||
IRB.CreateAdd(LocalStackBase, ConstantInt::get(IntptrTy, Pos)),
|
||||
AI->getType());
|
||||
replaceDbgDeclareForAlloca(AI, NewAllocaPtr, DIB);
|
||||
AI->replaceAllUsesWith(NewAllocaPtr);
|
||||
// Analyze lifetime intrinsics only for static allocas we handle.
|
||||
if (CheckLifetime)
|
||||
|
Reference in New Issue
Block a user