From db3a47c810639388c80ed173dda3623dac00ce0a Mon Sep 17 00:00:00 2001 From: beetrees Date: Fri, 14 Jun 2024 15:05:57 +0100 Subject: Fix silent truncation of inline ASM `srcloc` cookie when going through a `DiagnosticInfoSrcMgr` (#84559) The size of the inline ASM `srcloc` cookie was changed from 32 bits to 64 bits in [D105491](https://reviews.llvm.org/D105491). However, that commit only updated the size of the cookie in `DiagnosticInfoInlineAsm`, meaning that inline ASM diagnostics that are instead represented with a `DiagnosticInfoSrcMgr` have their cookies truncated to 32 bits. This PR replaces the remaining uses of `unsigned` to represent the cookie with `uint64_t`, allowing the cookie to make it all the way to the diagnostic handler without being truncated. --- llvm/lib/CodeGen/MachineModuleInfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp') diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 1dba591..b950f4f 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -185,7 +185,7 @@ INITIALIZE_PASS(MachineModuleInfoWrapperPass, "machinemoduleinfo", "Machine Module Information", false, false) char MachineModuleInfoWrapperPass::ID = 0; -static unsigned getLocCookie(const SMDiagnostic &SMD, const SourceMgr &SrcMgr, +static uint64_t getLocCookie(const SMDiagnostic &SMD, const SourceMgr &SrcMgr, std::vector &LocInfos) { // Look up a LocInfo for the buffer this diagnostic is coming from. unsigned BufNum = SrcMgr.FindBufferContainingLoc(SMD.getLoc()); @@ -195,7 +195,7 @@ static unsigned getLocCookie(const SMDiagnostic &SMD, const SourceMgr &SrcMgr, // If the inline asm had metadata associated with it, pull out a location // cookie corresponding to which line the error occurred on. - unsigned LocCookie = 0; + uint64_t LocCookie = 0; if (LocInfo) { unsigned ErrorLine = SMD.getLineNo() - 1; if (ErrorLine >= LocInfo->getNumOperands()) @@ -218,7 +218,7 @@ bool MachineModuleInfoWrapperPass::doInitialization(Module &M) { [&Ctx, &M](const SMDiagnostic &SMD, bool IsInlineAsm, const SourceMgr &SrcMgr, std::vector &LocInfos) { - unsigned LocCookie = 0; + uint64_t LocCookie = 0; if (IsInlineAsm) LocCookie = getLocCookie(SMD, SrcMgr, LocInfos); Ctx.diagnose( -- cgit v1.1