Skip to content

Commit

Permalink
Merge branch 'sycl' into iault/unsampled_image_arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacault committed Feb 23, 2024
2 parents efd0fc5 + 5a92a19 commit 77113e3
Show file tree
Hide file tree
Showing 188 changed files with 4,682 additions and 1,535 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

# Check current LLVM-Project results here: https://securityscorecards.dev/viewer/?uri=github.com/llvm/llvm-project
# Check current LLVM-Project results here: https://securityscorecards.dev/viewer/?uri=github.com/intel/llvm

name: Scorecard supply-chain security
on:
Expand All @@ -12,7 +12,7 @@ on:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '38 20 * * *'
- cron: '30 20 * * *'

# Declare default permissions as read only.
permissions:
Expand All @@ -22,7 +22,7 @@ jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
if: github.repository == 'llvm/llvm-project'
if: github.repository == 'intel/llvm'
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/sycl-linux-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,37 @@ jobs:
fail-fast: false
matrix:
include:
- name: Perf tests on Intel GEN12 Graphics system
- name: Intel GEN12 Graphics system
runner: '["Linux", "gen12"]'
- name: Perf tests on Intel Arc A-Series Graphics system
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest
image_extra_opts: --device=/dev/dri
reset_gpu: true
- name: Intel Arc A-Series Graphics system
runner: '["Linux", "arc"]'
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest
image_extra_opts: --device=/dev/dri
reset_gpu: true
- name: AMD system
runner: '["Linux", "amdgpu"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
image_extra_opts: --device=/dev/dri --device=/dev/kfd
extra_cmake_args: -DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1031"
- name: CUDA system
runner: '["Linux", "cuda"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
image_extra_opts: --gpus all
uses: ./.github/workflows/sycl-linux-run-tests.yml
with:
name: ${{ matrix.name }}
name: Perf tests on ${{ matrix.name }}
runner: ${{ matrix. runner }}
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest
image_options: -u 1001 --device=/dev/dri --privileged --cap-add SYS_ADMIN
image: ${{ matrix.image }}
image_options: -u 1001 --privileged --cap-add SYS_ADMIN ${{ matrix.image_extra_opts }}
target_devices: all
reset_gpu: true
reset_gpu: ${{ matrix.reset_gpu }}

env: '{"LIT_FILTER":"PerformanceTests/"}'
extra_lit_opts: -a -j 1 --param enable-perf-tests=True
extra_cmake_args: ${{ matrix.extra_cmake_args }}

ref: ${{ github.sha }}
merge_ref: ''
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sycl-linux-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ on:
options:
- 'opencl:cpu'
- 'opencl:gpu'
- 'opencl:acc'
- 'opencl:fpga'
- 'ext_oneapi_level_zero:gpu'
- 'ext_oneapi_hip:gpu'
tests_selector:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sycl-post-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- name: Intel GEN12 Graphics with Level Zero
runner: '["Linux", "gen12"]'
extra_lit_opts: --param gpu-intel-gen12=True
target_devices: ext_oneapi_level_zero:gpu;opencl:fpga
- name: Intel Arc A-Series Graphics with Level Zero
runner: '["Linux", "arc"]'
extra_lit_opts: --param matrix-xmx8=True --param gpu-intel-dg2=True
Expand Down
13 changes: 5 additions & 8 deletions clang/lib/CodeGen/CGVTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
llvm::GlobalVariable::LinkageTypes Linkage,
const CXXRecordDecl *RD) {
VTTBuilder Builder(CGM.getContext(), RD, /*GenerateDefinition=*/true);
llvm::ArrayType *ArrayType =
llvm::ArrayType::get(CGM.DefaultInt8PtrTy, Builder.getVTTComponents().size());
llvm::ArrayType *ArrayType = llvm::ArrayType::get(
CGM.GlobalsInt8PtrTy, Builder.getVTTComponents().size());

SmallVector<llvm::GlobalVariable *, 8> VTables;
SmallVector<VTableAddressPointsMapTy, 8> VTableAddressPoints;
Expand Down Expand Up @@ -81,9 +81,6 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
VTable->getValueType(), VTable, Idxs, /*InBounds=*/true,
/*InRangeIndex=*/1);

Init = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
Init, CGM.Int8PtrTy);

VTTComponents.push_back(Init);
}

Expand Down Expand Up @@ -117,9 +114,9 @@ llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

VTTBuilder Builder(CGM.getContext(), RD, /*GenerateDefinition=*/false);

llvm::ArrayType *ArrayType =
llvm::ArrayType::get(CGM.Int8PtrTy, Builder.getVTTComponents().size());
llvm::Align Align = CGM.getDataLayout().getABITypeAlign(CGM.Int8PtrTy);
llvm::ArrayType *ArrayType = llvm::ArrayType::get(
CGM.GlobalsInt8PtrTy, Builder.getVTTComponents().size());
llvm::Align Align = CGM.getDataLayout().getABITypeAlign(CGM.GlobalsInt8PtrTy);

llvm::GlobalVariable *GV = CGM.CreateOrReplaceCXXRuntimeVariable(
Name, ArrayType, llvm::GlobalValue::ExternalLinkage, Align);
Expand Down
32 changes: 22 additions & 10 deletions clang/lib/CodeGen/CGVTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ bool CodeGenVTables::useRelativeLayout() const {
llvm::Type *CodeGenModule::getVTableComponentType() const {
if (UseRelativeLayout(*this))
return Int32Ty;
return Int8PtrTy;
return GlobalsInt8PtrTy;
}

llvm::Type *CodeGenVTables::getVTableComponentType() const {
Expand All @@ -704,7 +704,7 @@ static void AddPointerLayoutOffset(const CodeGenModule &CGM,
CharUnits offset) {
builder.add(llvm::ConstantExpr::getIntToPtr(
llvm::ConstantInt::get(CGM.PtrDiffTy, offset.getQuantity()),
CGM.Int8PtrTy));
CGM.GlobalsInt8PtrTy));
}

static void AddRelativeLayoutOffset(const CodeGenModule &CGM,
Expand Down Expand Up @@ -741,7 +741,7 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
vtableHasLocalLinkage,
/*isCompleteDtor=*/false);
else
return builder.add(llvm::ConstantExpr::getBitCast(rtti, CGM.Int8PtrTy));
return builder.add(rtti);

case VTableComponent::CK_FunctionPointer:
case VTableComponent::CK_CompleteDtorPointer:
Expand All @@ -760,7 +760,8 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
? MD->hasAttr<CUDADeviceAttr>()
: (MD->hasAttr<CUDAHostAttr>() || !MD->hasAttr<CUDADeviceAttr>());
if (!CanEmitMethod)
return builder.add(llvm::ConstantExpr::getNullValue(CGM.Int8PtrTy));
return builder.add(
llvm::ConstantExpr::getNullValue(CGM.GlobalsInt8PtrTy));
// Method is acceptable, continue processing as usual.
}

Expand All @@ -773,20 +774,20 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
// with the local symbol. As a temporary solution, fill these components
// with zero. We shouldn't be calling these in the first place anyway.
if (useRelativeLayout())
return llvm::ConstantPointerNull::get(CGM.Int8PtrTy);
return llvm::ConstantPointerNull::get(CGM.GlobalsInt8PtrTy);

// For NVPTX devices in OpenMP emit special functon as null pointers,
// otherwise linking ends up with unresolved references.
if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPIsTargetDevice &&
CGM.getTriple().isNVPTX())
return llvm::ConstantPointerNull::get(CGM.Int8PtrTy);
return llvm::ConstantPointerNull::get(CGM.GlobalsInt8PtrTy);
llvm::FunctionType *fnTy =
llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
llvm::Constant *fn = cast<llvm::Constant>(
CGM.CreateRuntimeFunction(fnTy, name).getCallee());
if (auto f = dyn_cast<llvm::Function>(fn))
f->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
return llvm::ConstantExpr::getBitCast(fn, CGM.Int8PtrTy);
return fn;
};

llvm::Constant *fnPtr;
Expand Down Expand Up @@ -824,15 +825,26 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
return addRelativeComponent(
builder, fnPtr, vtableAddressPoint, vtableHasLocalLinkage,
component.getKind() == VTableComponent::CK_CompleteDtorPointer);
} else
return builder.add(llvm::ConstantExpr::getBitCast(fnPtr, CGM.Int8PtrTy));
} else {
// TODO: this icky and only exists due to functions being in the generic
// address space, rather than the global one, even though they are
// globals; fixing said issue might be intrusive, and will be done
// later.
unsigned FnAS = fnPtr->getType()->getPointerAddressSpace();
unsigned GVAS = CGM.GlobalsInt8PtrTy->getPointerAddressSpace();

if (FnAS != GVAS)
fnPtr =
llvm::ConstantExpr::getAddrSpaceCast(fnPtr, CGM.GlobalsInt8PtrTy);
return builder.add(fnPtr);
}
}

case VTableComponent::CK_UnusedFunctionPointer:
if (useRelativeLayout())
return builder.add(llvm::ConstantExpr::getNullValue(CGM.Int32Ty));
else
return builder.addNullPointer(CGM.Int8PtrTy);
return builder.addNullPointer(CGM.GlobalsInt8PtrTy);
}

llvm_unreachable("Unexpected vtable component kind");
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7982,7 +7982,7 @@ llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty,
// FIXME: should we even be calling this method if RTTI is disabled
// and it's not for EH?
if (!shouldEmitRTTI(ForEH))
return llvm::Constant::getNullValue(Int8PtrTy);
return llvm::Constant::getNullValue(GlobalsInt8PtrTy);

if (ForEH && Ty->isObjCObjectPointerType() &&
LangOpts.ObjCRuntime.isGNUFamily())
Expand Down
34 changes: 17 additions & 17 deletions clang/lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
CGF.EmitBlock(FnVirtual);

// Cast the adjusted this to a pointer to vtable pointer and load.
llvm::Type *VTableTy = Builder.getInt8PtrTy();
llvm::Type *VTableTy = CGF.CGM.GlobalsInt8PtrTy;
CharUnits VTablePtrAlign =
CGF.CGM.getDynamicOffsetAlignment(ThisAddr.getAlignment(), RD,
CGF.getPointerAlign());
Expand Down Expand Up @@ -1942,11 +1942,11 @@ llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructorWithVTT(
/// Load the VTT.
llvm::Value *VTT = CGF.LoadCXXVTT();
if (VirtualPointerIndex)
VTT = CGF.Builder.CreateConstInBoundsGEP1_64(
CGF.VoidPtrTy, VTT, VirtualPointerIndex);
VTT = CGF.Builder.CreateConstInBoundsGEP1_64(CGF.GlobalsVoidPtrTy, VTT,
VirtualPointerIndex);

// And load the address point from the VTT.
return CGF.Builder.CreateAlignedLoad(CGF.VoidPtrTy, VTT,
return CGF.Builder.CreateAlignedLoad(CGF.GlobalsVoidPtrTy, VTT,
CGF.getPointerAlign());
}

Expand Down Expand Up @@ -1974,12 +1974,13 @@ llvm::GlobalVariable *ItaniumCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
CGM.getItaniumVTableContext().getVTableLayout(RD);
llvm::Type *VTableType = CGM.getVTables().getVTableType(VTLayout);

// Use pointer alignment for the vtable. Otherwise we would align them based
// on the size of the initializer which doesn't make sense as only single
// values are read.
// Use pointer to global alignment for the vtable. Otherwise we would align
// them based on the size of the initializer which doesn't make sense as only
// single values are read.
LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr);
unsigned PAlign = CGM.getItaniumVTableContext().isRelativeLayout()
? 32
: CGM.getTarget().getPointerAlign(LangAS::Default);
: CGM.getTarget().getPointerAlign(AS);

VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
Name, VTableType, llvm::GlobalValue::ExternalLinkage,
Expand Down Expand Up @@ -3281,10 +3282,9 @@ ItaniumRTTIBuilder::GetAddrOfExternalRTTIDescriptor(QualType Ty) {
// Note for the future: If we would ever like to do deferred emission of
// RTTI, check if emitting vtables opportunistically need any adjustment.

GV = new llvm::GlobalVariable(CGM.getModule(), CGM.Int8PtrTy,
/*isConstant=*/true,
llvm::GlobalValue::ExternalLinkage, nullptr,
Name);
GV = new llvm::GlobalVariable(
CGM.getModule(), CGM.GlobalsInt8PtrTy,
/*isConstant=*/true, llvm::GlobalValue::ExternalLinkage, nullptr, Name);
const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
CGM.setGVProperties(GV, RD);
// Import the typeinfo symbol when all non-inline virtual methods are
Expand Down Expand Up @@ -3680,8 +3680,8 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
if (CGM.getItaniumVTableContext().isRelativeLayout())
VTable = CGM.getModule().getNamedAlias(VTableName);
if (!VTable) {
llvm::Type *Ty = llvm::ArrayType::get(CGM.DefaultInt8PtrTy, 0);
VTable = CGM.CreateRuntimeVariable(Ty, VTableName);
llvm::Type *Ty = llvm::ArrayType::get(CGM.GlobalsInt8PtrTy, 0);
VTable = CGM.getModule().getOrInsertGlobal(VTableName, Ty);
}

CGM.setDSOLocal(cast<llvm::GlobalValue>(VTable->stripPointerCasts()));
Expand All @@ -3698,7 +3698,7 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.Int8Ty, VTable, Eight);
} else {
llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
VTable = llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.DefaultInt8PtrTy,
VTable = llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.GlobalsInt8PtrTy,
VTable, Two);
}

Expand Down Expand Up @@ -3835,7 +3835,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
llvm::ConstantInt::get(CGM.Int64Ty, ((uint64_t)1) << 63);
TypeNameField = llvm::ConstantExpr::getAdd(TypeNameField, flag);
TypeNameField =
llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.Int8PtrTy);
llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.GlobalsInt8PtrTy);
} else {
TypeNameField = TypeName;
}
Expand Down Expand Up @@ -3965,7 +3965,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
GV->setComdat(M.getOrInsertComdat(GV->getName()));

CharUnits Align = CGM.getContext().toCharUnitsFromBits(
CGM.getTarget().getPointerAlign(LangAS::Default));
CGM.getTarget().getPointerAlign(CGM.GetGlobalVarAddressSpace(nullptr)));
GV->setAlignment(Align.getAsAlign());

// The Itanium ABI specifies that type_info objects must be globally
Expand Down
15 changes: 10 additions & 5 deletions clang/lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,22 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
// able to remove), or non-regular files. Underlying tools may have
// intentionally not overwritten them.

// Save the device code files(spv files) only if -fsycl-dump-device-code
// option is enabled.
// Save the device code files if -fsycl-dump-device-code option is enabled.
if (TheDriver.isDumpDeviceCodeEnabled()) {
Arg *DumpDeviceCodeArg =
getArgs().getLastArg(options::OPT_fsycl_dump_device_code_EQ);
std::string ExpectedDir =
DumpDeviceCodeArg ? DumpDeviceCodeArg->getValue() : "";
std::string ActualFile(File);
if (ActualFile.find(ExpectedDir) != std::string::npos &&
llvm::sys::path::extension(ActualFile).equals(".spv"))
return false;

if (ActualFile.find(ExpectedDir) != std::string::npos) {
// Save PTX files generated by LLVM NVPTX Back-End,
// when the nvptx*-nvidia-cuda is passed to -fsycl-targets.
if (DefaultToolChain.getTriple().isNVPTX())
return false;
if (llvm::sys::path::extension(ActualFile).equals(".spv"))
return false;
}
}

if (!llvm::sys::fs::can_write(File) || !llvm::sys::fs::is_regular_file(File))
Expand Down
13 changes: 9 additions & 4 deletions clang/lib/Driver/ToolChains/MSVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,23 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-defaultlib:oldnames");
}

if ((!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_fsycl) &&
if ((Args.hasArg(options::OPT_fsycl) &&
!Args.hasArg(options::OPT_nolibsycl)) ||
Args.hasArg(options::OPT_fsycl_host_compiler_EQ)) {
CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
TC.getDriver().Dir + "/../lib"));
// When msvcrtd is added via --dependent-lib, we add the sycld
// equivalent. Do not add the -defaultlib as it conflicts.
if (!isDependentLibAdded(Args, "msvcrtd")) {
if (!Args.hasArg(options::OPT__SLASH_MDd) &&
!isDependentLibAdded(Args, "msvcrtd")) {
if (Args.hasArg(options::OPT_fpreview_breaking_changes))
CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION "-preview.lib");
else
CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION ".lib");
} else {
if (Args.hasArg(options::OPT_fpreview_breaking_changes))
CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION
"-previewd.lib");
else
CmdArgs.push_back("-defaultlib:sycl" SYCL_MAJOR_VERSION "d.lib");
}
CmdArgs.push_back("-defaultlib:sycl-devicelib-host.lib");
}
Expand Down
20 changes: 20 additions & 0 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
C.getArgs().MakeArgString("--out-dir=" + OutputDirName));
}

// If fsycl-dump-device-code is passed, put the PTX files
// into the path provided in fsycl-dump-device-code.
if (T->getToolChain().getTriple().isNVPTX() &&
C.getDriver().isDumpDeviceCodeEnabled() && Ext.equals("s")) {
SmallString<128> OutputDir;

Arg *DumpDeviceCodeArg =
C.getArgs().getLastArg(options::OPT_fsycl_dump_device_code_EQ);

OutputDir = (DumpDeviceCodeArg ? DumpDeviceCodeArg->getValue() : "");

// If the output directory path is empty, put the PTX files in the
// current directory.
if (OutputDir.empty())
llvm::sys::path::native(OutputDir = "./");
else
OutputDir.append(llvm::sys::path::get_separator());
ForeachArgs.push_back(C.getArgs().MakeArgString("--out-dir=" + OutputDir));
}

ForeachArgs.push_back(C.getArgs().MakeArgString("--"));
ForeachArgs.push_back(
C.getArgs().MakeArgString(InputCommand->getExecutable()));
Expand Down
Loading

0 comments on commit 77113e3

Please sign in to comment.