Skip to content

Commit 2329a92

Browse files
committed
Revert "sanmd: refine selection of functions for UAR checking"
This reverts commit 9d4f1a9. Breaks under -DCOMPILER_RT_BUILD_SANITIZERS=OFF
1 parent 83387db commit 2329a92

File tree

3 files changed

+2
-46
lines changed

3 files changed

+2
-46
lines changed

compiler-rt/test/metadata/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ if(CAN_TARGET_x86_64)
44
set(METADATA_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
55
set(METADATA_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
66

7-
set(METADATA_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
8-
if (NOT COMPILER_RT_STANDALONE_BUILD)
9-
list(APPEND METADATA_TEST_DEPS asan ubsan)
10-
endif()
11-
127
set(SANITIZER_COMMON_TEST_TARGET_ARCH ${X86_64})
138
get_test_cc_for_arch(x86_64 METADATA_TEST_TARGET_CC METADATA_TEST_TARGET_CFLAGS)
149
configure_lit_site_cfg(
@@ -17,6 +12,6 @@ if(CAN_TARGET_x86_64)
1712

1813
add_lit_testsuite(check-sanmd "Running the SanitizerBinaryMetadata tests"
1914
${CMAKE_CURRENT_BINARY_DIR}
20-
DEPENDS ${METADATA_TEST_DEPS})
15+
DEPENDS ${SANITIZER_COMMON_LIT_TEST_DEPS})
2116
set_target_properties(check-sanmd PROPERTIES FOLDER "Compiler-RT Misc")
2217
endif()

compiler-rt/test/metadata/uar.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx %s -O1 -o %t -fexperimental-sanitize-metadata=covered,uar && %t | FileCheck %s
2-
// RUN: %clangxx %s -O1 -o %t -fexperimental-sanitize-metadata=covered,uar -fsanitize=address,signed-integer-overflow && %t | FileCheck %s
32

43
// CHECK: metadata add version 1
54

@@ -16,16 +15,6 @@ __attribute__((noinline, not_tail_called)) void use(int x) {
1615
// CHECK: empty: features=0 stack_args=0
1716
void empty() {}
1817

19-
// CHECK: simple: features=0 stack_args=0
20-
int simple(int *data, int index) { return data[index + 1]; }
21-
22-
// CHECK: builtins: features=0 stack_args=0
23-
int builtins() {
24-
int x = 0;
25-
__builtin_prefetch(&x);
26-
return x;
27-
}
28-
2918
// CHECK: ellipsis: features=0 stack_args=0
3019
void ellipsis(const char *fmt, ...) {
3120
int x;
@@ -71,11 +60,6 @@ __attribute__((noinline)) int tail_called(int x) { return x; }
7160
// CHECK: with_tail_call: features=2
7261
int with_tail_call(int x) { [[clang::musttail]] return tail_called(x); }
7362

74-
__attribute__((noinline, noreturn)) int noreturn(int x) { __builtin_trap(); }
75-
76-
// CHECK: with_noreturn_tail_call: features=0
77-
int with_noreturn_tail_call(int x) { return noreturn(x); }
78-
7963
// CHECK: local_array: features=0
8064
void local_array(int x) {
8165
int data[10];
@@ -97,16 +81,13 @@ void escaping_alloca(int size, int i) {
9781

9882
#define FUNCTIONS \
9983
FN(empty); \
100-
FN(simple); \
101-
FN(builtins); \
10284
FN(ellipsis); \
10385
FN(non_empty_function); \
10486
FN(no_stack_args); \
10587
FN(stack_args); \
10688
FN(more_stack_args); \
10789
FN(struct_stack_args); \
10890
FN(with_tail_call); \
109-
FN(with_noreturn_tail_call); \
11091
FN(local_array); \
11192
FN(local_alloca); \
11293
FN(escaping_alloca); \

llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -271,31 +271,11 @@ void SanitizerBinaryMetadata::runOn(Function &F, MetadataInfoSet &MIS) {
271271
}
272272
}
273273

274-
bool isUARSafeCall(CallInst *CI) {
275-
auto *F = CI->getCalledFunction();
276-
// There are no intrinsic functions that leak arguments.
277-
// If the called function does not return, the current function
278-
// does not return as well, so no possibility of use-after-return.
279-
// Sanitizer function also don't leak or don't return.
280-
// It's safe to both pass pointers to local variables to them
281-
// and to tail-call them.
282-
return F && (F->isIntrinsic() || F->doesNotReturn() ||
283-
F->getName().startswith("__asan_") ||
284-
F->getName().startswith("__hwsan_") ||
285-
F->getName().startswith("__ubsan_") ||
286-
F->getName().startswith("__msan_") ||
287-
F->getName().startswith("__tsan_"));
288-
}
289-
290274
bool hasUseAfterReturnUnsafeUses(Value &V) {
291275
for (User *U : V.users()) {
292276
if (auto *I = dyn_cast<Instruction>(U)) {
293277
if (I->isLifetimeStartOrEnd() || I->isDroppable())
294278
continue;
295-
if (auto *CI = dyn_cast<CallInst>(U)) {
296-
if (isUARSafeCall(CI))
297-
continue;
298-
}
299279
if (isa<LoadInst>(U))
300280
continue;
301281
if (auto *SI = dyn_cast<StoreInst>(U)) {
@@ -323,7 +303,7 @@ bool useAfterReturnUnsafe(Instruction &I) {
323303
// at runtime because there is no call instruction.
324304
// So conservatively mark the caller as requiring checking.
325305
else if (auto *CI = dyn_cast<CallInst>(&I))
326-
return CI->isTailCall() && !isUARSafeCall(CI);
306+
return CI->isTailCall();
327307
return false;
328308
}
329309

0 commit comments

Comments
 (0)