Skip to content

Commit d6e4899

Browse files
authored
Merge branch 'main' into users/rampitec/07-31-_amdgpu_regenerate_checks_in_the_codegen_amdgpu_fptrunc.f16.ll._nfc
2 parents 8910788 + 7b5a44c commit d6e4899

File tree

8 files changed

+76
-26
lines changed

8 files changed

+76
-26
lines changed

lldb/packages/Python/lldbsuite/test/builders/builder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def getCompiler(self):
2626

2727
def getTriple(self, arch):
2828
"""Returns the triple for the given architecture or None."""
29-
return None
29+
return configuration.triple
3030

3131
def getExtraMakeArgs(self):
3232
"""
@@ -37,6 +37,9 @@ def getExtraMakeArgs(self):
3737

3838
def getArchCFlags(self, architecture):
3939
"""Returns the ARCH_CFLAGS for the make system."""
40+
triple = self.getTriple(architecture)
41+
if triple:
42+
return ["ARCH_CFLAGS=-target {}".format(triple)]
4043
return []
4144

4245
def getMake(self, test_subdir, test_name):

lldb/packages/Python/lldbsuite/test/configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
sdkroot = None
4646
make_path = None
4747

48+
# Allow specifying a triple for cross compilation.
49+
triple = None
50+
4851
# The overriden dwarf verison.
4952
# Don't use this to test the current compiler's
5053
# DWARF version, as this won't be set if the
@@ -141,6 +144,7 @@
141144
# Typical values include Debug, Release, RelWithDebInfo and MinSizeRel
142145
cmake_build_type = None
143146

147+
144148
def shouldSkipBecauseOfCategories(test_categories):
145149
if use_categories:
146150
if (

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,13 @@ def parseOptionsAndInitTestdirs():
321321
logging.error("No SDK found with the name %s; aborting...", args.apple_sdk)
322322
sys.exit(-1)
323323

324+
if args.triple:
325+
configuration.triple = args.triple
326+
324327
if args.arch:
325328
configuration.arch = args.arch
329+
elif args.triple:
330+
configuration.arch = args.triple.split("-")[0]
326331
else:
327332
configuration.arch = platform_machine
328333

lldb/packages/Python/lldbsuite/test/dotest_args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ def create_parser():
5858
"""Specify the path to sysroot. This overrides apple_sdk sysroot."""
5959
),
6060
)
61+
group.add_argument(
62+
"--triple",
63+
metavar="triple",
64+
dest="triple",
65+
help=textwrap.dedent(
66+
"""Specify the target triple. Used for cross compilation."""
67+
),
68+
)
6169
if sys.platform == "darwin":
6270
group.add_argument(
6371
"--apple-sdk",

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ else
148148
endif
149149
endif
150150

151+
#----------------------------------------------------------------------
152+
# Use LLD when cross compiling on Darwin.
153+
#----------------------------------------------------------------------
154+
ifeq "$(HOST_OS)" "Darwin"
155+
ifneq (,$(filter $(OS), Android FreeBSD Linux NetBSD Windows_NT))
156+
LDFLAGS += -fuse-ld=lld
157+
endif
158+
endif
159+
160+
151161
#----------------------------------------------------------------------
152162
# ARCHFLAG is the flag used to tell the compiler which architecture
153163
# to compile for. The default is the flag that clang accepts.

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ static cl::opt<bool> ClGenerateTagsWithCalls(
160160
static cl::opt<bool> ClGlobals("hwasan-globals", cl::desc("Instrument globals"),
161161
cl::Hidden, cl::init(false));
162162

163+
static cl::opt<bool> ClAllGlobals(
164+
"hwasan-all-globals",
165+
cl::desc(
166+
"Instrument globals, even those within user-defined sections. Warning: "
167+
"This may break existing code which walks globals via linker-generated "
168+
"symbols, expects certain globals to be contiguous with each other, or "
169+
"makes other assumptions which are invalidated by HWASan "
170+
"instrumentation."),
171+
cl::Hidden, cl::init(false));
172+
163173
static cl::opt<int> ClMatchAllTag(
164174
"hwasan-match-all-tag",
165175
cl::desc("don't report bad accesses via pointers with this tag"),
@@ -681,11 +691,11 @@ void HWAddressSanitizer::initializeModule() {
681691
!CompileKernel && !UsePageAliases && optOr(ClGlobals, NewRuntime);
682692

683693
if (!CompileKernel) {
684-
createHwasanCtorComdat();
685-
686694
if (InstrumentGlobals)
687695
instrumentGlobals();
688696

697+
createHwasanCtorComdat();
698+
689699
bool InstrumentPersonalityFunctions =
690700
optOr(ClInstrumentPersonalityFunctions, NewRuntime);
691701
if (InstrumentPersonalityFunctions)
@@ -1772,11 +1782,17 @@ void HWAddressSanitizer::instrumentGlobals() {
17721782
if (GV.hasCommonLinkage())
17731783
continue;
17741784

1775-
// Globals with custom sections may be used in __start_/__stop_ enumeration,
1776-
// which would be broken both by adding tags and potentially by the extra
1777-
// padding/alignment that we insert.
1778-
if (GV.hasSection())
1779-
continue;
1785+
if (ClAllGlobals) {
1786+
// Avoid instrumenting intrinsic global variables.
1787+
if (GV.getSection() == "llvm.metadata")
1788+
continue;
1789+
} else {
1790+
// Globals with custom sections may be used in __start_/__stop_
1791+
// enumeration, which would be broken both by adding tags and potentially
1792+
// by the extra padding/alignment that we insert.
1793+
if (GV.hasSection())
1794+
continue;
1795+
}
17801796

17811797
Globals.push_back(&GV);
17821798
}

llvm/test/Instrumentation/HWAddressSanitizer/X86/globals.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
; RUN: opt < %s -S -passes=hwasan -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
22

3-
; CHECK: @__start_hwasan_globals = external hidden constant [0 x i8]
4-
; CHECK: @__stop_hwasan_globals = external hidden constant [0 x i8]
5-
6-
; CHECK: @hwasan.note = private constant { i32, i32, i32, [8 x i8], i32, i32 } { i32 8, i32 8, i32 3, [8 x i8] c"LLVM\00\00\00\00", i32 trunc (i64 sub (i64 ptrtoint (ptr @__start_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @__stop_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32) }, section ".note.hwasan.globals", comdat($hwasan.module_ctor), align 4
7-
8-
; CHECK: @hwasan.dummy.global = private constant [0 x i8] zeroinitializer, section "hwasan_globals", comdat($hwasan.module_ctor), !associated [[NOTE:![0-9]+]]
9-
103
; CHECK: @four.hwasan = private global { i32, [12 x i8] } { i32 1, [12 x i8] c"\00\00\00\00\00\00\00\00\00\00\00\10" }, align 16
114
; CHECK: @four.hwasan.descriptor = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @four.hwasan to i64), i64 ptrtoint (ptr @four.hwasan.descriptor to i64)) to i32), i32 268435460 }, section "hwasan_globals", !associated [[FOUR:![0-9]+]]
125

@@ -17,14 +10,21 @@
1710
; CHECK: @huge.hwasan.descriptor = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @huge.hwasan to i64), i64 ptrtoint (ptr @huge.hwasan.descriptor to i64)) to i32), i32 318767088 }, section "hwasan_globals", !associated [[HUGE:![0-9]+]]
1811
; CHECK: @huge.hwasan.descriptor.1 = private constant { i32, i32 } { i32 trunc (i64 add (i64 sub (i64 ptrtoint (ptr @huge.hwasan to i64), i64 ptrtoint (ptr @huge.hwasan.descriptor.1 to i64)), i64 16777200) to i32), i32 301989920 }, section "hwasan_globals", !associated [[HUGE]]
1912

13+
; CHECK: @__start_hwasan_globals = external hidden constant [0 x i8]
14+
; CHECK: @__stop_hwasan_globals = external hidden constant [0 x i8]
15+
16+
; CHECK: @hwasan.note = private constant { i32, i32, i32, [8 x i8], i32, i32 } { i32 8, i32 8, i32 3, [8 x i8] c"LLVM\00\00\00\00", i32 trunc (i64 sub (i64 ptrtoint (ptr @__start_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @__stop_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32) }, section ".note.hwasan.globals", comdat($hwasan.module_ctor), align 4
17+
18+
; CHECK: @hwasan.dummy.global = private constant [0 x i8] zeroinitializer, section "hwasan_globals", comdat($hwasan.module_ctor), !associated [[NOTE:![0-9]+]]
19+
2020
; CHECK: @four = alias i32, inttoptr (i64 add (i64 ptrtoint (ptr @four.hwasan to i64), i64 2305843009213693952) to ptr)
2121
; CHECK: @sixteen = alias [16 x i8], inttoptr (i64 add (i64 ptrtoint (ptr @sixteen.hwasan to i64), i64 2449958197289549824) to ptr)
2222
; CHECK: @huge = alias [16777232 x i8], inttoptr (i64 add (i64 ptrtoint (ptr @huge.hwasan to i64), i64 2594073385365405696) to ptr)
2323

24-
; CHECK: [[NOTE]] = !{ptr @hwasan.note}
2524
; CHECK: [[FOUR]] = !{ptr @four.hwasan}
2625
; CHECK: [[SIXTEEN]] = !{ptr @sixteen.hwasan}
2726
; CHECK: [[HUGE]] = !{ptr @huge.hwasan}
27+
; CHECK: [[NOTE]] = !{ptr @hwasan.note}
2828

2929
source_filename = "foo"
3030

llvm/test/Instrumentation/HWAddressSanitizer/globals.ll

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
; RUN: opt < %s -S -passes=hwasan -mtriple=aarch64--linux-android29 | FileCheck --check-prefixes=CHECK,CHECK29 %s
2-
; RUN: opt < %s -S -passes=hwasan -mtriple=aarch64--linux-android30 | FileCheck --check-prefixes=CHECK,CHECK30 %s
1+
; RUN: opt < %s -S -passes=hwasan -mtriple=aarch64--linux-android29 | FileCheck --check-prefixes=CHECK,CHECK29,NOALLGLOBALS %s
2+
; RUN: opt < %s -S -passes=hwasan -mtriple=aarch64--linux-android30 | FileCheck --check-prefixes=CHECK,CHECK30,NOALLGLOBALS %s
3+
; RUN: opt < %s -S -passes=hwasan -mtriple=riscv64-unknown-elf -hwasan-globals=1 -hwasan-all-globals=1 | FileCheck --check-prefixes=CHECK,CHECK30,ALLGLOBALS %s
34

45
; CHECK29: @four = global
56

67
; CHECK: @specialcaselisted = global i16 2, no_sanitize_hwaddress
7-
; CHECK: @insection = global i16 2, section "custom"
8-
; CHECK: @__start_hwasan_globals = external hidden constant [0 x i8]
9-
; CHECK: @__stop_hwasan_globals = external hidden constant [0 x i8]
10-
11-
; CHECK: @hwasan.note = private constant { i32, i32, i32, [8 x i8], i32, i32 } { i32 8, i32 8, i32 3, [8 x i8] c"LLVM\00\00\00\00", i32 trunc (i64 sub (i64 ptrtoint (ptr @__start_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @__stop_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32) }, section ".note.hwasan.globals", comdat($hwasan.module_ctor), align 4
12-
13-
; CHECK: @hwasan.dummy.global = private constant [0 x i8] zeroinitializer, section "hwasan_globals", comdat($hwasan.module_ctor), !associated [[NOTE:![0-9]+]]
8+
; NOALLGLOBALS: @insection = global i16 2, section "custom"
149

1510
; CHECK30: @four.hwasan = private global { i32, [12 x i8] } { i32 1, [12 x i8] c"\00\00\00\00\00\00\00\00\00\00\00\AC" }, align 16
1611
; CHECK30: @four.hwasan.descriptor = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @four.hwasan to i64), i64 ptrtoint (ptr @four.hwasan.descriptor to i64)) to i32), i32 -1409286140 }, section "hwasan_globals", !associated [[FOUR:![0-9]+]]
@@ -22,14 +17,23 @@
2217
; CHECK30: @huge.hwasan.descriptor = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @huge.hwasan to i64), i64 ptrtoint (ptr @huge.hwasan.descriptor to i64)) to i32), i32 -1358954512 }, section "hwasan_globals", !associated [[HUGE:![0-9]+]]
2318
; CHECK30: @huge.hwasan.descriptor.1 = private constant { i32, i32 } { i32 trunc (i64 add (i64 sub (i64 ptrtoint (ptr @huge.hwasan to i64), i64 ptrtoint (ptr @huge.hwasan.descriptor.1 to i64)), i64 16777200) to i32), i32 -1375731680 }, section "hwasan_globals", !associated [[HUGE]]
2419

20+
; ALLGLOBALS: @insection.hwasan = private global { i16, [14 x i8] } { i16 2, [14 x i8] c"\00\00\00\00\00\00\00\00\00\00\00\00\00\AF" }, section "custom", align 16
21+
22+
; CHECK: @__start_hwasan_globals = external hidden constant [0 x i8]
23+
; CHECK: @__stop_hwasan_globals = external hidden constant [0 x i8]
24+
25+
; CHECK: @hwasan.note = private constant { i32, i32, i32, [8 x i8], i32, i32 } { i32 8, i32 8, i32 3, [8 x i8] c"LLVM\00\00\00\00", i32 trunc (i64 sub (i64 ptrtoint (ptr @__start_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @__stop_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32) }, section ".note.hwasan.globals", comdat($hwasan.module_ctor), align 4
26+
27+
; CHECK: @hwasan.dummy.global = private constant [0 x i8] zeroinitializer, section "hwasan_globals", comdat($hwasan.module_ctor), !associated [[NOTE:![0-9]+]]
28+
2529
; CHECK30: @four = alias i32, inttoptr (i64 add (i64 ptrtoint (ptr @four.hwasan to i64), i64 -6052837899185946624) to ptr)
2630
; CHECK30: @sixteen = alias [16 x i8], inttoptr (i64 add (i64 ptrtoint (ptr @sixteen.hwasan to i64), i64 -5980780305148018688) to ptr)
2731
; CHECK30: @huge = alias [16777232 x i8], inttoptr (i64 add (i64 ptrtoint (ptr @huge.hwasan to i64), i64 -5908722711110090752) to ptr)
2832

29-
; CHECK: [[NOTE]] = !{ptr @hwasan.note}
3033
; CHECK30: [[FOUR]] = !{ptr @four.hwasan}
3134
; CHECK30: [[SIXTEEN]] = !{ptr @sixteen.hwasan}
3235
; CHECK30: [[HUGE]] = !{ptr @huge.hwasan}
36+
; CHECK: [[NOTE]] = !{ptr @hwasan.note}
3337

3438
source_filename = "foo"
3539

0 commit comments

Comments
 (0)