Skip to content

Commit d5a42a1

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.8-beta.1 [skip ci]
1 parent 69aad6d commit d5a42a1

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

clang/docs/AllocToken.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ take a final ``size_t token_id`` argument.
9292
9393
// C++ operators (mangled names)
9494
// operator new(size_t, size_t)
95-
void *__alloc_token_Znwm(size_t size, size_t token_id);
95+
void *__alloc_token__Znwm(size_t size, size_t token_id);
9696
// operator new[](size_t, size_t)
97-
void *__alloc_token_Znam(size_t size, size_t token_id);
97+
void *__alloc_token__Znam(size_t size, size_t token_id);
9898
// ... other variants like nothrow, etc., are also instrumented.
9999
100100
Fast ABI

clang/test/CodeGenCXX/alloc-token.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,42 +52,42 @@ void test_malloc_like() {
5252
// CHECK-LABEL: @_Z17test_operator_newv(
5353
void test_operator_new() {
5454
// FIXME: This should not be token ID 0!
55-
// CHECK: call {{.*}} ptr @__alloc_token_Znwm(i64 noundef 4, i64 0)
55+
// CHECK: call {{.*}} ptr @__alloc_token__Znwm(i64 noundef 4, i64 0)
5656
sink = __builtin_operator_new(sizeof(int));
57-
// CHECK: call {{.*}} ptr @__alloc_token_Znwm(i64 noundef 4, i64 0)
57+
// CHECK: call {{.*}} ptr @__alloc_token__Znwm(i64 noundef 4, i64 0)
5858
sink = ::operator new(sizeof(int));
5959
}
6060

6161
// CHECK-LABEL: @_Z25test_operator_new_nothrowv(
6262
void test_operator_new_nothrow() {
6363
// FIXME: This should not be token ID 0!
64-
// CHECK: call {{.*}} ptr @__alloc_token_ZnwmRKSt9nothrow_t(i64 noundef 4, ptr {{.*}} @_ZSt7nothrow, i64 0)
64+
// CHECK: call {{.*}} ptr @__alloc_token__ZnwmRKSt9nothrow_t(i64 noundef 4, ptr {{.*}} @_ZSt7nothrow, i64 0)
6565
sink = __builtin_operator_new(sizeof(int), std::nothrow);
66-
// CHECK: call {{.*}} ptr @__alloc_token_ZnwmRKSt9nothrow_t(i64 noundef 4, ptr {{.*}} @_ZSt7nothrow, i64 0)
66+
// CHECK: call {{.*}} ptr @__alloc_token__ZnwmRKSt9nothrow_t(i64 noundef 4, ptr {{.*}} @_ZSt7nothrow, i64 0)
6767
sink = ::operator new(sizeof(int), std::nothrow);
6868
}
6969

7070
// CHECK-LABEL: @_Z8test_newv(
7171
int *test_new() {
72-
// CHECK: call {{.*}} ptr @__alloc_token_Znwm(i64 noundef 4, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
72+
// CHECK: call {{.*}} ptr @__alloc_token__Znwm(i64 noundef 4, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
7373
return new int;
7474
}
7575

7676
// CHECK-LABEL: @_Z14test_new_arrayv(
7777
int *test_new_array() {
78-
// CHECK: call {{.*}} ptr @__alloc_token_Znam(i64 noundef 40, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
78+
// CHECK: call {{.*}} ptr @__alloc_token__Znam(i64 noundef 40, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
7979
return new int[10];
8080
}
8181

8282
// CHECK-LABEL: @_Z16test_new_nothrowv(
8383
int *test_new_nothrow() {
84-
// CHECK: call {{.*}} ptr @__alloc_token_ZnwmRKSt9nothrow_t(i64 noundef 4, ptr {{.*}} @_ZSt7nothrow, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
84+
// CHECK: call {{.*}} ptr @__alloc_token__ZnwmRKSt9nothrow_t(i64 noundef 4, ptr {{.*}} @_ZSt7nothrow, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
8585
return new (std::nothrow) int;
8686
}
8787

8888
// CHECK-LABEL: @_Z22test_new_array_nothrowv(
8989
int *test_new_array_nothrow() {
90-
// CHECK: call {{.*}} ptr @__alloc_token_ZnamRKSt9nothrow_t(i64 noundef 40, ptr {{.*}} @_ZSt7nothrow, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
90+
// CHECK: call {{.*}} ptr @__alloc_token__ZnamRKSt9nothrow_t(i64 noundef 40, ptr {{.*}} @_ZSt7nothrow, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
9191
return new (std::nothrow) int[10];
9292
}
9393

@@ -100,10 +100,10 @@ __attribute__((no_sanitize("alloc-token"))) int *no_sanitize_new() {
100100
// CHECK-LABEL: @_Z23test_size_returning_newv(
101101
void test_size_returning_new() {
102102
// FIXME: This should not be token ID 0!
103-
// CHECK: call { ptr, i64 } @__alloc_token_size_returning_new(i64 noundef 8, i64 0)
104-
// CHECK: call { ptr, i64 } @__alloc_token_size_returning_new_hot_cold(i64 noundef 8, i8 noundef zeroext 1, i64 0)
105-
// CHECK: call { ptr, i64 } @__alloc_token_size_returning_new_aligned(i64 noundef 8, i64 noundef 32, i64 0)
106-
// CHECK: call { ptr, i64 } @__alloc_token_size_returning_new_aligned_hot_cold(i64 noundef 8, i64 noundef 32, i8 noundef zeroext 1, i64 0)
103+
// CHECK: call { ptr, i64 } @__alloc_token___size_returning_new(i64 noundef 8, i64 0)
104+
// CHECK: call { ptr, i64 } @__alloc_token___size_returning_new_hot_cold(i64 noundef 8, i8 noundef zeroext 1, i64 0)
105+
// CHECK: call { ptr, i64 } @__alloc_token___size_returning_new_aligned(i64 noundef 8, i64 noundef 32, i64 0)
106+
// CHECK: call { ptr, i64 } @__alloc_token___size_returning_new_aligned_hot_cold(i64 noundef 8, i64 noundef 32, i8 noundef zeroext 1, i64 0)
107107
sink = __size_returning_new(sizeof(long)).p;
108108
sink = __size_returning_new_hot_cold(sizeof(long), __hot_cold_t{1}).p;
109109
sink = __size_returning_new_aligned(sizeof(long), std::align_val_t{32}).p;
@@ -122,7 +122,7 @@ void may_throw();
122122
// CHECK-LABEL: @_Z27test_exception_handling_newv(
123123
TestClass *test_exception_handling_new() {
124124
try {
125-
// CHECK: invoke {{.*}} ptr @__alloc_token_Znwm(i64 noundef 72, i64 {{[1-9][0-9]*}})
125+
// CHECK: invoke {{.*}} ptr @__alloc_token__Znwm(i64 noundef 72, i64 {{[1-9][0-9]*}})
126126
// CHECK-NEXT: !alloc_token
127127
TestClass *obj = new TestClass();
128128
may_throw();
@@ -134,15 +134,15 @@ TestClass *test_exception_handling_new() {
134134

135135
// CHECK-LABEL: @_Z14test_new_classv(
136136
TestClass *test_new_class() {
137-
// CHECK: call {{.*}} ptr @__alloc_token_Znwm(i64 noundef 72, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
137+
// CHECK: call {{.*}} ptr @__alloc_token__Znwm(i64 noundef 72, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
138138
TestClass *obj = new TestClass();
139139
obj->data[0] = 42;
140140
return obj;
141141
}
142142

143143
// CHECK-LABEL: @_Z20test_new_class_arrayv(
144144
TestClass *test_new_class_array() {
145-
// CHECK: call {{.*}} ptr @__alloc_token_Znam(i64 noundef 728, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
145+
// CHECK: call {{.*}} ptr @__alloc_token__Znam(i64 noundef 728, i64 {{[1-9][0-9]*}}){{.*}} !alloc_token
146146
TestClass* arr = new TestClass[10];
147147
arr[0].data[0] = 123;
148148
return arr;

llvm/lib/Transforms/Instrumentation/AllocToken.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,8 @@ FunctionCallee AllocToken::getTokenAllocFunction(const CallBase &CB,
438438
TokenAllocName += utostr(TokenID) + "_";
439439
else
440440
NewParams.push_back(IntPtrTy); // token ID
441+
TokenAllocName += Callee->getName();
441442
FunctionType *NewFTy = FunctionType::get(RetTy, NewParams, false);
442-
// Remove leading '_' - we add our own.
443-
StringRef No_ = Callee->getName().drop_while([](char C) { return C == '_'; });
444-
TokenAllocName += No_;
445443
FunctionCallee TokenAlloc = Mod.getOrInsertFunction(TokenAllocName, NewFTy);
446444
if (Function *F = dyn_cast<Function>(TokenAlloc.getCallee()))
447445
F->copyAttributesFrom(Callee); // preserve attrs

llvm/test/Instrumentation/AllocToken/basic.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ define ptr @test_cpp_operators() sanitize_alloc_token {
3535
; CHECK-LABEL: define ptr @test_cpp_operators(
3636
; CHECK-SAME: ) #[[ATTR5]] {
3737
; CHECK-NEXT: [[ENTRY:.*:]]
38-
; CHECK-NEXT: [[TMP0:%.*]] = call ptr @__alloc_token_Znwm(i64 32, i64 3)
39-
; CHECK-NEXT: [[TMP1:%.*]] = call ptr @__alloc_token_Znam(i64 64, i64 4)
38+
; CHECK-NEXT: [[TMP0:%.*]] = call ptr @__alloc_token__Znwm(i64 32, i64 3)
39+
; CHECK-NEXT: [[TMP1:%.*]] = call ptr @__alloc_token__Znam(i64 64, i64 4)
4040
; CHECK-NEXT: ret ptr [[TMP0]]
4141
;
4242
entry:

llvm/test/Instrumentation/AllocToken/basic32.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ define ptr @test_cpp_operators() sanitize_alloc_token {
2323
; CHECK-LABEL: define ptr @test_cpp_operators(
2424
; CHECK-SAME: ) #[[ATTR2]] {
2525
; CHECK-NEXT: [[ENTRY:.*:]]
26-
; CHECK-NEXT: [[TMP0:%.*]] = call ptr @__alloc_token_Znwm(i32 32, i32 1)
26+
; CHECK-NEXT: [[TMP0:%.*]] = call ptr @__alloc_token__Znwm(i32 32, i32 1)
2727
; CHECK-NEXT: ret ptr [[TMP0]]
2828
;
2929
entry:

llvm/test/Instrumentation/AllocToken/extralibfuncs.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define ptr @test_extra_libfuncs() sanitize_alloc_token {
1212
; CHECK-LABEL: define ptr @test_extra_libfuncs(
1313
; CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
1414
; CHECK-NEXT: [[ENTRY:.*:]]
15-
; CHECK-NEXT: [[TMP0:%.*]] = call { ptr, i64 } @__alloc_token_size_returning_new(i64 10, i64 6985720287680550851), !alloc_token [[META0:![0-9]+]]
15+
; CHECK-NEXT: [[TMP0:%.*]] = call { ptr, i64 } @__alloc_token___size_returning_new(i64 10, i64 6985720287680550851), !alloc_token [[META0:![0-9]+]]
1616
; CHECK-NEXT: [[PTR1:%.*]] = extractvalue { ptr, i64 } [[TMP0]], 0
1717
; CHECK-NEXT: ret ptr [[PTR1]]
1818
;
@@ -29,8 +29,8 @@ define ptr @test_replaceable_new() sanitize_alloc_token {
2929
; CHECK-LABEL: define ptr @test_replaceable_new(
3030
; CHECK-SAME: ) #[[ATTR1]] {
3131
; CHECK-NEXT: [[ENTRY:.*:]]
32-
; CHECK-NEXT: [[TMP0:%.*]] = call ptr @__alloc_token_Znwm(i64 32, i64 6985720287680550851), !alloc_token [[META0]]
33-
; CHECK-NEXT: [[TMP1:%.*]] = call ptr @__alloc_token_Znam(i64 64, i64 6985720287680550851), !alloc_token [[META0]]
32+
; CHECK-NEXT: [[TMP0:%.*]] = call ptr @__alloc_token__Znwm(i64 32, i64 6985720287680550851), !alloc_token [[META0]]
33+
; CHECK-NEXT: [[TMP1:%.*]] = call ptr @__alloc_token__Znam(i64 64, i64 6985720287680550851), !alloc_token [[META0]]
3434
; CHECK-NEXT: ret ptr [[TMP0]]
3535
;
3636
entry:

llvm/test/Instrumentation/AllocToken/fast.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ define ptr @test_cpp_operators() sanitize_alloc_token {
3232
; CHECK-LABEL: define ptr @test_cpp_operators(
3333
; CHECK-SAME: ) #[[ATTR4]] {
3434
; CHECK-NEXT: [[ENTRY:.*:]]
35-
; CHECK-NEXT: [[PTR1:%.*]] = call ptr @__alloc_token_0_Znwm(i64 32)
36-
; CHECK-NEXT: [[PTR2:%.*]] = call ptr @__alloc_token_1_Znam(i64 64)
35+
; CHECK-NEXT: [[PTR1:%.*]] = call ptr @__alloc_token_0__Znwm(i64 32)
36+
; CHECK-NEXT: [[PTR2:%.*]] = call ptr @__alloc_token_1__Znam(i64 64)
3737
; CHECK-NEXT: ret ptr [[PTR1]]
3838
;
3939
entry:

llvm/test/Instrumentation/AllocToken/invoke.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ define ptr @test_invoke_operator_new() sanitize_alloc_token personality ptr @__g
3232
; CHECK-LABEL: define ptr @test_invoke_operator_new(
3333
; CHECK-SAME: ) #[[ATTR0]] personality ptr @__gxx_personality_v0 {
3434
; CHECK-NEXT: [[ENTRY:.*:]]
35-
; CHECK-NEXT: [[TMP0:%.*]] = invoke ptr @__alloc_token_Znwm(i64 32, i64 1)
35+
; CHECK-NEXT: [[TMP0:%.*]] = invoke ptr @__alloc_token__Znwm(i64 32, i64 1)
3636
; CHECK-NEXT: to label %[[NORMAL:.*]] unwind label %[[CLEANUP:.*]]
3737
; CHECK: [[NORMAL]]:
3838
; CHECK-NEXT: ret ptr [[TMP0]]
@@ -60,7 +60,7 @@ define ptr @test_complex_invoke_flow() sanitize_alloc_token personality ptr @__g
6060
; CHECK-NEXT: [[TMP0:%.*]] = invoke ptr @__alloc_token_malloc(i64 16, i64 2)
6161
; CHECK-NEXT: to label %[[FIRST_OK:.*]] unwind label %[[CLEANUP1:.*]]
6262
; CHECK: [[FIRST_OK]]:
63-
; CHECK-NEXT: [[TMP1:%.*]] = invoke ptr @__alloc_token_Znwm(i64 32, i64 3)
63+
; CHECK-NEXT: [[TMP1:%.*]] = invoke ptr @__alloc_token__Znwm(i64 32, i64 3)
6464
; CHECK-NEXT: to label %[[SECOND_OK:.*]] unwind label %[[CLEANUP2:.*]]
6565
; CHECK: [[SECOND_OK]]:
6666
; CHECK-NEXT: ret ptr [[TMP0]]

0 commit comments

Comments
 (0)