Skip to content

Commit b3426f3

Browse files
authored
merge main into amd-staging (llvm#2414)
2 parents 4d96413 + 39f10ed commit b3426f3

File tree

6 files changed

+39
-7
lines changed

6 files changed

+39
-7
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,19 @@ void RewriteInstance::discoverFileObjects() {
13411341
}
13421342
}
13431343
}
1344+
1345+
// The linker may omit data markers for absolute long veneers. Introduce
1346+
// those markers artificially to assist the disassembler.
1347+
for (BinaryFunction &BF :
1348+
llvm::make_second_range(BC->getBinaryFunctions())) {
1349+
if (BF.getOneName().starts_with("__AArch64AbsLongThunk_") &&
1350+
BF.getSize() == 16 && !BF.getSizeOfDataInCodeAt(8)) {
1351+
BC->errs() << "BOLT-WARNING: missing data marker detected in veneer "
1352+
<< BF << '\n';
1353+
BF.markDataAtOffset(8);
1354+
BC->AddressToConstantIslandMap[BF.getAddress() + 8] = &BF;
1355+
}
1356+
}
13441357
}
13451358

13461359
if (!BC->IsLinuxKernel) {

bolt/test/AArch64/veneer-lld-abs.s

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@
66
# RUN: -fuse-ld=lld -Wl,-q
77
# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=CHECK-INPUT %s
88
# RUN: llvm-objcopy --remove-section .rela.mytext %t.exe
9-
# RUN: llvm-bolt %t.exe -o %t.bolt --elim-link-veneers=true --lite=0
9+
# RUN: llvm-bolt %t.exe -o %t.bolt
1010
# RUN: llvm-objdump -d -j .text %t.bolt | \
1111
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
1212

13+
## Occasionally, we see the linker not generating $d symbols for long veneers
14+
## causing BOLT to fail veneer elimination.
15+
# RUN: llvm-objcopy --remove-symbol-prefix=\$d %t.exe %t.no-marker.exe
16+
# RUN: llvm-bolt %t.no-marker.exe -o %t.no-marker.bolt \
17+
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT
18+
# RUN: llvm-objdump -d -j .text %t.no-marker.bolt | \
19+
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
20+
21+
# CHECK-BOLT-NOT: BOLT-WARNING: unable to disassemble instruction
22+
# CHECK-BOLT: BOLT-WARNING: missing data marker detected in veneer __AArch64AbsLongThunk_far_function
23+
1324
.text
1425
.balign 4
1526
.global far_function

clang/lib/Sema/SemaLoongArch.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ bool SemaLoongArch::CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
2828
// Basic intrinsics.
2929
case LoongArch::BI__builtin_loongarch_cacop_d:
3030
case LoongArch::BI__builtin_loongarch_cacop_w: {
31-
SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, llvm::maxUIntN(5));
32-
SemaRef.BuiltinConstantArgRange(TheCall, 2, llvm::minIntN(12),
33-
llvm::maxIntN(12));
34-
break;
31+
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, llvm::maxUIntN(5)) ||
32+
SemaRef.BuiltinConstantArgRange(TheCall, 2, llvm::minIntN(12),
33+
llvm::maxIntN(12));
3534
}
3635
case LoongArch::BI__builtin_loongarch_break:
3736
case LoongArch::BI__builtin_loongarch_dbar:

clang/test/CodeGen/LoongArch/intrinsic-la32-error.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ void test_feature(long *v_l, unsigned long *v_ul, int *v_i, unsigned ui, char c,
5252
}
5353
#endif
5454

55-
void cacop_d(unsigned long int a) {
55+
void cacop_w(unsigned long int a) {
5656
__builtin_loongarch_cacop_w(-1, a, 1024); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
5757
__builtin_loongarch_cacop_w(32, a, 1024); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
5858
__builtin_loongarch_cacop_w(1, a, -4096); // expected-error {{argument value -4096 is outside the valid range [-2048, 2047]}}
5959
__builtin_loongarch_cacop_w(1, a, 4096); // expected-error {{argument value 4096 is outside the valid range [-2048, 2047]}}
60+
__builtin_loongarch_cacop_w(-2, a, 5000); // expected-error {{argument value -2 is outside the valid range [0, 31]}}
6061
}
6162

6263
void dbar(int a) {

clang/test/CodeGen/LoongArch/intrinsic-la64-error.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ void test_feature(unsigned long *v_ul, int *v_i, float a, double b) {
2323
}
2424
#endif
2525

26+
void cacop_d(int a) {
27+
__builtin_loongarch_cacop_d(-1, a, 0); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
28+
__builtin_loongarch_cacop_d(1, a, 4000); // expected-error {{argument value 4000 is outside the valid range [-2048, 2047]}}
29+
__builtin_loongarch_cacop_d(-2, a, 5000); // expected-error {{argument value -2 is outside the valid range [0, 31]}}
30+
}
31+
2632
void csrrd_d(int a) {
2733
__builtin_loongarch_csrrd_d(16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}
2834
__builtin_loongarch_csrrd_d(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}

mlir/lib/Analysis/SliceAnalysis.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ static LogicalResult getBackwardSliceImpl(Operation *op,
111111
return getBackwardSliceImpl(parentOp, backwardSlice, options);
112112
}
113113
}
114+
} else {
115+
return failure();
114116
}
115-
return failure();
117+
return success();
116118
};
117119

118120
bool succeeded = true;

0 commit comments

Comments
 (0)