Skip to content

Commit

Permalink
merge main into amd-stg-open
Browse files Browse the repository at this point in the history
Revert items 2 and 3 and work separately with 1 to get time to integrate them into ASO
   [OpenMP] Introduce the KernelLaunchEnvironment as implicit
   [OpenMP][FIX] Allocate per launch memory for GPU team reductions (llvm#70752)
   [OpenMP][FIX] Do not add implicit argument to device Ctors and Dtors

Change-Id: I987405a1541ed3102ca78430496f611e565db9a0
  • Loading branch information
ronlieb committed Nov 2, 2023
2 parents 0a2e597 + 0e06ddf commit 2b69d00
Show file tree
Hide file tree
Showing 25 changed files with 391 additions and 220 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
- name: Fetch LLVM sources
uses: actions/checkout@v4
with:
fetch-depth: 2
fetch-depth: 2 # Fetches only the last 2 commits

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
with:
separator: ","
fetch_depth: 100 # Fetches only the last 10 commits
fetch_depth: 2000 # Fetches only the last 2000 commits

- name: "Listed files"
run: |
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# 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

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '38 20 * * 4'
push:
branches: [ "main" ]

# Declare default permissions as read only.
permissions:
contents: read

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write

steps:
- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
with:
results_file: results.sarif
results_format: sarif

# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
with:
sarif_file: results.sarif
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The LLVM Compiler Infrastructure

[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/llvm/llvm-project/badge)](https://securityscorecards.dev/viewer/?uri=github.com/llvm/llvm-project)

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/modularize/ModularizeUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ std::error_code ModularizeUtilities::loadModuleMap(
// Walks the modules and collects referenced headers into
// HeaderFileNames.
bool ModularizeUtilities::collectModuleMapHeaders(clang::ModuleMap *ModMap) {
SmallVector<std::pair<StringRef, const Module *>, 0> Vec;
SmallVector<std::pair<StringRef, const clang::Module *>, 0> Vec;
for (auto &M : ModMap->modules())
Vec.emplace_back(M.first(), M.second);
llvm::sort(Vec, llvm::less_first());
Expand All @@ -349,14 +349,14 @@ bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {
for (auto *Submodule : Mod.submodules())
collectModuleHeaders(*Submodule);

if (std::optional<Module::Header> UmbrellaHeader =
if (std::optional<clang::Module::Header> UmbrellaHeader =
Mod.getUmbrellaHeaderAsWritten()) {
std::string HeaderPath = getCanonicalPath(UmbrellaHeader->Entry.getName());
// Collect umbrella header.
HeaderFileNames.push_back(HeaderPath);

// FUTURE: When needed, umbrella header header collection goes here.
} else if (std::optional<Module::DirectoryName> UmbrellaDir =
} else if (std::optional<clang::Module::DirectoryName> UmbrellaDir =
Mod.getUmbrellaDirAsWritten()) {
// If there normal headers, assume these are umbrellas and skip collection.
if (Mod.Headers->size() == 0) {
Expand Down
3 changes: 2 additions & 1 deletion clang/include/clang/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
#include "clang/AST/Type.h"
#include "clang/Basic/AttrKinds.h"
#include "clang/Basic/AttributeCommonInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/Frontend/HLSL/HLSLResource.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
35 changes: 20 additions & 15 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,28 @@ class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
int Default = default;
}

// This argument is more complex, it includes the enumerator type name,
// a list of strings to accept, and a list of enumerators to map them to.
// This argument is more complex, it includes the enumerator type
// name, whether the enum type is externally defined, a list of
// strings to accept, and a list of enumerators to map them to.
class EnumArgument<string name, string type, list<string> values,
list<string> enums, bit opt = 0, bit fake = 0>
list<string> enums, bit opt = 0, bit fake = 0,
bit isExternalType = 0>
: Argument<name, opt, fake> {
string Type = type;
list<string> Values = values;
list<string> Enums = enums;
bit IsExternalType = isExternalType;
}

// FIXME: There should be a VariadicArgument type that takes any other type
// of argument and generates the appropriate type.
class VariadicEnumArgument<string name, string type, list<string> values,
list<string> enums> : Argument<name, 1> {
list<string> enums, bit isExternalType = 0>
: Argument<name, 1> {
string Type = type;
list<string> Values = values;
list<string> Enums = enums;
bit IsExternalType = isExternalType;
}

// This handles one spelling of an attribute.
Expand Down Expand Up @@ -4182,26 +4187,26 @@ def HLSLResource : InheritableAttr {
let Spellings = [];
let Subjects = SubjectList<[Struct]>;
let LangOpts = [HLSL];
let Args = [EnumArgument<"ResourceType", "ResourceClass",
let Args = [EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass",
["SRV", "UAV", "CBuffer", "Sampler"],
["SRV", "UAV", "CBuffer", "Sampler"]
>,
EnumArgument<"ResourceShape", "ResourceKind",
["SRV", "UAV", "CBuffer", "Sampler"],
/*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
EnumArgument<"ResourceKind", "llvm::hlsl::ResourceKind",
["Texture1D", "Texture2D", "Texture2DMS",
"Texture3D", "TextureCube", "Texture1DArray",
"Texture2DArray", "Texture2DMSArray",
"TextureCubeArray", "TypedBuffer", "RawBuffer",
"StructuredBuffer", "CBufferKind", "SamplerKind",
"TBuffer", "RTAccelerationStructure", "FeedbackTexture2D",
"FeedbackTexture2DArray"],
"StructuredBuffer", "CBuffer", "Sampler",
"TBuffer", "RTAccelerationStructure",
"FeedbackTexture2D", "FeedbackTexture2DArray"],
["Texture1D", "Texture2D", "Texture2DMS",
"Texture3D", "TextureCube", "Texture1DArray",
"Texture2DArray", "Texture2DMSArray",
"TextureCubeArray", "TypedBuffer", "RawBuffer",
"StructuredBuffer", "CBufferKind", "SamplerKind",
"TBuffer", "RTAccelerationStructure", "FeedbackTexture2D",
"FeedbackTexture2DArray"]
>
"StructuredBuffer", "CBuffer", "Sampler",
"TBuffer", "RTAccelerationStructure",
"FeedbackTexture2D", "FeedbackTexture2DArray"],
/*opt=*/0, /*fake=*/0, /*isExternalType=*/1>
];
let Documentation = [InternalOnly];
}
Expand Down
59 changes: 3 additions & 56 deletions clang/lib/CodeGen/CGHLSLRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,56 +223,6 @@ void CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
ResourceMD->addOperand(Res.getMetadata());
}

static llvm::hlsl::ResourceKind
castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
switch (RK) {
case HLSLResourceAttr::ResourceKind::Texture1D:
return llvm::hlsl::ResourceKind::Texture1D;
case HLSLResourceAttr::ResourceKind::Texture2D:
return llvm::hlsl::ResourceKind::Texture2D;
case HLSLResourceAttr::ResourceKind::Texture2DMS:
return llvm::hlsl::ResourceKind::Texture2DMS;
case HLSLResourceAttr::ResourceKind::Texture3D:
return llvm::hlsl::ResourceKind::Texture3D;
case HLSLResourceAttr::ResourceKind::TextureCube:
return llvm::hlsl::ResourceKind::TextureCube;
case HLSLResourceAttr::ResourceKind::Texture1DArray:
return llvm::hlsl::ResourceKind::Texture1DArray;
case HLSLResourceAttr::ResourceKind::Texture2DArray:
return llvm::hlsl::ResourceKind::Texture2DArray;
case HLSLResourceAttr::ResourceKind::Texture2DMSArray:
return llvm::hlsl::ResourceKind::Texture2DMSArray;
case HLSLResourceAttr::ResourceKind::TextureCubeArray:
return llvm::hlsl::ResourceKind::TextureCubeArray;
case HLSLResourceAttr::ResourceKind::TypedBuffer:
return llvm::hlsl::ResourceKind::TypedBuffer;
case HLSLResourceAttr::ResourceKind::RawBuffer:
return llvm::hlsl::ResourceKind::RawBuffer;
case HLSLResourceAttr::ResourceKind::StructuredBuffer:
return llvm::hlsl::ResourceKind::StructuredBuffer;
case HLSLResourceAttr::ResourceKind::CBufferKind:
return llvm::hlsl::ResourceKind::CBuffer;
case HLSLResourceAttr::ResourceKind::SamplerKind:
return llvm::hlsl::ResourceKind::Sampler;
case HLSLResourceAttr::ResourceKind::TBuffer:
return llvm::hlsl::ResourceKind::TBuffer;
case HLSLResourceAttr::ResourceKind::RTAccelerationStructure:
return llvm::hlsl::ResourceKind::RTAccelerationStructure;
case HLSLResourceAttr::ResourceKind::FeedbackTexture2D:
return llvm::hlsl::ResourceKind::FeedbackTexture2D;
case HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray:
return llvm::hlsl::ResourceKind::FeedbackTexture2DArray;
}
// Make sure to update HLSLResourceAttr::ResourceKind when add new Kind to
// hlsl::ResourceKind. Assume FeedbackTexture2DArray is the last enum for
// HLSLResourceAttr::ResourceKind.
static_assert(
static_cast<uint32_t>(
HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
(static_cast<uint32_t>(llvm::hlsl::ResourceKind::NumEntries) - 2));
llvm_unreachable("all switch cases should be covered");
}

void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) {
const Type *Ty = D->getType()->getPointeeOrArrayElementType();
if (!Ty)
Expand All @@ -284,15 +234,12 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) {
if (!Attr)
return;

HLSLResourceAttr::ResourceClass RC = Attr->getResourceType();
llvm::hlsl::ResourceKind RK =
castResourceShapeToResourceKind(Attr->getResourceShape());
llvm::hlsl::ResourceClass RC = Attr->getResourceClass();
llvm::hlsl::ResourceKind RK = Attr->getResourceKind();

QualType QT(Ty, 0);
BufferResBinding Binding(D->getAttr<HLSLResourceBindingAttr>());
addBufferResourceAnnotation(GV, QT.getAsString(),
static_cast<llvm::hlsl::ResourceClass>(RC), RK,
Binding);
addBufferResourceAnnotation(GV, QT.getAsString(), RC, RK, Binding);
}

CGHLSLRuntime::BufferResBinding::BufferResBinding(
Expand Down
8 changes: 3 additions & 5 deletions clang/lib/Sema/HLSLExternalSemaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ struct BuiltinTypeDeclBuilder {
return addMemberVariable("h", Ty, Access);
}

BuiltinTypeDeclBuilder &
annotateResourceClass(HLSLResourceAttr::ResourceClass RC,
HLSLResourceAttr::ResourceKind RK) {
BuiltinTypeDeclBuilder &annotateResourceClass(ResourceClass RC,
ResourceKind RK) {
if (Record->isCompleteDefinition())
return *this;
Record->addAttr(
Expand Down Expand Up @@ -503,7 +502,6 @@ void HLSLExternalSemaSource::completeBufferType(CXXRecordDecl *Record) {
.addHandleMember()
.addDefaultHandleConstructor(*SemaPtr, ResourceClass::UAV)
.addArraySubscriptOperators()
.annotateResourceClass(HLSLResourceAttr::UAV,
HLSLResourceAttr::TypedBuffer)
.annotateResourceClass(ResourceClass::UAV, ResourceKind::TypedBuffer)
.completeDefinition();
}
2 changes: 1 addition & 1 deletion clang/unittests/Sema/SemaNoloadLookupTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class NoloadLookupConsumer : public SemaConsumer {
if (!ID)
return true;

Module *M = ID->getImportedModule();
clang::Module *M = ID->getImportedModule();
assert(M);
if (M->Name != "R")
return true;
Expand Down
Loading

0 comments on commit 2b69d00

Please sign in to comment.