Skip to content

Commit 8481648

Browse files
authored
Don't add debug line information for LLVM alloca (#28412)
Don't add debug line information for LLVM alloca. This is not needed since we emit `dbg_declare`, and it can actually harm the debugging output by causing the debugger to erratically jump around when single stepping. - [x] paratest [Reviewed by @benharsh]
2 parents d069bbe + ded3121 commit 8481648

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler/llvm/llvmUtil.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "chpl/util/break.h"
2222
#include "llvmTracker.h"
2323
#include "llvmUtil.h"
24+
#include "llvmDebug.h"
2425
#include "symbol.h"
2526
#include "llvm/Support/Format.h"
2627

@@ -114,9 +115,19 @@ llvm::AllocaInst* createAllocaInFunctionEntry(llvm::IRBuilder<>* irBuilder,
114115
irBuilder->SetInsertPoint(&func->getEntryBlock());
115116
}
116117

118+
// reset the current debug location to avoid accidentally attaching it to the alloca
119+
llvm::DebugLoc currentDebugLocation;
120+
if (debugInfo) {
121+
currentDebugLocation = irBuilder->getCurrentDebugLocation();
122+
irBuilder->SetCurrentDebugLocation(llvm::DebugLoc());
123+
}
124+
117125
llvm::AllocaInst *tempVar = irBuilder->CreateAlloca(type, nullptr, name);
118126
trackLLVMValue(tempVar);
127+
119128
irBuilder->SetInsertPoint(&func->back());
129+
if (debugInfo)
130+
irBuilder->SetCurrentDebugLocation(currentDebugLocation);
120131
return tempVar;
121132
}
122133

0 commit comments

Comments
 (0)