Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 3d7ab62

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:9555736ac6d0 into amd-gfx:7c675722cfee
Local branch amd-gfx 7c67572 Merged main:f9149a34d9b4 into amd-gfx:0bf8d84ecbde Remote branch main 9555736 [BOLT][RISCV] Implement LO/HI relocations (llvm#67444)
2 parents 7c67572 + 9555736 commit 3d7ab62

File tree

140 files changed

+8175
-16925
lines changed

Some content is hidden

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

140 files changed

+8175
-16925
lines changed

bolt/lib/Core/Relocation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ static bool isSupportedRISCV(uint64_t Type) {
106106
case ELF::R_RISCV_RVC_BRANCH:
107107
case ELF::R_RISCV_ADD32:
108108
case ELF::R_RISCV_SUB32:
109+
case ELF::R_RISCV_HI20:
110+
case ELF::R_RISCV_LO12_I:
111+
case ELF::R_RISCV_LO12_S:
109112
return true;
110113
}
111114
}
@@ -202,6 +205,9 @@ static size_t getSizeForTypeRISCV(uint64_t Type) {
202205
case ELF::R_RISCV_CALL_PLT:
203206
case ELF::R_RISCV_ADD32:
204207
case ELF::R_RISCV_SUB32:
208+
case ELF::R_RISCV_HI20:
209+
case ELF::R_RISCV_LO12_I:
210+
case ELF::R_RISCV_LO12_S:
205211
return 4;
206212
case ELF::R_RISCV_GOT_HI20:
207213
// See extractValueRISCV for why this is necessary.
@@ -519,10 +525,13 @@ static uint64_t extractValueRISCV(uint64_t Type, uint64_t Contents,
519525
return extractUImmRISCV(Contents & 0xffffffff) +
520526
extractIImmRISCV(Contents >> 32);
521527
case ELF::R_RISCV_PCREL_HI20:
528+
case ELF::R_RISCV_HI20:
522529
return extractUImmRISCV(Contents);
523530
case ELF::R_RISCV_PCREL_LO12_I:
531+
case ELF::R_RISCV_LO12_I:
524532
return extractIImmRISCV(Contents);
525533
case ELF::R_RISCV_PCREL_LO12_S:
534+
case ELF::R_RISCV_LO12_S:
526535
return extractSImmRISCV(Contents);
527536
case ELF::R_RISCV_RVC_JUMP:
528537
return SignExtend64<11>(Contents >> 2);
@@ -692,6 +701,9 @@ static bool isPCRelativeRISCV(uint64_t Type) {
692701
llvm_unreachable("Unknown relocation type");
693702
case ELF::R_RISCV_ADD32:
694703
case ELF::R_RISCV_SUB32:
704+
case ELF::R_RISCV_HI20:
705+
case ELF::R_RISCV_LO12_I:
706+
case ELF::R_RISCV_LO12_S:
695707
return false;
696708
case ELF::R_RISCV_JAL:
697709
case ELF::R_RISCV_CALL:

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
4343
case ELF::R_RISCV_PCREL_HI20:
4444
case ELF::R_RISCV_PCREL_LO12_I:
4545
case ELF::R_RISCV_PCREL_LO12_S:
46+
case ELF::R_RISCV_HI20:
47+
case ELF::R_RISCV_LO12_I:
48+
case ELF::R_RISCV_LO12_S:
4649
return true;
4750
default:
4851
llvm_unreachable("Unexpected RISCV relocation type in code");
@@ -399,6 +402,11 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
399402
case ELF::R_RISCV_PCREL_LO12_I:
400403
case ELF::R_RISCV_PCREL_LO12_S:
401404
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_PCREL_LO, Ctx);
405+
case ELF::R_RISCV_HI20:
406+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_HI, Ctx);
407+
case ELF::R_RISCV_LO12_I:
408+
case ELF::R_RISCV_LO12_S:
409+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_LO, Ctx);
402410
case ELF::R_RISCV_CALL:
403411
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_CALL, Ctx);
404412
case ELF::R_RISCV_CALL_PLT:

bolt/test/RISCV/reloc-lohi.s

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: llvm-mc -triple riscv64 -filetype=obj -o %t.o %s
2+
// RUN: ld.lld -q -o %t %t.o
3+
// RUN: llvm-bolt --print-cfg --print-only=_start -o /dev/null %t \
4+
// RUN: | FileCheck %s
5+
6+
.data
7+
.globl d
8+
.p2align 3
9+
d:
10+
.dword 0
11+
12+
// CHECK-LABEL: Binary Function "_start" after building cfg {
13+
// CHECK: lui t0, %hi(d)
14+
// CHECK-NEXT: ld t0, %lo(d)(t0)
15+
// CHECK-NEXT: lui t0, %hi(d)
16+
// CHECK-NEXT: sd t0, %lo(d)(t0)
17+
.text
18+
.globl _start
19+
.p2align 1
20+
_start:
21+
lui t0, %hi(d)
22+
ld t0, %lo(d)(t0)
23+
lui t0, %hi(d)
24+
sd t0, %lo(d)(t0)
25+
ret
26+
.size _start, .-_start

clang/cmake/caches/CrossWinToARMLinux.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ if(DEFINED REMOTE_TEST_HOST)
162162
"\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}"
163163
CACHE STRING "")
164164

165-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
166-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
167-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
165+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_TEST_PARAMS "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS} 'executor=${DEFAULT_TEST_EXECUTOR}'" CACHE STRING "")
166+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_TEST_PARAMS "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS} 'executor=${DEFAULT_TEST_EXECUTOR}'" CACHE STRING "")
167+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_TEST_PARAMS "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS} 'executor=${DEFAULT_TEST_EXECUTOR}'" CACHE STRING "")
168168
endif()
169169

170170
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")

clang/lib/AST/ASTContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7890,6 +7890,7 @@ ASTContext::getObjCPropertyImplDeclForPropertyDecl(
78907890
/// kPropertyWeak = 'W' // 'weak' property
78917891
/// kPropertyStrong = 'P' // property GC'able
78927892
/// kPropertyNonAtomic = 'N' // property non-atomic
7893+
/// kPropertyOptional = '?' // property optional
78937894
/// };
78947895
/// @endcode
78957896
std::string
@@ -7915,6 +7916,9 @@ ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
79157916
// closely resembles encoding of ivars.
79167917
getObjCEncodingForPropertyType(PD->getType(), S);
79177918

7919+
if (PD->isOptional())
7920+
S += ",?";
7921+
79187922
if (PD->isReadOnly()) {
79197923
S += ",R";
79207924
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_copy)

clang/test/AST/attr-print-emit.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
// RUN: %clang -emit-ast -o %t.ast %s
33
// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
44

5+
// CHECK: void *aa() __attribute__((assume_aligned(64)));
6+
void *aa() __attribute__((assume_aligned(64)));
7+
8+
// CHECK: void *aa2() __attribute__((assume_aligned(64, 8)));
9+
void *aa2() __attribute__((assume_aligned(64, 8)));
10+
511
// CHECK: void xla(int a) __attribute__((xray_log_args(1)));
612
void xla(int a) __attribute__((xray_log_args(1)));
713

clang/test/CodeGenObjC/objc-asm-attribute-test.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin %s -o - | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-objc-root-class -emit-llvm -triple x86_64-apple-darwin %s -o - | FileCheck %s
22

33
__attribute__((objc_runtime_name("MySecretNamespace.Protocol")))
44
@protocol Protocol
@@ -10,6 +10,10 @@ + (void) ClsMethodP;
1010
@protocol Protocol2
1111
- (void) MethodP2;
1212
+ (void) ClsMethodP2;
13+
14+
@optional
15+
@property(retain) id optionalProp;
16+
1317
@end
1418

1519
__attribute__((objc_runtime_name("MySecretNamespace.Protocol3")))
@@ -57,6 +61,10 @@ id Test16877359(void) {
5761
// CHECK: @"OBJC_CLASS_$_MySecretNamespace.Message" ={{.*}} global %struct._class_t
5862
// CHECK: @"OBJC_METACLASS_$_MySecretNamespace.Message" ={{.*}} global %struct._class_t
5963

64+
// CHECK: @OBJC_PROP_NAME_ATTR_ = private unnamed_addr constant [13 x i8] c"optionalProp\00"
65+
// CHECK-NEXT: @OBJC_PROP_NAME_ATTR_.11 = private unnamed_addr constant [7 x i8] c"T@,?,&\00"
66+
// CHECK: @"_OBJC_$_PROP_LIST_MySecretNamespace.Protocol2" ={{.*}} [%struct._prop_t { ptr @OBJC_PROP_NAME_ATTR_, ptr @OBJC_PROP_NAME_ATTR_.11 }]
67+
6068
// CHECK: private unnamed_addr constant [42 x i8] c"T@\22MySecretNamespace.Message\22,&,V_msgProp\00"
6169
// CHECK: private unnamed_addr constant [76 x i8] c"T@\22MySecretNamespace.Message<MySecretNamespace.Protocol3>\22,&,V_msgProtoProp\00"
6270
// CHECK: private unnamed_addr constant [50 x i8] c"T@\22<MySecretNamespace.Protocol3>\22,&,V_idProtoProp\00"

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,19 @@ namespace {
320320
}
321321

322322
std::string getIsOmitted() const override {
323-
if (type == "IdentifierInfo *")
323+
auto IsOneOf = [](StringRef subject, auto... list) {
324+
return ((subject == list) || ...);
325+
};
326+
327+
if (IsOneOf(type, "IdentifierInfo *", "Expr *"))
324328
return "!get" + getUpperName().str() + "()";
325-
if (type == "TypeSourceInfo *")
329+
if (IsOneOf(type, "TypeSourceInfo *"))
326330
return "!get" + getUpperName().str() + "Loc()";
327-
if (type == "ParamIdx")
331+
if (IsOneOf(type, "ParamIdx"))
328332
return "!get" + getUpperName().str() + "().isValid()";
333+
334+
assert(IsOneOf(type, "unsigned", "int", "bool", "FunctionDecl *",
335+
"VarDecl *"));
329336
return "false";
330337
}
331338

flang/include/flang/Optimizer/Dialect/FIRType.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ inline bool isa_integer(mlir::Type t) {
146146
return t.isa<mlir::IndexType, mlir::IntegerType, fir::IntegerType>();
147147
}
148148

149+
/// Is `t` a vector type?
150+
inline bool isa_vector(mlir::Type t) {
151+
return t.isa<mlir::VectorType, fir::VectorType>();
152+
}
153+
149154
mlir::Type parseFirType(FIROpsDialect *, mlir::DialectAsmParser &parser);
150155

151156
void printFirType(FIROpsDialect *, mlir::Type ty, mlir::DialectAsmPrinter &p);
@@ -165,7 +170,7 @@ inline bool isa_char(mlir::Type t) { return t.isa<fir::CharacterType>(); }
165170
/// Is `t` a trivial intrinsic type? CHARACTER is <em>excluded</em> because it
166171
/// is a dependent type.
167172
inline bool isa_trivial(mlir::Type t) {
168-
return isa_integer(t) || isa_real(t) || isa_complex(t) ||
173+
return isa_integer(t) || isa_real(t) || isa_complex(t) || isa_vector(t) ||
169174
t.isa<fir::LogicalType>();
170175
}
171176

flang/lib/Lower/ConvertCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,8 @@ genIntrinsicRefCore(Fortran::lower::PreparedActualArguments &loweredActuals,
15151515
scalarResultType = hlfir::getFortranElementType(*callContext.resultType);
15161516
const std::string intrinsicName = callContext.getProcedureName();
15171517
// Let the intrinsic library lower the intrinsic procedure call.
1518-
auto [resultExv, mustBeFreed] =
1519-
genIntrinsicCall(builder, loc, intrinsicName, scalarResultType, operands);
1518+
auto [resultExv, mustBeFreed] = genIntrinsicCall(
1519+
builder, loc, intrinsicName, scalarResultType, operands, &converter);
15201520
for (const hlfir::CleanupFunction &fn : cleanupFns)
15211521
fn();
15221522
if (!fir::getBase(resultExv))

0 commit comments

Comments
 (0)