-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[llvm][fatlto] Drop any CFI related instrumentation after emitting bitcode #112788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ilovepi
merged 10 commits into
main
from
users/ilovepi/spr/llvmfatlto-drop-any-cfi-related-instrumentation-after-emitting-bitcode
Oct 31, 2024
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
68a064b
[𝘀𝗽𝗿] changes to main this commit is based on
ilovepi 3de3958
[𝘀𝗽𝗿] initial version
ilovepi 4a6acc7
[𝘀𝗽𝗿] changes introduced through rebase
ilovepi 95003b9
rebase
ilovepi ad89d61
Use new enum in constructor
ilovepi bb77205
[𝘀𝗽𝗿] changes introduced through rebase
ilovepi f60b316
Rebase
ilovepi f331c70
Update test to use cc1
ilovepi 6b0ae12
[𝘀𝗽𝗿] changes introduced through rebase
ilovepi 6fec2ec
rebase
ilovepi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,46 @@ | ||
| // REQUIRES: x86-registered-target | ||
|
|
||
| // RUN: %clangxx --target=x86_64-unknown-fuchsia -O2 -flto -ffat-lto-objects \ | ||
| // RUN: -fsanitize=cfi -fvisibility=hidden -S -emit-llvm -o - %s \ | ||
| // RUN: | FileCheck %s | ||
|
|
||
| // CHECK: llvm.embedded.object | ||
| // CHECK-SAME: section ".llvm.lto" | ||
|
|
||
| // CHECK-LABEL: define hidden void @foo | ||
| // CHECK: entry: | ||
| // CHECK-NEXT: %cmp14.not = icmp eq i64 %len, 0 | ||
| // CHECK-NEXT: br i1 %cmp14.not, label %for.end7, label %for.cond1.preheader.preheader | ||
| // CHECK: for.cond1.preheader.preheader: ; preds = %entry | ||
| // CHECK-NEXT: %arrayidx.1 = getelementptr inbounds nuw i8, ptr %ptr, i64 4 | ||
| // CHECK-NEXT: br label %for.cond1.preheader | ||
|
|
||
| // CHECK-NOT: @llvm.type.test | ||
|
|
||
| // The code below is a reduced case from https://github.com/llvm/llvm-project/issues/112053 | ||
| #define __PRINTFLIKE(__fmt, __varargs) __attribute__((__format__(__printf__, __fmt, __varargs))) | ||
| typedef void func(void* arg, const char* fmt, ...) __PRINTFLIKE(2, 3); | ||
| typedef __SIZE_TYPE__ size_t; | ||
| typedef unsigned long uintptr_t; | ||
|
|
||
| extern "C" | ||
| void foo(const void* ptr, size_t len, long disp_addr, | ||
| func* printf_func, void* printf_arg) { | ||
| uintptr_t address = (uintptr_t)ptr; | ||
| size_t count; | ||
|
|
||
| for (count = 0; count < len; count += 16) { | ||
| union { | ||
| unsigned int buf[4]; | ||
| unsigned char cbuf[16]; | ||
| } u; | ||
| size_t s = 10; | ||
| size_t i; | ||
|
|
||
| for (i = 0; i < s / 4; i++) { | ||
| u.buf[i] = ((const unsigned int*)address)[i]; | ||
| printf_func(printf_arg, "%08x ", static_cast<unsigned int>(u.buf[i])); | ||
| } | ||
| } | ||
| } | ||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| ; RUN: opt -S -passes=lowertypetests -lowertypetests-force-drop-type-tests -lowertypetests-drop-type-tests < %s | FileCheck %s | ||
|
|
||
| define void @func() { | ||
| entry: | ||
| %0 = tail call i1 @llvm.type.test(ptr null, metadata !"foo") | ||
| br i1 %0, label %exit, label %trap | ||
| ; CHECK: entry: | ||
| ; CHECK-NEXT: br i1 true, label %exit, label %trap | ||
| ; CHECK-NOT: @llvm.type.test | ||
|
|
||
| trap: | ||
| unreachable | ||
|
|
||
| exit: | ||
| ret void | ||
| } | ||
|
|
||
| declare i1 @llvm.type.test(ptr, metadata) #0 | ||
| attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this build? The ctor only takes three arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, you have a dependent change that adds the argument.
68a064b
I'm not really a big fan of adding another bool argument like this because it makes the callers less clear, can you do something else like make the existing argument into an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR depends on #112787 which adds the fourth argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I'm not super happy w/ the boolean either. The only reason its required is to avoid asserting for the new use case, but that also implies that assertion doesn't always hold, so I'm not sure if its really a good idea to keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And apologies for not adding you on both reviews. I had thought I added you and Nikita to #112787, but it looks like I hadn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion is to check that the code is only removing type test assumes (possibly involving a phi). So I wouldn't call the functionality that you're adding "always drop type tests". What you're adding is more like "drop type tests" and what's there already is "drop type test assumes". So maybe you can name the enumerators based on that.