Skip to content

Commit 9ec6f05

Browse files
author
Vadim Averin
authored
Small fixes in LLVM debug info (#7527)
1 parent fda7fab commit 9ec6f05

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

ydb/library/yql/minikql/codegen/codegen.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ class TCodegen : public ICodegen, private llvm::JITEventListener {
390390

391391
bool dumpTimers = compileOpts.Contains("time-passes");
392392
bool disableOpt = compileOpts.Contains("disable-opt");
393+
#ifndef NDEBUG
394+
disableOpt = true;
395+
#endif
393396

394397
#if defined(_msan_enabled_)
395398
ReverseGlobalMapping_[(const void*)&__emutls_get_address] = "__emutls_get_address";

ydb/library/yql/minikql/comp_nodes/mkql_wide_top_sort.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TWideTopWrapper<Sort
404404
#ifndef MKQL_DISABLE_CODEGEN
405405
ICodegeneratorInlineWideNode::TGenerateResult DoGenGetValues(const TCodegenContext& ctx, Value* statePtr, BasicBlock*& block) const {
406406
auto& context = ctx.Codegen.GetContext();
407-
DIScopeAnnotator annotate(*ctx.Annotator);
407+
DIScopeAnnotator annotate(ctx.Annotator);
408408

409409
const auto valueType = Type::getInt128Ty(context);
410410
const auto ptrValueType = PointerType::getUnqual(valueType);
@@ -424,7 +424,7 @@ using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TWideTopWrapper<Sort
424424

425425
for (auto i = 0U; i < getters.size(); ++i) {
426426
getters[Indexes[i]] = [i, outs, indexType, valueType, outputPtrType, outputType](const TCodegenContext& ctx, BasicBlock*& block) {
427-
DIScopeAnnotator annotate(*ctx.Annotator);
427+
DIScopeAnnotator annotate(ctx.Annotator);
428428
const auto values = annotate(new LoadInst(outputPtrType, outs, "values", block));
429429
const auto pointer = annotate(GetElementPtrInst::CreateInBounds(outputType, values, {ConstantInt::get(indexType, 0), ConstantInt::get(indexType, i)}, (TString("ptr_") += ToString(i)).c_str(), block));
430430
return annotate(new LoadInst(valueType, pointer, (TString("load_") += ToString(i)).c_str(), block));
@@ -927,7 +927,7 @@ using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TWideSortWrapper>;
927927
#ifndef MKQL_DISABLE_CODEGEN
928928
ICodegeneratorInlineWideNode::TGenerateResult DoGenGetValues(const TCodegenContext& ctx, Value* statePtr, BasicBlock*& block) const {
929929
auto& context = ctx.Codegen.GetContext();
930-
DIScopeAnnotator annotate(*ctx.Annotator);
930+
DIScopeAnnotator annotate(ctx.Annotator);
931931

932932
const auto valueType = Type::getInt128Ty(context);
933933
const auto ptrValueType = PointerType::getUnqual(valueType);
@@ -947,7 +947,7 @@ using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TWideSortWrapper>;
947947

948948
for (auto i = 0U; i < getters.size(); ++i) {
949949
getters[Indexes[i]] = [i, outs, indexType, valueType, outputPtrType, outputType](const TCodegenContext& ctx, BasicBlock*& block) {
950-
DIScopeAnnotator annotate(*ctx.Annotator);
950+
DIScopeAnnotator annotate(ctx.Annotator);
951951
const auto values = annotate(new LoadInst(outputPtrType, outs, "values", block));
952952
const auto pointer = annotate(GetElementPtrInst::CreateInBounds(outputType, values, {ConstantInt::get(indexType, 0), ConstantInt::get(indexType, i)}, (TString("ptr_") += ToString(i)).c_str(), block));
953953
return annotate(new LoadInst(valueType, pointer, (TString("load_") += ToString(i)).c_str(), block));

ydb/library/yql/minikql/computation/mkql_computation_node_codegen.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,7 @@ DISubprogramAnnotator::DISubprogramAnnotator(TCodegenContext& ctx, Function* sub
26182618
DISubprogramAnnotator::~DISubprogramAnnotator() {
26192619
Ctx.Annotator = nullptr;
26202620
{ // necessary stub annotation of "CallInst"s
2621-
DIScopeAnnotator stubAnnotate(*this);
2621+
DIScopeAnnotator stubAnnotate(this);
26222622
for (BasicBlock& block : *Func) {
26232623
for (Instruction& inst : block) {
26242624
if (CallInst* callInst = dyn_cast_or_null<CallInst>(&inst)) {
@@ -2651,13 +2651,17 @@ DISubprogram* DISubprogramAnnotator::MakeDISubprogram(const StringRef& name, con
26512651
);
26522652
}
26532653

2654-
DIScopeAnnotator::DIScopeAnnotator(DISubprogramAnnotator& subprogramAnnotator, const TSrcLocation& location)
2655-
: SubprogramAnnotator(subprogramAnnotator)
2656-
, Scope(SubprogramAnnotator.DebugBuilder->createLexicalBlock(SubprogramAnnotator.Subprogram, SubprogramAnnotator.MakeDIFile(location), location.line(), location.column()))
2657-
{}
2654+
DIScopeAnnotator::DIScopeAnnotator(DISubprogramAnnotator* subprogramAnnotator, const TSrcLocation& location)
2655+
: SubprogramAnnotator(nullptr)
2656+
, Scope(nullptr)
2657+
{
2658+
Y_ENSURE(subprogramAnnotator != nullptr);
2659+
SubprogramAnnotator = subprogramAnnotator;
2660+
Scope = SubprogramAnnotator->DebugBuilder->createLexicalBlock(SubprogramAnnotator->Subprogram, SubprogramAnnotator->MakeDIFile(location), location.line(), location.column());
2661+
}
26582662

26592663
Instruction* DIScopeAnnotator::operator()(Instruction* inst, const TSrcLocation& location) const {
2660-
inst->setDebugLoc(DILocation::get(SubprogramAnnotator.Ctx.Codegen.GetContext(), location.line(), location.column(), Scope));
2664+
inst->setDebugLoc(DILocation::get(SubprogramAnnotator->Ctx.Codegen.GetContext(), location.line(), location.column(), Scope));
26612665
return inst;
26622666
}
26632667

ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1247,12 +1247,12 @@ private:
12471247

12481248
class DIScopeAnnotator final {
12491249
public:
1250-
explicit DIScopeAnnotator(DISubprogramAnnotator& subprogramAnnotator, const TSrcLocation& location = TSrcLocation::current());
1250+
explicit DIScopeAnnotator(DISubprogramAnnotator* subprogramAnnotator, const TSrcLocation& location = TSrcLocation::current());
12511251

12521252
Instruction* operator()(Instruction* inst, const TSrcLocation& location = TSrcLocation::current()) const;
12531253

12541254
private:
1255-
DISubprogramAnnotator& SubprogramAnnotator;
1255+
DISubprogramAnnotator* SubprogramAnnotator;
12561256
DIScope* Scope;
12571257
};
12581258

0 commit comments

Comments
 (0)