LLVM build fix for VS2017 RC (19.00.24215.1)

2017-01-06 Thread Andrew Rogers via cfe-commits
Hi,

I just downloaded VS2017 RC on a clean Win10 machine, checked out LLVM &
clang and tried to build clang.

The following code in
\tools\clang\utils\TableGen\ClangDiagnosticsEmitter.cpp failed to compile:

RecordSet DiagsInPedanticSet;
RecordSet GroupsInPedanticSet;
InferPedantic inferPedantic(DGParentMap, Diags, DiagGroups,
DiagsInGroup);
inferPedantic.compute(&DiagsInPedanticSet, &GroupsInPedanticSet);
auto &PedDiags = DiagsInGroup["pedantic"];
// Put the diagnostics into a deterministic order.
RecordVec DiagsInPedantic(DiagsInPedanticSet.begin(),
  DiagsInPedanticSet.end());

because the RecordSet iterators created by DiagsInPedanticSet.begin() and
DiagsInPedanticSet.end() are not const iterators and the VS2017 vector code
tries to use (binary) operator* with one of these iterators, and expects  to
get a const ValueT but the compiler can currently only resolve the non-const
operator* on the DenseSet iterator. The patch implements operator* and
operator-> for const ValueT on the iterators in include/llvm/ADT/DenseSet.h.

The attached patch resolves the VS2017 build failure for me - do I need to
run further checks before someone can review/commit it for me?

Note: the fix is in the LLVM repository, not the clang repository.

Thanks, Andrew R


llvm-2017-build-fix.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [cfe-dev] Testcase for LLVM PR9350

2017-01-06 Thread Andrew Rogers via cfe-commits
Hi,

 

This is a (tested!) patch to add checks that both pre-increment and 
pre-decrement don’t overflow, for both char and short integer types (since 
they’re both narrower than int), as per the problem fixed in PR9350.

 

Thanks, Andrew R

 

From: Friedman, Eli [mailto:efrie...@codeaurora.org] 
Sent: 4 January 2017 6:42 pm
To: andrew.rog...@cantab.net; cfe-...@lists.llvm.org
Subject: Re: [cfe-dev] Testcase for LLVM PR9350

 

On 1/3/2017 2:28 PM, via cfe-dev wrote:

Hi clang devs, 

 

I was looking at PR9350 and saw that Eli added a test to check LLVM doesn't 
overflow on [signed] char increment:

 

--- cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:43:30 126815
+++ cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:49:12 126816
@@ -50,11 +50,17 @@
   // TRAPV_HANDLER: foo(
   --a;
   
-  
   // -fwrapv should turn off inbounds for GEP's, PR9256
   extern int* P;
   ++P;
   // DEFAULT: getelementptr inbounds i32*
   // WRAPV: getelementptr i32*
   // TRAPV: getelementptr inbounds i32*
+
+  // PR9350: char increment never overflows.
+  extern volatile signed char PR9350;
+  // DEFAULT: add i8 {{.*}}, 1
+  // WRAPV: add i8 {{.*}}, 1
+  // TRAPV: add i8 {{.*}}, 1
+  ++PR9350;
}

 

http://llvm.org/viewvc/llvm-project?view=revision 
 
&revision=126816

 

Presumably the logic about promotion to int applies the same as in the argument 
John gave in PR9350 since 6.5.3.1 §3 says "the prefix -- operator is analogous 
to the prefix ++ operator, except that the value of the operand is decremented".

 

Would it therefore make sense to add the equivalent test to integer-overflow.c 
that decrement of a [signed] char didn't ever cause underflow:

 

  // DEFAULT: sub i8 {{.*}}, 1
  // WRAPV: sub i8 {{.*}}, 1
  // TRAPV: sub i8 {{.*}}, 1
  --PR9350;

 


Yes, it probably makes sense to add a testcase like that.  Patch welcome.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project


llvm-pr9350-test-improvement.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] properly guard dump methods in Support lib classes (PR #139938)

2025-05-14 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz created 
https://github.com/llvm/llvm-project/pull/139938

## Purpose
Add proper preprocessor guards for all `dump()` methods in the LLVM support 
library. This change ensures these methods are not part of the public ABI for 
release builds.

## Overview
* Annotates all `dump` methods in Support and ADT source with the 
`LLVM_DUMP_METHOD` macro. 
* Conditionally includes all `dump` method definitions in Support and ADT 
source so they are only present on debug/assert builds and when 
`LLVM_ENABLE_DUMP` is explicitly defined. 

NOTE: For many of these `dump` methods, the implementation was already properly 
guarded but the declaration in the header file was not.

## Background
This PR is a redo of #139804 with some changes to fix clang and unit test build 
breaks.

This issue was raised in comments on #136629. I am addressing it as a separate 
change since it is independent from the changes being made in that PR.

According to [this 
documentation](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Compiler.h#L637),
 `dump` methods should be annotated with `LLVM_DUMP_METHOD` and conditionally 
included as follows:
```
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void dump() const;
#endif
```

## Validation
* Local release build succeeds.
* CI



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] properly guard dump methods in Support lib classes (PR #139938)

2025-05-14 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz ready_for_review 
https://github.com/llvm/llvm-project/pull/139938
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] properly guard dump methods in Support lib classes (PR #139938)

2025-05-19 Thread Andrew Rogers via cfe-commits

andrurogerz wrote:

> This approach causes issues when LLVM is built in release mode (with 
> -DNDEBUG) and external projects build against it in debug mode (with 
> -UNDEBUG). I appreciate that it does what the comment says should be done, 
> but I think what the comment says is wrong. Specifically, I now see in our 
> own project:

Taking a look now. Will revert today if there isn't a straight-forward fix.

https://github.com/llvm/llvm-project/pull/139938
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] properly guard dump methods in Support lib classes (PR #139938)

2025-05-19 Thread Andrew Rogers via cfe-commits

andrurogerz wrote:

Ok, this link error makes sense when building an external project in debug mode 
against an llvm release build. I didn't realize that was a thing, but it makes 
sense so my mistake.

The issue is that we must only guard `dump` methods (that have definitions 
outside of the header) if they are not referenced in a public header, even if 
that reference is also guarded. In this example, the static helper method 
`llvm::ScaledNumberBase::dumpllvm::ScaledNumberBase::dump` is called by another 
`dump` method in `llvm/Support/ScaledNumber.h`. I think this issue is safe 
enough to fix-forward, but I will revert if not. I'll get a PR up shortly 
either way.

https://github.com/llvm/llvm-project/pull/139938
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] properly guard dump methods in Support lib classes (PR #139938)

2025-05-19 Thread Andrew Rogers via cfe-commits

andrurogerz wrote:

@hvdijk thank you for the clear repro steps; I was able to reproduce the issue 
locally and verify that #140574 fixes it. It is a partial revert of only the 
`ScaledNumber` source changes; the rest of the changes in this PR do not appear 
to have the same issue. 

https://github.com/llvm/llvm-project/pull/139938
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] minor fixes for clang-cl Windows DLL build (PR #144386)

2025-06-16 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz created 
https://github.com/llvm/llvm-project/pull/144386

## Purpose

This patch makes a minor changes to LLVM and Clang so that LLVM can be built as 
a Windows DLL with `clang-cl`. These changes were not required for building a 
Windows DLL with MSVC.

## Background

The Windows DLL effort is tracked in #109483. Additional context is provided in 
[this 
discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307),
 and documentation for `LLVM_ABI` and related annotations is found in the LLVM 
repo 
[here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).
  

## Overview
Specific changes made in this patch:
- Remove `constexpr` fields that reference DLL exported symbols. These symbols 
cannot be resolved at compile time when building a Windows DLL using 
`clang-cl`, so they cannot be `constexpr`. Instead, they are made `const` and 
initialized in the implementation file rather than at declaration in the header.
- Annotate symbols now defined out-of-line with `LLVM_ABI` so they are exported 
when building as a shared library.
- Explicitly add default copy assignment operator for `ELFFile` to resolve a 
compiler warning.

## Validation

Local builds and tests to validate cross-platform compatibility. This included 
llvm, clang, and lldb on the following configurations:

- Windows with MSVC
- Windows with Clang
- Linux with GCC
- Linux with Clang
- Darwin with Clang

>From 50a64efe33d38b2cd8cc268908dd6bcbd55c0c97 Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Tue, 10 Jun 2025 12:49:55 -0700
Subject: [PATCH 1/2] constexpr fixes for clang-cl Windows DLL build

---
 .../lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp  |  2 +-
 llvm/include/llvm/BinaryFormat/Dwarf.h   | 12 ++--
 llvm/lib/BinaryFormat/Dwarf.cpp  | 12 
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp 
b/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
index 836fc375809ad..f965bfb590d80 100644
--- a/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
@@ -92,7 +92,7 @@ void Z3CrosscheckVisitor::finalizeVisitor(BugReporterContext 
&BRC,
   };
 
   auto AttemptOnce = [&](const llvm::SMTSolverRef &Solver) -> Z3Result {
-constexpr auto getCurrentTime = llvm::TimeRecord::getCurrentTime;
+auto getCurrentTime = llvm::TimeRecord::getCurrentTime;
 unsigned InitialRLimit = GetUsedRLimit(Solver);
 double Start = getCurrentTime(/*Start=*/true).getWallTime();
 std::optional IsSAT = Solver->check();
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h 
b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 2ead62025efa7..231b7ac17d75f 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -1191,32 +1191,32 @@ template  struct EnumTraits : public 
std::false_type {};
 
 template <> struct EnumTraits : public std::true_type {
   static constexpr char Type[3] = "AT";
-  static constexpr StringRef (*StringFn)(unsigned) = &AttributeString;
+  LLVM_ABI static StringRef (*const StringFn)(unsigned);
 };
 
 template <> struct EnumTraits : public std::true_type {
   static constexpr char Type[5] = "FORM";
-  static constexpr StringRef (*StringFn)(unsigned) = &FormEncodingString;
+  LLVM_ABI static StringRef (*const StringFn)(unsigned);
 };
 
 template <> struct EnumTraits : public std::true_type {
   static constexpr char Type[4] = "IDX";
-  static constexpr StringRef (*StringFn)(unsigned) = &IndexString;
+  LLVM_ABI static StringRef (*const StringFn)(unsigned);
 };
 
 template <> struct EnumTraits : public std::true_type {
   static constexpr char Type[4] = "TAG";
-  static constexpr StringRef (*StringFn)(unsigned) = &TagString;
+  LLVM_ABI static StringRef (*const StringFn)(unsigned);
 };
 
 template <> struct EnumTraits : public std::true_type {
   static constexpr char Type[4] = "LNS";
-  static constexpr StringRef (*StringFn)(unsigned) = &LNStandardString;
+  LLVM_ABI static StringRef (*const StringFn)(unsigned);
 };
 
 template <> struct EnumTraits : public std::true_type {
   static constexpr char Type[3] = "OP";
-  static constexpr StringRef (*StringFn)(unsigned) = &OperationEncodingString;
+  LLVM_ABI static StringRef (*const StringFn)(unsigned);
 };
 
 inline uint64_t computeTombstoneAddress(uint8_t AddressByteSize) {
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index b9b10a541b263..0d17dc175fed9 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -911,6 +911,18 @@ StringRef llvm::dwarf::RLEString(unsigned RLE) {
   }
 }
 
+StringRef (*const llvm::dwarf::EnumTraits::StringFn)(unsigned) = 
TagString;
+StringRef (*const llvm::dwarf::EnumTraits::StringFn)(unsigned) =
+AttributeString;
+StringRef (*const llvm::dwarf::EnumTraits::StringFn)(unsigned) =
+Fo

[clang] [llvm] [llvm] minor fixes for clang-cl Windows DLL build (PR #144386)

2025-06-16 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz ready_for_review 
https://github.com/llvm/llvm-project/pull/144386
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm] minor fixes for clang-cl Windows DLL build (PR #144386)

2025-06-17 Thread Andrew Rogers via cfe-commits

andrurogerz wrote:

> I think that the clang semantics are technically correct

Yes,  agreed. And in case it wasn't clear, this is `clang` behavior and is not 
specific to `clang-cl`.

https://github.com/llvm/llvm-project/pull/144386
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [llvm] annotate remaining LLVM interfaces for DLL export (PR #144746)

2025-06-18 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/144746
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [llvm] annotate remaining LLVM interfaces for DLL export (PR #144746)

2025-06-18 Thread Andrew Rogers via cfe-commits

andrurogerz wrote:

@compnerd, @vgvassilev other than the annotations for llvm-c and Demangle 
libraries, which require new annotation macros, this is the bulk of the 
remaining annotation code-mod. Please review at your convenience, thanks!

https://github.com/llvm/llvm-project/pull/144746
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [llvm] annotate remaining LLVM interfaces for DLL export (PR #144746)

2025-06-18 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz ready_for_review 
https://github.com/llvm/llvm-project/pull/144746
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [llvm] annotate remaining LLVM interfaces for DLL export (PR #144746)

2025-06-18 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz created 
https://github.com/llvm/llvm-project/pull/144746

## Purpose

This patch is one in a series of code-mods that annotate LLVM’s public 
interface for export. This patch annotates the remaining LLVM interface that 
was missed in, or modified since, previous patches. The annotations currently 
have no meaningful impact on the LLVM build; however, they are  a prerequisite 
to support an LLVM Windows DLL (shared library) build.

## Background

This effort is tracked in #109483. Additional context is provided in [this 
discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307),
 and documentation for `LLVM_ABI` and related annotations is found in the LLVM 
repo 
[here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).
  

## Overview

The bulk of these changes were generated automatically using the [Interface 
Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed 
formatting with `git clang-format`.

The following manual adjustments were also applied after running IDS:
- Remove local `extern` declarations of `llvm::PrintPipelinePasses` because it 
is already correctly declared with an `LLVM_ABI` annotation in 
`llvm\Passes\PassBuilder.h`. Leaving these declarations results in a gcc 
compile warning unless they are also annotated with `LLVM_ABI`.
- Similarly, remove local `extern` declarations of `ProfileSummaryCutoffHot` 
and `UseContextLessSummary` from `llvm/tools/llvm-profgen/ProfileGenerator.cpp` 
since they are declared with `LLVM_ABI` in `llvm\ProfileData\ProfileCommon.h`.
- Annotate the private method `IEEEFloat::addOrSubtractSignificand` with 
`LLVM_ABI` because it is used by a unit test friend class.
- Annotate several `friend` function declarations with `LLVM_ABI_FRIEND` since 
the corresponding function declarations are annotated with `LLVM_ABI` (required 
by MSVC).
- Explicitly instantiate `CallLowering::setArgFlags` template method instances 
in `CodeGen/GlobalISel/CallLowering.h` and annotate them with `LLVM_ABI`. These 
methods are already explicitly instantiated in 
`lib/CodeGen/GlobalISel/CallLowering.cpp` but were not declared in the header.
- Add default ctor and delete copy ctor and copy assignment operator in 
`Telemetry::Manager`. This is required because the class is now annotated with 
`LLVM_ABI` and cannot otherwise be fully instantiated for export.
- Annotate a small number of symbol declarations in implementation files with 
`LLVM_ABI`. These symbols are referenced by tools/tests but not declared in 
headers.
- Annotate several explicit template instantiations with `LLVM_EXPORT_TEMPLATE`.

## Validation

Local builds and tests to validate cross-platform compatibility. This included 
llvm, clang, and lldb on the following configurations:

- Windows with MSVC
- Windows with Clang
- Linux with GCC
- Linux with Clang
- Darwin with Clang

>From 4242b976d58b47dab09424e23127a953df3cc342 Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Tue, 17 Jun 2025 10:18:06 -0700
Subject: [PATCH 1/3] [llvm] annotate remaining interfaces for DLL export

---
 llvm/include/llvm/Analysis/DXILResource.h |  2 +-
 llvm/include/llvm/Analysis/IR2Vec.h   | 49 ++-
 llvm/include/llvm/Analysis/ValueTracking.h|  4 +-
 llvm/include/llvm/BinaryFormat/DXContainer.h  |  2 +-
 llvm/include/llvm/CodeGenTypes/LowLevelType.h |  5 +-
 .../llvm/CodeGenTypes/MachineValueType.h  |  9 ++--
 .../llvm/DebugInfo/DWARF/DWARFCFIPrinter.h|  3 +-
 .../llvm/DebugInfo/DWARF/DWARFCFIProgram.h|  4 +-
 .../llvm/DebugInfo/DWARF/DWARFExpression.h|  6 +--
 .../LogicalView/Core/LVSourceLanguage.h   |  3 +-
 llvm/include/llvm/ExecutionEngine/Orc/COFF.h  |  3 +-
 .../llvm/Frontend/Directive/Spelling.h|  3 +-
 .../llvm/Frontend/Driver/CodeGenOptions.h |  2 +-
 .../Frontend/HLSL/HLSLRootSignatureUtils.h|  6 +--
 llvm/include/llvm/Support/ConvertUTF.h|  6 +--
 llvm/include/llvm/Support/KnownFPClass.h  | 11 +++--
 llvm/include/llvm/Support/ProgramStack.h  |  7 +--
 llvm/include/llvm/Support/TextEncoding.h  |  5 +-
 llvm/include/llvm/Telemetry/Telemetry.h   |  5 +-
 .../ToolDrivers/llvm-dlltool/DlltoolDriver.h  |  2 +-
 .../llvm/ToolDrivers/llvm-lib/LibDriver.h |  2 +-
 llvm/include/llvm/Transforms/IPO/Attributor.h |  4 +-
 llvm/include/llvm/WindowsDriver/MSVCPaths.h   | 25 +-
 .../WindowsManifest/WindowsManifestMerger.h   | 13 ++---
 24 files changed, 97 insertions(+), 84 deletions(-)

diff --git a/llvm/include/llvm/Analysis/DXILResource.h 
b/llvm/include/llvm/Analysis/DXILResource.h
index cfc21b3ec202b..07b0e97a20fce 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -34,7 +34,7 @@ namespace dxil {
 
 // Returns the resource name from dx_resource_handlefrombinding or
 // dx_resource_handlefromimplicitbinding call
-StringRef getResourceNameFromBindingCall(CallInst *CI);
+L

[clang] [flang] [llvm] [llvm] fix extern cl::opt definitions for DLL export (PR #145374)

2025-06-23 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz created 
https://github.com/llvm/llvm-project/pull/145374

## Purpose
This patch is one in a series of code-mods that annotate LLVM’s public 
interface for export. This patch ensures a few `cl::opt` declarations are 
properly annotated with `LLVM_ABI`. The annotations currently have no 
meaningful impact on the LLVM build; however, they are  a prerequisite to 
support an LLVM Windows DLL (shared library) build.

## Background
This effort is tracked in #109483. Additional context is provided in [this 
discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307),
 and documentation for `LLVM_ABI` and related annotations is found in the LLVM 
repo 
[here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).
  

## Overview
- Remove local `extern` declarations of `llvm::PrintPipelinePasses` because it 
is already correctly declared with an `LLVM_ABI` annotation in 
`llvm\Passes\PassBuilder.h`. Leaving these declarations results in a gcc 
compile warning unless they are also annotated with `LLVM_ABI`.
- Similarly, remove local `extern` declarations of `ProfileSummaryCutoffHot` 
and `UseContextLessSummary` from `llvm/tools/llvm-profgen/ProfileGenerator.cpp` 
since they are declared with `LLVM_ABI` in `llvm\ProfileData\ProfileCommon.h`.
- Explicitly annotate the extern declaration of `ProfileCorrelate` in 
`clang/lib/CodeGen/BackendUtil.cpp` since it is not declared in a header. The 
definition of `ProfileCorrelate` in 
`llvm\lib\Transforms\Instrumentation\InstrProfiling.cpp` is already annotated 
with `LLVM_ABI`.

## Validation
Local builds and tests to validate cross-platform compatibility. This included 
llvm, clang, and lldb on the following configurations:

- Windows with MSVC
- Windows with Clang
- Linux with GCC
- Linux with Clang
- Darwin with Clang

>From e1aca7f1242246d8a4adbb069205171f6242bb95 Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Mon, 23 Jun 2025 10:47:54 -0700
Subject: [PATCH] [llvm] fix extern cl::opt definitions for DLL export

---
 clang/lib/CodeGen/BackendUtil.cpp| 6 +++---
 flang/lib/Frontend/FrontendActions.cpp   | 4 
 llvm/tools/llvm-profgen/ProfileGenerator.cpp | 2 --
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7e0a3cf5591ce..97bc063ad34e5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ProfileData/InstrProfCorrelator.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Program.h"
@@ -96,8 +97,6 @@ using namespace llvm;
 #include "llvm/Support/Extension.def"
 
 namespace llvm {
-extern cl::opt PrintPipelinePasses;
-
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
@@ -118,7 +117,8 @@ static cl::opt ClPGOColdFuncAttr(
clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
   "Mark cold functions with optnone.")));
 
-extern cl::opt ProfileCorrelate;
+LLVM_ABI extern cl::opt
+ProfileCorrelate;
 } // namespace llvm
 namespace clang {
 extern llvm::cl::opt ClSanitizeGuardChecks;
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index d684eeb696755..bf15def3f3b2e 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -74,10 +74,6 @@
 #include 
 #include 
 
-namespace llvm {
-extern cl::opt PrintPipelinePasses;
-} // namespace llvm
-
 using namespace Fortran::frontend;
 
 constexpr llvm::StringLiteral timingIdParse = "Parse";
diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp 
b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
index b47c77c5f2ff3..db686c3b597eb 100644
--- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -108,8 +108,6 @@ using namespace llvm;
 using namespace sampleprof;
 
 namespace llvm {
-extern cl::opt ProfileSummaryCutoffHot;
-extern cl::opt UseContextLessSummary;
 
 namespace sampleprof {
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [llvm] fix extern cl::opt definitions for DLL export (PR #145374)

2025-06-23 Thread Andrew Rogers via cfe-commits

https://github.com/andrurogerz updated 
https://github.com/llvm/llvm-project/pull/145374

>From 8f95bca7eecfefca8849b8dc630aefd6c43967e6 Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Mon, 23 Jun 2025 10:47:54 -0700
Subject: [PATCH] [llvm] fix extern cl::opt definitions for DLL export

---
 clang/lib/CodeGen/BackendUtil.cpp| 6 +++---
 flang/lib/Frontend/FrontendActions.cpp   | 4 
 llvm/tools/llvm-profgen/ProfileGenerator.cpp | 2 --
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7e0a3cf5591ce..97bc063ad34e5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ProfileData/InstrProfCorrelator.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Program.h"
@@ -96,8 +97,6 @@ using namespace llvm;
 #include "llvm/Support/Extension.def"
 
 namespace llvm {
-extern cl::opt PrintPipelinePasses;
-
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
@@ -118,7 +117,8 @@ static cl::opt ClPGOColdFuncAttr(
clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
   "Mark cold functions with optnone.")));
 
-extern cl::opt ProfileCorrelate;
+LLVM_ABI extern cl::opt
+ProfileCorrelate;
 } // namespace llvm
 namespace clang {
 extern llvm::cl::opt ClSanitizeGuardChecks;
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index d684eeb696755..bf15def3f3b2e 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -74,10 +74,6 @@
 #include 
 #include 
 
-namespace llvm {
-extern cl::opt PrintPipelinePasses;
-} // namespace llvm
-
 using namespace Fortran::frontend;
 
 constexpr llvm::StringLiteral timingIdParse = "Parse";
diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp 
b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
index b47c77c5f2ff3..db686c3b597eb 100644
--- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -108,8 +108,6 @@ using namespace llvm;
 using namespace sampleprof;
 
 namespace llvm {
-extern cl::opt ProfileSummaryCutoffHot;
-extern cl::opt UseContextLessSummary;
 
 namespace sampleprof {
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [llvm] fix extern cl::opt definitions for DLL export (PR #145374)

2025-06-25 Thread Andrew Rogers via cfe-commits

andrurogerz wrote:

@compnerd, @vgvassilev another hopefully quick one, thanks!

https://github.com/llvm/llvm-project/pull/145374
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Triple: Forward declare Twine and remove include (PR #145685)

2025-06-25 Thread Andrew Rogers via cfe-commits


@@ -349,7 +350,12 @@ class Triple {
   /// triple fields unknown.
   Triple() = default;
 
+  LLVM_ABI explicit Triple(std::string &&Str);
+  LLVM_ABI explicit Triple(StringRef Str) : Triple(Str.str()) {}
   LLVM_ABI explicit Triple(const Twine &Str);
+  LLVM_ABI explicit Triple(const char *Str) : Triple(std::string(Str)) {}
+  LLVM_ABI explicit Triple(const std::string &Str) : Triple(std::string(Str)) 
{}

andrurogerz wrote:

Yes, @compnerd is right. Please leave-off the `LLVM_ABI` annotation from any 
method defined entirely in the header.

We should eventually be able to flag this via a static analysis CI job.

https://github.com/llvm/llvm-project/pull/145685
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits