Skip to content

Commit a8a0084

Browse files
committed
Update debug info when changing CC to Fast
This fixes #144301
1 parent 48e54f3 commit a8a0084

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,14 @@ static void RemovePreallocated(Function *F) {
19201920
}
19211921
}
19221922

1923+
static unsigned char GetDebugInfoFastCC(const Triple &Triple) {
1924+
if (Triple.isOSWindows() && Triple.isArch32Bit()) {
1925+
return llvm::dwarf::DW_CC_BORLAND_msfastcall;
1926+
}
1927+
1928+
return llvm::dwarf::DW_CC_normal;
1929+
}
1930+
19231931
static bool
19241932
OptimizeFunctions(Module &M,
19251933
function_ref<TargetLibraryInfo &(Function &)> GetTLI,
@@ -1938,6 +1946,9 @@ OptimizeFunctions(Module &M,
19381946
if (hasOnlyColdCalls(F, GetBFI, ChangeableCCCache))
19391947
AllCallsCold.push_back(&F);
19401948

1949+
unsigned char DebugInfoFastCC =
1950+
GetDebugInfoFastCC(Triple(M.getTargetTriple()));
1951+
19411952
// Optimize functions.
19421953
for (Function &F : llvm::make_early_inc_range(M)) {
19431954
// Don't perform global opt pass on naked functions; we don't want fast
@@ -2021,6 +2032,13 @@ OptimizeFunctions(Module &M,
20212032
// Fast calling convention.
20222033
F.setCallingConv(CallingConv::Fast);
20232034
ChangeCalleesToFastCall(&F);
2035+
2036+
if (F.getSubprogram()) {
2037+
DISubprogram *SP = F.getSubprogram();
2038+
auto Temp = SP->getType()->cloneWithCC(DebugInfoFastCC);
2039+
SP->replaceType(MDNode::replaceWithPermanent(std::move(Temp)));
2040+
}
2041+
20242042
++NumFastCallFns;
20252043
Changed = true;
20262044
}

0 commit comments

Comments
 (0)