Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,12 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
//
// Make sure the object has not escaped here, and then check that none of the
// call arguments alias the object below.
//
// We model calls that can return twice (setjmp) as clobbering non-escaping
// objects, to model any accesses that may occur prior to the second return.
if (!isa<Constant>(Object) && Call != Object &&
AAQI.CA->isNotCapturedBefore(Object, Call, /*OrAt*/ false)) {
AAQI.CA->isNotCapturedBefore(Object, Call, /*OrAt*/ false) &&
!Call->hasFnAttr(Attribute::ReturnsTwice)) {

// Optimistically assume that call doesn't touch Object and check this
// assumption in the following loop.
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/GVN/setjmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ declare i32 @setjmp() returns_twice
declare void @longjmp()
declare ptr @malloc(i64)

; FIXME: This is a miscompile.
define i32 @test() {
; CHECK-LABEL: define i32 @test() {
; CHECK-NEXT: [[MALLOC:%.*]] = call noalias ptr @malloc(i64 4)
Expand All @@ -18,7 +17,8 @@ define i32 @test() {
; CHECK-NEXT: call void @longjmp()
; CHECK-NEXT: unreachable
; CHECK: [[IF_END]]:
; CHECK-NEXT: ret i32 10
; CHECK-NEXT: [[RES:%.*]] = load i32, ptr [[MALLOC]], align 4
; CHECK-NEXT: ret i32 [[RES]]
;
%malloc = call noalias ptr @malloc(i64 4)
store i32 10, ptr %malloc, align 4
Expand Down