summaryrefslogtreecommitdiffstats
path: root/llvm/docs
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-11-02 01:21:51 +0000
committerTim Northover <tnorthover@apple.com>2014-11-02 01:21:51 +0000
commitab60bb9b8185e8e3c8b398a03a993de950d891cb (patch)
treef51ec2df4c9ee0be96f5901433482bba302ea7c1 /llvm/docs
parent27e35f23029a6ae29fbd543776e0189dbee81811 (diff)
downloadbcm5719-llvm-ab60bb9b8185e8e3c8b398a03a993de950d891cb.tar.gz
bcm5719-llvm-ab60bb9b8185e8e3c8b398a03a993de950d891cb.zip
Docs: update va_arg example with valid x86_64 va_list type.
The given example was overflowing its alloca and segfaulting if actually run on x86, so it's a good idea to provide something that works there too. Patch by Ramkumar Ramachandra. llvm-svn: 221077
Diffstat (limited to 'llvm/docs')
-rw-r--r--llvm/docs/LangRef.rst13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index ddef80318e2..3b7d80ba376 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -6884,14 +6884,21 @@ variable argument handling intrinsic functions are used.
.. code-block:: llvm
+ ; This struct is different for every platform. For most platforms,
+ ; it is merely an i8*.
+ %struct.va_list = type { i8* }
+
+ ; For Unix x86_64 platforms, va_list is the following struct:
+ ; %struct.va_list = type { i32, i32, i8*, i8* }
+
define i32 @test(i32 %X, ...) {
; Initialize variable argument processing
- %ap = alloca i8*
- %ap2 = bitcast i8** %ap to i8*
+ %ap = alloca %struct.va_list
+ %ap2 = bitcast %struct.va_list* %ap to i8*
call void @llvm.va_start(i8* %ap2)
; Read a single integer argument
- %tmp = va_arg i8** %ap, i32
+ %tmp = va_arg i8* %ap2, i32
; Demonstrate usage of llvm.va_copy and llvm.va_end
%aq = alloca i8*
OpenPOWER on IntegriCloud