Skip to content

Commit e6d48f3

Browse files
authored
Merge pull request #81 from sx-aurora-dev/feature/merge-upstream-20210817-2
Feature/merge upstream 20210817 2
2 parents 79cae65 + 1294162 commit e6d48f3

File tree

427 files changed

+18941
-16130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

427 files changed

+18941
-16130
lines changed

clang/include/clang/AST/Type.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3456,10 +3456,6 @@ class ConstantMatrixType final : public MatrixType {
34563456
protected:
34573457
friend class ASTContext;
34583458

3459-
/// The element type of the matrix.
3460-
// FIXME: Appears to be unused? There is also MatrixType::ElementType...
3461-
QualType ElementType;
3462-
34633459
/// Number of rows and columns.
34643460
unsigned NumRows;
34653461
unsigned NumColumns;

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,10 @@ def ReservedIdentifier : DiagGroup<"reserved-identifier",
821821
// under separate flags.
822822
//
823823
def UnreachableCodeLoopIncrement : DiagGroup<"unreachable-code-loop-increment">;
824+
def UnreachableCodeFallthrough : DiagGroup<"unreachable-code-fallthrough">;
824825
def UnreachableCode : DiagGroup<"unreachable-code",
825-
[UnreachableCodeLoopIncrement]>;
826+
[UnreachableCodeLoopIncrement,
827+
UnreachableCodeFallthrough]>;
826828
def UnreachableCodeBreak : DiagGroup<"unreachable-code-break">;
827829
def UnreachableCodeReturn : DiagGroup<"unreachable-code-return">;
828830
def UnreachableCodeAggressive : DiagGroup<"unreachable-code-aggressive",

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,9 @@ def warn_unreachable_return : Warning<
682682
def warn_unreachable_loop_increment : Warning<
683683
"loop will run at most once (loop increment never executed)">,
684684
InGroup<UnreachableCodeLoopIncrement>, DefaultIgnore;
685+
def warn_unreachable_fallthrough_attr : Warning<
686+
"fallthrough annotation in unreachable code">,
687+
InGroup<UnreachableCodeFallthrough>, DefaultIgnore;
685688
def note_unreachable_silence : Note<
686689
"silence by adding parentheses to mark code as explicitly dead">;
687690

@@ -9578,9 +9581,6 @@ def err_fallthrough_attr_outside_switch : Error<
95789581
"fallthrough annotation is outside switch statement">;
95799582
def err_fallthrough_attr_invalid_placement : Error<
95809583
"fallthrough annotation does not directly precede switch label">;
9581-
def warn_fallthrough_attr_unreachable : Warning<
9582-
"fallthrough annotation in unreachable code">,
9583-
InGroup<ImplicitFallthrough>, DefaultIgnore;
95849584

95859585
def warn_unreachable_default : Warning<
95869586
"default label in switch which covers all enumeration values">,

clang/include/clang/Basic/TargetInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,11 @@ class TargetInfo : public virtual TransferrableTargetInfo,
871871
/// across the current set of primary and secondary targets.
872872
virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0;
873873

874+
/// Returns target-specific min and max values VScale_Range.
875+
virtual Optional<std::pair<unsigned, unsigned>>
876+
getVScaleRange(const LangOptions &LangOpts) const {
877+
return None;
878+
}
874879
/// The __builtin_clz* and __builtin_ctz* built-in
875880
/// functions are specified to have undefined results for zero inputs, but
876881
/// on targets that support these operations in a way that provides

clang/lib/AST/ASTDiagnostic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,9 @@ class TemplateDiff {
10881088
Ty->getAs<TemplateSpecializationType>())
10891089
return TST;
10901090

1091+
if (const auto* SubstType = Ty->getAs<SubstTemplateTypeParmType>())
1092+
Ty = SubstType->getReplacementType();
1093+
10911094
const RecordType *RT = Ty->getAs<RecordType>();
10921095

10931096
if (!RT)

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ ArrayRef<Builtin::Info> AArch64TargetInfo::getTargetBuiltins() const {
424424
Builtin::FirstTSBuiltin);
425425
}
426426

427+
Optional<std::pair<unsigned, unsigned>>
428+
AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
429+
if (LangOpts.ArmSveVectorBits) {
430+
unsigned VScale = LangOpts.ArmSveVectorBits / 128;
431+
return std::pair<unsigned, unsigned>(VScale, VScale);
432+
}
433+
if (hasFeature("sve"))
434+
return std::pair<unsigned, unsigned>(0, 16);
435+
return None;
436+
}
437+
427438
bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
428439
return Feature == "aarch64" || Feature == "arm64" || Feature == "arm" ||
429440
(Feature == "neon" && (FPU & NeonMode)) ||

clang/lib/Basic/Targets/AArch64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
9696

9797
ArrayRef<Builtin::Info> getTargetBuiltins() const override;
9898

99+
Optional<std::pair<unsigned, unsigned>>
100+
getVScaleRange(const LangOptions &LangOpts) const override;
101+
99102
bool hasFeature(StringRef Feature) const override;
100103
bool handleTargetFeatures(std::vector<std::string> &Features,
101104
DiagnosticsEngine &Diags) override;

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,13 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
484484
// function.
485485
CurFn->addFnAttr("min-legal-vector-width", llvm::utostr(LargestVectorWidth));
486486

487-
// Add vscale attribute if appropriate.
488-
if (getLangOpts().ArmSveVectorBits) {
489-
unsigned VScale = getLangOpts().ArmSveVectorBits / 128;
490-
CurFn->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs(getLLVMContext(),
491-
VScale, VScale));
487+
// Add vscale_range attribute if appropriate.
488+
Optional<std::pair<unsigned, unsigned>> VScaleRange =
489+
getContext().getTargetInfo().getVScaleRange(getLangOpts());
490+
if (VScaleRange) {
491+
CurFn->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs(
492+
getLLVMContext(), VScaleRange.getValue().first,
493+
VScaleRange.getValue().second));
492494
}
493495

494496
// If we generated an unreachable return block, delete it now.

clang/lib/Driver/ToolChains/AVR.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,21 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
453453
}
454454

455455
llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
456+
// Search avr-libc installation according to avr-gcc installation.
457+
std::string GCCParent(GCCInstallation.getParentLibPath());
458+
std::string Path(GCCParent + "/avr");
459+
if (llvm::sys::fs::is_directory(Path))
460+
return Path;
461+
Path = GCCParent + "/../avr";
462+
if (llvm::sys::fs::is_directory(Path))
463+
return Path;
464+
465+
// Search avr-libc installation from possible locations, and return the first
466+
// one that exists, if there is no avr-gcc installed.
456467
for (StringRef PossiblePath : PossibleAVRLibcLocations) {
457468
std::string Path = getDriver().SysRoot + PossiblePath.str();
458-
// Return the first avr-libc installation that exists.
459469
if (llvm::sys::fs::is_directory(Path))
460-
return Optional<std::string>(Path);
470+
return Path;
461471
}
462472

463473
return llvm::None;

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ namespace {
11251125
// unreachable in all instantiations of the template.
11261126
if (!IsTemplateInstantiation)
11271127
S.Diag(AS->getBeginLoc(),
1128-
diag::warn_fallthrough_attr_unreachable);
1128+
diag::warn_unreachable_fallthrough_attr);
11291129
markFallthroughVisited(AS);
11301130
++AnnotatedCnt;
11311131
break;

clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file defines a CheckObjCInstMethSignature, a flow-insenstive check
9+
// This file defines a CheckObjCInstMethSignature, a flow-insensitive check
1010
// that determines if an Objective-C class interface incorrectly redefines
1111
// the method signature in a subclass.
1212
//

clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file defines a CheckNSError, a flow-insenstive check
9+
// This file defines a CheckNSError, a flow-insensitive check
1010
// that determines if an Objective-C class interface correctly returns
1111
// a non-void return type.
1212
//

clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,15 +1289,32 @@ var findNum = function() {
12891289
return out;
12901290
};
12911291
1292+
var classListAdd = function(el, theClass) {
1293+
if(!el.className.baseVal)
1294+
el.className += " " + theClass;
1295+
else
1296+
el.className.baseVal += " " + theClass;
1297+
};
1298+
1299+
var classListRemove = function(el, theClass) {
1300+
var className = (!el.className.baseVal) ?
1301+
el.className : el.className.baseVal;
1302+
className = className.replace(" " + theClass, "");
1303+
if(!el.className.baseVal)
1304+
el.className = className;
1305+
else
1306+
el.className.baseVal = className;
1307+
};
1308+
12921309
var scrollTo = function(el) {
12931310
querySelectorAllArray(".selected").forEach(function(s) {
1294-
s.classList.remove("selected");
1311+
classListRemove(s, "selected");
12951312
});
1296-
el.classList.add("selected");
1313+
classListAdd(el, "selected");
12971314
window.scrollBy(0, el.getBoundingClientRect().top -
12981315
(window.innerHeight / 2));
12991316
highlightArrowsForSelectedEvent();
1300-
}
1317+
};
13011318
13021319
var move = function(num, up, numItems) {
13031320
if (num == 1 && up || num == numItems - 1 && !up) {
@@ -1332,9 +1349,11 @@ window.addEventListener("keydown", function (event) {
13321349
if (event.defaultPrevented) {
13331350
return;
13341351
}
1335-
if (event.key == "j") {
1352+
// key 'j'
1353+
if (event.keyCode == 74) {
13361354
navigateTo(/*up=*/false);
1337-
} else if (event.key == "k") {
1355+
// key 'k'
1356+
} else if (event.keyCode == 75) {
13381357
navigateTo(/*up=*/true);
13391358
} else {
13401359
return;
@@ -1350,8 +1369,11 @@ StringRef HTMLDiagnostics::generateArrowDrawingJavascript() {
13501369
<script type='text/javascript'>
13511370
// Return range of numbers from a range [lower, upper).
13521371
function range(lower, upper) {
1353-
const size = upper - lower;
1354-
return Array.from(new Array(size), (x, i) => i + lower);
1372+
var array = [];
1373+
for (var i = lower; i <= upper; ++i) {
1374+
array.push(i);
1375+
}
1376+
return array;
13551377
}
13561378
13571379
var getRelatedArrowIndices = function(pathId) {
@@ -1371,7 +1393,9 @@ var highlightArrowsForSelectedEvent = function() {
13711393
const arrowIndicesToHighlight = getRelatedArrowIndices(selectedNum);
13721394
arrowIndicesToHighlight.forEach((index) => {
13731395
var arrow = document.querySelector("#arrow" + index);
1374-
arrow.classList.add("selected");
1396+
if(arrow) {
1397+
classListAdd(arrow, "selected")
1398+
}
13751399
});
13761400
}
13771401

clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=512
44
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=1024
55
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=2048
6+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2 -msve-vector-bits=128 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=128
7+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2 -msve-vector-bits=256 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=256
8+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2 -msve-vector-bits=scalable -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-NONE
69
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=scalable -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-NONE
710
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-NONE
811

912
// CHECK-LABEL: @func() #0
1013
// CHECK: attributes #0 = { {{.*}} vscale_range([[#div(VBITS,128)]],[[#div(VBITS,128)]]) {{.*}} }
11-
// CHECK-NONE-NOT: vscale_range
14+
// CHECK-NONE: attributes #0 = { {{.*}} vscale_range(0,16) {{.*}} }
1215
void func() {}

clang/test/CodeGen/thinlto-distributed-newpm.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
; CHECK-O: Running pass: LoopSimplifyPass on main
135135
; CHECK-O: Running analysis: LoopAnalysis on main
136136
; CHECK-O: Running pass: LCSSAPass on main
137-
; CHECK-O: Running analysis: MemorySSAAnalysis on main
138137
; CHECK-O: Running analysis: AAManager on main
139138
; CHECK-O: Running analysis: BasicAA on main
140139
; CHECK-O: Running analysis: ScalarEvolutionAnalysis on main
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -fcuda-is-device \
2+
// RUN: -target-cpu gfx90a -Rpass=atomic-expand -S -o - 2>&1 | \
3+
// RUN: FileCheck %s --check-prefix=GFX90A-CAS
4+
5+
// REQUIRES: amdgpu-registered-target
6+
7+
#include "Inputs/cuda.h"
8+
#include <stdatomic.h>
9+
10+
// GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at system memory scope
11+
// GFX90A-CAS-LABEL: _Z14atomic_add_casPf
12+
// GFX90A-CAS: flat_atomic_cmpswap v0, v[2:3], v[4:5] glc
13+
// GFX90A-CAS: s_cbranch_execnz
14+
__device__ float atomic_add_cas(float *p) {
15+
return __atomic_fetch_add(p, 1.0f, memory_order_relaxed);
16+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu gfx90a \
2+
// RUN: -Rpass=atomic-expand -S -o - 2>&1 | \
3+
// RUN: FileCheck %s --check-prefix=REMARK
4+
5+
// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu gfx90a \
6+
// RUN: -Rpass=atomic-expand -S -emit-llvm -o - 2>&1 | \
7+
// RUN: FileCheck %s --check-prefix=GFX90A-CAS
8+
9+
// REQUIRES: amdgpu-registered-target
10+
11+
typedef enum memory_order {
12+
memory_order_relaxed = __ATOMIC_RELAXED,
13+
memory_order_acquire = __ATOMIC_ACQUIRE,
14+
memory_order_release = __ATOMIC_RELEASE,
15+
memory_order_acq_rel = __ATOMIC_ACQ_REL,
16+
memory_order_seq_cst = __ATOMIC_SEQ_CST
17+
} memory_order;
18+
19+
typedef enum memory_scope {
20+
memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
21+
memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
22+
memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
23+
memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
24+
#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
25+
memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
26+
#endif
27+
} memory_scope;
28+
29+
// REMARK: remark: A compare and swap loop was generated for an atomic fadd operation at workgroup-one-as memory scope [-Rpass=atomic-expand]
30+
// REMARK: remark: A compare and swap loop was generated for an atomic fadd operation at agent-one-as memory scope [-Rpass=atomic-expand]
31+
// REMARK: remark: A compare and swap loop was generated for an atomic fadd operation at one-as memory scope [-Rpass=atomic-expand]
32+
// REMARK: remark: A compare and swap loop was generated for an atomic fadd operation at wavefront-one-as memory scope [-Rpass=atomic-expand]
33+
// GFX90A-CAS-LABEL: @atomic_cas
34+
// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("workgroup-one-as") monotonic
35+
// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("agent-one-as") monotonic
36+
// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("one-as") monotonic
37+
// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("wavefront-one-as") monotonic
38+
float atomic_cas(__global atomic_float *d, float a) {
39+
float ret1 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_work_group);
40+
float ret2 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_device);
41+
float ret3 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_all_svm_devices);
42+
float ret4 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, memory_scope_sub_group);
43+
}

clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/include/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/lib/libavr.a

Whitespace-only changes.

clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/lib/gcc/avr/10.3.0/libgcc.a

Whitespace-only changes.

clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/include/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/lib/libavr.a

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--- !ELF
2+
FileHeader:
3+
Class: ELFCLASS[[BITS]]
4+
Data: ELFDATA2[[ENCODING]]
5+
Type: ET_REL

clang/test/Driver/avr-toolchain.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@
66
// CHECK1-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]"
77
// CHECK1-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree]]"
88
// CHECK1-SAME: "-internal-isystem"
9-
// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/avr/include"
9+
// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/gcc/avr/5.4.0/../../../avr/include"
1010
// CHECK1-NOT: "-L
1111
// CHECK1: avr-ld"
1212
// CHECK1-SAME: "-o" "a.out"
1313
// CHECK1-SAME: {{^}} "--gc-sections"
1414

15+
// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 %s
16+
// CHECK2: clang{{.*}} "-cc1" "-triple" "avr"
17+
// CHECK2-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2/opt/local]]"
18+
// CHECK2-SAME: "-internal-isystem"
19+
// CHECK2-SAME: {{^}} "[[SYSROOT]]/lib/gcc/avr/10.3.0/../../../../avr/include"
20+
21+
// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2 -S 2>&1 | FileCheck --check-prefix=CHECK3 %s
22+
// CHECK3: clang{{.*}} "-cc1" "-triple" "avr"
23+
// CHECK3-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2]]"
24+
// CHECK3-SAME: "-internal-isystem"
25+
// CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
26+
1527
// RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
1628
// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
1729

clang/test/Driver/clang-offload-wrapper.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
//
2020
// Check bitcode produced by the wrapper tool.
2121
//
22-
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt
22+
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt 2>&1 | FileCheck %s --check-prefix ELF-WARNING
2323
// RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR
2424

25+
// ELF-WARNING: is not an ELF image, so notes cannot be added to it.
2526
// CHECK-IR: target triple = "x86_64-pc-linux-gnu"
2627

2728
// CHECK-IR-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i{{32|64}}, i32, i32 }
@@ -53,3 +54,24 @@
5354
// CHECK-IR: ret void
5455

5556
// CHECK-IR: declare void @__tgt_unregister_lib([[DESCTY]]*)
57+
58+
// Check that clang-offload-wrapper adds LLVMOMPOFFLOAD notes
59+
// into the ELF offload images:
60+
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64le -DBITS=64 -DENCODING=LSB
61+
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64le.bc %t.64le
62+
// RUN: llvm-dis %t.wrapper.elf64le.bc -o - | FileCheck %s --check-prefix OMPNOTES
63+
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64be -DBITS=64 -DENCODING=MSB
64+
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64be.bc %t.64be
65+
// RUN: llvm-dis %t.wrapper.elf64be.bc -o - | FileCheck %s --check-prefix OMPNOTES
66+
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32le -DBITS=32 -DENCODING=LSB
67+
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32le.bc %t.32le
68+
// RUN: llvm-dis %t.wrapper.elf32le.bc -o - | FileCheck %s --check-prefix OMPNOTES
69+
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32be -DBITS=32 -DENCODING=MSB
70+
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32be.bc %t.32be
71+
// RUN: llvm-dis %t.wrapper.elf32be.bc -o - | FileCheck %s --check-prefix OMPNOTES
72+
73+
// There is no clean way for extracting the offload image
74+
// from the object file currently, so try to find
75+
// the inserted ELF notes in the device image variable's
76+
// initializer:
77+
// OMPNOTES: @{{.+}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"{{.*}}LLVMOMPOFFLOAD{{.*}}LLVMOMPOFFLOAD{{.*}}LLVMOMPOFFLOAD{{.*}}"

0 commit comments

Comments
 (0)