forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged main:5099dc341f7f into amd-gfx:ab27814b3805
Local branch amd-gfx ab27814 Merged main:7539bcf994ed into amd-gfx:0e8798f5c1bd Remote branch main 5099dc3 [Clang][CodeGen] Fix use of CXXThisValue with StrictVTablePointers (llvm#68169)
- Loading branch information
Showing
62 changed files
with
6,449 additions
and
1,151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// RUN: %clang_cc1 %s -I%S -triple=x86_64-pc-windows-msvc -fstrict-vtable-pointers -disable-llvm-passes -O1 -emit-llvm -o %t.ll | ||
// RUN: FileCheck %s < %t.ll | ||
|
||
struct A { | ||
virtual ~A(); | ||
}; | ||
struct B : virtual A {}; | ||
class C : B {}; | ||
C foo; | ||
|
||
// CHECK-LABEL: define {{.*}} @"??0C@@QEAA@XZ"(ptr {{.*}} %this, i32 {{.*}} %is_most_derived) | ||
// CHECK: ctor.init_vbases: | ||
// CHECK-NEXT: %0 = getelementptr inbounds i8, ptr %this1, i64 0 | ||
// CHECK-NEXT: store ptr @"??_8C@@7B@", ptr %0 | ||
// CHECK-NEXT: %1 = call ptr @llvm.launder.invariant.group.p0(ptr %this1) | ||
// CHECK-NEXT: %2 = getelementptr inbounds i8, ptr %1, i64 8 | ||
// CHECK-NEXT: %call = call noundef ptr @"??0A@@QEAA@XZ"(ptr {{.*}} %2) #2 | ||
// CHECK-NEXT: br label %ctor.skip_vbases | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: ctor.skip_vbases: | ||
// CHECK-NEXT: %3 = call ptr @llvm.launder.invariant.group.p0(ptr %this1) | ||
// CHECK-NEXT: %call3 = call noundef ptr @"??0B@@QEAA@XZ"(ptr {{.*}} %3, i32 noundef 0) #2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//===--- Stack smashing test to check stack canary set up ----------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/__support/CPP/string.h" | ||
#include "src/__support/OSUtil/io.h" | ||
#include "src/pthread/pthread_atfork.h" | ||
#include "src/signal/raise.h" | ||
#include "src/sys/wait/wait.h" | ||
#include "src/sys/wait/wait4.h" | ||
#include "src/sys/wait/waitpid.h" | ||
#include "src/unistd/fork.h" | ||
|
||
#include "test/IntegrationTest/test.h" | ||
|
||
#include <errno.h> | ||
#include <signal.h> | ||
#include <sys/wait.h> | ||
#include <unistd.h> | ||
|
||
void no_stack_smashing_normal_exit() { | ||
pid_t pid = LIBC_NAMESPACE::fork(); | ||
if (pid == 0) { | ||
// Child process | ||
char foo[30]; | ||
for (int i = 0; i < 30; i++) | ||
foo[i] = (foo[i] != 42) ? 42 : 24; | ||
return; | ||
} | ||
ASSERT_TRUE(pid > 0); | ||
int status; | ||
pid_t cpid = LIBC_NAMESPACE::wait(&status); | ||
ASSERT_TRUE(cpid > 0); | ||
ASSERT_EQ(cpid, pid); | ||
ASSERT_TRUE(WIFEXITED(status)); | ||
} | ||
|
||
void stack_smashing_abort() { | ||
pid_t pid = LIBC_NAMESPACE::fork(); | ||
if (pid == 0) { | ||
// Child process | ||
char foo[30]; | ||
char *frame_ptr = static_cast<char *>(__builtin_frame_address(0)); | ||
char *cur_ptr = &foo[0]; | ||
// Corrupt the stack | ||
while (cur_ptr != frame_ptr) { | ||
*cur_ptr = (*cur_ptr != 42) ? 42 : 24; | ||
cur_ptr++; | ||
} | ||
return; | ||
} | ||
ASSERT_TRUE(pid > 0); | ||
int status; | ||
pid_t cpid = LIBC_NAMESPACE::wait(&status); | ||
ASSERT_TRUE(cpid > 0); | ||
ASSERT_EQ(cpid, pid); | ||
ASSERT_TRUE(WTERMSIG(status) == SIGABRT); | ||
} | ||
|
||
TEST_MAIN(int argc, char **argv, char **envp) { | ||
no_stack_smashing_normal_exit(); | ||
stack_smashing_abort(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.