-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[IR] Allow poison argument to lifetime markers #151148
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
Open
nikic
wants to merge
1
commit into
llvm:main
Choose a base branch
from
nikic:lifetime-poison
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−36
Open
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -7598,7 +7598,9 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, | |
if (TM.getOptLevel() == CodeGenOptLevel::None) | ||
return; | ||
|
||
const AllocaInst *LifetimeObject = cast<AllocaInst>(I.getArgOperand(1)); | ||
const AllocaInst *LifetimeObject = dyn_cast<AllocaInst>(I.getArgOperand(1)); | ||
if (!LifetimeObject) | ||
return; | ||
Comment on lines
+7601
to
+7603
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing tests? |
||
|
||
// First check that the Alloca is static, otherwise it won't have a | ||
// valid frame index. | ||
|
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
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 was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
llvm/test/Transforms/InstCombine/unreachable-alloca-lifetime-markers.ll
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,42 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -passes=instcombine < %s | FileCheck %s | ||
|
||
; Make sure this does not crash. | ||
|
||
define void @pr150338(ptr %arg) { | ||
; CHECK-LABEL: define void @pr150338( | ||
; CHECK-SAME: ptr [[ARG:%.*]]) { | ||
; CHECK-NEXT: store i1 true, ptr poison, align 1 | ||
; CHECK-NEXT: ret void | ||
; | ||
%a = alloca i32 | ||
store ptr %a, ptr %arg | ||
store i1 true, ptr poison | ||
call void @llvm.lifetime.end.p0(i64 4, ptr %a) | ||
ret void | ||
} | ||
|
||
define ptr @pr151119() { | ||
; CHECK-LABEL: define ptr @pr151119() { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: store i1 false, ptr poison, align 1 | ||
; CHECK-NEXT: br i1 false, label %[[BB1:.*]], label %[[BB2:.*]] | ||
; CHECK: [[BB1]]: | ||
; CHECK-NEXT: br label %[[BB2]] | ||
; CHECK: [[BB2]]: | ||
; CHECK-NEXT: br label %[[BB1]] | ||
; | ||
entry: | ||
%a = alloca i32, align 4 | ||
store i1 false, ptr poison | ||
br i1 false, label %bb1, label %bb2 | ||
|
||
bb1: | ||
%phi1 = phi ptr [ null, %entry ], [ %phi2, %bb2 ] | ||
call void @llvm.lifetime.start.p0(i64 4, ptr %a) | ||
br label %bb2 | ||
|
||
bb2: | ||
%phi2 = phi ptr [ null, %entry ], [ %a, %bb1 ] | ||
br label %bb1 | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Can we relax this to any constant? As it is this will require special casing in llvm-reduce at a minimum, but other places also could replace with null
Uh oh!
There was an error while loading. Please reload this page.
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.
I'd rather not broaden this if we can be avoided at all. Allowing any constant would also allow globals, where people might reasonable expect it to do something.
Adding some special cases to llvm-reduce should be fine to avoid invalid reductions, e.g. #93713 is now more relevant. We can also skip the zero replacement for lifetimes, which just is not a useful thing to do (it should be either dropped entirely or left alone -- also the fact that llvm-reduce replaces the size argument with zero is really annoying, though that will go away soon anyway).
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.
#151694 and #151697 should avoid invalid reductions.