LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 51846 - Sink: moves calls that may not return
Summary: Sink: moves calls that may not return
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2021-09-14 02:56 PDT by Nuno Lopes
Modified: 2021-09-14 02:56 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Lopes 2021-09-14 02:56:12 PDT
Test: Transforms/Sink/call.ll

Transformation only valid if willreturn & nounwind attributes are present.


define i32 @test_sink_no_stores(i1 %z) {
%0:
  %l = call i32 @f_load_global() nowrite nofree
  br i1 %z, label %true, label %false

%false:
  ret i32 0

%true:
  ret i32 %l
}
=>
define i32 @test_sink_no_stores(i1 %z) {
%0:
  br i1 %z, label %true, label %false

%false:
  ret i32 0

%true:
  %l = call i32 @f_load_global() nowrite nofree
  ret i32 %l
}
Transformation doesn't verify!
ERROR: Source is more defined than target

Example:
i1 %z = undef

Source:
i32 %l = UB triggered!

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 1	alloc type: 0
Block 1 >	size: 0	align: 1

Target:
UB triggered on br