[llvm-bugs] [Bug 40642] New: After 350404, clang drops volatile load
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 7 02:39:48 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40642
Bug ID: 40642
Summary: After 350404, clang drops volatile load
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: hans at chromium.org
CC: aaron at aaronballman.com, htmldeveloper at gmail.com,
llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Reproducer:
$ cat /tmp/c.cc
template <class T> struct S {
void foo() {
if (true)
reinterpret_cast<const volatile unsigned char*>(m_ptr)[0];
}
int* m_ptr;
};
void f(S<int> *x) {
x->foo();
}
With r350403:
$ /work/llvm.monorepo/build.release/bin/clang.good -cc1 -triple
x86_64-unknown-linux-gnu -S -emit-llvm /tmp/c.cc -o - | grep -A999 'define
linkonce_odr void @_ZN1SIiE3fooEv'
define linkonce_odr void @_ZN1SIiE3fooEv(%struct.S* %this) #0 comdat align 2 {
entry:
%this.addr = alloca %struct.S*, align 8
store %struct.S* %this, %struct.S** %this.addr, align 8
%this1 = load %struct.S*, %struct.S** %this.addr, align 8
%m_ptr = getelementptr inbounds %struct.S, %struct.S* %this1, i32 0, i32 0
%0 = load i32*, i32** %m_ptr, align 8
%1 = bitcast i32* %0 to i8*
%arrayidx = getelementptr inbounds i8, i8* %1, i64 0
%2 = load volatile i8, i8* %arrayidx, align 1
ret void
}
With r350404:
$ /work/llvm.monorepo/build.release/bin/clang.bad -cc1 -triple
x86_64-unknown-linux-gnu -S -emit-llvm /tmp/c.cc -o - | grep -A999 'define
linkonce_odr void @_ZN1SIiE3fooEv'
define linkonce_odr void @_ZN1SIiE3fooEv(%struct.S* %this) #0 comdat align 2 {
entry:
%this.addr = alloca %struct.S*, align 8
store %struct.S* %this, %struct.S** %this.addr, align 8
%this1 = load %struct.S*, %struct.S** %this.addr, align 8
%m_ptr = getelementptr inbounds %struct.S, %struct.S* %this1, i32 0, i32 0
%0 = load i32*, i32** %m_ptr, align 8
%1 = bitcast i32* %0 to i8*
%arrayidx = getelementptr inbounds i8, i8* %1, i64 0
ret void
}
Note that "%2 = load volatile i8, i8* %arrayidx, align 1" is missing.
Adding a void cast, i.e. "(void)reinterpret_cast<const volatile unsigned
char*>(m_ptr)[0];" makes the load appear also with r350404.
The regression was caught by test failures in pdfium
(https://bugs.chromium.org/p/chromium/issues/detail?id=929475)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190207/ea461eb2/attachment.html>
More information about the llvm-bugs
mailing list