|
16 | 16 | #include "ir/irvar.h" |
17 | 17 | #include "llvm/ADT/StringExtras.h" |
18 | 18 | #include "llvm/ADT/StringSwitch.h" |
19 | | -#include <cstring> |
20 | 19 | #include <stdio.h> |
21 | 20 |
|
22 | 21 | using namespace dmd; |
@@ -660,19 +659,27 @@ bool isDeviceArrayComparisonHook(Dsymbol *sym) { |
660 | 659 | Module *m = sym->getModule(); |
661 | 660 | if (!m) |
662 | 661 | return false; |
| 662 | + const ModuleDeclaration *md = m->md; |
| 663 | + if (!md) |
| 664 | + return false; |
663 | 665 | // These druntime modules are host-only, but their templates (`__cmp`, |
664 | 666 | // `__equals` and helpers like `isEqual`/`at`) are the lowering hooks emitted |
665 | 667 | // for array `<`/`==` in device code, so they must not be skipped. |
666 | | - const char *fqn = m->toPrettyChars(); |
667 | | - if (!strcmp(fqn, "core.internal.array.comparison") || |
668 | | - !strcmp(fqn, "core.internal.array.equality")) |
| 668 | + Identifier *const internal = Identifier::idPool("internal"); |
| 669 | + if (md->packages.length == 3 && md->packages.ptr[0] == Id::core && |
| 670 | + md->packages.ptr[1] == internal && |
| 671 | + md->packages.ptr[2] == Identifier::idPool("array") && |
| 672 | + (md->id == Identifier::idPool("comparison") || |
| 673 | + md->id == Identifier::idPool("equality"))) |
669 | 674 | return true; |
670 | 675 | // From core.internal.string only `dstrcmp` is a device-legal hook helper (the |
671 | 676 | // `char`/string `__cmp` specialization calls it). The rest of that module |
672 | 677 | // (e.g. signedToTempString) contains device-illegal code, so don't exempt the |
673 | 678 | // whole module. |
674 | | - if (!strcmp(fqn, "core.internal.string")) |
675 | | - return sym->ident && !strcmp(sym->ident->toChars(), "dstrcmp"); |
| 679 | + if (md->packages.length == 2 && md->packages.ptr[0] == Id::core && |
| 680 | + md->packages.ptr[1] == internal && |
| 681 | + md->id == Identifier::idPool("string")) |
| 682 | + return sym->ident == Identifier::idPool("dstrcmp"); |
676 | 683 | return false; |
677 | 684 | } |
678 | 685 |
|
|
0 commit comments