Skip to content

Commit 851741c

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (8 commits)
2 parents 5ba5da3 + a37ca84 commit 851741c

File tree

23 files changed

+1444
-383
lines changed

23 files changed

+1444
-383
lines changed

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,13 @@ jobs:
172172
outputs:
173173
lts: ${{ steps.work.outputs.lts }}
174174
steps:
175-
- name: Download scripts
175+
- name: Download scripts and configs
176176
run: |
177177
wget raw.githubusercontent.com/intel/llvm/${{ github.sha }}/devops/scripts/generate_test_matrix.js
178178
wget raw.githubusercontent.com/intel/llvm/${{ github.sha }}/devops/test_configs.json
179+
wget raw.githubusercontent.com/intel/llvm/sycl/devops/dependencies.json
180+
mv dependencies.json dependencies.sycl.json
181+
wget raw.githubusercontent.com/intel/llvm/${{ github.sha }}/devops/dependencies.json
179182
- id: work
180183
uses: actions/github-script@v6
181184
name: Generate matrix
@@ -196,6 +199,7 @@ jobs:
196199
include: ${{ fromJSON(needs.resolve_matrix.outputs.lts) }}
197200
name: ${{ matrix.name }}
198201
runs-on: ${{ matrix.runs-on }}
202+
env: ${{ matrix.env }}
199203
container:
200204
image: ${{ matrix.image }}
201205
options: ${{ matrix.container_options }}
@@ -208,6 +212,15 @@ jobs:
208212
- run: cp -r /actions .
209213
- name: Register cleanup after job is finished
210214
uses: ./actions/cleanup
215+
- name: Install drivers
216+
if: env.compute_runtime_tag != ''
217+
run: |
218+
if [ -e /opt/install_drivers.sh ]; then
219+
# TODO pack this script into container
220+
wget raw.githubusercontent.com/intel/llvm/${{ github.sha }}/devops/scripts/get_release.py
221+
sudo mv get_release.py /opt/
222+
sudo -E /opt/install_drivers.sh --all
223+
fi
211224
# FIXME cached_checkout fails here, but works everywhere else
212225
- uses: actions/checkout@v2
213226
with:

clang/include/clang/Basic/AttrDocs.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,6 +3629,7 @@ occur after the first argument of the attribute, the N+2'th argument of the
36293629
attribute will occur after the second argument of the attribute, etc.
36303630
The generated call to ``llvm.ptr.annotation`` will have the following arguments
36313631
in this order:
3632+
36323633
* First argument is a pointer to the field.
36333634
* A pointer to a string literal in a constant global variable. This will
36343635
always be "sycl-properties".
@@ -3639,6 +3640,7 @@ in this order:
36393640
literals in constant global variables. These pointers to string literals
36403641
occur in pairs. If the second value of a pair was a ``nullptr`` or an empty
36413642
string then the pointer will be a null-pointer.
3643+
36423644
A pair will not be in the call to ``llvm.ptr.annotation`` if the first value of
36433645
the pair is an empty string.
36443646

devops/scripts/generate_test_matrix.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,45 @@ module.exports = ({core, process}) => {
44
if (err) {
55
console.log(`Error reading file from disk: ${err}`);
66
} else {
7+
const driverNew =
8+
JSON.parse(fs.readFileSync('./dependencies.json', 'utf8'));
9+
const driverOld =
10+
JSON.parse(fs.readFileSync('./dependencies.sycl.json', 'utf8'));
711
const testConfigs = JSON.parse(data);
812
const inputs = JSON.parse(process.env.GHA_INPUTS);
13+
const needsDrivers =
14+
driverNew["linux"]["compute_runtime"]["version"] !==
15+
driverOld["linux"]["compute_runtime"]["version"] ||
16+
driverNew["linux"]["igc"]["version"] !==
17+
driverOld["linux"]["igc"]["version"] ||
18+
driverNew["linux"]["cm"]["version"] !==
19+
driverOld["linux"]["cm"]["version"] ||
20+
driverNew["linux"]["tbb"]["version"] !==
21+
driverOld["linux"]["tbb"]["version"] ||
22+
driverNew["linux"]["oclcpu"]["version"] !==
23+
driverOld["linux"]["oclcpu"]["version"] ||
24+
driverNew["linux"]["fpgaemu"]["version"] !==
25+
driverOld["linux"]["fpgaemu"]["version"];
926

1027
const ltsConfigs = inputs.lts_config.split(';');
1128

1229
const enabledLTSConfigs = [];
1330

1431
testConfigs.lts.forEach(v => {
1532
if (ltsConfigs.includes(v.config)) {
33+
if (needsDrivers) {
34+
v["env"] = {
35+
"compute_runtime_tag" :
36+
driverNew["linux"]["compute_runtime"]["github_tag"],
37+
"igc_tag" : driverNew["linux"]["igc"]["github_tag"],
38+
"cm_tag" : driverNew["linux"]["cm"]["github_tag"],
39+
"tbb_tag" : driverNew["linux"]["tbb"]["github_tag"],
40+
"cpu_tag" : driverNew["linux"]["oclcpu"]["github_tag"],
41+
"fpgaemu_tag" : driverNew["linux"]["fpgaemu"]["github_tag"],
42+
};
43+
} else {
44+
v["env"] = {};
45+
}
1646
enabledLTSConfigs.push(v);
1747
}
1848
});
@@ -23,6 +53,11 @@ module.exports = ({core, process}) => {
2353
for (let [key, value] of Object.entries(inputs)) {
2454
ltsString = ltsString.replaceAll("${{ inputs." + key + " }}", value);
2555
}
56+
if (needsDrivers) {
57+
ltsString = ltsString.replaceAll(
58+
"ghcr.io/intel/llvm/ubuntu2004_intel_drivers:latest",
59+
"ghcr.io/intel/llvm/ubuntu2004_base:latest");
60+
}
2661

2762
core.setOutput('lts', ltsString);
2863
}

devops/scripts/install_drivers.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fi;
2121

2222
InstallTBB () {
2323
if [ "$TBB_INSTALLED" = false ]; then
24+
mkdir -p $INSTALL_LOCATION
2425
cd $INSTALL_LOCATION
2526
echo "Installing TBB..."
2627
echo "TBB version $TBB_TAG"
@@ -54,6 +55,7 @@ InstallIGFX () {
5455
InstallCPURT () {
5556
echo "Installing Intel OpenCL CPU Runtime..."
5657
echo "CPU Runtime version $CPU_TAG"
58+
mkdir -p $INSTALL_LOCATION
5759
cd $INSTALL_LOCATION
5860
if [ -d "$INSTALL_LOCATION/oclcpu" ]; then
5961
echo "$INSTALL_LOCATION/oclcpu exists and will be removed!"
@@ -73,12 +75,13 @@ InstallCPURT () {
7375
InstallFPGAEmu () {
7476
echo "Installing Intel FPGA Fast Emulator..."
7577
echo "FPGA Emulator version $FPGA_TAG"
78+
mkdir -p $INSTALL_LOCATION
7679
cd $INSTALL_LOCATION
7780
if [ -d "$INSTALL_LOCATION/fpgaemu" ]; then
7881
echo "$INSTALL_LOCATION/fpgaemu exists and will be removed!"
7982
rm -Rf $INSTALL_LOCATION/oclcpu;
8083
fi
81-
python3 /get_release.py intel/llvm $FPGA_TAG \
84+
python3 $LOCATION/get_release.py intel/llvm $FPGA_TAG \
8285
| grep -E ".*fpgaemu.*tar.gz" \
8386
| wget -qi - && \
8487
mkdir fpgaemu && tar -xf *.tar.gz -C fpgaemu && rm *.tar.gz

libclc/utils/libclc-remangler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
55
Core
66
Demangle
77
Support
8+
TransformUtils
89
)
910

1011
add_clang_tool(libclc-remangler LibclcRemangler.cpp)

libclc/utils/libclc-remangler/LibclcRemangler.cpp

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111
// `unsigned long`, and `char` to appear as if they use `long long`,
1212
// `unsigned long long`, and `signed char`, as is consistent with the primitive
1313
// types defined by OpenCL C. Following a remangling, the original function
14-
// mangling will be made an alias to either the remangled function or a function
15-
// with a suitable function if any exists. In some cases an alias of the
16-
// remangled function is created for functions where multiple parameters have
17-
// been replaced, and the replaced values are aliases.
14+
// mangling will be built as a clone of either the remangled function or a
15+
// function with a suitable function if any exists. In some cases a clone of
16+
// the remangled function is created for functions where multiple parameters
17+
// have been replaced, and the replaced values are aliases.
1818
//
19-
// Original Alias Example:
19+
// Original Clone Example:
2020
// If libclc defined a function `f(long)` the mangled name would be
2121
// `_Z1fl`. The remangler would rename this function to `_Z1fx`
22-
// (`f(long long)`.) If the target uses 64-bit `long`, `_Z1fl` is made
23-
// an alias to the old function now under the name `_Z1fx`, whereas if
24-
// the target uses 32-bit `long`, `_Z1fl` is made an alias to `_Z1fi`
22+
// (`f(long long)`.) If the target uses 64-bit `long`, `_Z1fl` is
23+
// cloned from the old function now under the name `_Z1fx`, whereas if
24+
// the target uses 32-bit `long`, `_Z1fl` is cloned from `_Z1fi`
2525
// (`f(int)`) if such a function exists.
2626
//
27-
// Remangled Alias Example:
27+
// Remangled Clone Example:
2828
// In cases where the remangled name squashes valid versions of a
29-
// function an alias is created. `f(long, char, signed char)` would be
29+
// function a clone is created. `f(long, char, signed char)` would be
3030
// mangled to
3131
// `_Z1flca`. The remangler would rename this function to `_Z1fyaa`
3232
// (`f(long long, signed char, signed char)`). If the target uses a
33-
// signed char then a valid alias `_Z1fyca`,
33+
// signed char then a valid clone `_Z1fyca`,
3434
// (`f(long long, char, signed char)`), is not defined. The remangler
35-
// creates an alias of the renamed function,`_Z1fyaa` , to this
35+
// creates a clone of the renamed function,`_Z1fyaa` , to this
3636
// permutation, `_Z1fyca`.
3737
//
3838
//===----------------------------------------------------------------------===//
@@ -58,6 +58,8 @@
5858
#include "llvm/Support/Signals.h"
5959
#include "llvm/Support/ToolOutputFile.h"
6060
#include "llvm/Support/raw_ostream.h"
61+
#include "llvm/Transforms/Utils/Cloning.h"
62+
#include "llvm/Transforms/Utils/ValueMapper.h"
6163

6264
#include <iostream>
6365
#include <memory>
@@ -153,7 +155,7 @@ class DefaultAllocator {
153155
public:
154156
void reset() { Alloc.reset(); }
155157

156-
template <typename T, typename... Args> T *makeNode(Args &&... args) {
158+
template <typename T, typename... Args> T *makeNode(Args &&...args) {
157159
return new (Alloc.allocate(sizeof(T))) T(std::forward<Args>(args)...);
158160
}
159161

@@ -478,19 +480,19 @@ class Remangler {
478480

479481
class TargetTypeReplacements {
480482
SmallDenseMap<const char *, const char *> ParameterTypeReplacements;
481-
SmallDenseMap<const char *, const char *> AliasTypeReplacements;
482-
SmallDenseMap<const char *, const char *> RemangledAliasTypeReplacements;
483+
SmallDenseMap<const char *, const char *> CloneTypeReplacements;
484+
SmallDenseMap<const char *, const char *> RemangledCloneTypeReplacements;
483485

484486
void CreateRemangledTypeReplacements() {
485487
// RemangleTypes which are not aliases or not the exact same alias type
486488
for (auto &TypeReplacementPair : ParameterTypeReplacements)
487-
if (AliasTypeReplacements.find(TypeReplacementPair.getFirst()) ==
488-
AliasTypeReplacements.end())
489-
RemangledAliasTypeReplacements[TypeReplacementPair.getFirst()] =
489+
if (CloneTypeReplacements.find(TypeReplacementPair.getFirst()) ==
490+
CloneTypeReplacements.end())
491+
RemangledCloneTypeReplacements[TypeReplacementPair.getFirst()] =
490492
TypeReplacementPair.getSecond();
491-
else if (AliasTypeReplacements[TypeReplacementPair.getFirst()] !=
493+
else if (CloneTypeReplacements[TypeReplacementPair.getFirst()] !=
492494
TypeReplacementPair.getSecond())
493-
RemangledAliasTypeReplacements[TypeReplacementPair.getFirst()] =
495+
RemangledCloneTypeReplacements[TypeReplacementPair.getFirst()] =
494496
TypeReplacementPair.getSecond();
495497
}
496498

@@ -503,22 +505,22 @@ class TargetTypeReplacements {
503505
// Replace char with signed char
504506
ParameterTypeReplacements["char"] = "signed char";
505507

506-
// Make replaced long functions aliases to either integer or long long
508+
// Make replaced long functions clones of either integer or long long
507509
// variant
508510
if (LongWidth == SupportedLongWidth::L32) {
509-
AliasTypeReplacements["long"] = "int";
510-
AliasTypeReplacements["unsigned long"] = "unsigned int";
511+
CloneTypeReplacements["long"] = "int";
512+
CloneTypeReplacements["unsigned long"] = "unsigned int";
511513
} else {
512-
AliasTypeReplacements["long"] = "long long";
513-
AliasTypeReplacements["unsigned long"] = "unsigned long long";
514+
CloneTypeReplacements["long"] = "long long";
515+
CloneTypeReplacements["unsigned long"] = "unsigned long long";
514516
}
515517

516-
// Make replaced char functions aliases to either integer or long long
518+
// Make replaced char functions clones of either integer or long long
517519
// variant
518520
if (CharSignedness == Signedness::Signed) {
519-
AliasTypeReplacements["char"] = "signed char";
521+
CloneTypeReplacements["char"] = "signed char";
520522
} else {
521-
AliasTypeReplacements["char"] = "unsigned char";
523+
CloneTypeReplacements["char"] = "unsigned char";
522524
}
523525

524526
CreateRemangledTypeReplacements();
@@ -528,21 +530,21 @@ class TargetTypeReplacements {
528530
return ParameterTypeReplacements;
529531
}
530532

531-
SmallDenseMap<const char *, const char *> getAliasTypeReplacements() {
532-
return AliasTypeReplacements;
533+
SmallDenseMap<const char *, const char *> getCloneTypeReplacements() {
534+
return CloneTypeReplacements;
533535
}
534536

535537
SmallDenseMap<const char *, const char *>
536-
getRemangledAliasTypeReplacements() {
537-
return RemangledAliasTypeReplacements;
538+
getRemangledCloneTypeReplacements() {
539+
return RemangledCloneTypeReplacements;
538540
}
539541
};
540542

541-
bool createAliasFromMap(
543+
bool createCloneFromMap(
542544
Module *M, std::string originalName,
543545
const itanium_demangle::Node *functionTree,
544546
SmallDenseMap<const char *, const char *> TypeReplacements,
545-
bool AliaseeTypeReplacement = false) {
547+
bool CloneeTypeReplacement = false) {
546548
Remangler ATR{functionTree, TypeReplacements};
547549
std::string RemangledName = ATR.remangle();
548550

@@ -553,39 +555,41 @@ bool createAliasFromMap(
553555
if (RemangledName == originalName)
554556
return true;
555557

556-
StringRef AliasName, AliaseeName;
557-
if (AliaseeTypeReplacement) {
558-
AliasName = originalName;
559-
AliaseeName = RemangledName;
558+
StringRef CloneName, CloneeName;
559+
if (CloneeTypeReplacement) {
560+
CloneName = originalName;
561+
CloneeName = RemangledName;
560562
} else {
561-
AliasName = RemangledName;
562-
AliaseeName = originalName;
563+
CloneName = RemangledName;
564+
CloneeName = originalName;
563565
}
564566

565-
Function *Aliasee = M->getFunction(AliaseeName);
566-
if (Aliasee) {
567-
GlobalAlias::create(AliasName, Aliasee);
567+
Function *Clonee = M->getFunction(CloneeName);
568+
if (Clonee) {
569+
ValueToValueMapTy Dummy;
570+
Function *NewF = CloneFunction(Clonee, Dummy);
571+
NewF->setName(std::string(CloneName));
568572
} else if (Verbose) {
569-
std::cout << "Could not create alias " << AliasName.data() << " : missing "
570-
<< AliaseeName.data() << std::endl;
573+
std::cout << "Could not create copy " << CloneName.data() << " : missing "
574+
<< CloneeName.data() << std::endl;
571575
}
572576

573577
return true;
574578
}
575579

576-
bool createAliases(Module *M, std::string originalMangledName,
577-
std::string remangledName,
578-
const itanium_demangle::Node *functionTree,
579-
TargetTypeReplacements replacements) {
580-
// create alias of original function
581-
if (!createAliasFromMap(M, originalMangledName, functionTree,
582-
replacements.getAliasTypeReplacements(),
583-
/* AliaseeTypeReplacement= */ true))
580+
bool createClones(Module *M, std::string originalMangledName,
581+
std::string remangledName,
582+
const itanium_demangle::Node *functionTree,
583+
TargetTypeReplacements replacements) {
584+
// create clone of original function
585+
if (!createCloneFromMap(M, originalMangledName, functionTree,
586+
replacements.getCloneTypeReplacements(),
587+
/* CloneeTypeReplacement= */ true))
584588
return false;
585589

586-
// create alias from remangled function
587-
if (!createAliasFromMap(M, remangledName, functionTree,
588-
replacements.getRemangledAliasTypeReplacements()))
590+
// create clone of remangled function
591+
if (!createCloneFromMap(M, remangledName, functionTree,
592+
replacements.getRemangledCloneTypeReplacements()))
589593
return false;
590594

591595
return true;
@@ -621,10 +625,10 @@ bool remangleFunction(Function &func, Module *M,
621625
}
622626
func.setName(RemangledName);
623627

624-
// Make an alias to a suitable function using the old name if there is a
625-
// type-mapping and the corresponding aliasee function exists.
626-
if (!createAliases(M, MangledName, RemangledName, FunctionTree,
627-
replacements))
628+
// Make a clone of a suitable function using the old name if there is a
629+
// type-mapping and the corresponding clonee function exists.
630+
if (!createClones(M, MangledName, RemangledName, FunctionTree,
631+
replacements))
628632
return false;
629633
}
630634

@@ -661,10 +665,14 @@ int main(int argc, const char **argv) {
661665
return 1;
662666
}
663667

664-
bool Success = true;
668+
std::vector<Function *> FuncList;
665669
for (auto &Func : M->getFunctionList())
666-
Success = remangleFunction(Func, M.get(), Replacements) && Success;
670+
FuncList.push_back(&Func);
667671

672+
bool Success = true;
673+
for (auto Func : FuncList) {
674+
Success = remangleFunction(*Func, M.get(), Replacements) && Success;
675+
}
668676
// Only fail after all to give as much context as possible.
669677
if (!Success) {
670678
errs() << "Failed to remangle all mangled functions in module.\n";

0 commit comments

Comments
 (0)