Fixed some debug locations with line 0 (#3784)

This commit is contained in:
Adam Yang 2021-05-20 04:30:26 -07:00 коммит произвёл GitHub
Родитель 64fdd16ee0
Коммит 37e802cd07
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 38 добавлений и 3 удалений

Просмотреть файл

@ -106,7 +106,13 @@ public:
}
/// \brief Set location information used by debugging information.
void SetCurrentDebugLocation(DebugLoc L) { CurDbgLocation = std::move(L); }
void SetCurrentDebugLocation(DebugLoc L) { CurDbgLocation = std::move(L);
// HLSL Change - begin
// Don't propagate debug locations at line 0
if (CurDbgLocation && CurDbgLocation.getLine() == 0)
CurDbgLocation = nullptr;
// HLSL Change - end
}
/// \brief Get location information used by debugging information.
const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; }

Просмотреть файл

@ -6087,7 +6087,7 @@ void PatchDebugInfo(DebugInfoFinder &DbgFinder, Function *F, GlobalVariable *GV,
DITypeIdentifierMap EmptyMap;
DIBuilder DIB(*GV->getParent());
DIScope *Scope = Subprogram;
DebugLoc Loc = DebugLoc::get(0, 0, Scope);
DebugLoc Loc = DebugLoc::get(DGV->getLine(), 0, Scope);
// If the variable is a member of another variable, find the offset and size
bool IsFragment = false;

Просмотреть файл

@ -885,7 +885,8 @@ static void fixupLineNumbers(Function *Fn, Function::iterator FI,
if (!getDebugMetadataVersionFromModule(*Fn->getParent()))
return;
if (DISubprogram *Subprogram = getDISubprogram(Fn)) {
TheCallDL = DebugLoc(llvm::DILocation::get(Fn->getContext(), 0, 0, Subprogram));
// Just give it the submodule's line, so it doesn't have line number 0
TheCallDL = DebugLoc(llvm::DILocation::get(Fn->getContext(), Subprogram->getLine(), 0, Subprogram));
TheCall->setDebugLoc(TheCallDL);
}
else {

Просмотреть файл

@ -0,0 +1,28 @@
// RUN: %dxc -Zi -E main -T ps_6_0 /Zi /O0 %s | FileCheck %s
// CHECK-NOT: !{{[0-9]+}} = !DILocation(line: 0,
// Regression test to make sure debug locations with 0
// as line number don't show up.
struct My_Struct {
float m_foo;
float m_bar;
void set_foo(float foo) {
m_foo = foo;
m_foo *= 2;
}
void test() {
m_bar = m_bar * 2;
}
};
static My_Struct s = { 0.0, 0.0 };
[RootSignature("")]
float main(float foo : FOO) : SV_Target {
s.set_foo(foo);
s.test();
return s.m_bar;
}