Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to handle compilation, expected exactly one compiler job #827

Closed
ZequanWu opened this issue Jul 23, 2021 · 6 comments
Closed

Unable to handle compilation, expected exactly one compiler job #827

ZequanWu opened this issue Jul 23, 2021 · 6 comments

Comments

@ZequanWu
Copy link

I built llvm in MacOS (enabled "clang;lld;compiler-rt"), and saw the following error when opening compiler-rt/lib/profile/InstrProfilingFile.c. I only saw this kind of error in files under compiler-rt folder. For files under other folders like clang, llvm, lld, I don't see that and it works well.

Logs
Unable to handle compilation, expected exactly one compiler job in ' "/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang" "-cc1" "-triple" "i386-apple-ios9.0.0-simulator" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-fsyntax-only" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "InstrProfilingFile.c" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=all" "-fno-rounding-math" "-munwind-tables" "-faligned-alloc-unavailable" "-target-sdk-version=14.5" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "yonah" "-tune-cpu" "generic" "-debugger-tuning=lldb" "-target-linker-version" "609.8" "-nostdinc++" "-resource-dir" "/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0" "-isysroot" "/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk" "-isysroot" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk" "-D" "_DEBUG" "-D" "__STDC_CONSTANT_MACROS" "-D" "__STDC_FORMAT_MACROS" "-D" "__STDC_LIMIT_MACROS" "-I" "/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile" "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile" "-I" "/Users/zequanwu/llvm-project/build/release/include" "-I" "/Users/zequanwu/llvm-project/llvm/include" "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/.." "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include" "-D" "NDEBUG" "-D" "COMPILER_RT_HAS_ATOMICS=1" "-D" "COMPILER_RT_HAS_FCNTL_LCK=1" "-D" "COMPILER_RT_HAS_UNAME=1" "-U" "NDEBUG" "-internal-isystem" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include" "-internal-isystem" "/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include" "-internal-externc-isystem" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include" "-O3" "-Werror=date-time" "-Werror=unguarded-availability-new" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wwrite-strings" "-Wmissing-field-initializers" "-Wno-long-long" "-Wc++98-compat-extra-semi" "-Wimplicit-fallthrough" "-Wcovered-switch-default" "-Wdelete-non-virtual-dtor" "-Wstring-conversion" "-Wmisleading-indentation" "-Wall" "-Wno-unused-parameter" "-Wno-pedantic" "-pedantic" "-fconst-strings" "-fdebug-compilation-dir" "/Users/zequanwu/llvm-project/build/release" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-vectorize-loops" "-vectorize-slp" "-x" "c" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"; "/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang" "-cc1" "-triple" "x86_64-apple-ios9.0.0-simulator" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-Werror=implicit-function-declaration" "-fsyntax-only" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "InstrProfilingFile.c" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=all" "-fno-rounding-math" "-munwind-tables" "-faligned-alloc-unavailable" "-target-sdk-version=14.5" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "core2" "-tune-cpu" "generic" "-debugger-tuning=lldb" "-target-linker-version" "609.8" "-nostdinc++" "-resource-dir" "/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0" "-isysroot" "/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk" "-isysroot" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk" "-D" "_DEBUG" "-D" "__STDC_CONSTANT_MACROS" "-D" "__STDC_FORMAT_MACROS" "-D" "__STDC_LIMIT_MACROS" "-I" "/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile" "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile" "-I" "/Users/zequanwu/llvm-project/build/release/include" "-I" "/Users/zequanwu/llvm-project/llvm/include" "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/.." "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include" "-D" "NDEBUG" "-D" "COMPILER_RT_HAS_ATOMICS=1" "-D" "COMPILER_RT_HAS_FCNTL_LCK=1" "-D" "COMPILER_RT_HAS_UNAME=1" "-U" "NDEBUG" "-internal-isystem" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include" "-internal-isystem" "/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include" "-internal-externc-isystem" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include" "-O3" "-Werror=date-time" "-Werror=unguarded-availability-new" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wwrite-strings" "-Wmissing-field-initializers" "-Wno-long-long" "-Wc++98-compat-extra-semi" "-Wimplicit-fallthrough" "-Wcovered-switch-default" "-Wdelete-non-virtual-dtor" "-Wstring-conversion" "-Wmisleading-indentation" "-Wall" "-Wno-unused-parameter" "-Wno-pedantic" "-pedantic" "-fconst-strings" "-fdebug-compilation-dir" "/Users/zequanwu/llvm-project/build/release" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-vectorize-loops" "-vectorize-slp" "-x" "c" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"; "/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang" "-cc1" "-triple" "arm64-apple-ios9.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-Werror=implicit-function-declaration" "-fsyntax-only" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "InstrProfilingFile.c" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-fno-rounding-math" "-munwind-tables" "-faligned-alloc-unavailable" "-target-sdk-version=14.5" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-a7" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" "+aes" "-target-abi" "darwinpcs" "-fallow-half-arguments-and-returns" "-debugger-tuning=lldb" "-target-linker-version" "609.8" "-nostdinc++" "-resource-dir" "/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0" "-isysroot" "/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk" "-isysroot" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk" "-D" "_DEBUG" "-D" "__STDC_CONSTANT_MACROS" "-D" "__STDC_FORMAT_MACROS" "-D" "__STDC_LIMIT_MACROS" "-I" "/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile" "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile" "-I" "/Users/zequanwu/llvm-project/build/release/include" "-I" "/Users/zequanwu/llvm-project/llvm/include" "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/.." "-I" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include" "-D" "NDEBUG" "-D" "COMPILER_RT_HAS_ATOMICS=1" "-D" "COMPILER_RT_HAS_FCNTL_LCK=1" "-D" "COMPILER_RT_HAS_UNAME=1" "-U" "NDEBUG" "-internal-isystem" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include" "-internal-isystem" "/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include" "-internal-externc-isystem" "/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include" "-O3" "-Werror=date-time" "-Werror=unguarded-availability-new" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wwrite-strings" "-Wmissing-field-initializers" "-Wno-long-long" "-Wc++98-compat-extra-semi" "-Wimplicit-fallthrough" "-Wcovered-switch-default" "-Wdelete-non-virtual-dtor" "-Wstring-conversion" "-Wmisleading-indentation" "-Wall" "-Wno-unused-parameter" "-Wno-pedantic" "-pedantic" "-fconst-strings" "-fdebug-compilation-dir" "/Users/zequanwu/llvm-project/build/release" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-vectorize-loops" "-vectorize-slp" "-x" "c" "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"; 'clang(fe_expected_compiler_job)

More logs:

[Error - 5:31:11 PM] Request textDocument/documentLink failed.
[object Object]
[Error - 5:31:11 PM] Request textDocument/codeAction failed.
[object Object]
V[17:31:12.124] <<< {"id":81,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":19,"line":167},"start":{"character":19,"line":167}},"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[17:31:12.124] <-- textDocument/codeAction(81)
I[17:31:12.124] --> reply:textDocument/codeAction(81) 0 ms, error: invalid AST
V[17:31:12.124] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":81,"jsonrpc":"2.0"}

I[17:31:12.124] --> textDocument/clangd.fileStatus
V[17:31:12.124] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

[Error - 5:31:12 PM] Request textDocument/codeAction failed.

There are 13 entries in compilation_database.json with following file field:
"file": "/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfiling.c"

System information
Clangd version: clangd version 12.0.0 (https://github.com/clangd/llvm-project 8a844a3a321ea56da21af4d48433ad493b1bcfae)
OS: MacOS 11.3.1.
Editor: VS Code 1.58.1
Plugin: clangd

@kadircet
Copy link
Member

kadircet commented Aug 2, 2021

can you provide full clangd logs ? they should contain the compile flags received from your database. it seems like you are compiling for multiple architectures within a single compilation, I don't know what clang flag triggers that though.

@ZequanWu
Copy link
Author

ZequanWu commented Aug 5, 2021

I added --log=verbose as clangd argument in vscode.
log:

I[11:30:07.932] clangd version 12.0.0 (https://github.com/clangd/llvm-project 8a844a3a321ea56da21af4d48433ad493b1bcfae)
I[11:30:07.933] PID: 93803
I[11:30:07.933] Working directory: /Users/zequanwu/llvm-project
I[11:30:07.933] argv[0]: /Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/bin/clangd
I[11:30:07.933] argv[1]: --log=verbose
V[11:30:07.933] User config file is /Users/zequanwu/Library/Preferences/clangd/config.yaml
I[11:30:07.933] Starting LSP over stdin/stdout
V[11:30:07.934] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"1.1.0"},"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"foldingRange":{"dynamicRegistration":true,"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticHighlightingCapabilities":{"semanticHighlighting":true},"semanticTokens":{"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":true},"documentChanges":true,"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"Visual Studio Code","version":"1.58.2"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":[]},"locale":"en-us","processId":93794,"rootPath":"/Users/zequanwu/llvm-project","rootUri":"file:///Users/zequanwu/llvm-project","trace":"off","workspaceFolders":[{"name":"llvm-project","uri":"file:///Users/zequanwu/llvm-project"}]}}

I[11:30:07.934] <-- initialize(0)
I[11:30:07.934] Client supports legacy semanticHighlights notification and standard semanticTokens request, choosing the latter (no notifications).
V[11:30:07.934] Invoking /usr/bin/xcrun to find clang installation
V[11:30:07.955] Invoking /usr/bin/xcrun to find clang installation
I[11:30:07.975] --> reply:initialize(0) 40 ms
V[11:30:07.975] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"allCommitCharacters":[" ","\t","(",")","[","]","{","}","<",">",":",";",",","+","-","/","*","%","^","&","#","?",".","=","\"","'","|"],"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"implementationProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":[],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","enum","enumMember","type","dependent","dependent","namespace","typeParameter","concept","type","macro","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 12.0.0 (https://github.com/clangd/llvm-project 8a844a3a321ea56da21af4d48433ad493b1bcfae)"}}}

V[11:30:07.997] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[11:30:07.997] <-- initialized
V[11:30:07.999] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"c","text":"/*===- InstrProfilingFile.c - Write instrumentation to a file -------------===*\\\n|*\n|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n|* See https://llvm.org/LICENSE.txt for license information.\n|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n|*\n\\*===----------------------------------------------------------------------===*/\n\n#if !defined(__Fuchsia__)\n\n#include <assert.h>\n#include <errno.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#ifdef _MSC_VER\n/* For _alloca. */\n#include <malloc.h>\n#endif\n#if defined(_WIN32)\n#include \"WindowsMMap.h\"\n/* For _chsize_s */\n#include <io.h>\n#include <process.h>\n#else\n#include <sys/file.h>\n#include <sys/mman.h>\n#include <unistd.h>\n#if defined(__linux__)\n#include <sys/types.h>\n#endif\n#endif\n\n#include \"InstrProfiling.h\"\n#include \"InstrProfilingInternal.h\"\n#include \"InstrProfilingPort.h\"\n#include \"InstrProfilingUtil.h\"\n\n/* From where is profile name specified.\n * The order the enumerators define their\n * precedence. Re-order them may lead to\n * runtime behavior change. */\ntypedef enum ProfileNameSpecifier {\n  PNS_unknown = 0,\n  PNS_default,\n  PNS_command_line,\n  PNS_environment,\n  PNS_runtime_api\n} ProfileNameSpecifier;\n\nstatic const char *getPNSStr(ProfileNameSpecifier PNS) {\n  switch (PNS) {\n  case PNS_default:\n    return \"default setting\";\n  case PNS_command_line:\n    return \"command line\";\n  case PNS_environment:\n    return \"environment variable\";\n  case PNS_runtime_api:\n    return \"runtime API\";\n  default:\n    return \"Unknown\";\n  }\n}\n\n#define MAX_PID_SIZE 16\n/* Data structure holding the result of parsed filename pattern. */\ntypedef struct lprofFilename {\n  /* File name string possibly with %p or %h specifiers. */\n  const char *FilenamePat;\n  /* A flag indicating if FilenamePat's memory is allocated\n   * by runtime. */\n  unsigned OwnsFilenamePat;\n  const char *ProfilePathPrefix;\n  char PidChars[MAX_PID_SIZE];\n  char *TmpDir;\n  char Hostname[COMPILER_RT_MAX_HOSTLEN];\n  unsigned NumPids;\n  unsigned NumHosts;\n  /* When in-process merging is enabled, this parameter specifies\n   * the total number of profile data files shared by all the processes\n   * spawned from the same binary. By default the value is 1. If merging\n   * is not enabled, its value should be 0. This parameter is specified\n   * by the %[0-9]m specifier. For instance %2m enables merging using\n   * 2 profile data files. %1m is equivalent to %m. Also %m specifier\n   * can only appear once at the end of the name pattern. */\n  unsigned MergePoolSize;\n  ProfileNameSpecifier PNS;\n} lprofFilename;\n\nstatic lprofFilename lprofCurFilename = {0,   0, 0, {0}, NULL,\n                                         {0}, 0, 0, 0,   PNS_unknown};\n\nstatic int ProfileMergeRequested = 0;\nstatic int isProfileMergeRequested() { return ProfileMergeRequested; }\nstatic void setProfileMergeRequested(int EnableMerge) {\n  ProfileMergeRequested = EnableMerge;\n}\n\nstatic FILE *ProfileFile = NULL;\nstatic FILE *getProfileFile() { return ProfileFile; }\nstatic void setProfileFile(FILE *File) { ProfileFile = File; }\n\nCOMPILER_RT_VISIBILITY void __llvm_profile_set_file_object(FILE *File,\n                                                           int EnableMerge) {\n  if (__llvm_profile_is_continuous_mode_enabled()) {\n    PROF_WARN(\"__llvm_profile_set_file_object(fd=%d) not supported, because \"\n              \"continuous sync mode (%%c) is enabled\",\n              fileno(File));\n    return;\n  }\n  setProfileFile(File);\n  setProfileMergeRequested(EnableMerge);\n}\n\nstatic int getCurFilenameLength();\nstatic const char *getCurFilename(char *FilenameBuf, int ForceUseBuf);\nstatic unsigned doMerging() {\n  return lprofCurFilename.MergePoolSize || isProfileMergeRequested();\n}\n\n/* Return 1 if there is an error, otherwise return  0.  */\nstatic uint32_t fileWriter(ProfDataWriter *This, ProfDataIOVec *IOVecs,\n                           uint32_t NumIOVecs) {\n  uint32_t I;\n  FILE *File = (FILE *)This->WriterCtx;\n  char Zeroes[sizeof(uint64_t)] = {0};\n  for (I = 0; I < NumIOVecs; I++) {\n    if (IOVecs[I].Data) {\n      if (fwrite(IOVecs[I].Data, IOVecs[I].ElmSize, IOVecs[I].NumElm, File) !=\n          IOVecs[I].NumElm)\n        return 1;\n    } else if (IOVecs[I].UseZeroPadding) {\n      size_t BytesToWrite = IOVecs[I].ElmSize * IOVecs[I].NumElm;\n      while (BytesToWrite > 0) {\n        size_t PartialWriteLen =\n            (sizeof(uint64_t) > BytesToWrite) ? BytesToWrite : sizeof(uint64_t);\n        if (fwrite(Zeroes, sizeof(uint8_t), PartialWriteLen, File) !=\n            PartialWriteLen) {\n          return 1;\n        }\n        BytesToWrite -= PartialWriteLen;\n      }\n    } else {\n      if (fseek(File, IOVecs[I].ElmSize * IOVecs[I].NumElm, SEEK_CUR) == -1)\n        return 1;\n    }\n  }\n  return 0;\n}\n\n/* TODO: make buffer size controllable by an internal option, and compiler can pass the size\n   to runtime via a variable. */\nstatic uint32_t orderFileWriter(FILE *File, const uint32_t *DataStart) {\n  if (fwrite(DataStart, sizeof(uint32_t), INSTR_ORDER_FILE_BUFFER_SIZE, File) !=\n      INSTR_ORDER_FILE_BUFFER_SIZE)\n    return 1;\n  return 0;\n}\n\nstatic void initFileWriter(ProfDataWriter *This, FILE *File) {\n  This->Write = fileWriter;\n  This->WriterCtx = File;\n}\n\nCOMPILER_RT_VISIBILITY ProfBufferIO *\nlprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {\n  FreeHook = &free;\n  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);\n  VPBufferSize = BufferSz;\n  ProfDataWriter *fileWriter =\n      (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);\n  initFileWriter(fileWriter, File);\n  ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);\n  IO->OwnFileWriter = 1;\n  return IO;\n}\n\nstatic void setupIOBuffer() {\n  const char *BufferSzStr = 0;\n  BufferSzStr = getenv(\"LLVM_VP_BUFFER_SIZE\");\n  if (BufferSzStr && BufferSzStr[0]) {\n    VPBufferSize = atoi(BufferSzStr);\n    DynamicBufferIOBuffer = (uint8_t *)calloc(VPBufferSize, 1);\n  }\n}\n\n/* Get the size of the profile file. If there are any errors, print the\n * message under the assumption that the profile is being read for merging\n * purposes, and return -1. Otherwise return the file size in the inout param\n * \\p ProfileFileSize. */\nstatic int getProfileFileSizeForMerging(FILE *ProfileFile,\n                                        uint64_t *ProfileFileSize) {\n  if (fseek(ProfileFile, 0L, SEEK_END) == -1) {\n    PROF_ERR(\"Unable to merge profile data, unable to get size: %s\\n\",\n             strerror(errno));\n    return -1;\n  }\n  *ProfileFileSize = ftell(ProfileFile);\n\n  /* Restore file offset.  */\n  if (fseek(ProfileFile, 0L, SEEK_SET) == -1) {\n    PROF_ERR(\"Unable to merge profile data, unable to rewind: %s\\n\",\n             strerror(errno));\n    return -1;\n  }\n\n  if (*ProfileFileSize > 0 &&\n      *ProfileFileSize < sizeof(__llvm_profile_header)) {\n    PROF_WARN(\"Unable to merge profile data: %s\\n\",\n              \"source profile file is too small.\");\n    return -1;\n  }\n  return 0;\n}\n\n/* mmap() \\p ProfileFile for profile merging purposes, assuming that an\n * exclusive lock is held on the file and that \\p ProfileFileSize is the\n * length of the file. Return the mmap'd buffer in the inout variable\n * \\p ProfileBuffer. Returns -1 on failure. On success, the caller is\n * responsible for unmapping the mmap'd buffer in \\p ProfileBuffer. */\nstatic int mmapProfileForMerging(FILE *ProfileFile, uint64_t ProfileFileSize,\n                                 char **ProfileBuffer) {\n  *ProfileBuffer = mmap(NULL, ProfileFileSize, PROT_READ, MAP_SHARED | MAP_FILE,\n                        fileno(ProfileFile), 0);\n  if (*ProfileBuffer == MAP_FAILED) {\n    PROF_ERR(\"Unable to merge profile data, mmap failed: %s\\n\",\n             strerror(errno));\n    return -1;\n  }\n\n  if (__llvm_profile_check_compatibility(*ProfileBuffer, ProfileFileSize)) {\n    (void)munmap(*ProfileBuffer, ProfileFileSize);\n    PROF_WARN(\"Unable to merge profile data: %s\\n\",\n              \"source profile file is not compatible.\");\n    return -1;\n  }\n  return 0;\n}\n\n/* Read profile data in \\c ProfileFile and merge with in-memory\n   profile counters. Returns -1 if there is fatal error, otheriwse\n   0 is returned. Returning 0 does not mean merge is actually\n   performed. If merge is actually done, *MergeDone is set to 1.\n*/\nstatic int doProfileMerging(FILE *ProfileFile, int *MergeDone) {\n  uint64_t ProfileFileSize;\n  char *ProfileBuffer;\n\n  /* Get the size of the profile on disk. */\n  if (getProfileFileSizeForMerging(ProfileFile, &ProfileFileSize) == -1)\n    return -1;\n\n  /* Nothing to merge.  */\n  if (!ProfileFileSize)\n    return 0;\n\n  /* mmap() the profile and check that it is compatible with the data in\n   * the current image. */\n  if (mmapProfileForMerging(ProfileFile, ProfileFileSize, &ProfileBuffer) == -1)\n    return -1;\n\n  /* Now start merging */\n  if (__llvm_profile_merge_from_buffer(ProfileBuffer, ProfileFileSize)) {\n    PROF_ERR(\"%s\\n\", \"Invalid profile data to merge\");\n    (void)munmap(ProfileBuffer, ProfileFileSize);\n    return -1;\n  }\n\n  // Truncate the file in case merging of value profile did not happen to\n  // prevent from leaving garbage data at the end of the profile file.\n  (void)COMPILER_RT_FTRUNCATE(ProfileFile,\n                              __llvm_profile_get_size_for_buffer());\n\n  (void)munmap(ProfileBuffer, ProfileFileSize);\n  *MergeDone = 1;\n\n  return 0;\n}\n\n/* Create the directory holding the file, if needed. */\nstatic void createProfileDir(const char *Filename) {\n  size_t Length = strlen(Filename);\n  if (lprofFindFirstDirSeparator(Filename)) {\n    char *Copy = (char *)COMPILER_RT_ALLOCA(Length + 1);\n    strncpy(Copy, Filename, Length + 1);\n    __llvm_profile_recursive_mkdir(Copy);\n  }\n}\n\n/* Open the profile data for merging. It opens the file in r+b mode with\n * file locking.  If the file has content which is compatible with the\n * current process, it also reads in the profile data in the file and merge\n * it with in-memory counters. After the profile data is merged in memory,\n * the original profile data is truncated and gets ready for the profile\n * dumper. With profile merging enabled, each executable as well as any of\n * its instrumented shared libraries dump profile data into their own data file.\n*/\nstatic FILE *openFileForMerging(const char *ProfileFileName, int *MergeDone) {\n  FILE *ProfileFile = NULL;\n  int rc;\n\n  ProfileFile = getProfileFile();\n  if (ProfileFile) {\n    lprofLockFileHandle(ProfileFile);\n  } else {\n    createProfileDir(ProfileFileName);\n    ProfileFile = lprofOpenFileEx(ProfileFileName);\n  }\n  if (!ProfileFile)\n    return NULL;\n\n  rc = doProfileMerging(ProfileFile, MergeDone);\n  if (rc || (!*MergeDone && COMPILER_RT_FTRUNCATE(ProfileFile, 0L)) ||\n      fseek(ProfileFile, 0L, SEEK_SET) == -1) {\n    PROF_ERR(\"Profile Merging of file %s failed: %s\\n\", ProfileFileName,\n             strerror(errno));\n    fclose(ProfileFile);\n    return NULL;\n  }\n  return ProfileFile;\n}\n\nstatic FILE *getFileObject(const char *OutputName) {\n  FILE *File;\n  File = getProfileFile();\n  if (File != NULL) {\n    return File;\n  }\n\n  return fopen(OutputName, \"ab\");\n}\n\n/* Write profile data to file \\c OutputName.  */\nstatic int writeFile(const char *OutputName) {\n  int RetVal;\n  FILE *OutputFile;\n\n  int MergeDone = 0;\n  VPMergeHook = &lprofMergeValueProfData;\n  if (doMerging())\n    OutputFile = openFileForMerging(OutputName, &MergeDone);\n  else\n    OutputFile = getFileObject(OutputName);\n\n  if (!OutputFile)\n    return -1;\n\n  FreeHook = &free;\n  setupIOBuffer();\n  ProfDataWriter fileWriter;\n  initFileWriter(&fileWriter, OutputFile);\n  RetVal = lprofWriteData(&fileWriter, lprofGetVPDataReader(), MergeDone);\n\n  if (OutputFile == getProfileFile()) {\n    fflush(OutputFile);\n    if (doMerging()) {\n      lprofUnlockFileHandle(OutputFile);\n    }\n  } else {\n    fclose(OutputFile);\n  }\n\n  return RetVal;\n}\n\n/* Write order data to file \\c OutputName.  */\nstatic int writeOrderFile(const char *OutputName) {\n  int RetVal;\n  FILE *OutputFile;\n\n  OutputFile = fopen(OutputName, \"w\");\n\n  if (!OutputFile) {\n    PROF_WARN(\"can't open file with mode ab: %s\\n\", OutputName);\n    return -1;\n  }\n\n  FreeHook = &free;\n  setupIOBuffer();\n  const uint32_t *DataBegin = __llvm_profile_begin_orderfile();\n  RetVal = orderFileWriter(OutputFile, DataBegin);\n\n  fclose(OutputFile);\n  return RetVal;\n}\n\n#define LPROF_INIT_ONCE_ENV \"__LLVM_PROFILE_RT_INIT_ONCE\"\n\nstatic void truncateCurrentFile(void) {\n  const char *Filename;\n  char *FilenameBuf;\n  FILE *File;\n  int Length;\n\n  Length = getCurFilenameLength();\n  FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);\n  Filename = getCurFilename(FilenameBuf, 0);\n  if (!Filename)\n    return;\n\n  /* Only create the profile directory and truncate an existing profile once.\n   * In continuous mode, this is necessary, as the profile is written-to by the\n   * runtime initializer. */\n  int initialized = getenv(LPROF_INIT_ONCE_ENV) != NULL;\n  if (initialized)\n    return;\n#if defined(_WIN32)\n  _putenv(LPROF_INIT_ONCE_ENV \"=\" LPROF_INIT_ONCE_ENV);\n#else\n  setenv(LPROF_INIT_ONCE_ENV, LPROF_INIT_ONCE_ENV, 1);\n#endif\n\n  /* Create the profile dir (even if online merging is enabled), so that\n   * the profile file can be set up if continuous mode is enabled. */\n  createProfileDir(Filename);\n\n  /* By pass file truncation to allow online raw profile merging. */\n  if (lprofCurFilename.MergePoolSize)\n    return;\n\n  /* Truncate the file.  Later we'll reopen and append. */\n  File = fopen(Filename, \"w\");\n  if (!File)\n    return;\n  fclose(File);\n}\n\n/* Write a partial profile to \\p Filename, which is required to be backed by\n * the open file object \\p File. */\nstatic int writeProfileWithFileObject(const char *Filename, FILE *File) {\n  setProfileFile(File);\n  int rc = writeFile(Filename);\n  if (rc)\n    PROF_ERR(\"Failed to write file \\\"%s\\\": %s\\n\", Filename, strerror(errno));\n  setProfileFile(NULL);\n  return rc;\n}\n\nstatic void initializeProfileForContinuousMode(void) {\n#if defined(__APPLE__)\n  static const int continuousModeSupported = 1;\n  static const int useBiasVar = 0;\n  static const char* fileOpenMode = \"a+b\";\n  intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR = 0;\n  intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR = 0;\n#elif defined(__ELF__) || defined(_WIN32)\n#if defined(_WIN32)\n  COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;\n#if defined(_M_IX86) || defined(__i386__)\n#define WIN_SYM_PREFIX \"_\"\n#else\n#define WIN_SYM_PREFIX\n#endif\n#pragma comment(                                                               \\\n    linker, \"/alternatename:\" WIN_SYM_PREFIX INSTR_PROF_QUOTE(                 \\\n                INSTR_PROF_PROFILE_COUNTER_BIAS_VAR) \"=\" WIN_SYM_PREFIX        \\\n                INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR))\n#else\n  COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR\n      __attribute__((weak, alias(INSTR_PROF_QUOTE(\n                               INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR))));\n#endif\n  static const int continuousModeSupported = 1;\n  static const int useBiasVar = 1;\n  static const char* fileOpenMode = \"w+b\";\n#define INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR                            \\\n  INSTR_PROF_CONCAT(INSTR_PROF_PROFILE_COUNTER_BIAS_VAR, _default)\n  intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR = 0;\n  /* This symbol is defined by the compiler when runtime counter relocation is\n   * used and runtime provides a weak alias so we can check if it's defined.\n   */\n  void *BiasAddr = &INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;\n  void *BiasDefaultAddr = &INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR;\n  if (BiasAddr == BiasDefaultAddr) {\n    PROF_ERR(\"%s\\n\", \"__llvm_profile_counter_bias is undefined\");\n    return;\n  }\n#else\n  static const int useBiasVar = 0;\n  static const int continuousModeSupported = 0;\n#endif\n  if (!__llvm_profile_is_continuous_mode_enabled() || !continuousModeSupported)\n    return;\n\n  /* Get the sizes of various profile data sections. Taken from\n   * __llvm_profile_get_size_for_buffer(). */\n  const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();\n  const __llvm_profile_data *DataEnd = __llvm_profile_end_data();\n  const uint64_t *CountersBegin = __llvm_profile_begin_counters();\n  const uint64_t *CountersEnd = __llvm_profile_end_counters();\n  const char *NamesBegin = __llvm_profile_begin_names();\n  const char *NamesEnd = __llvm_profile_end_names();\n  const uint64_t NamesSize = (NamesEnd - NamesBegin) * sizeof(char);\n  uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);\n  uint64_t CountersSize = CountersEnd - CountersBegin;\n  const uint64_t CountersOffset =\n      sizeof(__llvm_profile_header) + (DataSize * sizeof(__llvm_profile_data));\n\n  int Length = getCurFilenameLength();\n  char *FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);\n  const char *Filename = getCurFilename(FilenameBuf, 0);\n  if (!Filename)\n    return;\n\n  FILE *File = NULL;\n  char *Profile = NULL;\n  off_t CurrentFileOffset = 0;\n  off_t OffsetModPage = 0;\n\n  /* Whether an exclusive lock on the profile must be dropped after init.\n   * Use a cleanup to warn if the unlock does not occur. */\n  COMPILER_RT_CLEANUP(warnIfNonZero) int ProfileRequiresUnlock = 0;\n\n  if (doMerging()) {\n    if (useBiasVar) {\n      File = lprofOpenFileEx(Filename);\n      if (!File)\n        return;\n\n      uint64_t ProfileFileSize = 0;\n      if (getProfileFileSizeForMerging(File, &ProfileFileSize) == -1) {\n        lprofUnlockFileHandle(File);\n        fclose(File);\n        return;\n      }\n\n      if (!ProfileFileSize) {\n        if (writeProfileWithFileObject(Filename, File) == -1) {\n          fclose(File);\n          return;\n        }\n      } else {\n        /* The merged profile has a non-zero length. Check that it is compatible\n         * with the data in this process. */\n        if (mmapProfileForMerging(File, ProfileFileSize, &Profile) == -1) {\n          fclose(File);\n          return;\n        }\n      }\n    } else {\n      /* We are merging profiles. Map the counter section as shared memory into\n       * the profile, i.e. into each participating process. An increment in one\n       * process should be visible to every other process with the same counter\n       * section mapped. */\n      File = lprofOpenFileEx(Filename);\n      if (!File)\n        return;\n\n      ProfileRequiresUnlock = 1;\n\n      uint64_t ProfileFileSize;\n      if (getProfileFileSizeForMerging(File, &ProfileFileSize) == -1) {\n        lprofUnlockFileHandle(File);\n        fclose(File);\n      }\n\n      if (ProfileFileSize == 0) {\n        /* Grow the profile so that mmap() can succeed.  Leak the file handle,\n         * as the file should stay open. */\n        if (writeProfileWithFileObject(Filename, File) != 0) {\n          lprofUnlockFileHandle(File);\n          fclose(File);\n        }\n      } else {\n        /* The merged profile has a non-zero length. Check that it is compatible\n         * with the data in this process. */\n        char *ProfileBuffer;\n        if (mmapProfileForMerging(File, ProfileFileSize, &ProfileBuffer) ==\n                -1 ||\n            munmap(ProfileBuffer, ProfileFileSize) == -1) {\n          lprofUnlockFileHandle(File);\n          fclose(File);\n        }\n      }\n    }\n  } else {\n    File = fopen(Filename, fileOpenMode);\n    if (!File)\n      return;\n    /* Check that the offset within the file is page-aligned. */\n    CurrentFileOffset = ftello(File);\n    unsigned PageSize = getpagesize();\n    OffsetModPage = CurrentFileOffset % PageSize;\n    if (OffsetModPage != 0) {\n      PROF_ERR(\"Continuous counter sync mode is enabled, but raw profile is not\"\n               \"page-aligned. CurrentFileOffset = %\" PRIu64 \", pagesz = %u.\\n\",\n               (uint64_t)CurrentFileOffset, PageSize);\n      return;\n    }\n    if (writeProfileWithFileObject(Filename, File) != 0) {\n      fclose(File);\n      return;\n    }\n  }\n\n  if (CountersSize > 0) {\n    if (useBiasVar) {\n      /* Get the file size. */\n      uint64_t FileSize = ftell(File);\n\n      /* Map the profile. */\n      Profile = (char *)mmap(NULL, FileSize, PROT_READ | PROT_WRITE, MAP_SHARED,\n                             fileno(File), 0);\n      if (Profile == MAP_FAILED) {\n        PROF_ERR(\"Unable to mmap profile: %s\\n\", strerror(errno));\n        return;\n      }\n      /* Update the profile fields based on the current mapping. */\n      INSTR_PROF_PROFILE_COUNTER_BIAS_VAR =\n          (intptr_t)Profile - (uintptr_t)CountersBegin + CountersOffset;\n\n      /* Return the memory allocated for counters to OS. */\n      lprofReleaseMemoryPagesToOS((uintptr_t)CountersBegin,\n                                  (uintptr_t)CountersEnd);\n    } else {\n      int Fileno = fileno(File);\n\n      /* Determine how much padding is needed before/after the counters and\n       * after the names. */\n      uint64_t PaddingBytesBeforeCounters, PaddingBytesAfterCounters,\n          PaddingBytesAfterNames;\n      __llvm_profile_get_padding_sizes_for_counters(\n          DataSize, CountersSize, NamesSize, &PaddingBytesBeforeCounters,\n          &PaddingBytesAfterCounters, &PaddingBytesAfterNames);\n\n      uint64_t PageAlignedCountersLength =\n          (CountersSize * sizeof(uint64_t)) + PaddingBytesAfterCounters;\n      uint64_t FileOffsetToCounters =\n          CurrentFileOffset + sizeof(__llvm_profile_header) +\n          (DataSize * sizeof(__llvm_profile_data)) + PaddingBytesBeforeCounters;\n\n      uint64_t *CounterMmap =\n          (uint64_t *)mmap((void *)CountersBegin, PageAlignedCountersLength,\n                           PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED,\n                           Fileno, FileOffsetToCounters);\n      if (CounterMmap != CountersBegin) {\n        PROF_ERR(\n            \"Continuous counter sync mode is enabled, but mmap() failed (%s).\\n\"\n            \"  - CountersBegin: %p\\n\"\n            \"  - PageAlignedCountersLength: %\" PRIu64 \"\\n\"\n            \"  - Fileno: %d\\n\"\n            \"  - FileOffsetToCounters: %\" PRIu64 \"\\n\",\n            strerror(errno), CountersBegin, PageAlignedCountersLength, Fileno,\n            FileOffsetToCounters);\n      }\n    }\n  }\n\n  if (ProfileRequiresUnlock) {\n    lprofUnlockFileHandle(File);\n    fclose(File);\n  }\n}\n\nstatic const char *DefaultProfileName = \"default.profraw\";\nstatic void resetFilenameToDefault(void) {\n  if (lprofCurFilename.FilenamePat && lprofCurFilename.OwnsFilenamePat) {\n    free((void *)lprofCurFilename.FilenamePat);\n  }\n  memset(&lprofCurFilename, 0, sizeof(lprofCurFilename));\n  lprofCurFilename.FilenamePat = DefaultProfileName;\n  lprofCurFilename.PNS = PNS_default;\n}\n\nstatic unsigned getMergePoolSize(const char *FilenamePat, int *I) {\n  unsigned J = 0, Num = 0;\n  for (;; ++J) {\n    char C = FilenamePat[*I + J];\n    if (C == 'm') {\n      *I += J;\n      return Num ? Num : 1;\n    }\n    if (C < '0' || C > '9')\n      break;\n    Num = Num * 10 + C - '0';\n\n    /* If FilenamePat[*I+J] is between '0' and '9', the next byte is guaranteed\n     * to be in-bound as the string is null terminated. */\n  }\n  return 0;\n}\n\n/* Assert that Idx does index past a string null terminator. Return the\n * result of the check. */\nstatic int checkBounds(int Idx, int Strlen) {\n  assert(Idx <= Strlen && \"Indexing past string null terminator\");\n  return Idx <= Strlen;\n}\n\n/* Parses the pattern string \\p FilenamePat and stores the result to\n * lprofcurFilename structure. */\nstatic int parseFilenamePattern(const char *FilenamePat,\n                                unsigned CopyFilenamePat) {\n  int NumPids = 0, NumHosts = 0, I;\n  char *PidChars = &lprofCurFilename.PidChars[0];\n  char *Hostname = &lprofCurFilename.Hostname[0];\n  int MergingEnabled = 0;\n  int FilenamePatLen = strlen(FilenamePat);\n\n  /* Clean up cached prefix and filename.  */\n  if (lprofCurFilename.ProfilePathPrefix)\n    free((void *)lprofCurFilename.ProfilePathPrefix);\n\n  if (lprofCurFilename.FilenamePat && lprofCurFilename.OwnsFilenamePat) {\n    free((void *)lprofCurFilename.FilenamePat);\n  }\n\n  memset(&lprofCurFilename, 0, sizeof(lprofCurFilename));\n\n  if (!CopyFilenamePat)\n    lprofCurFilename.FilenamePat = FilenamePat;\n  else {\n    lprofCurFilename.FilenamePat = strdup(FilenamePat);\n    lprofCurFilename.OwnsFilenamePat = 1;\n  }\n  /* Check the filename for \"%p\", which indicates a pid-substitution. */\n  for (I = 0; checkBounds(I, FilenamePatLen) && FilenamePat[I]; ++I) {\n    if (FilenamePat[I] == '%') {\n      ++I; /* Advance to the next character. */\n      if (!checkBounds(I, FilenamePatLen))\n        break;\n      if (FilenamePat[I] == 'p') {\n        if (!NumPids++) {\n          if (snprintf(PidChars, MAX_PID_SIZE, \"%ld\", (long)getpid()) <= 0) {\n            PROF_WARN(\"Unable to get pid for filename pattern %s. Using the \"\n                      \"default name.\",\n                      FilenamePat);\n            return -1;\n          }\n        }\n      } else if (FilenamePat[I] == 'h') {\n        if (!NumHosts++)\n          if (COMPILER_RT_GETHOSTNAME(Hostname, COMPILER_RT_MAX_HOSTLEN)) {\n            PROF_WARN(\"Unable to get hostname for filename pattern %s. Using \"\n                      \"the default name.\",\n                      FilenamePat);\n            return -1;\n          }\n      } else if (FilenamePat[I] == 't') {\n        lprofCurFilename.TmpDir = getenv(\"TMPDIR\");\n        if (!lprofCurFilename.TmpDir) {\n          PROF_WARN(\"Unable to get the TMPDIR environment variable, referenced \"\n                    \"in %s. Using the default path.\",\n                    FilenamePat);\n          return -1;\n        }\n      } else if (FilenamePat[I] == 'c') {\n        if (__llvm_profile_is_continuous_mode_enabled()) {\n          PROF_WARN(\"%%c specifier can only be specified once in %s.\\n\",\n                    FilenamePat);\n          return -1;\n        }\n#if defined(__APPLE__) || defined(__ELF__) || defined(_WIN32)\n        __llvm_profile_set_page_size(getpagesize());\n        __llvm_profile_enable_continuous_mode();\n#else\n        PROF_WARN(\"%s\", \"Continous mode is currently only supported for Mach-O,\"\n                        \" ELF and COFF formats.\");\n        return -1;\n#endif\n      } else {\n        unsigned MergePoolSize = getMergePoolSize(FilenamePat, &I);\n        if (!MergePoolSize)\n          continue;\n        if (MergingEnabled) {\n          PROF_WARN(\"%%m specifier can only be specified once in %s.\\n\",\n                    FilenamePat);\n          return -1;\n        }\n        MergingEnabled = 1;\n        lprofCurFilename.MergePoolSize = MergePoolSize;\n      }\n    }\n  }\n\n  lprofCurFilename.NumPids = NumPids;\n  lprofCurFilename.NumHosts = NumHosts;\n  return 0;\n}\n\nstatic void parseAndSetFilename(const char *FilenamePat,\n                                ProfileNameSpecifier PNS,\n                                unsigned CopyFilenamePat) {\n\n  const char *OldFilenamePat = lprofCurFilename.FilenamePat;\n  ProfileNameSpecifier OldPNS = lprofCurFilename.PNS;\n\n  /* The old profile name specifier takes precedence over the old one. */\n  if (PNS < OldPNS)\n    return;\n\n  if (!FilenamePat)\n    FilenamePat = DefaultProfileName;\n\n  if (OldFilenamePat && !strcmp(OldFilenamePat, FilenamePat)) {\n    lprofCurFilename.PNS = PNS;\n    return;\n  }\n\n  /* When PNS >= OldPNS, the last one wins. */\n  if (!FilenamePat || parseFilenamePattern(FilenamePat, CopyFilenamePat))\n    resetFilenameToDefault();\n  lprofCurFilename.PNS = PNS;\n\n  if (!OldFilenamePat) {\n    if (getenv(\"LLVM_PROFILE_VERBOSE\"))\n      PROF_NOTE(\"Set profile file path to \\\"%s\\\" via %s.\\n\",\n                lprofCurFilename.FilenamePat, getPNSStr(PNS));\n  } else {\n    if (getenv(\"LLVM_PROFILE_VERBOSE\"))\n      PROF_NOTE(\"Override old profile path \\\"%s\\\" via %s to \\\"%s\\\" via %s.\\n\",\n                OldFilenamePat, getPNSStr(OldPNS), lprofCurFilename.FilenamePat,\n                getPNSStr(PNS));\n  }\n\n  truncateCurrentFile();\n  if (__llvm_profile_is_continuous_mode_enabled())\n    initializeProfileForContinuousMode();\n}\n\n/* Return buffer length that is required to store the current profile\n * filename with PID and hostname substitutions. */\n/* The length to hold uint64_t followed by 3 digits pool id including '_' */\n#define SIGLEN 24\nstatic int getCurFilenameLength() {\n  int Len;\n  if (!lprofCurFilename.FilenamePat || !lprofCurFilename.FilenamePat[0])\n    return 0;\n\n  if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts ||\n        lprofCurFilename.TmpDir || lprofCurFilename.MergePoolSize))\n    return strlen(lprofCurFilename.FilenamePat);\n\n  Len = strlen(lprofCurFilename.FilenamePat) +\n        lprofCurFilename.NumPids * (strlen(lprofCurFilename.PidChars) - 2) +\n        lprofCurFilename.NumHosts * (strlen(lprofCurFilename.Hostname) - 2) +\n        (lprofCurFilename.TmpDir ? (strlen(lprofCurFilename.TmpDir) - 1) : 0);\n  if (lprofCurFilename.MergePoolSize)\n    Len += SIGLEN;\n  return Len;\n}\n\n/* Return the pointer to the current profile file name (after substituting\n * PIDs and Hostnames in filename pattern. \\p FilenameBuf is the buffer\n * to store the resulting filename. If no substitution is needed, the\n * current filename pattern string is directly returned, unless ForceUseBuf\n * is enabled. */\nstatic const char *getCurFilename(char *FilenameBuf, int ForceUseBuf) {\n  int I, J, PidLength, HostNameLength, TmpDirLength, FilenamePatLength;\n  const char *FilenamePat = lprofCurFilename.FilenamePat;\n\n  if (!lprofCurFilename.FilenamePat || !lprofCurFilename.FilenamePat[0])\n    return 0;\n\n  if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts ||\n        lprofCurFilename.TmpDir || lprofCurFilename.MergePoolSize ||\n        __llvm_profile_is_continuous_mode_enabled())) {\n    if (!ForceUseBuf)\n      return lprofCurFilename.FilenamePat;\n\n    FilenamePatLength = strlen(lprofCurFilename.FilenamePat);\n    memcpy(FilenameBuf, lprofCurFilename.FilenamePat, FilenamePatLength);\n    FilenameBuf[FilenamePatLength] = '\\0';\n    return FilenameBuf;\n  }\n\n  PidLength = strlen(lprofCurFilename.PidChars);\n  HostNameLength = strlen(lprofCurFilename.Hostname);\n  TmpDirLength = lprofCurFilename.TmpDir ? strlen(lprofCurFilename.TmpDir) : 0;\n  /* Construct the new filename. */\n  for (I = 0, J = 0; FilenamePat[I]; ++I)\n    if (FilenamePat[I] == '%') {\n      if (FilenamePat[++I] == 'p') {\n        memcpy(FilenameBuf + J, lprofCurFilename.PidChars, PidLength);\n        J += PidLength;\n      } else if (FilenamePat[I] == 'h') {\n        memcpy(FilenameBuf + J, lprofCurFilename.Hostname, HostNameLength);\n        J += HostNameLength;\n      } else if (FilenamePat[I] == 't') {\n        memcpy(FilenameBuf + J, lprofCurFilename.TmpDir, TmpDirLength);\n        FilenameBuf[J + TmpDirLength] = DIR_SEPARATOR;\n        J += TmpDirLength + 1;\n      } else {\n        if (!getMergePoolSize(FilenamePat, &I))\n          continue;\n        char LoadModuleSignature[SIGLEN + 1];\n        int S;\n        int ProfilePoolId = getpid() % lprofCurFilename.MergePoolSize;\n        S = snprintf(LoadModuleSignature, SIGLEN + 1, \"%\" PRIu64 \"_%d\",\n                     lprofGetLoadModuleSignature(), ProfilePoolId);\n        if (S == -1 || S > SIGLEN)\n          S = SIGLEN;\n        memcpy(FilenameBuf + J, LoadModuleSignature, S);\n        J += S;\n      }\n      /* Drop any unknown substitutions. */\n    } else\n      FilenameBuf[J++] = FilenamePat[I];\n  FilenameBuf[J] = 0;\n\n  return FilenameBuf;\n}\n\n/* Returns the pointer to the environment variable\n * string. Returns null if the env var is not set. */\nstatic const char *getFilenamePatFromEnv(void) {\n  const char *Filename = getenv(\"LLVM_PROFILE_FILE\");\n  if (!Filename || !Filename[0])\n    return 0;\n  return Filename;\n}\n\nCOMPILER_RT_VISIBILITY\nconst char *__llvm_profile_get_path_prefix(void) {\n  int Length;\n  char *FilenameBuf, *Prefix;\n  const char *Filename, *PrefixEnd;\n\n  if (lprofCurFilename.ProfilePathPrefix)\n    return lprofCurFilename.ProfilePathPrefix;\n\n  Length = getCurFilenameLength();\n  FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);\n  Filename = getCurFilename(FilenameBuf, 0);\n  if (!Filename)\n    return \"\\0\";\n\n  PrefixEnd = lprofFindLastDirSeparator(Filename);\n  if (!PrefixEnd)\n    return \"\\0\";\n\n  Length = PrefixEnd - Filename + 1;\n  Prefix = (char *)malloc(Length + 1);\n  if (!Prefix) {\n    PROF_ERR(\"Failed to %s\\n\", \"allocate memory.\");\n    return \"\\0\";\n  }\n  memcpy(Prefix, Filename, Length);\n  Prefix[Length] = '\\0';\n  lprofCurFilename.ProfilePathPrefix = Prefix;\n  return Prefix;\n}\n\nCOMPILER_RT_VISIBILITY\nconst char *__llvm_profile_get_filename(void) {\n  int Length;\n  char *FilenameBuf;\n  const char *Filename;\n\n  Length = getCurFilenameLength();\n  FilenameBuf = (char *)malloc(Length + 1);\n  if (!FilenameBuf) {\n    PROF_ERR(\"Failed to %s\\n\", \"allocate memory.\");\n    return \"\\0\";\n  }\n  Filename = getCurFilename(FilenameBuf, 1);\n  if (!Filename)\n    return \"\\0\";\n\n  return FilenameBuf;\n}\n\n/* This API initializes the file handling, both user specified\n * profile path via -fprofile-instr-generate= and LLVM_PROFILE_FILE\n * environment variable can override this default value.\n */\nCOMPILER_RT_VISIBILITY\nvoid __llvm_profile_initialize_file(void) {\n  const char *EnvFilenamePat;\n  const char *SelectedPat = NULL;\n  ProfileNameSpecifier PNS = PNS_unknown;\n  int hasCommandLineOverrider = (INSTR_PROF_PROFILE_NAME_VAR[0] != 0);\n\n  EnvFilenamePat = getFilenamePatFromEnv();\n  if (EnvFilenamePat) {\n    /* Pass CopyFilenamePat = 1, to ensure that the filename would be valid\n       at the  moment when __llvm_profile_write_file() gets executed. */\n    parseAndSetFilename(EnvFilenamePat, PNS_environment, 1);\n    return;\n  } else if (hasCommandLineOverrider) {\n    SelectedPat = INSTR_PROF_PROFILE_NAME_VAR;\n    PNS = PNS_command_line;\n  } else {\n    SelectedPat = NULL;\n    PNS = PNS_default;\n  }\n\n  parseAndSetFilename(SelectedPat, PNS, 0);\n}\n\n/* This method is invoked by the runtime initialization hook\n * InstrProfilingRuntime.o if it is linked in.\n */\nCOMPILER_RT_VISIBILITY\nvoid __llvm_profile_initialize(void) {\n  __llvm_profile_initialize_file();\n  if (!__llvm_profile_is_continuous_mode_enabled())\n    __llvm_profile_register_write_file_atexit();\n}\n\n/* This API is directly called by the user application code. It has the\n * highest precedence compared with LLVM_PROFILE_FILE environment variable\n * and command line option -fprofile-instr-generate=<profile_name>.\n */\nCOMPILER_RT_VISIBILITY\nvoid __llvm_profile_set_filename(const char *FilenamePat) {\n  if (__llvm_profile_is_continuous_mode_enabled())\n    return;\n  parseAndSetFilename(FilenamePat, PNS_runtime_api, 1);\n}\n\n/* The public API for writing profile data into the file with name\n * set by previous calls to __llvm_profile_set_filename or\n * __llvm_profile_override_default_filename or\n * __llvm_profile_initialize_file. */\nCOMPILER_RT_VISIBILITY\nint __llvm_profile_write_file(void) {\n  int rc, Length;\n  const char *Filename;\n  char *FilenameBuf;\n  int PDeathSig = 0;\n\n  if (lprofProfileDumped() || __llvm_profile_is_continuous_mode_enabled()) {\n    PROF_NOTE(\"Profile data not written to file: %s.\\n\", \"already written\");\n    return 0;\n  }\n\n  Length = getCurFilenameLength();\n  FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);\n  Filename = getCurFilename(FilenameBuf, 0);\n\n  /* Check the filename. */\n  if (!Filename) {\n    PROF_ERR(\"Failed to write file : %s\\n\", \"Filename not set\");\n    return -1;\n  }\n\n  /* Check if there is llvm/runtime version mismatch.  */\n  if (GET_VERSION(__llvm_profile_get_version()) != INSTR_PROF_RAW_VERSION) {\n    PROF_ERR(\"Runtime and instrumentation version mismatch : \"\n             \"expected %d, but get %d\\n\",\n             INSTR_PROF_RAW_VERSION,\n             (int)GET_VERSION(__llvm_profile_get_version()));\n    return -1;\n  }\n\n  // Temporarily suspend getting SIGKILL when the parent exits.\n  PDeathSig = lprofSuspendSigKill();\n\n  /* Write profile data to the file. */\n  rc = writeFile(Filename);\n  if (rc)\n    PROF_ERR(\"Failed to write file \\\"%s\\\": %s\\n\", Filename, strerror(errno));\n\n  // Restore SIGKILL.\n  if (PDeathSig == 1)\n    lprofRestoreSigKill();\n\n  return rc;\n}\n\nCOMPILER_RT_VISIBILITY\nint __llvm_profile_dump(void) {\n  if (!doMerging())\n    PROF_WARN(\"Later invocation of __llvm_profile_dump can lead to clobbering \"\n              \" of previously dumped profile data : %s. Either use %%m \"\n              \"in profile name or change profile name before dumping.\\n\",\n              \"online profile merging is not on\");\n  int rc = __llvm_profile_write_file();\n  lprofSetProfileDumped(1);\n  return rc;\n}\n\n/* Order file data will be saved in a file with suffx .order. */\nstatic const char *OrderFileSuffix = \".order\";\n\nCOMPILER_RT_VISIBILITY\nint __llvm_orderfile_write_file(void) {\n  int rc, Length, LengthBeforeAppend, SuffixLength;\n  const char *Filename;\n  char *FilenameBuf;\n  int PDeathSig = 0;\n\n  SuffixLength = strlen(OrderFileSuffix);\n  Length = getCurFilenameLength() + SuffixLength;\n  FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);\n  Filename = getCurFilename(FilenameBuf, 1);\n\n  /* Check the filename. */\n  if (!Filename) {\n    PROF_ERR(\"Failed to write file : %s\\n\", \"Filename not set\");\n    return -1;\n  }\n\n  /* Append order file suffix */\n  LengthBeforeAppend = strlen(Filename);\n  memcpy(FilenameBuf + LengthBeforeAppend, OrderFileSuffix, SuffixLength);\n  FilenameBuf[LengthBeforeAppend + SuffixLength] = '\\0';\n\n  /* Check if there is llvm/runtime version mismatch.  */\n  if (GET_VERSION(__llvm_profile_get_version()) != INSTR_PROF_RAW_VERSION) {\n    PROF_ERR(\"Runtime and instrumentation version mismatch : \"\n             \"expected %d, but get %d\\n\",\n             INSTR_PROF_RAW_VERSION,\n             (int)GET_VERSION(__llvm_profile_get_version()));\n    return -1;\n  }\n\n  // Temporarily suspend getting SIGKILL when the parent exits.\n  PDeathSig = lprofSuspendSigKill();\n\n  /* Write order data to the file. */\n  rc = writeOrderFile(Filename);\n  if (rc)\n    PROF_ERR(\"Failed to write file \\\"%s\\\": %s\\n\", Filename, strerror(errno));\n\n  // Restore SIGKILL.\n  if (PDeathSig == 1)\n    lprofRestoreSigKill();\n\n  return rc;\n}\n\nCOMPILER_RT_VISIBILITY\nint __llvm_orderfile_dump(void) {\n  int rc = __llvm_orderfile_write_file();\n  return rc;\n}\n\nstatic void writeFileWithoutReturn(void) { __llvm_profile_write_file(); }\n\nCOMPILER_RT_VISIBILITY\nint __llvm_profile_register_write_file_atexit(void) {\n  static int HasBeenRegistered = 0;\n\n  if (HasBeenRegistered)\n    return 0;\n\n  lprofSetupValueProfiler();\n\n  HasBeenRegistered = 1;\n  return atexit(writeFileWithoutReturn);\n}\n\n#endif\n","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c","version":1}}}

I[11:30:08.001] <-- textDocument/didOpen
V[11:30:08.020] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:08.020] <-- textDocument/documentSymbol(1)
V[11:30:08.020] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":42,"line":459},"start":{"character":42,"line":459}},"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:08.020] <-- textDocument/codeAction(2)
V[11:30:08.020] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:08.020] <-- textDocument/documentLink(3)
I[11:30:08.102] Loaded compilation database from /Users/zequanwu/llvm-project/compile_commands.json
V[11:30:08.102] Broadcasting compilation database from /Users/zequanwu/llvm-project
I[11:30:08.103] ASTWorker building file /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c version 1 with command 
[/Users/zequanwu/llvm-project/build/release]
/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile -I/Users/zequanwu/llvm-project/compiler-rt/lib/profile -I/Users/zequanwu/llvm-project/build/release/include -I/Users/zequanwu/llvm-project/llvm/include -I/Users/zequanwu/llvm-project/compiler-rt/lib/profile/.. -I/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include -fPIC -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wdelete-non-virtual-dtor -Wstring-conversion -Wmisleading-indentation -Wall -Wno-unused-parameter -O3 -DNDEBUG -arch i386 -arch x86_64 -arch arm64 -isysroot /Users/zequanwu/llvm-project/sysroot/MacOSX.sdk -stdlib=libc++ -mios-simulator-version-min=9.0 -isysroot /Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -fno-lto -fPIC -Wno-pedantic -DCOMPILER_RT_HAS_ATOMICS=1 -DCOMPILER_RT_HAS_FCNTL_LCK=1 -DCOMPILER_RT_HAS_UNAME=1 -nostdinc++ -UNDEBUG -o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_iossim.dir/InstrProfilingFile.c.o -c /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c -fsyntax-only -resource-dir=/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0
E[11:30:08.106] Could not build CompilerInvocation for file /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c
I[11:30:08.106] --> textDocument/publishDiagnostics
V[11:30:08.106] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"fe_expected_compiler_job","message":"Unable to handle compilation, expected exactly one compiler job in ' \"/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang\" \"-cc1\" \"-triple\" \"i386-apple-ios9.0.0-simulator\" \"-Wundef-prefix=TARGET_OS_\" \"-Werror=undef-prefix\" \"-fsyntax-only\" \"-disable-free\" \"-disable-llvm-verifier\" \"-discard-value-names\" \"-main-file-name\" \"InstrProfilingFile.c\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-mframe-pointer=all\" \"-fno-rounding-math\" \"-munwind-tables\" \"-faligned-alloc-unavailable\" \"-target-sdk-version=14.5\" \"-fcompatibility-qualified-id-block-type-checking\" \"-fvisibility-inlines-hidden-static-local-var\" \"-target-cpu\" \"yonah\" \"-tune-cpu\" \"generic\" \"-debugger-tuning=lldb\" \"-target-linker-version\" \"609.8\" \"-nostdinc++\" \"-resource-dir\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0\" \"-isysroot\" \"/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk\" \"-isysroot\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk\" \"-D\" \"_DEBUG\" \"-D\" \"__STDC_CONSTANT_MACROS\" \"-D\" \"__STDC_FORMAT_MACROS\" \"-D\" \"__STDC_LIMIT_MACROS\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/include\" \"-I\" \"/Users/zequanwu/llvm-project/llvm/include\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/..\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include\" \"-D\" \"NDEBUG\" \"-D\" \"COMPILER_RT_HAS_ATOMICS=1\" \"-D\" \"COMPILER_RT_HAS_FCNTL_LCK=1\" \"-D\" \"COMPILER_RT_HAS_UNAME=1\" \"-U\" \"NDEBUG\" \"-internal-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include\" \"-internal-isystem\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include\" \"-internal-externc-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include\" \"-O3\" \"-Werror=date-time\" \"-Werror=unguarded-availability-new\" \"-Wall\" \"-Wextra\" \"-Wno-unused-parameter\" \"-Wwrite-strings\" \"-Wmissing-field-initializers\" \"-Wno-long-long\" \"-Wc++98-compat-extra-semi\" \"-Wimplicit-fallthrough\" \"-Wcovered-switch-default\" \"-Wdelete-non-virtual-dtor\" \"-Wstring-conversion\" \"-Wmisleading-indentation\" \"-Wall\" \"-Wno-unused-parameter\" \"-Wno-pedantic\" \"-pedantic\" \"-fconst-strings\" \"-fdebug-compilation-dir\" \"/Users/zequanwu/llvm-project/build/release\" \"-ferror-limit\" \"19\" \"-stack-protector\" \"1\" \"-fblocks\" \"-fencode-extended-block-signature\" \"-fregister-global-dtors-with-atexit\" \"-fgnuc-version=4.2.1\" \"-fmax-type-align=16\" \"-vectorize-loops\" \"-vectorize-slp\" \"-x\" \"c\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c\";  \"/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang\" \"-cc1\" \"-triple\" \"x86_64-apple-ios9.0.0-simulator\" \"-Wundef-prefix=TARGET_OS_\" \"-Werror=undef-prefix\" \"-Wdeprecated-objc-isa-usage\" \"-Werror=deprecated-objc-isa-usage\" \"-Werror=implicit-function-declaration\" \"-fsyntax-only\" \"-disable-free\" \"-disable-llvm-verifier\" \"-discard-value-names\" \"-main-file-name\" \"InstrProfilingFile.c\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-mframe-pointer=all\" \"-fno-rounding-math\" \"-munwind-tables\" \"-faligned-alloc-unavailable\" \"-target-sdk-version=14.5\" \"-fcompatibility-qualified-id-block-type-checking\" \"-fvisibility-inlines-hidden-static-local-var\" \"-target-cpu\" \"core2\" \"-tune-cpu\" \"generic\" \"-debugger-tuning=lldb\" \"-target-linker-version\" \"609.8\" \"-nostdinc++\" \"-resource-dir\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0\" \"-isysroot\" \"/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk\" \"-isysroot\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk\" \"-D\" \"_DEBUG\" \"-D\" \"__STDC_CONSTANT_MACROS\" \"-D\" \"__STDC_FORMAT_MACROS\" \"-D\" \"__STDC_LIMIT_MACROS\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/include\" \"-I\" \"/Users/zequanwu/llvm-project/llvm/include\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/..\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include\" \"-D\" \"NDEBUG\" \"-D\" \"COMPILER_RT_HAS_ATOMICS=1\" \"-D\" \"COMPILER_RT_HAS_FCNTL_LCK=1\" \"-D\" \"COMPILER_RT_HAS_UNAME=1\" \"-U\" \"NDEBUG\" \"-internal-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include\" \"-internal-isystem\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include\" \"-internal-externc-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include\" \"-O3\" \"-Werror=date-time\" \"-Werror=unguarded-availability-new\" \"-Wall\" \"-Wextra\" \"-Wno-unused-parameter\" \"-Wwrite-strings\" \"-Wmissing-field-initializers\" \"-Wno-long-long\" \"-Wc++98-compat-extra-semi\" \"-Wimplicit-fallthrough\" \"-Wcovered-switch-default\" \"-Wdelete-non-virtual-dtor\" \"-Wstring-conversion\" \"-Wmisleading-indentation\" \"-Wall\" \"-Wno-unused-parameter\" \"-Wno-pedantic\" \"-pedantic\" \"-fconst-strings\" \"-fdebug-compilation-dir\" \"/Users/zequanwu/llvm-project/build/release\" \"-ferror-limit\" \"19\" \"-stack-protector\" \"1\" \"-fblocks\" \"-fencode-extended-block-signature\" \"-fregister-global-dtors-with-atexit\" \"-fgnuc-version=4.2.1\" \"-fmax-type-align=16\" \"-vectorize-loops\" \"-vectorize-slp\" \"-x\" \"c\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c\";  \"/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang\" \"-cc1\" \"-triple\" \"arm64-apple-ios9.0.0\" \"-Wundef-prefix=TARGET_OS_\" \"-Werror=undef-prefix\" \"-Wdeprecated-objc-isa-usage\" \"-Werror=deprecated-objc-isa-usage\" \"-Werror=implicit-function-declaration\" \"-fsyntax-only\" \"-disable-free\" \"-disable-llvm-verifier\" \"-discard-value-names\" \"-main-file-name\" \"InstrProfilingFile.c\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-mframe-pointer=non-leaf\" \"-fno-rounding-math\" \"-munwind-tables\" \"-faligned-alloc-unavailable\" \"-target-sdk-version=14.5\" \"-fcompatibility-qualified-id-block-type-checking\" \"-fvisibility-inlines-hidden-static-local-var\" \"-target-cpu\" \"apple-a7\" \"-target-feature\" \"+fp-armv8\" \"-target-feature\" \"+neon\" \"-target-feature\" \"+crypto\" \"-target-feature\" \"+zcm\" \"-target-feature\" \"+zcz\" \"-target-feature\" \"+sha2\" \"-target-feature\" \"+aes\" \"-target-abi\" \"darwinpcs\" \"-fallow-half-arguments-and-returns\" \"-debugger-tuning=lldb\" \"-target-linker-version\" \"609.8\" \"-nostdinc++\" \"-resource-dir\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0\" \"-isysroot\" \"/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk\" \"-isysroot\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk\" \"-D\" \"_DEBUG\" \"-D\" \"__STDC_CONSTANT_MACROS\" \"-D\" \"__STDC_FORMAT_MACROS\" \"-D\" \"__STDC_LIMIT_MACROS\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/include\" \"-I\" \"/Users/zequanwu/llvm-project/llvm/include\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/..\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include\" \"-D\" \"NDEBUG\" \"-D\" \"COMPILER_RT_HAS_ATOMICS=1\" \"-D\" \"COMPILER_RT_HAS_FCNTL_LCK=1\" \"-D\" \"COMPILER_RT_HAS_UNAME=1\" \"-U\" \"NDEBUG\" \"-internal-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include\" \"-internal-isystem\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include\" \"-internal-externc-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include\" \"-O3\" \"-Werror=date-time\" \"-Werror=unguarded-availability-new\" \"-Wall\" \"-Wextra\" \"-Wno-unused-parameter\" \"-Wwrite-strings\" \"-Wmissing-field-initializers\" \"-Wno-long-long\" \"-Wc++98-compat-extra-semi\" \"-Wimplicit-fallthrough\" \"-Wcovered-switch-default\" \"-Wdelete-non-virtual-dtor\" \"-Wstring-conversion\" \"-Wmisleading-indentation\" \"-Wall\" \"-Wno-unused-parameter\" \"-Wno-pedantic\" \"-pedantic\" \"-fconst-strings\" \"-fdebug-compilation-dir\" \"/Users/zequanwu/llvm-project/build/release\" \"-ferror-limit\" \"19\" \"-stack-protector\" \"1\" \"-fblocks\" \"-fencode-extended-block-signature\" \"-fregister-global-dtors-with-atexit\" \"-fgnuc-version=4.2.1\" \"-fmax-type-align=16\" \"-vectorize-loops\" \"-vectorize-slp\" \"-x\" \"c\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c\"; '","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c","version":1}}

V[11:30:08.109] ASTWorker rebuilding evicted AST to run DocumentSymbols: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c version 1
I[11:30:08.109] --> reply:textDocument/documentSymbol(1) 89 ms, error: invalid AST
V[11:30:08.109] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":1,"jsonrpc":"2.0"}

I[11:30:08.109] --> reply:textDocument/codeAction(2) 89 ms, error: invalid AST
V[11:30:08.109] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":2,"jsonrpc":"2.0"}

I[11:30:08.109] --> reply:textDocument/documentLink(3) 89 ms, error: invalid AST
[Error - 11:30:08 AM] Request textDocument/documentSymbol failed.
[object Object]
V[11:30:08.109] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":3,"jsonrpc":"2.0"}

I[11:30:08.109] --> textDocument/clangd.fileStatus
V[11:30:08.109] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

[Error - 11:30:08 AM] Request textDocument/codeAction failed.
[object Object]
[Error - 11:30:08 AM] Request textDocument/documentLink failed.
[object Object]
V[11:30:08.308] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:08.308] <-- textDocument/semanticTokens/full(4)
I[11:30:08.309] --> reply:textDocument/semanticTokens/full(4) 0 ms, error: invalid AST
V[11:30:08.309] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":4,"jsonrpc":"2.0"}

I[11:30:08.309] --> textDocument/clangd.fileStatus
[Error - 11:30:08 AM] Request textDocument/semanticTokens/full failed.
[object Object]
V[11:30:08.309] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

I[11:30:08.325] Loaded compilation database from /Users/zequanwu/llvm-project/build/release/compile_commands.json
V[11:30:08.364] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":42,"line":459},"start":{"character":42,"line":459}},"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:08.364] <-- textDocument/codeAction(5)
I[11:30:08.364] --> reply:textDocument/codeAction(5) 0 ms, error: invalid AST
V[11:30:08.364] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":5,"jsonrpc":"2.0"}

I[11:30:08.364] --> textDocument/clangd.fileStatus
V[11:30:08.364] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

[Error - 11:30:08 AM] Request textDocument/codeAction failed.
[object Object]
I[11:30:08.382] --> window/workDoneProgress/create(0)
V[11:30:08.382] >>> {"id":0,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"backgroundIndexProgress"}}

I[11:30:08.382] Enqueueing 5366 commands for indexing
V[11:30:08.383] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[11:30:08.383] <-- reply(0)
I[11:30:08.383] --> $/progress
V[11:30:08.383] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"begin","percentage":0,"title":"indexing"}}}

I[11:30:08.383] --> $/progress
V[11:30:08.383] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"report","message":"0/1","percentage":0}}}

V[11:30:09.277] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_sync.cpp
V[11:30:09.663] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerCrossOver.cpp
V[11:30:10.150] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
V[11:30:10.177] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_handlers_cxx.cpp
V[11:30:10.242] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
V[11:30:10.634] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp
V[11:30:10.664] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
V[11:30:10.988] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_type_traits.cpp
V[11:30:11.170] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cpp
V[11:30:11.209] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash.cpp
V[11:30:11.223] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtil.cpp
V[11:30:11.249] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
V[11:30:11.249] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
V[11:30:11.268] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
V[11:30:11.410] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_ignoreset.cpp
V[11:30:11.441] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c
V[11:30:11.456] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
V[11:30:11.461] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_malloc_win.cpp
V[11:30:11.530] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp
V[11:30:11.532] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_win.cpp
V[11:30:11.546] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
V[11:30:11.578] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
V[11:30:11.592] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_diag_standalone.cpp
V[11:30:11.639] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
V[11:30:11.673] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/lsan/lsan_common_mac.cpp
V[11:30:11.673] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/interception/interception_win.cpp
V[11:30:11.675] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
V[11:30:11.696] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_symbolize.cpp
V[11:30:11.706] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
V[11:30:11.773] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
V[11:30:11.826] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_fuchsia.cpp
V[11:30:11.826] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_report.cpp
V[11:30:11.981] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c
V[11:30:11.986] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/lsan/lsan_common_linux.cpp
V[11:30:11.988] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_descriptions.cpp
V[11:30:12.046] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac_libcdep.cpp
V[11:30:12.100] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
V[11:30:12.224] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
V[11:30:12.241] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_nolibc.cpp
V[11:30:12.287] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp
V[11:30:12.302] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
V[11:30:12.407] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
V[11:30:12.451] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_fuchsia.cpp
V[11:30:12.475] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
V[11:30:12.494] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_libdispatch.cpp
V[11:30:12.543] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_mman.cpp
V[11:30:12.623] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
V[11:30:12.628] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
V[11:30:12.732] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.cpp
V[11:30:12.960] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
V[11:30:12.979] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerSHA1.cpp
V[11:30:13.016] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
V[11:30:13.021] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
V[11:30:13.033] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
V[11:30:13.052] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cpp
V[11:30:13.079] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_thread.cpp
V[11:30:13.166] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:13.166] <-- textDocument/documentSymbol(6)
I[11:30:13.167] --> reply:textDocument/documentSymbol(6) 0 ms, error: invalid AST
V[11:30:13.167] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":6,"jsonrpc":"2.0"}

I[11:30:13.167] --> textDocument/clangd.fileStatus
V[11:30:13.167] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

[Error - 11:30:13 AM] Request textDocument/documentSymbol failed.
[object Object]
V[11:30:13.186] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

I[11:30:13.186] <-- textDocument/documentLink(7)
I[11:30:13.186] --> reply:textDocument/documentLink(7) 0 ms, error: invalid AST
V[11:30:13.186] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":7,"jsonrpc":"2.0"}

I[11:30:13.186] --> textDocument/clangd.fileStatus
V[11:30:13.186] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

[Error - 11:30:13 AM] Request textDocument/documentLink failed.
[object Object]
V[11:30:13.604] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp
V[11:30:13.728] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_init_standalone.cpp
V[11:30:13.779] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector2.cpp
V[11:30:13.949] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cpp
V[11:30:13.957] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
V[11:30:13.964] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerIO.cpp
V[11:30:14.201] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_flags.cpp
V[11:30:14.203] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
V[11:30:14.214] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_linux.cpp
V[11:30:14.222] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_preinit.cpp
V[11:30:14.230] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mutex.cpp
V[11:30:14.231] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_md5.cpp
V[11:30:14.311] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_win.cpp
V[11:30:14.347] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_vector_clock.cpp
V[11:30:14.412] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_suppressions.cpp
V[11:30:14.450] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
V[11:30:14.465] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
V[11:30:14.477] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingUtil.c
V[11:30:14.489] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_fd.cpp
V[11:30:14.494] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_flags.cpp
V[11:30:14.725] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
V[11:30:14.726] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
V[11:30:14.739] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
V[11:30:14.771] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_mutexset.cpp
V[11:30:14.782] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
V[11:30:14.784] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
V[11:30:14.888] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_proc.cpp
V[11:30:14.916] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerFork.cpp
V[11:30:14.931] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
V[11:30:15.007] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_stats.cpp
V[11:30:15.024] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_external.cpp
V[11:30:15.030] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_shadow_setup.cpp
V[11:30:15.257] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/stats/stats.cpp
V[11:30:15.282] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
V[11:30:15.301] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
V[11:30:15.325] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
V[11:30:15.382] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cpp
V[11:30:15.383] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_clock.cpp
V[11:30:15.384] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp
V[11:30:15.396] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/stats/stats_client.cpp
V[11:30:15.401] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp
V[11:30:15.410] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
V[11:30:15.444] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_globals_win.cpp
V[11:30:15.487] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingValue.c
V[11:30:15.490] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_malloc_mac.cpp
V[11:30:15.596] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/interception/interception_type_test.cpp
V[11:30:15.609] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_monitor.cpp
V[11:30:15.627] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interface_java.cpp
V[11:30:15.668] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
V[11:30:15.841] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/interception/interception_mac.cpp
V[11:30:15.842] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cpp
V[11:30:15.908] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
V[11:30:15.908] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_handlers.cpp
V[11:30:15.966] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
V[11:30:15.973] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
V[11:30:15.991] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp
V[11:30:15.999] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cpp
V[11:30:16.029] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp
V[11:30:16.049] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingMergeFile.c
V[11:30:16.075] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp
V[11:30:16.095] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interface.cpp
V[11:30:16.143] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_value.cpp
V[11:30:16.292] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_errors.cpp
V[11:30:16.416] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp
V[11:30:16.421] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_posix.cpp
V[11:30:16.445] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
V[11:30:16.482] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
V[11:30:16.485] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp
V[11:30:16.496] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
V[11:30:16.524] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_suppressions.cpp
V[11:30:16.527] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
V[11:30:16.538] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
V[11:30:16.727] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_debugging.cpp
V[11:30:16.734] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
V[11:30:16.742] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c
V[11:30:16.750] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
V[11:30:16.753] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp
V[11:30:16.762] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
V[11:30:16.846] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_memory_profile.cpp
V[11:30:16.865] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cpp
V[11:30:16.872] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_premap_shadow.cpp
V[11:30:17.151] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
V[11:30:17.165] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_coverage_win_sections.cpp
V[11:30:17.317] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_flags.cpp
V[11:30:17.318] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
V[11:30:17.337] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
V[11:30:17.420] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerIOWindows.cpp
V[11:30:17.529] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_stack.cpp
V[11:30:17.543] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.cpp
V[11:30:17.630] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
V[11:30:17.658] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
V[11:30:17.673] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
V[11:30:17.674] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
V[11:30:17.904] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_fuchsia.cpp
V[11:30:17.926] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp
V[11:30:17.932] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_mac.cpp
V[11:30:17.940] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
V[11:30:17.967] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_allocator_report.cpp
V[11:30:17.994] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_report.cpp
V[11:30:18.014] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_signals_standalone.cpp
V[11:30:18.036] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp
V[11:30:18.108] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_flags.cpp
V[11:30:18.142] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_poisoning.cpp
V[11:30:18.157] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp
V[11:30:18.175] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
V[11:30:18.184] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
V[11:30:18.188] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_mac.cpp
V[11:30:18.241] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_coverage_fuchsia.cpp
V[11:30:18.294] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_activation.cpp
V[11:30:18.315] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_init.cpp
V[11:30:18.335] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_mach_vm.cpp
V[11:30:18.364] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_stack_trace.cpp
V[11:30:18.374] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/interception/interception_linux.cpp
V[11:30:18.413] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_fake_stack.cpp
V[11:30:18.421] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_errno.cpp
V[11:30:18.451] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp
V[11:30:18.462] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sancov_flags.cpp
V[11:30:18.551] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingRuntime.cpp
V[11:30:18.560] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerMerge.cpp
V[11:30:18.590] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
V[11:30:18.673] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
V[11:30:18.708] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
V[11:30:18.712] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
V[11:30:18.764] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[{"code":"fe_expected_compiler_job","message":"Unable to handle compilation, expected exactly one compiler job in ' \"/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang\" \"-cc1\" \"-triple\" \"i386-apple-ios9.0.0-simulator\" \"-Wundef-prefix=TARGET_OS_\" \"-Werror=undef-prefix\" \"-fsyntax-only\" \"-disable-free\" \"-disable-llvm-verifier\" \"-discard-value-names\" \"-main-file-name\" \"InstrProfilingFile.c\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-mframe-pointer=all\" \"-fno-rounding-math\" \"-munwind-tables\" \"-faligned-alloc-unavailable\" \"-target-sdk-version=14.5\" \"-fcompatibility-qualified-id-block-type-checking\" \"-fvisibility-inlines-hidden-static-local-var\" \"-target-cpu\" \"yonah\" \"-tune-cpu\" \"generic\" \"-debugger-tuning=lldb\" \"-target-linker-version\" \"609.8\" \"-nostdinc++\" \"-resource-dir\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0\" \"-isysroot\" \"/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk\" \"-isysroot\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk\" \"-D\" \"_DEBUG\" \"-D\" \"__STDC_CONSTANT_MACROS\" \"-D\" \"__STDC_FORMAT_MACROS\" \"-D\" \"__STDC_LIMIT_MACROS\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/include\" \"-I\" \"/Users/zequanwu/llvm-project/llvm/include\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/..\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include\" \"-D\" \"NDEBUG\" \"-D\" \"COMPILER_RT_HAS_ATOMICS=1\" \"-D\" \"COMPILER_RT_HAS_FCNTL_LCK=1\" \"-D\" \"COMPILER_RT_HAS_UNAME=1\" \"-U\" \"NDEBUG\" \"-internal-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include\" \"-internal-isystem\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include\" \"-internal-externc-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include\" \"-O3\" \"-Werror=date-time\" \"-Werror=unguarded-availability-new\" \"-Wall\" \"-Wextra\" \"-Wno-unused-parameter\" \"-Wwrite-strings\" \"-Wmissing-field-initializers\" \"-Wno-long-long\" \"-Wc++98-compat-extra-semi\" \"-Wimplicit-fallthrough\" \"-Wcovered-switch-default\" \"-Wdelete-non-virtual-dtor\" \"-Wstring-conversion\" \"-Wmisleading-indentation\" \"-Wall\" \"-Wno-unused-parameter\" \"-Wno-pedantic\" \"-pedantic\" \"-fconst-strings\" \"-fdebug-compilation-dir\" \"/Users/zequanwu/llvm-project/build/release\" \"-ferror-limit\" \"19\" \"-stack-protector\" \"1\" \"-fblocks\" \"-fencode-extended-block-signature\" \"-fregister-global-dtors-with-atexit\" \"-fgnuc-version=4.2.1\" \"-fmax-type-align=16\" \"-vectorize-loops\" \"-vectorize-slp\" \"-x\" \"c\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c\";  \"/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang\" \"-cc1\" \"-triple\" \"x86_64-apple-ios9.0.0-simulator\" \"-Wundef-prefix=TARGET_OS_\" \"-Werror=undef-prefix\" \"-Wdeprecated-objc-isa-usage\" \"-Werror=deprecated-objc-isa-usage\" \"-Werror=implicit-function-declaration\" \"-fsyntax-only\" \"-disable-free\" \"-disable-llvm-verifier\" \"-discard-value-names\" \"-main-file-name\" \"InstrProfilingFile.c\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-mframe-pointer=all\" \"-fno-rounding-math\" \"-munwind-tables\" \"-faligned-alloc-unavailable\" \"-target-sdk-version=14.5\" \"-fcompatibility-qualified-id-block-type-checking\" \"-fvisibility-inlines-hidden-static-local-var\" \"-target-cpu\" \"core2\" \"-tune-cpu\" \"generic\" \"-debugger-tuning=lldb\" \"-target-linker-version\" \"609.8\" \"-nostdinc++\" \"-resource-dir\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0\" \"-isysroot\" \"/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk\" \"-isysroot\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk\" \"-D\" \"_DEBUG\" \"-D\" \"__STDC_CONSTANT_MACROS\" \"-D\" \"__STDC_FORMAT_MACROS\" \"-D\" \"__STDC_LIMIT_MACROS\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/include\" \"-I\" \"/Users/zequanwu/llvm-project/llvm/include\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/..\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include\" \"-D\" \"NDEBUG\" \"-D\" \"COMPILER_RT_HAS_ATOMICS=1\" \"-D\" \"COMPILER_RT_HAS_FCNTL_LCK=1\" \"-D\" \"COMPILER_RT_HAS_UNAME=1\" \"-U\" \"NDEBUG\" \"-internal-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include\" \"-internal-isystem\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include\" \"-internal-externc-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include\" \"-O3\" \"-Werror=date-time\" \"-Werror=unguarded-availability-new\" \"-Wall\" \"-Wextra\" \"-Wno-unused-parameter\" \"-Wwrite-strings\" \"-Wmissing-field-initializers\" \"-Wno-long-long\" \"-Wc++98-compat-extra-semi\" \"-Wimplicit-fallthrough\" \"-Wcovered-switch-default\" \"-Wdelete-non-virtual-dtor\" \"-Wstring-conversion\" \"-Wmisleading-indentation\" \"-Wall\" \"-Wno-unused-parameter\" \"-Wno-pedantic\" \"-pedantic\" \"-fconst-strings\" \"-fdebug-compilation-dir\" \"/Users/zequanwu/llvm-project/build/release\" \"-ferror-limit\" \"19\" \"-stack-protector\" \"1\" \"-fblocks\" \"-fencode-extended-block-signature\" \"-fregister-global-dtors-with-atexit\" \"-fgnuc-version=4.2.1\" \"-fmax-type-align=16\" \"-vectorize-loops\" \"-vectorize-slp\" \"-x\" \"c\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c\";  \"/Users/zequanwu/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang\" \"-cc1\" \"-triple\" \"arm64-apple-ios9.0.0\" \"-Wundef-prefix=TARGET_OS_\" \"-Werror=undef-prefix\" \"-Wdeprecated-objc-isa-usage\" \"-Werror=deprecated-objc-isa-usage\" \"-Werror=implicit-function-declaration\" \"-fsyntax-only\" \"-disable-free\" \"-disable-llvm-verifier\" \"-discard-value-names\" \"-main-file-name\" \"InstrProfilingFile.c\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-mframe-pointer=non-leaf\" \"-fno-rounding-math\" \"-munwind-tables\" \"-faligned-alloc-unavailable\" \"-target-sdk-version=14.5\" \"-fcompatibility-qualified-id-block-type-checking\" \"-fvisibility-inlines-hidden-static-local-var\" \"-target-cpu\" \"apple-a7\" \"-target-feature\" \"+fp-armv8\" \"-target-feature\" \"+neon\" \"-target-feature\" \"+crypto\" \"-target-feature\" \"+zcm\" \"-target-feature\" \"+zcz\" \"-target-feature\" \"+sha2\" \"-target-feature\" \"+aes\" \"-target-abi\" \"darwinpcs\" \"-fallow-half-arguments-and-returns\" \"-debugger-tuning=lldb\" \"-target-linker-version\" \"609.8\" \"-nostdinc++\" \"-resource-dir\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0\" \"-isysroot\" \"/Users/zequanwu/llvm-project/sysroot/MacOSX.sdk\" \"-isysroot\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk\" \"-D\" \"_DEBUG\" \"-D\" \"__STDC_CONSTANT_MACROS\" \"-D\" \"__STDC_FORMAT_MACROS\" \"-D\" \"__STDC_LIMIT_MACROS\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/projects/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile\" \"-I\" \"/Users/zequanwu/llvm-project/build/release/include\" \"-I\" \"/Users/zequanwu/llvm-project/llvm/include\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/..\" \"-I\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/../../include\" \"-D\" \"NDEBUG\" \"-D\" \"COMPILER_RT_HAS_ATOMICS=1\" \"-D\" \"COMPILER_RT_HAS_FCNTL_LCK=1\" \"-D\" \"COMPILER_RT_HAS_UNAME=1\" \"-U\" \"NDEBUG\" \"-internal-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/local/include\" \"-internal-isystem\" \"/Users/zequanwu/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/12.0.0/clangd_12.0.0/lib/clang/12.0.0/include\" \"-internal-externc-isystem\" \"/Applications/Xcode_12.5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include\" \"-O3\" \"-Werror=date-time\" \"-Werror=unguarded-availability-new\" \"-Wall\" \"-Wextra\" \"-Wno-unused-parameter\" \"-Wwrite-strings\" \"-Wmissing-field-initializers\" \"-Wno-long-long\" \"-Wc++98-compat-extra-semi\" \"-Wimplicit-fallthrough\" \"-Wcovered-switch-default\" \"-Wdelete-non-virtual-dtor\" \"-Wstring-conversion\" \"-Wmisleading-indentation\" \"-Wall\" \"-Wno-unused-parameter\" \"-Wno-pedantic\" \"-pedantic\" \"-fconst-strings\" \"-fdebug-compilation-dir\" \"/Users/zequanwu/llvm-project/build/release\" \"-ferror-limit\" \"19\" \"-stack-protector\" \"1\" \"-fblocks\" \"-fencode-extended-block-signature\" \"-fregister-global-dtors-with-atexit\" \"-fgnuc-version=4.2.1\" \"-fmax-type-align=16\" \"-vectorize-loops\" \"-vectorize-slp\" \"-x\" \"c\" \"/Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c\"; '","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"}]},"range":{"end":{"character":0,"line":1146},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}}

V[11:30:18.764] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerExtFunctionsDlsym.cpp
I[11:30:18.764] <-- textDocument/codeAction(8)
I[11:30:18.764] --> reply:textDocument/codeAction(8) 0 ms, error: invalid AST
V[11:30:18.764] >>> {"error":{"code":-32001,"message":"invalid AST"},"id":8,"jsonrpc":"2.0"}

I[11:30:18.764] --> textDocument/clangd.fileStatus
V[11:30:18.764] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/zequanwu/llvm-project/compiler-rt/lib/profile/InstrProfilingFile.c"}}

[Error - 11:30:18 AM] Request textDocument/codeAction failed.
[object Object]
V[11:30:18.765] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
V[11:30:18.785] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
V[11:30:18.789] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/lsan/lsan_common.cpp
V[11:30:18.846] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/asan/asan_globals.cpp
V[11:30:18.955] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_debugging.cpp
V[11:30:18.974] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
V[11:30:18.976] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_solaris.cpp
V[11:30:18.979] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
V[11:30:19.013] Failed to load shard: /Users/zequanwu/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp

@kadircet
Copy link
Member

kadircet commented Aug 5, 2021

As I've suspected, you've got -arch i386 -arch x86_64 -arch arm64 in your compile flags which results in 3 compilation actions.
We should drop multiple arch options in clangd, but the question is which one to keep (or whether to keep any at all).

In the meantime you can workaround the issue by putting a .clangd file in your project root with contents:

CompileFlags:
  Remove: [-arch]

This will drop all -arch flags and make clang default to your host's architecture. If you want to edit code while targeting a specific architecture you can change contents to (while changing foo with your desired arch):

CompileFlags:
  Remove: [-arch]
  Add: [-arch, foo]

@ZequanWu
Copy link
Author

ZequanWu commented Aug 5, 2021

Thanks, that works.

@sam-mccall
Copy link
Member

Yeah exactly which is best is fuzzy (the example shows "first" isn't ideal), but clearly anything is better than what we do now.

BTW the easiest way to repro this on non-mac is adding a mac target (exact target doesn't matter).
compile_flags.txt:

--target=arm64e-apple-darwin20
-arch
i386
-arch
x86_64

@kadircet
Copy link
Member

kadircet commented Aug 6, 2021 via email

sam-mccall added a commit to llvm/llvm-project that referenced this issue Aug 12, 2021
…ble job.

This happens in createInvocationWithCommandLine but only clangd currently passes
ShouldRecoverOnErorrs (sic).

One cause of this (with correct command) is several -arch arguments for mac
multi-arch support.

Fixes clangd/clangd#827

Differential Revision: https://reviews.llvm.org/D107632
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
This patch strips all the arch options in case of multiple ones. As it
results in multiple compiler jobs, which clangd cannot handle.

It doesn't pick any over the others as it is unclear which one the user wants
and defaulting to host architecture seems less surprising. Users also have the
ability to explicitly specify the architecture they want via clangd config
files.

Fixes clangd/clangd#827.

Differential Revision: https://reviews.llvm.org/D107634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants