[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)

2024-01-09 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

> @ChuanqiXu9, I managed to push the commit here back to #76774 and we can 
> continue the discussion there. Would that be sufficient?

The intention of split the patch is to ease the reviewing. If you are glad to 
do that, yes, it will be pretty good : )

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


[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)

2024-01-09 Thread Chuanqi Xu via llvm-branch-commits

https://github.com/ChuanqiXu9 closed 
https://github.com/llvm/llvm-project/pull/77417
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Serialization] Load Specialization Lazily (2/2) (PR #77417)

2024-01-09 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

Then this is not needed as far as I understood.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# Building the modules needs to happen before the other script commands
+# are executed. Therefore the commands are added to the front of the
+# list.
+if has_std_compat_module:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} %{compile_flags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.compat.pcm -c 
%{module}/std.compat.cppm",
+)
+moduleCompileFlags.append("%T/std.compat.pcm")
+
+# Make sure the std module is added before std.compat.
+# Libc++'s std.compat module will depend on its std module.
+# It is not known whether the compiler expects the modules in the order
+# of their dependencies. However it's trivial to provide them in that
+# order.

ldionne wrote:

@ChuanqiXu9 Is this required? We should know for sure here.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# Building the modules needs to happen before the other script commands
+# are executed. Therefore the commands are added to the front of the
+# list.
+if has_std_compat_module:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} %{compile_flags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.compat.pcm -c 
%{module}/std.compat.cppm",

ldionne wrote:

In a follow-up patch, I think we should rename this to `modules-dir`. In fact 
the other variables might need a renaming too:

```diff
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in 
b/libcxx/test/configs/cmake-bridge.cfg.in
index 0e3c3040c964..93a7a9bb8129 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -25,12 +25,12 @@ config.test_exec_root = os.path.join('@CMAKE_BINARY_DIR@', 
'test')
 # Add substitutions for bootstrapping the test suite configuration
 import shlex
 config.substitutions.append(('%{cxx}', shlex.quote('@CMAKE_CXX_COMPILER@')))
-config.substitutions.append(('%{libcxx}', '@LIBCXX_SOURCE_DIR@'))
-config.substitutions.append(('%{include}', '@LIBCXX_GENERATED_INCLUDE_DIR@'))
-config.substitutions.append(('%{target-include}', 
'@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@'))
-config.substitutions.append(('%{lib}', '@LIBCXX_LIBRARY_DIR@'))
-config.substitutions.append(('%{module}', '@LIBCXX_GENERATED_MODULE_DIR@'))
-config.substitutions.append(('%{test-tools}', '@LIBCXX_TEST_TOOLS_PATH@'))
+config.substitutions.append(('%{libcxx-dir}', '@LIBCXX_SOURCE_DIR@'))
+config.substitutions.append(('%{include-dir}', 
'@LIBCXX_GENERATED_INCLUDE_DIR@'))
+config.substitutions.append(('%{target-include-dir}', 
'@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@'))
+config.substitutions.append(('%{lib-dir}', '@LIBCXX_LIBRARY_DIR@'))
+config.substitutions.append(('%{modules-dir}', 
'@LIBCXX_GENERATED_MODULE_DIR@'))
+config.substitutions.append(('%{test-tools-dir}', '@LIBCXX_TEST_TOOLS_PATH@'))
 
 # The test needs to manually rebuild the module. The compiler flags used in the
 # test need to be the same as the compiler flags used to generate the module.
```

This would make this a lot easier to read IMO.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne requested changes to this pull request.

This generally looks good to me, but I have some feedback per our live review! 
Thanks, this is a great simplification overall.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")

ldionne wrote:

What happens if you drop this? Shouldn't Clang still find the modules since you 
append e.g. `%T/std.compat.pcm` to the compilation flags (which is an absolute 
path)?

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -317,6 +317,18 @@ def _getAndroidDeviceApi(cfg):
 AddSubstitution("%{clang-tidy}", lambda cfg: 
_getSuitableClangTidy(cfg))
 ],
 ),
+# Whether module support for the platform is available.
+Feature(
+name="has-no-module-support",
+# The libc of these platforms have functions with internal linkages.

ldionne wrote:

```suggestion
# The libc of these platforms have functions with internal linkage.
```

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script

ldionne wrote:

This has the downside that we'll only notice the incorrect `MODULES: <...>` 
entry when *running* the test, and it will appear as a test failure. I'd expect 
it to be some kind of configuration failure instead. I would suggest this:

```
def _validateModuleDependencies(modules):
  for m in modules:
if m not in ('std', 'std.compat'):
  raise RuntimeError(f"Invalid module dependency '{m}', only 'std' and 
'std.compat' are valid")
```

Then in here you say

```
_validateModuleDependencies(modules)
has_std_module = 'std' in modules
has_std_compat_module = 'std.compat' in modules
```

Or maybe you don't need the `has_foo_module` variables anymore.


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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# Building the modules needs to happen before the other script commands
+# are executed. Therefore the commands are added to the front of the
+# list.
+if has_std_compat_module:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} %{compile_flags} "

ldionne wrote:

I'm not a big fan of introducing a new `%{module_flags}` substitution here. 
Those are fundamental substitutions and we should try not to add new ones 
unless strictly required, but in this case it's kind of a workaround for the 
chicken-and-egg problem you mention. Instead, we could perhaps instead do 
(pseudo-code):

```
%dbg(MODULE std.compat) %{cxx} %{flags} {substitutions['%{compile_flags}']}
```

Basically, we'd evaluate the `%{compile_flags}` substitution right here instead 
of delaying it until the test actually runs. Then we could add `std.pcm` to 
`%{compile_flags}` in a mechanism similar to `ADDITIONAL_COMPILE_FLAGS` and it 
should all work.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -223,6 +283,12 @@ class CxxStandardLibraryTest(lit.formats.FileBasedTest):
 allows adding special compilation flags without having to use a
 .sh.cpp test, which would be more powerful but perhaps overkill.
 
+// MODULE: std std.compat

ldionne wrote:

Maybe `MODULE_DEPENDENCIES` makes more sense?

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -223,6 +283,12 @@ class CxxStandardLibraryTest(lit.formats.FileBasedTest):
 allows adding special compilation flags without having to use a
 .sh.cpp test, which would be more powerful but perhaps overkill.
 
+// MODULE: std std.compat
+
+   This directive will build the required C++23 standard library
+   modules and add the additional compiler flags in
+   %{module_flags}. (Libc++ offers these modules in C++20 as an

ldionne wrote:

And this documentation will need to be updated.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Louis Dionne via llvm-branch-commits


@@ -317,6 +317,18 @@ def _getAndroidDeviceApi(cfg):
 AddSubstitution("%{clang-tidy}", lambda cfg: 
_getSuitableClangTidy(cfg))
 ],
 ),
+# Whether module support for the platform is available.
+Feature(
+name="has-no-module-support",

ldionne wrote:

```suggestion
name="has-no-cxx-module-support",
```

To disambiguate with clang modules?

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


[llvm-branch-commits] [libcxx] [libc++][modules] Fixes clang-tidy exports. (PR #76288)

2024-01-09 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/76288
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Fixes clang-tidy exports. (PR #76288)

2024-01-09 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne approved this pull request.


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


[llvm-branch-commits] [libcxx] [libc++][modules] Improves std.compat module. (PR #76330)

2024-01-09 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne commented:

This generally looks OK to me, but I'd like to see it once the parent patches 
have landed.

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


[llvm-branch-commits] [libcxx] [libc++][modules] Improves std.compat module. (PR #76330)

2024-01-09 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne approved this pull request.

I guess I don't actually need to see this again if the CI passes once this is 
rebased on top of the parent changes.

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


[llvm-branch-commits] [libcxx] [llvm] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Mark de Wever via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")

mordante wrote:

I tested it `%T/std.compat.pcm` gives an absolute path, but it gives `fatal 
error: module 'std.compat' not found`. AFAIK this is intended. @ChuanqiXu9 do 
you want to chime in?

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


[llvm-branch-commits] [lld] [llvm] [RISCV] Support RISC-V TLSDESC in LLD (PR #77516)

2024-01-09 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi created 
https://github.com/llvm/llvm-project/pull/77516

This patch adds support for RISC-V TLSDESC relocations, as described in
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373.

It does not attempt to handle relaxation for these cases, which will be
handled separately.



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


[llvm-branch-commits] [lld] [llvm] [RISCV] Support RISC-V TLSDESC in LLD (PR #77516)

2024-01-09 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-elf

Author: Paul Kirth (ilovepi)


Changes

This patch adds support for RISC-V TLSDESC relocations, as described in
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373.

It does not attempt to handle relaxation for these cases, which will be
handled separately.


---
Full diff: https://github.com/llvm/llvm-project/pull/77516.diff


6 Files Affected:

- (modified) lld/ELF/Arch/RISCV.cpp (+20) 
- (modified) lld/ELF/InputSection.cpp (+1) 
- (modified) lld/ELF/Relocations.cpp (+2-2) 
- (modified) lld/ELF/Relocations.h (+4) 
- (modified) lld/ELF/Writer.cpp (+2-1) 
- (added) lld/test/ELF/riscv-tlsdesc-le.s (+43) 


``diff
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 1d3d179e5d6fb5..460cccbabdb002 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -44,6 +44,7 @@ class RISCV final : public TargetInfo {
   void relocate(uint8_t *loc, const Relocation &rel,
 uint64_t val) const override;
   void relocateAlloc(InputSectionBase &sec, uint8_t *buf) const override;
+  RelExpr adjustTlsExpr(RelType type, RelExpr expr) const override;
   bool relaxOnce(int pass) const override;
 };
 
@@ -120,6 +121,8 @@ RISCV::RISCV() {
   }
   gotRel = symbolicRel;
 
+  tlsDescRel = R_RISCV_TLSDESC_CALL;
+
   // .got[0] = _DYNAMIC
   gotHeaderEntriesNum = 1;
 
@@ -298,6 +301,13 @@ RelExpr RISCV::getRelExpr(const RelType type, const Symbol 
&s,
 return R_TLSGD_PC;
   case R_RISCV_TLS_GOT_HI20:
 return R_GOT_PC;
+  case R_RISCV_TLSDESC_HI20:
+return R_TLSDESC_PC;
+  case R_RISCV_TLSDESC_LOAD_LO12:
+  case R_RISCV_TLSDESC_ADD_LO12:
+return R_TLSDESC;
+  case R_RISCV_TLSDESC_CALL:
+return R_TLSDESC_CALL;
   case R_RISCV_TPREL_HI20:
   case R_RISCV_TPREL_LO12_I:
   case R_RISCV_TPREL_LO12_S:
@@ -420,6 +430,7 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, 
uint64_t val) const {
   case R_RISCV_PCREL_HI20:
   case R_RISCV_TLS_GD_HI20:
   case R_RISCV_TLS_GOT_HI20:
+  case R_RISCV_TLSDESC_HI20:
   case R_RISCV_TPREL_HI20:
   case R_RISCV_HI20: {
 uint64_t hi = val + 0x800;
@@ -430,6 +441,8 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, 
uint64_t val) const {
 
   case R_RISCV_PCREL_LO12_I:
   case R_RISCV_TPREL_LO12_I:
+  case R_RISCV_TLSDESC_LOAD_LO12:
+  case R_RISCV_TLSDESC_ADD_LO12:
   case R_RISCV_LO12_I: {
 uint64_t hi = (val + 0x800) >> 12;
 uint64_t lo = val - (hi << 12);
@@ -557,6 +570,13 @@ void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t 
*buf) const {
   }
 }
 
+RelExpr RISCV::adjustTlsExpr(RelType type, RelExpr expr) const {
+  if (expr == R_RELAX_TLS_GD_TO_IE) {
+return R_RELAX_TLS_GD_TO_IE_ABS;
+  }
+  return expr;
+}
+
 namespace {
 struct SymbolAnchor {
   uint64_t offset;
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 53b496bd084258..90f55c4b8a6b1c 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -851,6 +851,7 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile 
*file, RelType type,
 return sym.getSize() + a;
   case R_TLSDESC:
 return in.got->getTlsDescAddr(sym) + a;
+  case R_RISCV_TLSDESC_HI:
   case R_TLSDESC_PC:
 return in.got->getTlsDescAddr(sym) + a - p;
   case R_TLSDESC_GOTPLT:
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 20eb02b8798447..6e67a13731fea8 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1269,7 +1269,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
 
   if (oneof(expr) &&
+R_TLSDESC_GOTPLT, R_RISCV_TLSDESC_HI>(expr) &&
   config->shared) {
 if (expr != R_TLSDESC_CALL) {
   sym.setFlags(NEEDS_TLSDESC);
@@ -1333,7 +1333,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
 
   if (oneof(expr)) {
+R_LOONGARCH_TLSGD_PAGE_PC, R_RISCV_TLSDESC_HI>(expr)) {
 if (!toExecRelax) {
   sym.setFlags(NEEDS_TLSGD);
   c.addReloc({expr, type, offset, addend, &sym});
diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h
index cfb9092149f3e0..9a24fe8a219dab 100644
--- a/lld/ELF/Relocations.h
+++ b/lld/ELF/Relocations.h
@@ -103,6 +103,10 @@ enum RelExpr {
   R_RISCV_ADD,
   R_RISCV_LEB128,
   R_RISCV_PC_INDIRECT,
+  R_RISCV_TLSDESC_HI,
+  R_RISCV_TLSDESC_LOAD_LO,
+  R_RISCV_TLSDESC_ADD_LO,
+  R_RISCV_TLSDESC_CALLER,
   // Same as R_PC but with page-aligned semantics.
   R_LOONGARCH_PAGE_PC,
   // Same as R_PLT_PC but with page-aligned semantics.
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index dfec5e07301a74..34bb3da2a1c343 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1950,7 +1950,8 @@ template  void 
Writer::finalizeSections() {
   }
 }
 
-if (config->emachine == EM_386 || config->emachine == EM_X86_64) {
+if (config->emachine == EM_386 || config->emachine == EM_X86_64 ||
+config->emachine =

[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/76246

>From 196cedd36534b02a7c55cf4a1746b34f87ead467 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 20 Dec 2023 20:43:38 +0100
Subject: [PATCH 1/2] [libc++][modules] Adds module testing.

This adds a new module test infrastructure. This requires tagging tests
using modules. The test runner uses this information to determine the
compiler flags needed to build and use the module.

Currently modules are build per test, which allows testing them for
tests with ADDITIONAL_COMPILE_FLAGS. At the moment only 4 tests use
modules. Therefore the performance penalty is not measurable. If in the
future more tests use modules it would be good to measure the overhead
and determine whether it's acceptable.
---
 libcxx/test/libcxx/module_std.gen.py  |  3 +-
 libcxx/test/libcxx/module_std_compat.gen.py   |  3 +-
 .../libcxx/selftest/modules/no-modules.sh.cpp | 12 +++
 .../modules/std-and-std.compat-module.sh.cpp  | 23 ++
 .../libcxx/selftest/modules/std-module.sh.cpp | 25 ++
 .../selftest/modules/std.compat-module.sh.cpp | 25 ++
 .../modules/unknown-module.compile.pass.cpp   | 13 
 libcxx/test/std/modules/std.compat.pass.cpp   |  5 +-
 libcxx/test/std/modules/std.pass.cpp  |  5 +-
 libcxx/utils/libcxx/test/features.py  | 12 +++
 libcxx/utils/libcxx/test/format.py| 76 +--
 libcxx/utils/libcxx/test/modules.py   |  5 +-
 12 files changed, 196 insertions(+), 11 deletions(-)
 create mode 100644 libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
 create mode 100644 
libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
 create mode 100644 libcxx/test/libcxx/selftest/modules/std-module.sh.cpp
 create mode 100644 libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp
 create mode 100644 
libcxx/test/libcxx/selftest/modules/unknown-module.compile.pass.cpp

diff --git a/libcxx/test/libcxx/module_std.gen.py 
b/libcxx/test/libcxx/module_std.gen.py
index 8e03d6e5b5b523..3ad2aff9d085f4 100644
--- a/libcxx/test/libcxx/module_std.gen.py
+++ b/libcxx/test/libcxx/module_std.gen.py
@@ -29,7 +29,8 @@
 "%{clang-tidy}",
 "%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
 "%{cxx}",
-"%{flags} %{compile_flags}",
+"%{flags} %{compile_flags} %{module_flags}",
+"std",
 )
 
 
diff --git a/libcxx/test/libcxx/module_std_compat.gen.py 
b/libcxx/test/libcxx/module_std_compat.gen.py
index c4792db3d71e62..63fdd8188937e1 100644
--- a/libcxx/test/libcxx/module_std_compat.gen.py
+++ b/libcxx/test/libcxx/module_std_compat.gen.py
@@ -29,7 +29,8 @@
 "%{clang-tidy}",
 "%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
 "%{cxx}",
-"%{flags} %{compile_flags}",
+"%{flags} %{compile_flags} %{module_flags}",
+"std.compat",
 )
 
 
diff --git a/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp 
b/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
new file mode 100644
index 00..86d0afc13e3c40
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
@@ -0,0 +1,12 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Make sure that the module flags are empty when no module is supplied.
+
+// MODULES:
+// RUN: echo "%{module_flags}"  | grep "^$"
diff --git 
a/libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp 
b/libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
new file mode 100644
index 00..da9497f2dbb768
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
@@ -0,0 +1,23 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-module-support
+
+// Make sure that the module flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module breaks this test.
+
+// MODULES: std std.compat
+//
+// RUN: echo "%{module_flags}" | grep -- "-fprebuilt-module-path="
+// RUN: echo "%{module_flags}" | grep "std.pcm"
+// RUN: echo "%{module_flags}" | grep "std.compat.pcm"
diff --git a/libcxx/test/libcxx/selftest/modules/std-module.sh.cpp 
b/libcxx/test/libcxx/s

[llvm-branch-commits] [lld] [llvm] [RISCV] Support RISC-V TLSDESC in LLD (PR #77516)

2024-01-09 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/77516

>From ed9f0c9de1e8f75acdae90ef714323147539d215 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 9 Jan 2024 22:50:19 +
Subject: [PATCH] Add checks for both local and global accesses

Created using spr 1.3.4
---
 lld/test/ELF/riscv-tlsdesc-le.s | 45 +++--
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/lld/test/ELF/riscv-tlsdesc-le.s b/lld/test/ELF/riscv-tlsdesc-le.s
index 6aa670cffb59b8..21541ee5977019 100644
--- a/lld/test/ELF/riscv-tlsdesc-le.s
+++ b/lld/test/ELF/riscv-tlsdesc-le.s
@@ -3,17 +3,23 @@
 // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | 
FileCheck %s
 // RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=REL %s
 
-//  CHECK: 12d8 <_start>:
-// CHECK-NEXT:12d8:   auipc   a0, 1
-// CHECK-NEXT:12dc:   ld  a1, 920(a0)
-// CHECK-NEXT:12e0:   addia0, a0, 920
-// CHECK-NEXT:12e4:   jalrt0, a1
-// CHECK-NEXT:12e8:   add a0, a0, tp
-// CHECK-NEXT:12ec:   ret
+//  CHECK: 1318 <_start>:
+// CHECK-NEXT:1318:   auipc   a0, 1
+// CHECK-NEXT:131c:   ld  a1, 1008(a0)
+// CHECK-NEXT:1320:   addia0, a0, 1008
+// CHECK-NEXT:1324:   jalrt0, a1
+// CHECK-NEXT:1328:   add a0, a0, tp
+// CHECK-NEXT:132c:   auipc   a0, 1
+// CHECK-NEXT:1330:   ld  a1, 1040(a0)
+// CHECK-NEXT:1334:   addia0, a0, 1040
+// CHECK-NEXT:1338:   jalrt0, a1
+// CHECK-NEXT:133c:   add a0, a0, tp
+// CHECK-NEXT:1340:   ret
 
-//  REL: Relocation section '.rela.dyn' at offset 0x{{[0-9a-f]+}} contains 
2 entries
-//  REL: R_RISCV_TLSDESC_CALL ffe8
-// REL-NEXT: R_RISCV_TLSDESC_CALL 0
+//  REL: Relocation section '.rela.dyn' at offset 0x{{[0-9a-f]+}} contains 
3 entries
+//  REL: R_RISCV_TLSDESC_CALL  ffd4
+// REL-NEXT: R_RISCV_TLSDESC_CALL  4
+// REL-NEXT: R_RISCV_TLSDESC_CALL  ffe8
 
.text
.attribute  4, 16
@@ -23,21 +29,32 @@
.p2align2
.type   _start,@function
 _start: # @_start
-# %bb.0:# %entry
+// access local variable
 .Ltlsdesc_hi0:
auipc   a0, %tlsdesc_hi(unspecified)
ld  a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0)
addia0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi0)
jalrt0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0)
add a0, a0, tp
+
+// access global variable
+.Ltlsdesc_hi1:
+   auipc   a0, %tlsdesc_hi(unspecified)
+   ld  a1, %tlsdesc_load_lo(.Ltlsdesc_hi1)(a0)
+   addia0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi1)
+   jalrt0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi1)
+   add a0, a0, tp
ret
 .Lfunc_end0:
.size   _start, .Lfunc_end0-_start
 # -- End function
.section".note.GNU-stack","",@progbits
 
-.section .tbss,"awT",@nobits
-.p2align 2
+   .section .tbss,"awT",@nobits
+   .p2align 2
+   .global v1
+v1:
+   .zero4
 
 unspecified:
-.zero4
+   .zero4

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


[llvm-branch-commits] [llvm] cebd720 - Revert "[SEH][CodeGen] Add test to track CFG optimization bug for SEH (#77441)"

2024-01-09 Thread via llvm-branch-commits

Author: HaohaiWen
Date: 2024-01-10T09:24:52+08:00
New Revision: cebd720ab6429bbf2f8d09c37c2965782f23dbab

URL: 
https://github.com/llvm/llvm-project/commit/cebd720ab6429bbf2f8d09c37c2965782f23dbab
DIFF: 
https://github.com/llvm/llvm-project/commit/cebd720ab6429bbf2f8d09c37c2965782f23dbab.diff

LOG: Revert "[SEH][CodeGen] Add test to track CFG optimization bug for SEH 
(#77441)"

This reverts commit a2dba0c97756c65c7dd9d91bec2ceda80a933bb1.

Added: 


Modified: 


Removed: 
llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll



diff  --git a/llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll 
b/llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll
deleted file mode 100644
index bd6743f7c414b4..00
--- a/llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll
+++ /dev/null
@@ -1,81 +0,0 @@
-; XFAIL: *
-; RUN: llc -mtriple=x86_64-pc-windows-msvc %s
-define dso_local void @main(ptr %addr, ptr %src, ptr %dst) personality ptr 
@__CxxFrameHandler3 !dbg !11 {
-entry:
-  %tmp0 = load float, ptr %src
-  %src1 = getelementptr inbounds float, ptr %src, i64 1
-  %tmp1 = load float, ptr %src1
-  %src2 = getelementptr inbounds float, ptr %src, i64 2
-  %tmp2 = load float, ptr %src2
-  %src3 = getelementptr inbounds float, ptr %src, i64 3
-  %tmp3 = load float, ptr %src3
-  %src4 = getelementptr inbounds float, ptr %src, i64 4
-  %tmp4 = load float, ptr %src4
-  %src5 = getelementptr inbounds float, ptr %src, i64 5
-  %tmp5 = load float, ptr %src5
-  %src6 = getelementptr inbounds float, ptr %src, i64 6
-  %tmp6 = load float, ptr %src6
-  invoke void @foo(ptr %addr)
-  to label %scope_begin unwind label %ehcleanup1, !dbg !13
-
-scope_begin:
-  invoke void @llvm.seh.scope.begin()
-  to label %scope_end unwind label %ehcleanup, !dbg !13
-
-scope_end:
-  invoke void @llvm.seh.scope.end()
-  to label %finish unwind label %ehcleanup, !dbg !13
-
-ehcleanup:
-  %0 = cleanuppad within none [], !dbg !13
-  call void @llvm.dbg.value(metadata ptr %addr, metadata !12, metadata 
!DIExpression()), !dbg !13
-  call void @foo(ptr %addr) [ "funclet"(token %0) ], !dbg !13
-  cleanupret from %0 unwind label %ehcleanup1, !dbg !13
-
-ehcleanup1:
-  %1 = cleanuppad within none [], !dbg !13
-  call void @foo(ptr %addr) [ "funclet"(token %1) ], !dbg !13
-  cleanupret from %1 unwind to caller, !dbg !13
-
-finish:
-  store float %tmp0, ptr %dst
-  %dst1 = getelementptr inbounds float, ptr %dst, i64 1
-  store float %tmp1, ptr %dst1
-  %dst2 = getelementptr inbounds float, ptr %dst, i64 2
-  store float %tmp2, ptr %dst2
-  %dst3 = getelementptr inbounds float, ptr %dst, i64 3
-  store float %tmp3, ptr %dst3
-  %dst4 = getelementptr inbounds float, ptr %dst, i64 4
-  store float %tmp4, ptr %dst4
-  %dst5 = getelementptr inbounds float, ptr %dst, i64 5
-  store float %tmp5, ptr %dst5
-  %dst6 = getelementptr inbounds float, ptr %dst, i64 6
-  store float %tmp6, ptr %dst6
-  ret void
-}
-
-declare dso_local void @llvm.seh.scope.begin()
-declare dso_local void @llvm.seh.scope.end()
-declare dso_local i32 @__CxxFrameHandler3(...)
-declare dso_local void @foo(ptr %addr)
-declare void @llvm.dbg.value(metadata, metadata, metadata)
-
-!llvm.module.flags = !{!0, !1, !2, !3}
-!llvm.dbg.cu = !{!14}
-
-!0 = !{i32 2, !"eh-asynch", i32 1}
-!1 = !{i32 2, !"CodeView", i32 1}
-!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = !{i32 7, !"uwtable", i32 2}
-
-!4 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
-!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)
-!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
-!8 = !DISubroutineType(types: !9)
-!9 = !{null, !7, !5, !5}
-!10 = !DIFile(filename: "c:/main.cpp", directory: "")
-!11 = distinct !DISubprogram(name: "main", scope: !10, file: !10, line: 5, 
type: !8, scopeLine: 11, unit: !14)
-!12 = !DILocalVariable(name: "addr", scope: !11, file: !10, line: 5, type: !7)
-!13 = !DILocation(line: 7, scope: !11)
-!14 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !10, 
isOptimized: true, emissionKind: FullDebug, splitDebugInlining: false, 
nameTableKind: None)



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


[llvm-branch-commits] [llvm] cebd720 - Revert "[SEH][CodeGen] Add test to track CFG optimization bug for SEH (#77441)"

2024-01-09 Thread via llvm-branch-commits

Author: HaohaiWen
Date: 2024-01-10T09:24:52+08:00
New Revision: cebd720ab6429bbf2f8d09c37c2965782f23dbab

URL: 
https://github.com/llvm/llvm-project/commit/cebd720ab6429bbf2f8d09c37c2965782f23dbab
DIFF: 
https://github.com/llvm/llvm-project/commit/cebd720ab6429bbf2f8d09c37c2965782f23dbab.diff

LOG: Revert "[SEH][CodeGen] Add test to track CFG optimization bug for SEH 
(#77441)"

This reverts commit a2dba0c97756c65c7dd9d91bec2ceda80a933bb1.

Added: 


Modified: 


Removed: 
llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll



diff  --git a/llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll 
b/llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll
deleted file mode 100644
index bd6743f7c414b4..00
--- a/llvm/test/CodeGen/X86/windows-seh-EHa-PreserveCFG.ll
+++ /dev/null
@@ -1,81 +0,0 @@
-; XFAIL: *
-; RUN: llc -mtriple=x86_64-pc-windows-msvc %s
-define dso_local void @main(ptr %addr, ptr %src, ptr %dst) personality ptr 
@__CxxFrameHandler3 !dbg !11 {
-entry:
-  %tmp0 = load float, ptr %src
-  %src1 = getelementptr inbounds float, ptr %src, i64 1
-  %tmp1 = load float, ptr %src1
-  %src2 = getelementptr inbounds float, ptr %src, i64 2
-  %tmp2 = load float, ptr %src2
-  %src3 = getelementptr inbounds float, ptr %src, i64 3
-  %tmp3 = load float, ptr %src3
-  %src4 = getelementptr inbounds float, ptr %src, i64 4
-  %tmp4 = load float, ptr %src4
-  %src5 = getelementptr inbounds float, ptr %src, i64 5
-  %tmp5 = load float, ptr %src5
-  %src6 = getelementptr inbounds float, ptr %src, i64 6
-  %tmp6 = load float, ptr %src6
-  invoke void @foo(ptr %addr)
-  to label %scope_begin unwind label %ehcleanup1, !dbg !13
-
-scope_begin:
-  invoke void @llvm.seh.scope.begin()
-  to label %scope_end unwind label %ehcleanup, !dbg !13
-
-scope_end:
-  invoke void @llvm.seh.scope.end()
-  to label %finish unwind label %ehcleanup, !dbg !13
-
-ehcleanup:
-  %0 = cleanuppad within none [], !dbg !13
-  call void @llvm.dbg.value(metadata ptr %addr, metadata !12, metadata 
!DIExpression()), !dbg !13
-  call void @foo(ptr %addr) [ "funclet"(token %0) ], !dbg !13
-  cleanupret from %0 unwind label %ehcleanup1, !dbg !13
-
-ehcleanup1:
-  %1 = cleanuppad within none [], !dbg !13
-  call void @foo(ptr %addr) [ "funclet"(token %1) ], !dbg !13
-  cleanupret from %1 unwind to caller, !dbg !13
-
-finish:
-  store float %tmp0, ptr %dst
-  %dst1 = getelementptr inbounds float, ptr %dst, i64 1
-  store float %tmp1, ptr %dst1
-  %dst2 = getelementptr inbounds float, ptr %dst, i64 2
-  store float %tmp2, ptr %dst2
-  %dst3 = getelementptr inbounds float, ptr %dst, i64 3
-  store float %tmp3, ptr %dst3
-  %dst4 = getelementptr inbounds float, ptr %dst, i64 4
-  store float %tmp4, ptr %dst4
-  %dst5 = getelementptr inbounds float, ptr %dst, i64 5
-  store float %tmp5, ptr %dst5
-  %dst6 = getelementptr inbounds float, ptr %dst, i64 6
-  store float %tmp6, ptr %dst6
-  ret void
-}
-
-declare dso_local void @llvm.seh.scope.begin()
-declare dso_local void @llvm.seh.scope.end()
-declare dso_local i32 @__CxxFrameHandler3(...)
-declare dso_local void @foo(ptr %addr)
-declare void @llvm.dbg.value(metadata, metadata, metadata)
-
-!llvm.module.flags = !{!0, !1, !2, !3}
-!llvm.dbg.cu = !{!14}
-
-!0 = !{i32 2, !"eh-asynch", i32 1}
-!1 = !{i32 2, !"CodeView", i32 1}
-!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = !{i32 7, !"uwtable", i32 2}
-
-!4 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
-!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)
-!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
-!8 = !DISubroutineType(types: !9)
-!9 = !{null, !7, !5, !5}
-!10 = !DIFile(filename: "c:/main.cpp", directory: "")
-!11 = distinct !DISubprogram(name: "main", scope: !10, file: !10, line: 5, 
type: !8, scopeLine: 11, unit: !14)
-!12 = !DILocalVariable(name: "addr", scope: !11, file: !10, line: 5, type: !7)
-!13 = !DILocation(line: 7, scope: !11)
-!14 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !10, 
isOptimized: true, emissionKind: FullDebug, splitDebugInlining: false, 
nameTableKind: None)



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


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-09 Thread Chuanqi Xu via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")

ChuanqiXu9 wrote:

I didn't read the patch completely so I don't know the concatenated command 
line. But the behavior matches current expectation of clang. Now when clang 
sees an `import` for a named module, clang will only find that named module by 
`-fprebuilt-module-path` or 
`-fmodule-file==`.

I guess you're talking about the case about:

```
clang++ std.compat.pcm use.cc -o use
```

where use.cc uses std.compat module. 

This command line will be split into 3 processes like:

```
clang_cc1 std.compat.pcm  -c -o std.compat.o
clang_cc1 use.cc -c -o use.o
clang_cc1 std.compat.o use.o -o use
```

So the second step won't know about `std.compat.pcm`.

While it is technically possible to improve that, I feel it is not so useful 
since the major expected users of modules should use a build system instead of 
concatenating the command line manually.

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