<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 06/25/2014 02:10 PM, Tom Stellard
wrote:<br>
</div>
<blockquote cite="mid:20140625211012.GB4219@freedesktop.org"
type="cite">
<pre wrap="">Hi Reid,
Here is an updated patch with a Sema test.
-Tom
On Wed, Jun 25, 2014 at 04:31:52PM -0400, Tom Stellard wrote:
</pre>
<blockquote type="cite">
<pre wrap="">---
include/clang/Basic/TargetInfo.h | 4 +---
lib/Basic/TargetInfo.cpp | 9 +++++++++
test/CodeGen/record-lowering-non-zero-as.cl | 14 ++++++++++++++
3 files changed, 24 insertions(+), 3 deletions(-)
create mode 100644 test/CodeGen/record-lowering-non-zero-as.cl
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index e1d0116..65dc101 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -790,9 +790,7 @@ public:
}
protected:
- virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
- return PointerWidth;
- }
+ virtual uint64_t getPointerWidthV(unsigned AddrSpace) const;
virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
return PointerAlign;
}
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index 71e39dd..d0f6306 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -17,6 +17,7 @@
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/Support/ErrorHandling.h"
#include <cstdlib>
using namespace clang;
@@ -242,6 +243,14 @@ bool TargetInfo::isTypeSigned(IntType T) {
};
}
+uint64_t TargetInfo::getPointerWidthV(unsigned AddrSpace) const {
+ if (!DescriptionString)
+ return PointerWidth;
+
+ llvm::DataLayout DL(DescriptionString);
+ return DL.getPointerSizeInBits(AddrSpace);
+}</pre>
</blockquote>
</blockquote>
<br>
Can you do this without reparsing the datalayout string every time
this is used?<br>
<br>
<blockquote cite="mid:20140625211012.GB4219@freedesktop.org"
type="cite">
<blockquote type="cite">
<pre wrap="">
+
/// setForcedLangOptions - Set forced language options.
/// Apply changes to the target information with respect to certain
/// language options which change the target configuration.
diff --git a/test/CodeGen/record-lowering-non-zero-as.cl b/test/CodeGen/record-lowering-non-zero-as.cl
new file mode 100644
index 0000000..a96756f
--- /dev/null
+++ b/test/CodeGen/record-lowering-non-zero-as.cl
@@ -0,0 +1,14 @@
+// REQUIRES: r600-registered-target
+// RUN: %clang -target r600 -mcpu=verde -S -emit-llvm -o - %s
+
+// Record lowering was crashing on SI and newer targets, because it
+// was using the wrong size for test::ptr. Since global memory
+// has 64-bit pointers, sizeof(test::ptr) should be 8.
+
+struct test {
+ global int *ptr;
+};
+
+void func(struct test t, global int *ptr) {
+ *ptr = 0;
+}
--
1.8.1.5
_______________________________________________
cfe-commits mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a>
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cfe-commits mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a>
</pre>
</blockquote>
</blockquote>
<br>
</body>
</html>