Skip to content

Commit 1c0d172

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:157ba33007fe into amd-gfx:f5e3081cf03f
Local branch amd-gfx f5e3081 Merged main:89a2e7015968 into amd-gfx:acddebee9f46 Remote branch main 157ba33 [CSKY,test] Update switch.ll
2 parents f5e3081 + 157ba33 commit 1c0d172

38 files changed

+482
-306
lines changed

compiler-rt/include/sanitizer/allocator_interface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void SANITIZER_CDECL __sanitizer_free_hook(const volatile void *ptr);
8383
other threads.
8484
*/
8585
int SANITIZER_CDECL __sanitizer_install_malloc_and_free_hooks(
86-
void (*SANITIZER_CDECL malloc_hook)(const volatile void *, size_t),
87-
void (*SANITIZER_CDECL free_hook)(const volatile void *));
86+
void(SANITIZER_CDECL *malloc_hook)(const volatile void *, size_t),
87+
void(SANITIZER_CDECL *free_hook)(const volatile void *));
8888

8989
/* Drains allocator quarantines (calling thread's and global ones), returns
9090
freed memory back to OS and releases other non-essential internal allocator

compiler-rt/include/sanitizer/dfsan_interface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ typedef uint8_t dfsan_label;
2525
typedef uint32_t dfsan_origin;
2626

2727
/// Signature of the callback argument to dfsan_set_write_callback().
28-
typedef void (*SANITIZER_CDECL dfsan_write_callback_t)(int fd, const void *buf,
29-
size_t count);
28+
typedef void(SANITIZER_CDECL *dfsan_write_callback_t)(int fd, const void *buf,
29+
size_t count);
3030

3131
/// Signature of the callback argument to dfsan_set_conditional_callback().
32-
typedef void (*SANITIZER_CDECL dfsan_conditional_callback_t)(
32+
typedef void(SANITIZER_CDECL *dfsan_conditional_callback_t)(
3333
dfsan_label label, dfsan_origin origin);
3434

3535
/// Signature of the callback argument to dfsan_set_reaches_function_callback().
3636
/// The description is intended to hold the name of the variable.
37-
typedef void (*SANITIZER_CDECL dfsan_reaches_function_callback_t)(
37+
typedef void(SANITIZER_CDECL *dfsan_reaches_function_callback_t)(
3838
dfsan_label label, dfsan_origin origin, const char *file, unsigned int line,
3939
const char *function);
4040

compiler-rt/include/sanitizer/msan_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const char *SANITIZER_CDECL __msan_default_options(void);
108108

109109
/* Deprecated. Call __sanitizer_set_death_callback instead. */
110110
void SANITIZER_CDECL
111-
__msan_set_death_callback(void (*SANITIZER_CDECL callback)(void));
111+
__msan_set_death_callback(void(SANITIZER_CDECL *callback)(void));
112112

113113
/* Update shadow for the application copy of size bytes from src to dst.
114114
Src and dst are application addresses. This function does not copy the

lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
417417
// xcrun didn't find a matching SDK. Not an error, we'll try
418418
// different spellings.
419419
LLDB_LOG(log, "xcrun returned exit code {0}", status);
420+
if (!output_str.empty())
421+
LLDB_LOG(log, "xcrun output was:\n{0}", output_str);
420422
return "";
421423
}
422424
if (output_str.empty()) {

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 479279
19+
#define LLVM_MAIN_REVISION 479290
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ bool llvm::isTriviallyVectorizable(Intrinsic::ID ID) {
9191
case Intrinsic::canonicalize:
9292
case Intrinsic::fptosi_sat:
9393
case Intrinsic::fptoui_sat:
94+
case Intrinsic::lrint:
95+
case Intrinsic::llrint:
9496
return true;
9597
default:
9698
return false;
@@ -122,6 +124,8 @@ bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
122124
switch (ID) {
123125
case Intrinsic::fptosi_sat:
124126
case Intrinsic::fptoui_sat:
127+
case Intrinsic::lrint:
128+
case Intrinsic::llrint:
125129
return OpdIdx == -1 || OpdIdx == 0;
126130
case Intrinsic::is_fpclass:
127131
return OpdIdx == 0;

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,8 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
20192019
if (M.getDirectAccessExternalData() &&
20202020
!TM.getTargetTriple().isWindowsGNUEnvironment() &&
20212021
!TM.getTargetTriple().isOSFreeBSD() &&
2022-
!TM.getTargetTriple().isOSDarwin())
2022+
(!TM.getTargetTriple().isOSDarwin() ||
2023+
TM.getRelocationModel() == Reloc::Static))
20232024
GV->setDSOLocal(true);
20242025
}
20252026
}

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4978,7 +4978,7 @@ void ARMBaseInstrInfo::expandLoadStackGuardBase(MachineBasicBlock::iterator MI,
49784978
TargetFlags |= ARMII::MO_DLLIMPORT;
49794979
else if (IsIndirect)
49804980
TargetFlags |= ARMII::MO_COFFSTUB;
4981-
} else if (Subtarget.isGVInGOT(GV)) {
4981+
} else if (IsIndirect) {
49824982
TargetFlags |= ARMII::MO_GOT;
49834983
}
49844984

llvm/lib/Target/ARM/ARMInstrInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ void ARMInstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI) const {
104104
const GlobalValue *GV =
105105
cast<GlobalValue>((*MI->memoperands_begin())->getValue());
106106

107-
if (!Subtarget.useMovt() || Subtarget.isGVInGOT(GV)) {
108-
if (TM.isPositionIndependent())
107+
bool ForceELFGOTPIC = Subtarget.isTargetELF() && !GV->isDSOLocal();
108+
if (!Subtarget.useMovt() || ForceELFGOTPIC) {
109+
// For ELF non-PIC, use GOT PIC code sequence as well because R_ARM_GOT_ABS
110+
// does not have assembler support.
111+
if (TM.isPositionIndependent() || ForceELFGOTPIC)
109112
expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_pcrel, ARM::LDRi12);
110113
else
111114
expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_abs, ARM::LDRi12);

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,9 @@ struct OpenMPOpt {
978978
}
979979
}
980980

981+
if (OMPInfoCache.OpenMPPostLink)
982+
Changed |= removeRuntimeSymbols();
983+
981984
return Changed;
982985
}
983986

@@ -1507,6 +1510,37 @@ struct OpenMPOpt {
15071510
return Changed;
15081511
}
15091512

1513+
/// Tries to remove known runtime symbols that are optional from the module.
1514+
bool removeRuntimeSymbols() {
1515+
// The RPC client symbol is defined in `libc` and indicates that something
1516+
// required an RPC server. If its users were all optimized out then we can
1517+
// safely remove it.
1518+
// TODO: This should be somewhere more common in the future.
1519+
if (GlobalVariable *GV = M.getNamedGlobal("__llvm_libc_rpc_client")) {
1520+
if (!GV->getType()->isPointerTy())
1521+
return false;
1522+
1523+
Constant *C = GV->getInitializer();
1524+
if (!C)
1525+
return false;
1526+
1527+
// Check to see if the only user of the RPC client is the external handle.
1528+
GlobalVariable *Client = dyn_cast<GlobalVariable>(C->stripPointerCasts());
1529+
if (!Client || Client->getNumUses() > 1 ||
1530+
Client->user_back() != GV->getInitializer())
1531+
return false;
1532+
1533+
Client->replaceAllUsesWith(PoisonValue::get(Client->getType()));
1534+
Client->eraseFromParent();
1535+
1536+
GV->replaceAllUsesWith(PoisonValue::get(GV->getType()));
1537+
GV->eraseFromParent();
1538+
1539+
return true;
1540+
}
1541+
return false;
1542+
}
1543+
15101544
/// Tries to hide the latency of runtime calls that involve host to
15111545
/// device memory transfers by splitting them into their "issue" and "wait"
15121546
/// versions. The "issue" is moved upwards as much as possible. The "wait" is

llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ bool SimplifyIndvar::eliminateTrunc(TruncInst *TI) {
539539
for (auto *ICI : ICmpUsers) {
540540
bool IsSwapped = L->isLoopInvariant(ICI->getOperand(0));
541541
auto *Op1 = IsSwapped ? ICI->getOperand(0) : ICI->getOperand(1);
542-
Instruction *Ext = nullptr;
542+
IRBuilder<> Builder(ICI);
543+
Value *Ext = nullptr;
543544
// For signed/unsigned predicate, replace the old comparison with comparison
544545
// of immediate IV against sext/zext of the invariant argument. If we can
545546
// use either sext or zext (i.e. we are dealing with equality predicate),
@@ -550,18 +551,18 @@ bool SimplifyIndvar::eliminateTrunc(TruncInst *TI) {
550551
if (IsSwapped) Pred = ICmpInst::getSwappedPredicate(Pred);
551552
if (CanUseZExt(ICI)) {
552553
assert(DoesZExtCollapse && "Unprofitable zext?");
553-
Ext = new ZExtInst(Op1, IVTy, "zext", ICI);
554+
Ext = Builder.CreateZExt(Op1, IVTy, "zext");
554555
Pred = ICmpInst::getUnsignedPredicate(Pred);
555556
} else {
556557
assert(DoesSExtCollapse && "Unprofitable sext?");
557-
Ext = new SExtInst(Op1, IVTy, "sext", ICI);
558+
Ext = Builder.CreateSExt(Op1, IVTy, "sext");
558559
assert(Pred == ICmpInst::getSignedPredicate(Pred) && "Must be signed!");
559560
}
560561
bool Changed;
561562
L->makeLoopInvariant(Ext, Changed);
562563
(void)Changed;
563-
ICmpInst *NewICI = new ICmpInst(ICI, Pred, IV, Ext);
564-
ICI->replaceAllUsesWith(NewICI);
564+
auto *NewCmp = Builder.CreateICmp(Pred, IV, Ext);
565+
ICI->replaceAllUsesWith(NewCmp);
565566
DeadInsts.emplace_back(ICI);
566567
}
567568

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2+
;; direct-access-external-data is false due to PIC Level, so __stack_chk_guard
3+
;; is dso_preemtable. Check that we use GOT PIC code sequence as well because
4+
;; R_ARM_GOT_ABS does not have assembler support.
5+
; RUN: llc -relocation-model=static < %s | FileCheck %s
6+
; RUN: llc -relocation-model=pic < %s | FileCheck %s
7+
8+
target triple = "armv7a-linux-gnueabi"
9+
10+
define i32 @test1() #0 {
11+
; CHECK-LABEL: test1:
12+
; CHECK: @ %bb.0:
13+
; CHECK-NEXT: push {r11, lr}
14+
; CHECK-NEXT: sub sp, sp, #8
15+
; CHECK-NEXT: sub sp, sp, #1024
16+
; CHECK-NEXT: ldr r0, .LCPI0_0
17+
; CHECK-NEXT: .LPC0_0:
18+
; CHECK-NEXT: add r0, pc, r0
19+
; CHECK-NEXT: ldr r0, [r0]
20+
; CHECK-NEXT: ldr r0, [r0]
21+
; CHECK-NEXT: str r0, [sp, #1028]
22+
; CHECK-NEXT: add r0, sp, #4
23+
; CHECK-NEXT: bl foo
24+
; CHECK-NEXT: ldr r0, [sp, #1028]
25+
; CHECK-NEXT: ldr r1, .LCPI0_1
26+
; CHECK-NEXT: .LPC0_1:
27+
; CHECK-NEXT: add r1, pc, r1
28+
; CHECK-NEXT: ldr r1, [r1]
29+
; CHECK-NEXT: ldr r1, [r1]
30+
; CHECK-NEXT: cmp r1, r0
31+
; CHECK-NEXT: moveq r0, #0
32+
; CHECK-NEXT: addeq sp, sp, #8
33+
; CHECK-NEXT: addeq sp, sp, #1024
34+
; CHECK-NEXT: popeq {r11, pc}
35+
; CHECK-NEXT: .LBB0_1:
36+
; CHECK-NEXT: bl __stack_chk_fail
37+
; CHECK-NEXT: .p2align 2
38+
; CHECK-NEXT: @ %bb.2:
39+
; CHECK-NEXT: .LCPI0_0:
40+
; CHECK-NEXT: .Ltmp0:
41+
; CHECK-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_0+8)-.Ltmp0)
42+
; CHECK-NEXT: .LCPI0_1:
43+
; CHECK-NEXT: .Ltmp1:
44+
; CHECK-NEXT: .long __stack_chk_guard(GOT_PREL)-((.LPC0_1+8)-.Ltmp1)
45+
%a1 = alloca [256 x i32], align 4
46+
call void @foo(ptr %a1) #3
47+
ret i32 0
48+
}
49+
50+
declare void @foo(ptr)
51+
52+
attributes #0 = { nounwind sspstrong }
53+
54+
!llvm.module.flags = !{!0}
55+
!0 = !{i32 8, !"PIC Level", i32 2}

llvm/test/CodeGen/ARM/stack_guard_remat.ll

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
2-
; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
3-
; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=DYNAMIC-NO-PIC
4-
; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC-V7
5-
; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC-V7
6-
; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=DYNAMIC-NO-PIC-V7
1+
; RUN: rm -rf %t && split-file %s %t && cd %t
2+
; RUN: cat main.ll pic-flag.ll > pic.ll
3+
; RUN: llc < pic.ll -mtriple=arm-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
4+
; RUN: llc < main.ll -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
5+
; RUN: llc < main.ll -mtriple=arm-apple-ios -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefixes=NO-PIC,DYNAMIC-NO-PIC
6+
; RUN: llc < pic.ll -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC-V7
7+
; RUN: llc < main.ll -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC-V7
8+
; RUN: llc < main.ll -mtriple=armv7-apple-ios -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=DYNAMIC-NO-PIC-V7
79

810
;PIC: foo2
911
;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
@@ -47,6 +49,7 @@
4749
;DYNAMIC-NO-PIC-V7: L___stack_chk_guard$non_lazy_ptr:
4850
;DYNAMIC-NO-PIC-V7: .indirect_symbol ___stack_chk_guard
4951

52+
;--- main.ll
5053
; Function Attrs: nounwind ssp
5154
define i32 @test_stack_guard_remat() #0 {
5255
%a1 = alloca [256 x i32], align 4
@@ -67,5 +70,6 @@ declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
6770

6871
attributes #0 = { nounwind ssp "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
6972

73+
;--- pic-flag.ll
7074
!llvm.module.flags = !{!0}
7175
!0 = !{i32 7, !"PIC Level", i32 2}

0 commit comments

Comments
 (0)