From 7ec39dcc39d81c5cf6241d5af7ffd689992fa80a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 8 May 2013 09:23:53 +0000 Subject: [PATCH 001/467] Add clang-tools-extra to the list of things to tag for the release. llvm-svn: 181402 --- llvm/utils/release/tag.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/utils/release/tag.sh b/llvm/utils/release/tag.sh index cc4fc8085bd6..c327174f8115 100755 --- a/llvm/utils/release/tag.sh +++ b/llvm/utils/release/tag.sh @@ -32,7 +32,7 @@ function usage() { function tag_version() { set -x - for proj in llvm cfe dragonegg test-suite compiler-rt libcxx ; do + for proj in llvm cfe dragonegg test-suite compiler-rt libcxx clang-tools-extra ; do if svn ls $base_url/$proj/branches/release_$release > /dev/null 2>&1 ; then if [ $rebranch = "no" ]; then continue @@ -49,7 +49,7 @@ function tag_version() { function tag_release_candidate() { set -x - for proj in llvm cfe dragonegg test-suite compiler-rt libcxx ; do + for proj in llvm cfe dragonegg test-suite compiler-rt libcxx clang-tools-extra ; do if ! svn ls $base_url/$proj/tags/RELEASE_$release > /dev/null 2>&1 ; then svn mkdir -m "Creating release directory for release_$release." $base_url/$proj/tags/RELEASE_$release fi -- GitLab From 0dd712e050963094b48125211d5e7458c254b10b Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 8 May 2013 09:31:10 +0000 Subject: [PATCH 002/467] Add libcxx and clang-tools-extra to the testing thing. llvm-svn: 181418 --- llvm/utils/release/test-release.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/utils/release/test-release.sh b/llvm/utils/release/test-release.sh index a62e82974aca..104945b0eb19 100755 --- a/llvm/utils/release/test-release.sh +++ b/llvm/utils/release/test-release.sh @@ -18,7 +18,7 @@ else MAKE=make fi -projects="llvm cfe dragonegg compiler-rt test-suite" +projects="llvm cfe dragonegg compiler-rt libcxx test-suite clang-tools-extra" # Base SVN URL for the sources. Base_url="http://llvm.org/svn/llvm-project" @@ -210,13 +210,20 @@ function export_sources() { if [ ! -h clang ]; then ln -s ../../cfe.src clang fi + cd $BuildDir/llvm.src/tools/clang/tools + if [ ! -h clang-tools-extra ]; then + ln -s ../../../../clang-tools-extra.src extra + fi cd $BuildDir/llvm.src/projects - if [ ! -h llvm-test ]; then - ln -s ../../test-suite.src llvm-test + if [ ! -h test-suite ]; then + ln -s ../../test-suite.src test-suite fi if [ ! -h compiler-rt ]; then ln -s ../../compiler-rt.src compiler-rt fi + if [ ! -h libcxx ]; then + ln -s ../../libcxx.src libcxx + fi cd $BuildDir } -- GitLab From 1fb61c6eed3f375896c66ea5554a917ae6cb73fe Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Wed, 8 May 2013 09:41:12 +0000 Subject: [PATCH 003/467] This patch fixes two tests marked as XFAIL among the ARM assembler tests. The reference encoding is correct, but written in the wrong byte order (these are Thumb tests, while the reference is in ARM byte order). llvm-svn: 181420 --- llvm/test/MC/ARM/neont2-vld-encoding.s | 103 ++++++++++++------------- llvm/test/MC/ARM/neont2-vst-encoding.s | 93 +++++++++++----------- 2 files changed, 97 insertions(+), 99 deletions(-) diff --git a/llvm/test/MC/ARM/neont2-vld-encoding.s b/llvm/test/MC/ARM/neont2-vld-encoding.s index 7db855278116..d379d170bab5 100644 --- a/llvm/test/MC/ARM/neont2-vld-encoding.s +++ b/llvm/test/MC/ARM/neont2-vld-encoding.s @@ -1,112 +1,111 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple thumb-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * .code 16 -@ CHECK: vld1.8 {d16}, [r0:64] @ encoding: [0x1f,0x07,0x60,0xf9] - vld1.8 {d16}, [r0:64] -@ CHECK: vld1.16 {d16}, [r0] @ encoding: [0x4f,0x07,0x60,0xf9] +@ CHECK: vld1.8 {d16}, [r0:64] @ encoding: [0x60,0xf9,0x1f,0x07] + vld1.8 {d16}, [r0:64] +@ CHECK: vld1.16 {d16}, [r0] @ encoding: [0x60,0xf9,0x4f,0x07] vld1.16 {d16}, [r0] -@ CHECK: vld1.32 {d16}, [r0] @ encoding: [0x8f,0x07,0x60,0xf9] +@ CHECK: vld1.32 {d16}, [r0] @ encoding: [0x60,0xf9,0x8f,0x07] vld1.32 {d16}, [r0] -@ CHECK: vld1.64 {d16}, [r0] @ encoding: [0xcf,0x07,0x60,0xf9] +@ CHECK: vld1.64 {d16}, [r0] @ encoding: [0x60,0xf9,0xcf,0x07] vld1.64 {d16}, [r0] -@ CHECK: vld1.8 {d16, d17}, [r0:64] @ encoding: [0x1f,0x0a,0x60,0xf9] +@ CHECK: vld1.8 {d16, d17}, [r0:64] @ encoding: [0x60,0xf9,0x1f,0x0a] vld1.8 {d16, d17}, [r0:64] -@ CHECK: vld1.16 {d16, d17}, [r0:128] @ encoding: [0x6f,0x0a,0x60,0xf9] +@ CHECK: vld1.16 {d16, d17}, [r0:128] @ encoding: [0x60,0xf9,0x6f,0x0a] vld1.16 {d16, d17}, [r0:128] -@ CHECK: vld1.32 {d16, d17}, [r0] @ encoding: [0x8f,0x0a,0x60,0xf9] +@ CHECK: vld1.32 {d16, d17}, [r0] @ encoding: [0x60,0xf9,0x8f,0x0a] vld1.32 {d16, d17}, [r0] -@ CHECK: vld1.64 {d16, d17}, [r0] @ encoding: [0xcf,0x0a,0x60,0xf9] +@ CHECK: vld1.64 {d16, d17}, [r0] @ encoding: [0x60,0xf9,0xcf,0x0a] vld1.64 {d16, d17}, [r0] -@ CHECK: vld2.8 {d16, d17}, [r0:64] @ encoding: [0x1f,0x08,0x60,0xf9] +@ CHECK: vld2.8 {d16, d17}, [r0:64] @ encoding: [0x60,0xf9,0x1f,0x08] vld2.8 {d16, d17}, [r0:64] -@ CHECK: vld2.16 {d16, d17}, [r0:128] @ encoding: [0x6f,0x08,0x60,0xf9] +@ CHECK: vld2.16 {d16, d17}, [r0:128] @ encoding: [0x60,0xf9,0x6f,0x08] vld2.16 {d16, d17}, [r0:128] -@ CHECK: vld2.32 {d16, d17}, [r0] @ encoding: [0x8f,0x08,0x60,0xf9] +@ CHECK: vld2.32 {d16, d17}, [r0] @ encoding: [0x60,0xf9,0x8f,0x08] vld2.32 {d16, d17}, [r0] -@ CHECK: vld2.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x1f,0x03,0x60,0xf9] +@ CHECK: vld2.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x60,0xf9,0x1f,0x03] vld2.8 {d16, d17, d18, d19}, [r0:64] -@ CHECK: vld2.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x6f,0x03,0x60,0xf9] +@ CHECK: vld2.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x60,0xf9,0x6f,0x03] vld2.16 {d16, d17, d18, d19}, [r0:128] -@ CHECK: vld2.32 {d16, d17, d18, d19}, [r0:256] @ encoding: [0xbf,0x03,0x60,0xf9] +@ CHECK: vld2.32 {d16, d17, d18, d19}, [r0:256] @ encoding: [0x60,0xf9,0xbf,0x03] vld2.32 {d16, d17, d18, d19}, [r0:256] -@ CHECK: vld3.8 {d16, d17, d18}, [r0:64] @ encoding: [0x1f,0x04,0x60,0xf9] +@ CHECK: vld3.8 {d16, d17, d18}, [r0:64] @ encoding: [0x60,0xf9,0x1f,0x04] vld3.8 {d16, d17, d18}, [r0:64] -@ CHECK: vld3.16 {d16, d17, d18}, [r0] @ encoding: [0x4f,0x04,0x60,0xf9] +@ CHECK: vld3.16 {d16, d17, d18}, [r0] @ encoding: [0x60,0xf9,0x4f,0x04] vld3.16 {d16, d17, d18}, [r0] -@ CHECK: vld3.32 {d16, d17, d18}, [r0] @ encoding: [0x8f,0x04,0x60,0xf9] +@ CHECK: vld3.32 {d16, d17, d18}, [r0] @ encoding: [0x60,0xf9,0x8f,0x04] vld3.32 {d16, d17, d18}, [r0] -@ CHECK: vld3.8 {d16, d18, d20}, [r0:64]! @ encoding: [0x1d,0x05,0x60,0xf9] +@ CHECK: vld3.8 {d16, d18, d20}, [r0:64]! @ encoding: [0x60,0xf9,0x1d,0x05] vld3.8 {d16, d18, d20}, [r0:64]! -@ CHECK: vld3.8 {d17, d19, d21}, [r0:64]! @ encoding: [0x1d,0x15,0x60,0xf9] +@ CHECK: vld3.8 {d17, d19, d21}, [r0:64]! @ encoding: [0x60,0xf9,0x1d,0x15] vld3.8 {d17, d19, d21}, [r0:64]! -@ CHECK: vld3.16 {d16, d18, d20}, [r0]! @ encoding: [0x4d,0x05,0x60,0xf9] +@ CHECK: vld3.16 {d16, d18, d20}, [r0]! @ encoding: [0x60,0xf9,0x4d,0x05] vld3.16 {d16, d18, d20}, [r0]! -@ CHECK: vld3.16 {d17, d19, d21}, [r0]! @ encoding: [0x4d,0x15,0x60,0xf9] +@ CHECK: vld3.16 {d17, d19, d21}, [r0]! @ encoding: [0x60,0xf9,0x4d,0x15] vld3.16 {d17, d19, d21}, [r0]! -@ CHECK: vld3.32 {d16, d18, d20}, [r0]! @ encoding: [0x8d,0x05,0x60,0xf9] +@ CHECK: vld3.32 {d16, d18, d20}, [r0]! @ encoding: [0x60,0xf9,0x8d,0x05] vld3.32 {d16, d18, d20}, [r0]! -@ CHECK: vld3.32 {d17, d19, d21}, [r0]! @ encoding: [0x8d,0x15,0x60,0xf9] +@ CHECK: vld3.32 {d17, d19, d21}, [r0]! @ encoding: [0x60,0xf9,0x8d,0x15] vld3.32 {d17, d19, d21}, [r0]! -@ CHECK: vld4.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x1f,0x00,0x60,0xf9] +@ CHECK: vld4.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x60,0xf9,0x1f,0x00] vld4.8 {d16, d17, d18, d19}, [r0:64] -@ CHECK: vld4.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x6f,0x00,0x60,0xf9] +@ CHECK: vld4.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x60,0xf9,0x6f,0x00] vld4.16 {d16, d17, d18, d19}, [r0:128] -@ CHECK: vld4.32 {d16, d17, d18, d19}, [r0:256] @ encoding: [0xbf,0x00,0x60,0xf9] +@ CHECK: vld4.32 {d16, d17, d18, d19}, [r0:256] @ encoding: [0x60,0xf9,0xbf,0x00] vld4.32 {d16, d17, d18, d19}, [r0:256] -@ CHECK: vld4.8 {d16, d18, d20, d22}, [r0:256]! @ encoding: [0x3d,0x01,0x60,0xf9] +@ CHECK: vld4.8 {d16, d18, d20, d22}, [r0:256]! @ encoding: [0x60,0xf9,0x3d,0x01] vld4.8 {d16, d18, d20, d22}, [r0:256]! -@ CHECK: vld4.8 {d17, d19, d21, d23}, [r0:256]! @ encoding: [0x3d,0x11,0x60,0xf9] +@ CHECK: vld4.8 {d17, d19, d21, d23}, [r0:256]! @ encoding: [0x60,0xf9,0x3d,0x11] vld4.8 {d17, d19, d21, d23}, [r0:256]! -@ CHECK: vld4.16 {d16, d18, d20, d22}, [r0]! @ encoding: [0x4d,0x01,0x60,0xf9] +@ CHECK: vld4.16 {d16, d18, d20, d22}, [r0]! @ encoding: [0x60,0xf9,0x4d,0x01] vld4.16 {d16, d18, d20, d22}, [r0]! -@ CHECK: vld4.16 {d17, d19, d21, d23}, [r0]! @ encoding: [0x4d,0x11,0x60,0xf9] +@ CHECK: vld4.16 {d17, d19, d21, d23}, [r0]! @ encoding: [0x60,0xf9,0x4d,0x11] vld4.16 {d17, d19, d21, d23}, [r0]! -@ CHECK: vld4.32 {d16, d18, d20, d22}, [r0]! @ encoding: [0x8d,0x01,0x60,0xf9] +@ CHECK: vld4.32 {d16, d18, d20, d22}, [r0]! @ encoding: [0x60,0xf9,0x8d,0x01] vld4.32 {d16, d18, d20, d22}, [r0]! -@ CHECK: vld4.32 {d17, d19, d21, d23}, [r0]! @ encoding: [0x8d,0x11,0x60,0xf9] +@ CHECK: vld4.32 {d17, d19, d21, d23}, [r0]! @ encoding: [0x60,0xf9,0x8d,0x11] vld4.32 {d17, d19, d21, d23}, [r0]! -@ CHECK: vld1.8 {d16[3]}, [r0] @ encoding: [0x6f,0x00,0xe0,0xf9] +@ CHECK: vld1.8 {d16[3]}, [r0] @ encoding: [0xe0,0xf9,0x6f,0x00] vld1.8 {d16[3]}, [r0] -@ CHECK: vld1.16 {d16[2]}, [r0:16] @ encoding: [0x9f,0x04,0xe0,0xf9] +@ CHECK: vld1.16 {d16[2]}, [r0:16] @ encoding: [0xe0,0xf9,0x9f,0x04] vld1.16 {d16[2]}, [r0:16] -@ CHECK: vld1.32 {d16[1]}, [r0:32] @ encoding: [0xbf,0x08,0xe0,0xf9] +@ CHECK: vld1.32 {d16[1]}, [r0:32] @ encoding: [0xe0,0xf9,0xbf,0x08] vld1.32 {d16[1]}, [r0:32] -@ CHECK: vld2.8 {d16[1], d17[1]}, [r0:16] @ encoding: [0x3f,0x01,0xe0,0xf9] +@ CHECK: vld2.8 {d16[1], d17[1]}, [r0:16] @ encoding: [0xe0,0xf9,0x3f,0x01] vld2.8 {d16[1], d17[1]}, [r0:16] -@ CHECK: vld2.16 {d16[1], d17[1]}, [r0:32] @ encoding: [0x5f,0x05,0xe0,0xf9] +@ CHECK: vld2.16 {d16[1], d17[1]}, [r0:32] @ encoding: [0xe0,0xf9,0x5f,0x05] vld2.16 {d16[1], d17[1]}, [r0:32] -@ CHECK: vld2.32 {d16[1], d17[1]}, [r0] @ encoding: [0x8f,0x09,0xe0,0xf9] +@ CHECK: vld2.32 {d16[1], d17[1]}, [r0] @ encoding: [0xe0,0xf9,0x8f,0x09] vld2.32 {d16[1], d17[1]}, [r0] -@ CHECK: vld2.16 {d17[1], d19[1]}, [r0] @ encoding: [0x6f,0x15,0xe0,0xf9] +@ CHECK: vld2.16 {d17[1], d19[1]}, [r0] @ encoding: [0xe0,0xf9,0x6f,0x15] vld2.16 {d17[1], d19[1]}, [r0] -@ CHECK: vld2.32 {d17[0], d19[0]}, [r0:64] @ encoding: [0x5f,0x19,0xe0,0xf9] +@ CHECK: vld2.32 {d17[0], d19[0]}, [r0:64] @ encoding: [0xe0,0xf9,0x5f,0x19] vld2.32 {d17[0], d19[0]}, [r0:64] -@ CHECK: vld3.8 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x2f,0x02,0xe0,0xf9] +@ CHECK: vld3.8 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0xe0,0xf9,0x2f,0x02] vld3.8 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vld3.16 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x4f,0x06,0xe0,0xf9] +@ CHECK: vld3.16 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0xe0,0xf9,0x4f,0x06] vld3.16 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vld3.32 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x8f,0x0a,0xe0,0xf9] +@ CHECK: vld3.32 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0xe0,0xf9,0x8f,0x0a] vld3.32 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vld3.16 {d16[1], d18[1], d20[1]}, [r0] @ encoding: [0x6f,0x06,0xe0,0xf9] +@ CHECK: vld3.16 {d16[1], d18[1], d20[1]}, [r0] @ encoding: [0xe0,0xf9,0x6f,0x06] vld3.16 {d16[1], d18[1], d20[1]}, [r0] -@ CHECK: vld3.32 {d17[1], d19[1], d21[1]}, [r0] @ encoding: [0xcf,0x1a,0xe0,0xf9] +@ CHECK: vld3.32 {d17[1], d19[1], d21[1]}, [r0] @ encoding: [0xe0,0xf9,0xcf,0x1a] vld3.32 {d17[1], d19[1], d21[1]}, [r0] -@ CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0:32] @ encoding: [0x3f,0x03,0xe0,0xf9] +@ CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0:32] @ encoding: [0xe0,0xf9,0x3f,0x03] vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0:32] -@ CHECK: vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] @ encoding: [0x4f,0x07,0xe0,0xf9] +@ CHECK: vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] @ encoding: [0xe0,0xf9,0x4f,0x07] vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] -@ CHECK: vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0:128] @ encoding: [0xaf,0x0b,0xe0,0xf9] +@ CHECK: vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0:128] @ encoding: [0xe0,0xf9,0xaf,0x0b] vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0:128] -@ CHECK: vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0:64] @ encoding: [0x7f,0x07,0xe0,0xf9] +@ CHECK: vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0:64] @ encoding: [0xe0,0xf9,0x7f,0x07] vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0:64] -@ CHECK: vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ encoding: [0x4f,0x1b,0xe0,0xf9] +@ CHECK: vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ encoding: [0xe0,0xf9,0x4f,0x1b] vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] diff --git a/llvm/test/MC/ARM/neont2-vst-encoding.s b/llvm/test/MC/ARM/neont2-vst-encoding.s index 9adf7514f4b7..410d8f349f11 100644 --- a/llvm/test/MC/ARM/neont2-vst-encoding.s +++ b/llvm/test/MC/ARM/neont2-vst-encoding.s @@ -1,105 +1,104 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple thumb-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * .code 16 -@ CHECK: vst1.8 {d16}, [r0:64] @ encoding: [0x1f,0x07,0x40,0xf9] +@ CHECK: vst1.8 {d16}, [r0:64] @ encoding: [0x40,0xf9,0x1f,0x07] vst1.8 {d16}, [r0:64] -@ CHECK: vst1.16 {d16}, [r0] @ encoding: [0x4f,0x07,0x40,0xf9] +@ CHECK: vst1.16 {d16}, [r0] @ encoding: [0x40,0xf9,0x4f,0x07] vst1.16 {d16}, [r0] -@ CHECK: vst1.32 {d16}, [r0] @ encoding: [0x8f,0x07,0x40,0xf9] +@ CHECK: vst1.32 {d16}, [r0] @ encoding: [0x40,0xf9,0x8f,0x07] vst1.32 {d16}, [r0] -@ CHECK: vst1.64 {d16}, [r0] @ encoding: [0xcf,0x07,0x40,0xf9] +@ CHECK: vst1.64 {d16}, [r0] @ encoding: [0x40,0xf9,0xcf,0x07] vst1.64 {d16}, [r0] -@ CHECK: vst1.8 {d16, d17}, [r0:64] @ encoding: [0x1f,0x0a,0x40,0xf9] +@ CHECK: vst1.8 {d16, d17}, [r0:64] @ encoding: [0x40,0xf9,0x1f,0x0a] vst1.8 {d16, d17}, [r0:64] -@ CHECK: vst1.16 {d16, d17}, [r0:128] @ encoding: [0x6f,0x0a,0x40,0xf9] +@ CHECK: vst1.16 {d16, d17}, [r0:128] @ encoding: [0x40,0xf9,0x6f,0x0a] vst1.16 {d16, d17}, [r0:128] -@ CHECK: vst1.32 {d16, d17}, [r0] @ encoding: [0x8f,0x0a,0x40,0xf9] +@ CHECK: vst1.32 {d16, d17}, [r0] @ encoding: [0x40,0xf9,0x8f,0x0a] vst1.32 {d16, d17}, [r0] -@ CHECK: vst1.64 {d16, d17}, [r0] @ encoding: [0xcf,0x0a,0x40,0xf9] +@ CHECK: vst1.64 {d16, d17}, [r0] @ encoding: [0x40,0xf9,0xcf,0x0a] vst1.64 {d16, d17}, [r0] -@ CHECK: vst2.8 {d16, d17}, [r0:64] @ encoding: [0x1f,0x08,0x40,0xf9] +@ CHECK: vst2.8 {d16, d17}, [r0:64] @ encoding: [0x40,0xf9,0x1f,0x08] vst2.8 {d16, d17}, [r0:64] -@ CHECK: vst2.16 {d16, d17}, [r0:128] @ encoding: [0x6f,0x08,0x40,0xf9] +@ CHECK: vst2.16 {d16, d17}, [r0:128] @ encoding: [0x40,0xf9,0x6f,0x08] vst2.16 {d16, d17}, [r0:128] -@ CHECK: vst2.32 {d16, d17}, [r0] @ encoding: [0x8f,0x08,0x40,0xf9] +@ CHECK: vst2.32 {d16, d17}, [r0] @ encoding: [0x40,0xf9,0x8f,0x08] vst2.32 {d16, d17}, [r0] -@ CHECK: vst2.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x1f,0x03,0x40,0xf9] +@ CHECK: vst2.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x40,0xf9,0x1f,0x03] vst2.8 {d16, d17, d18, d19}, [r0:64] -@ CHECK: vst2.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x6f,0x03,0x40,0xf9] +@ CHECK: vst2.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x40,0xf9,0x6f,0x03] vst2.16 {d16, d17, d18, d19}, [r0:128] -@ CHECK: vst2.32 {d16, d17, d18, d19}, [r0:256] @ encoding: [0xbf,0x03,0x40,0xf9] +@ CHECK: vst2.32 {d16, d17, d18, d19}, [r0:256] @ encoding: [0x40,0xf9,0xbf,0x03] vst2.32 {d16, d17, d18, d19}, [r0:256] -@ CHECK: vst3.8 {d16, d17, d18}, [r0:64] @ encoding: [0x1f,0x04,0x40,0xf9] +@ CHECK: vst3.8 {d16, d17, d18}, [r0:64] @ encoding: [0x40,0xf9,0x1f,0x04] vst3.8 {d16, d17, d18}, [r0:64] -@ CHECK: vst3.16 {d16, d17, d18}, [r0] @ encoding: [0x4f,0x04,0x40,0xf9] +@ CHECK: vst3.16 {d16, d17, d18}, [r0] @ encoding: [0x40,0xf9,0x4f,0x04] vst3.16 {d16, d17, d18}, [r0] -@ CHECK: vst3.32 {d16, d17, d18}, [r0] @ encoding: [0x8f,0x04,0x40,0xf9] +@ CHECK: vst3.32 {d16, d17, d18}, [r0] @ encoding: [0x40,0xf9,0x8f,0x04] vst3.32 {d16, d17, d18}, [r0] -@ CHECK: vst3.8 {d16, d18, d20}, [r0:64]! @ encoding: [0x1d,0x05,0x40,0xf9] +@ CHECK: vst3.8 {d16, d18, d20}, [r0:64]! @ encoding: [0x40,0xf9,0x1d,0x05] vst3.8 {d16, d18, d20}, [r0:64]! -@ CHECK: vst3.8 {d17, d19, d21}, [r0:64]! @ encoding: [0x1d,0x15,0x40,0xf9] +@ CHECK: vst3.8 {d17, d19, d21}, [r0:64]! @ encoding: [0x40,0xf9,0x1d,0x15] vst3.8 {d17, d19, d21}, [r0:64]! -@ CHECK: vst3.16 {d16, d18, d20}, [r0]! @ encoding: [0x4d,0x05,0x40,0xf9] +@ CHECK: vst3.16 {d16, d18, d20}, [r0]! @ encoding: [0x40,0xf9,0x4d,0x05] vst3.16 {d16, d18, d20}, [r0]! -@ CHECK: vst3.16 {d17, d19, d21}, [r0]! @ encoding: [0x4d,0x15,0x40,0xf9] +@ CHECK: vst3.16 {d17, d19, d21}, [r0]! @ encoding: [0x40,0xf9,0x4d,0x15] vst3.16 {d17, d19, d21}, [r0]! -@ CHECK: vst3.32 {d16, d18, d20}, [r0]! @ encoding: [0x8d,0x05,0x40,0xf9] +@ CHECK: vst3.32 {d16, d18, d20}, [r0]! @ encoding: [0x40,0xf9,0x8d,0x05] vst3.32 {d16, d18, d20}, [r0]! -@ CHECK: vst3.32 {d17, d19, d21}, [r0]! @ encoding: [0x8d,0x15,0x40,0xf9] +@ CHECK: vst3.32 {d17, d19, d21}, [r0]! @ encoding: [0x40,0xf9,0x8d,0x15] vst3.32 {d17, d19, d21}, [r0]! -@ CHECK: vst4.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x1f,0x00,0x40,0xf9] +@ CHECK: vst4.8 {d16, d17, d18, d19}, [r0:64] @ encoding: [0x40,0xf9,0x1f,0x00] vst4.8 {d16, d17, d18, d19}, [r0:64] -@ CHECK: vst4.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x6f,0x00,0x40,0xf9] +@ CHECK: vst4.16 {d16, d17, d18, d19}, [r0:128] @ encoding: [0x40,0xf9,0x6f,0x00] vst4.16 {d16, d17, d18, d19}, [r0:128] -@ CHECK: vst4.8 {d16, d18, d20, d22}, [r0:256]! @ encoding: [0x3d,0x01,0x40,0xf9] +@ CHECK: vst4.8 {d16, d18, d20, d22}, [r0:256]! @ encoding: [0x40,0xf9,0x3d,0x01] vst4.8 {d16, d18, d20, d22}, [r0:256]! -@ CHECK: vst4.8 {d17, d19, d21, d23}, [r0:256]! @ encoding: [0x3d,0x11,0x40,0xf9] +@ CHECK: vst4.8 {d17, d19, d21, d23}, [r0:256]! @ encoding: [0x40,0xf9,0x3d,0x11] vst4.8 {d17, d19, d21, d23}, [r0:256]! -@ CHECK: vst4.16 {d16, d18, d20, d22}, [r0]! @ encoding: [0x4d,0x01,0x40,0xf9] +@ CHECK: vst4.16 {d16, d18, d20, d22}, [r0]! @ encoding: [0x40,0xf9,0x4d,0x01] vst4.16 {d16, d18, d20, d22}, [r0]! -@ CHECK: vst4.16 {d17, d19, d21, d23}, [r0]! @ encoding: [0x4d,0x11,0x40,0xf9] +@ CHECK: vst4.16 {d17, d19, d21, d23}, [r0]! @ encoding: [0x40,0xf9,0x4d,0x11] vst4.16 {d17, d19, d21, d23}, [r0]! -@ CHECK: vst4.32 {d16, d18, d20, d22}, [r0]! @ encoding: [0x8d,0x01,0x40,0xf9] +@ CHECK: vst4.32 {d16, d18, d20, d22}, [r0]! @ encoding: [0x40,0xf9,0x8d,0x01] vst4.32 {d16, d18, d20, d22}, [r0]! -@ CHECK: vst4.32 {d17, d19, d21, d23}, [r0]! @ encoding: [0x8d,0x11,0x40,0xf9] +@ CHECK: vst4.32 {d17, d19, d21, d23}, [r0]! @ encoding: [0x40,0xf9,0x8d,0x11] vst4.32 {d17, d19, d21, d23}, [r0]! -@ CHECK: vst2.8 {d16[1], d17[1]}, [r0:16] @ encoding: [0x3f,0x01,0xc0,0xf9] +@ CHECK: vst2.8 {d16[1], d17[1]}, [r0:16] @ encoding: [0xc0,0xf9,0x3f,0x01] vst2.8 {d16[1], d17[1]}, [r0:16] -@ CHECK: vst2.16 {d16[1], d17[1]}, [r0:32] @ encoding: [0x5f,0x05,0xc0,0xf9] +@ CHECK: vst2.16 {d16[1], d17[1]}, [r0:32] @ encoding: [0xc0,0xf9,0x5f,0x05] vst2.16 {d16[1], d17[1]}, [r0:32] -@ CHECK: vst2.32 {d16[1], d17[1]}, [r0] @ encoding: [0x8f,0x09,0xc0,0xf9] +@ CHECK: vst2.32 {d16[1], d17[1]}, [r0] @ encoding: [0xc0,0xf9,0x8f,0x09] vst2.32 {d16[1], d17[1]}, [r0] -@ CHECK: vst2.16 {d17[1], d19[1]}, [r0] @ encoding: [0x6f,0x15,0xc0,0xf9] +@ CHECK: vst2.16 {d17[1], d19[1]}, [r0] @ encoding: [0xc0,0xf9,0x6f,0x15] vst2.16 {d17[1], d19[1]}, [r0] -@ CHECK: vst2.32 {d17[0], d19[0]}, [r0:64] @ encoding: [0x5f,0x19,0xc0,0xf9] +@ CHECK: vst2.32 {d17[0], d19[0]}, [r0:64] @ encoding: [0xc0,0xf9,0x5f,0x19] vst2.32 {d17[0], d19[0]}, [r0:64] -@ CHECK: vst3.8 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x2f,0x02,0xc0,0xf9] +@ CHECK: vst3.8 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0xc0,0xf9,0x2f,0x02] vst3.8 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vst3.16 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x4f,0x06,0xc0,0xf9] +@ CHECK: vst3.16 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0xc0,0xf9,0x4f,0x06] vst3.16 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vst3.32 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x8f,0x0a,0xc0,0xf9] +@ CHECK: vst3.32 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0xc0,0xf9,0x8f,0x0a] vst3.32 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vst3.16 {d17[2], d19[2], d21[2]}, [r0] @ encoding: [0xaf,0x16,0xc0,0xf9] +@ CHECK: vst3.16 {d17[2], d19[2], d21[2]}, [r0] @ encoding: [0xc0,0xf9,0xaf,0x16] vst3.16 {d17[2], d19[2], d21[2]}, [r0] -@ CHECK: vst3.32 {d16[0], d18[0], d20[0]}, [r0] @ encoding: [0x4f,0x0a,0xc0,0xf9] +@ CHECK: vst3.32 {d16[0], d18[0], d20[0]}, [r0] @ encoding: [0xc0,0xf9,0x4f,0x0a] vst3.32 {d16[0], d18[0], d20[0]}, [r0] -@ CHECK: vst4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0:32] @ encoding: [0x3f,0x03,0xc0,0xf9] +@ CHECK: vst4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0:32] @ encoding: [0xc0,0xf9,0x3f,0x03] vst4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0:32] -@ CHECK: vst4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] @ encoding: [0x4f,0x07,0xc0,0xf9] +@ CHECK: vst4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] @ encoding: [0xc0,0xf9,0x4f,0x07] vst4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] -@ CHECK: vst4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0:128] @ encoding: [0xaf,0x0b,0xc0,0xf9] +@ CHECK: vst4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0:128] @ encoding: [0xc0,0xf9,0xaf,0x0b] vst4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0:128] -@ CHECK: vst4.16 {d17[3], d19[3], d21[3], d23[3]}, [r0:64] @ encoding: [0xff,0x17,0xc0,0xf9] +@ CHECK: vst4.16 {d17[3], d19[3], d21[3], d23[3]}, [r0:64] @ encoding: [0xc0,0xf9,0xff,0x17] vst4.16 {d17[3], d19[3], d21[3], d23[3]}, [r0:64] -@ CHECK: vst4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ encoding: [0x4f,0x1b,0xc0,0xf9] +@ CHECK: vst4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ encoding: [0xc0,0xf9,0x4f,0x1b] vst4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ rdar://11082188 -- GitLab From 0f0234e16ece8610248ce0a7113f7bb75853ed58 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 8 May 2013 10:00:18 +0000 Subject: [PATCH 004/467] Change indentation of multi-line nested name specifiers. Before: aaaaaaaa:: aaaaaaaa:: aaaaaaaa(); After: aaaaaaaa:: aaaaaaaa:: aaaaaaaa(); The reason for the change is that: a) we are not sure which is better b) it is a really rare edge case c) it simplifies the code d) it currently causes problems with memoization llvm-svn: 181421 --- clang/lib/Format/Format.cpp | 15 +++------------ clang/unittests/Format/FormatTest.cpp | 4 ++-- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 4c7c405e81e8..814017a51272 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -338,10 +338,6 @@ private: return ColonPos < Other.ColonPos; if (StartOfFunctionCall != Other.StartOfFunctionCall) return StartOfFunctionCall < Other.StartOfFunctionCall; - if (NestedNameSpecifierContinuation != - Other.NestedNameSpecifierContinuation) - return NestedNameSpecifierContinuation < - Other.NestedNameSpecifierContinuation; if (CallContinuation != Other.CallContinuation) return CallContinuation < Other.CallContinuation; if (VariablePos != Other.VariablePos) @@ -432,13 +428,6 @@ private: } else if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess != 0) { State.Column = State.Stack.back().FirstLessLess; - } else if (Previous.is(tok::coloncolon)) { - if (State.Stack.back().NestedNameSpecifierContinuation == 0) { - State.Column = ContinuationIndent; - State.Stack.back().NestedNameSpecifierContinuation = State.Column; - } else { - State.Column = State.Stack.back().NestedNameSpecifierContinuation; - } } else if (Current.isOneOf(tok::period, tok::arrow)) { if (State.Stack.back().CallContinuation == 0) { State.Column = ContinuationIndent; @@ -464,7 +453,8 @@ private: State.Stack.back().ColonPos = State.Column + Current.FormatTok.TokenLength; } - } else if (Current.Type == TT_StartOfName || Previous.is(tok::equal) || + } else if (Current.Type == TT_StartOfName || + Previous.isOneOf(tok::coloncolon, tok::equal) || Previous.Type == TT_ObjCMethodExpr) { State.Column = ContinuationIndent; } else { @@ -854,6 +844,7 @@ private: // Reconstruct the solution. reconstructPath(InitialState, Queue.top().second); + DEBUG(llvm::errs() << "Total number of analyzed states: " << Count << "\n"); DEBUG(llvm::errs() << "---\n"); // Return the column after the last token of the solution. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 92435fe0fe40..2a11f80eaa59 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2338,11 +2338,11 @@ TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa());"); - // FIXME: Should we have an extra indent after the second break? + // FIXME: Should we have the extra indent after the second break? verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); // FIXME: Look into whether we should indent 4 from the start or 4 from // "bbbbb..." here instead of what we are doing now. -- GitLab From 5829a98c48cf9009e4887e89e3075b3058909e8e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 8 May 2013 10:39:05 +0000 Subject: [PATCH 005/467] [nolibc] Disable the GCC stack protector when building sanitizer runtimes. This is the first in a sequence of changes designed to eliminate the libc dependency in sanitizer_common. The main motivation for these changes is to be able to provide an alternative for the current interceptor-based technique for instrumenting functions in libc. In this new technique, we compile libc with instrumentation. This has the potential advantages of being more accurate than interception and reducing the amount of custom code required for each libc function. As a side effect of this, we cannot depend on libc in the sanitizer runtime due to mutual dependency issues. This change disables the GCC stack protector, which introduces a libc dependency and is enabled by default in Ubuntu. Differential Revision: http://llvm-reviews.chandlerc.com/D755 llvm-svn: 181422 --- compiler-rt/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 9deb608a5b00..f94af32cebfb 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -126,6 +126,7 @@ set(SANITIZER_COMMON_CFLAGS -fno-exceptions -fomit-frame-pointer -funwind-tables + -fno-stack-protector -O3 ) if(NOT WIN32) -- GitLab From 08e53ee551a41bb0d96b4c78d906fc79df3050cd Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Wed, 8 May 2013 12:16:14 +0000 Subject: [PATCH 006/467] PPCInstrInfo::optimizeCompareInstr should not optimize FP compares The floating-point record forms on PPC don't set the condition register bits based on a comparison with zero (like the integer record forms do), but rather based on the exception status bits. llvm-svn: 181423 --- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | 29 +++++++++--------------- llvm/test/CodeGen/PowerPC/optcmp.ll | 4 ++-- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp index e6dac83e849c..d94acde101e8 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -1096,8 +1096,11 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr, int OpC = CmpInstr->getOpcode(); unsigned CRReg = CmpInstr->getOperand(0).getReg(); - bool isFP = OpC == PPC::FCMPUS || OpC == PPC::FCMPUD; - unsigned CRRecReg = isFP ? PPC::CR1 : PPC::CR0; + + // FP record forms set CR1 based on the execption status bits, not a + // comparison with zero. + if (OpC == PPC::FCMPUS || OpC == PPC::FCMPUD) + return false; // The record forms set the condition register based on a signed comparison // with zero (so says the ISA manual). This is not as straightforward as it @@ -1140,9 +1143,9 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr, equalityOnly = true; } else return false; - } else if (!isFP) + } else equalityOnly = is64BitUnsignedCompare; - } else if (!isFP) + } else equalityOnly = is32BitUnsignedCompare; if (equalityOnly) { @@ -1211,8 +1214,8 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr, unsigned IOpC = Instr.getOpcode(); if (&*I != CmpInstr && ( - Instr.modifiesRegister(CRRecReg, TRI) || - Instr.readsRegister(CRRecReg, TRI))) + Instr.modifiesRegister(PPC::CR0, TRI) || + Instr.readsRegister(PPC::CR0, TRI))) // This instruction modifies or uses the record condition register after // the one we want to change. While we could do this transformation, it // would likely not be profitable. This transformation removes one @@ -1232,15 +1235,6 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr, break; } - if (isFP && (IOpC == PPC::FSUB || IOpC == PPC::FSUBS) && - ((Instr.getOperand(1).getReg() == SrcReg && - Instr.getOperand(2).getReg() == SrcReg2) || - (Instr.getOperand(1).getReg() == SrcReg2 && - Instr.getOperand(2).getReg() == SrcReg))) { - Sub = &*I; - break; - } - if (I == B) // The 'and' is below the comparison instruction. return false; @@ -1286,8 +1280,7 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr, // The operands to subf are the opposite of sub, so only in the fixed-point // case, invert the order. - if (!isFP) - ShouldSwap = !ShouldSwap; + ShouldSwap = !ShouldSwap; } if (ShouldSwap) @@ -1326,7 +1319,7 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr, MachineBasicBlock::iterator MII = MI; BuildMI(*MI->getParent(), llvm::next(MII), MI->getDebugLoc(), get(TargetOpcode::COPY), CRReg) - .addReg(CRRecReg, MIOpC != NewOpC ? RegState::Kill : 0); + .addReg(PPC::CR0, MIOpC != NewOpC ? RegState::Kill : 0); if (MIOpC != NewOpC) { // We need to be careful here: we're replacing one instruction with diff --git a/llvm/test/CodeGen/PowerPC/optcmp.ll b/llvm/test/CodeGen/PowerPC/optcmp.ll index 1fce464dd335..523f329303bf 100644 --- a/llvm/test/CodeGen/PowerPC/optcmp.ll +++ b/llvm/test/CodeGen/PowerPC/optcmp.ll @@ -118,7 +118,7 @@ entry: ret double %cond ; CHECK: @food -; CHECK: fsub. 0, 1, 2 +; CHECK-NOT: fsub. 0, 1, 2 ; CHECK: stfd 0, 0(5) } @@ -131,7 +131,7 @@ entry: ret float %cond ; CHECK: @foof -; CHECK: fsubs. 0, 1, 2 +; CHECK-NOT: fsubs. 0, 1, 2 ; CHECK: stfs 0, 0(5) } -- GitLab From af179b8d637e0c36d308a1a67aa1d54eb80ed6dc Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 8 May 2013 12:45:55 +0000 Subject: [PATCH 007/467] [sanitizer] Move GetStackTrace from ASan to sanitizer_common. llvm-svn: 181424 --- compiler-rt/lib/asan/asan_linux.cc | 18 ----------- compiler-rt/lib/asan/asan_mac.cc | 12 -------- compiler-rt/lib/asan/asan_stack.h | 20 +++++++++++-- compiler-rt/lib/asan/asan_win.cc | 24 --------------- .../lib/sanitizer_common/sanitizer_posix.cc | 23 +++++++++++++- .../sanitizer_common/sanitizer_stacktrace.h | 11 +++++++ .../lib/sanitizer_common/sanitizer_win.cc | 30 ++++++++++++++++++- 7 files changed, 79 insertions(+), 59 deletions(-) diff --git a/compiler-rt/lib/asan/asan_linux.cc b/compiler-rt/lib/asan/asan_linux.cc index 148b5f053b46..17bb4ca5f01c 100644 --- a/compiler-rt/lib/asan/asan_linux.cc +++ b/compiler-rt/lib/asan/asan_linux.cc @@ -102,24 +102,6 @@ void AsanPlatformThreadInit() { // Nothing here for now. } -void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast) { -#if defined(__arm__) || \ - defined(__powerpc__) || defined(__powerpc64__) || \ - defined(__sparc__) - fast = false; -#endif - if (!fast) - return stack->SlowUnwindStack(pc, max_s); - stack->size = 0; - stack->trace[0] = pc; - if (max_s > 1) { - stack->max_size = max_s; - if (!asan_inited) return; - if (AsanThread *t = GetCurrentThread()) - stack->FastUnwindStack(pc, bp, t->stack_top(), t->stack_bottom()); - } -} - #if !SANITIZER_ANDROID void ReadContextStack(void *context, uptr *stack, uptr *ssize) { ucontext_t *ucp = (ucontext_t*)context; diff --git a/compiler-rt/lib/asan/asan_mac.cc b/compiler-rt/lib/asan/asan_mac.cc index 63fb5f6dd31b..4313534008e7 100644 --- a/compiler-rt/lib/asan/asan_mac.cc +++ b/compiler-rt/lib/asan/asan_mac.cc @@ -229,18 +229,6 @@ bool AsanInterceptsSignal(int signum) { void AsanPlatformThreadInit() { } -void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast) { - (void)fast; - stack->size = 0; - stack->trace[0] = pc; - if ((max_s) > 1) { - stack->max_size = max_s; - if (!asan_inited) return; - if (AsanThread *t = GetCurrentThread()) - stack->FastUnwindStack(pc, bp, t->stack_top(), t->stack_bottom()); - } -} - void ReadContextStack(void *context, uptr *stack, uptr *ssize) { UNIMPLEMENTED(); } diff --git a/compiler-rt/lib/asan/asan_stack.h b/compiler-rt/lib/asan/asan_stack.h index cd30abbb4b21..176aa183c93b 100644 --- a/compiler-rt/lib/asan/asan_stack.h +++ b/compiler-rt/lib/asan/asan_stack.h @@ -15,12 +15,12 @@ #define ASAN_STACK_H #include "asan_flags.h" +#include "asan_thread.h" #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_stacktrace.h" namespace __asan { -void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast); void PrintStack(StackTrace *stack); } // namespace __asan @@ -28,10 +28,24 @@ void PrintStack(StackTrace *stack); // Get the stack trace with the given pc and bp. // The pc will be in the position 0 of the resulting stack trace. // The bp may refer to the current frame or to the caller's frame. -// fast_unwind is currently unused. +#if SANITIZER_WINDOWS #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \ StackTrace stack; \ - GetStackTrace(&stack, max_s, pc, bp, fast) + GetStackTrace(&stack, max_s, pc, bp, 0, 0, fast) +#else +#define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \ + StackTrace stack; \ + { \ + uptr stack_top = 0, stack_bottom = 0; \ + AsanThread *t; \ + if (asan_inited && (t = GetCurrentThread())) { \ + stack_top = t->stack_top(); \ + stack_bottom = t->stack_bottom(); \ + } \ + GetStackTrace(&stack, max_s, pc, bp, \ + stack_top, stack_bottom, fast); \ + } +#endif // SANITIZER_WINDOWS // NOTE: A Rule of thumb is to retrieve stack trace in the interceptors // as early as possible (in functions exposed to the user), as we generally diff --git a/compiler-rt/lib/asan/asan_win.cc b/compiler-rt/lib/asan/asan_win.cc index 49a389971c43..f74de7227ed2 100644 --- a/compiler-rt/lib/asan/asan_win.cc +++ b/compiler-rt/lib/asan/asan_win.cc @@ -32,30 +32,6 @@ static BlockingMutex dbghelp_lock(LINKER_INITIALIZED); static bool dbghelp_initialized = false; #pragma comment(lib, "dbghelp.lib") -void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast) { - (void)fast; - stack->max_size = max_s; - void *tmp[kStackTraceMax]; - - // FIXME: CaptureStackBackTrace might be too slow for us. - // FIXME: Compare with StackWalk64. - // FIXME: Look at LLVMUnhandledExceptionFilter in Signals.inc - uptr cs_ret = CaptureStackBackTrace(1, stack->max_size, tmp, 0); - uptr offset = 0; - // Skip the RTL frames by searching for the PC in the stacktrace. - // FIXME: this doesn't work well for the malloc/free stacks yet. - for (uptr i = 0; i < cs_ret; i++) { - if (pc != (uptr)tmp[i]) - continue; - offset = i; - break; - } - - stack->size = cs_ret - offset; - for (uptr i = 0; i < stack->size; i++) - stack->trace[i] = (uptr)tmp[i + offset]; -} - // ---------------------- TSD ---------------- {{{1 static bool tsd_key_inited = false; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc index 2aae414fefe9..7fec5cf4c366 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc @@ -18,6 +18,7 @@ #include "sanitizer_common.h" #include "sanitizer_libc.h" #include "sanitizer_procmaps.h" +#include "sanitizer_stacktrace.h" #include #include @@ -228,6 +229,26 @@ int internal_isatty(fd_t fd) { return isatty(fd); } +void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, + uptr stack_top, uptr stack_bottom, bool fast) { +#if !SANITIZER_CAN_FAST_UNWIND + fast = false; +#endif +#if SANITIZER_MAC + // Always unwind fast on Mac. + (void)fast; +#else + if (!fast || (stack_top == stack_bottom)) + return stack->SlowUnwindStack(pc, max_s); +#endif // SANITIZER_MAC + stack->size = 0; + stack->trace[0] = pc; + if (max_s > 1) { + stack->max_size = max_s; + stack->FastUnwindStack(pc, bp, stack_top, stack_bottom); + } +} + } // namespace __sanitizer -#endif // SANITIZER_LINUX || __APPLE_ +#endif // SANITIZER_LINUX || SANITIZER_MAC diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h index b9ea9b43592d..fcfdd7e0b59b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h @@ -19,6 +19,14 @@ namespace __sanitizer { static const uptr kStackTraceMax = 256; +#if SANITIZER_LINUX && (defined(__arm__) || \ + defined(__powerpc__) || defined(__powerpc64__) || \ + defined(__sparc__)) +#define SANITIZER_CAN_FAST_UNWIND 0 +#else +#define SANITIZER_CAN_FAST_UNWIND 1 +#endif + struct StackTrace { typedef bool (*SymbolizeCallback)(const void *pc, char *out_buffer, int out_size); @@ -61,6 +69,9 @@ struct StackTrace { const char *StripPathPrefix(const char *filepath, const char *strip_file_prefix); +void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, + uptr stack_top, uptr stack_bottom, bool fast); + } // namespace __sanitizer // Use this macro if you want to print stack trace with the caller diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc index 48874a1dc8eb..95445be65461 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc @@ -23,8 +23,9 @@ #include "sanitizer_common.h" #include "sanitizer_libc.h" -#include "sanitizer_placement_new.h" #include "sanitizer_mutex.h" +#include "sanitizer_placement_new.h" +#include "sanitizer_stacktrace.h" namespace __sanitizer { @@ -346,6 +347,33 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size, *tls_size = 0; } +void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, + uptr stack_top, uptr stack_bottom, bool fast) { + (void)fast; + (void)stack_top; + (void)stack_bottom; + stack->max_size = max_s; + void *tmp[kStackTraceMax]; + + // FIXME: CaptureStackBackTrace might be too slow for us. + // FIXME: Compare with StackWalk64. + // FIXME: Look at LLVMUnhandledExceptionFilter in Signals.inc + uptr cs_ret = CaptureStackBackTrace(1, stack->max_size, tmp, 0); + uptr offset = 0; + // Skip the RTL frames by searching for the PC in the stacktrace. + // FIXME: this doesn't work well for the malloc/free stacks yet. + for (uptr i = 0; i < cs_ret; i++) { + if (pc != (uptr)tmp[i]) + continue; + offset = i; + break; + } + + stack->size = cs_ret - offset; + for (uptr i = 0; i < stack->size; i++) + stack->trace[i] = (uptr)tmp[i + offset]; +} + } // namespace __sanitizer #endif // _WIN32 -- GitLab From 7bbd7aa7fe63f9df9e4d30355180cfcf0785973c Mon Sep 17 00:00:00 2001 From: Michel Danzer Date: Wed, 8 May 2013 13:07:29 +0000 Subject: [PATCH 008/467] R600/SI: Add lit tests for llvm.SI.imageload and llvm.SI.resinfo intrinsics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adapted from the llvm.SI.sample test. Reviewed-by: Christian König llvm-svn: 181425 --- llvm/test/CodeGen/R600/llvm.SI.imageload.ll | 87 ++++++++++++++++ llvm/test/CodeGen/R600/llvm.SI.resinfo.ll | 110 ++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 llvm/test/CodeGen/R600/llvm.SI.imageload.ll create mode 100644 llvm/test/CodeGen/R600/llvm.SI.resinfo.ll diff --git a/llvm/test/CodeGen/R600/llvm.SI.imageload.ll b/llvm/test/CodeGen/R600/llvm.SI.imageload.ll new file mode 100644 index 000000000000..6b321f036222 --- /dev/null +++ b/llvm/test/CodeGen/R600/llvm.SI.imageload.ll @@ -0,0 +1,87 @@ +;RUN: llc < %s -march=r600 -mcpu=verde | FileCheck %s + +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 15, 0, 0, -1 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+_VGPR[0-9]+}}, 3, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+}}, 2, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+}}, 1, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+}}, 4, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+}}, 8, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+_VGPR[0-9]+}}, 5, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+_VGPR[0-9]+}}, 12, 0, 0, -1 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 7, 0, 0, 0 +;CHECK: IMAGE_LOAD_MIP {{VGPR[0-9]+}}, 8, 0, 0, -1 + +define void @test(i32 %a1, i32 %a2, i32 %a3, i32 %a4) { + %v1 = insertelement <4 x i32> undef, i32 %a1, i32 0 + %v2 = insertelement <4 x i32> undef, i32 %a1, i32 1 + %v3 = insertelement <4 x i32> undef, i32 %a1, i32 2 + %v4 = insertelement <4 x i32> undef, i32 %a1, i32 3 + %v5 = insertelement <4 x i32> undef, i32 %a2, i32 0 + %v6 = insertelement <4 x i32> undef, i32 %a2, i32 1 + %v10 = insertelement <4 x i32> undef, i32 %a3, i32 1 + %v11 = insertelement <4 x i32> undef, i32 %a3, i32 2 + %v15 = insertelement <4 x i32> undef, i32 %a4, i32 2 + %v16 = insertelement <4 x i32> undef, i32 %a4, i32 3 + %res1 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v1, + <8 x i32> undef, i32 1) + %res2 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v2, + <8 x i32> undef, i32 2) + %res3 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v3, + <8 x i32> undef, i32 3) + %res4 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v4, + <8 x i32> undef, i32 4) + %res5 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v5, + <8 x i32> undef, i32 5) + %res6 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v6, + <8 x i32> undef, i32 6) + %res10 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v10, + <8 x i32> undef, i32 10) + %res11 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v11, + <8 x i32> undef, i32 11) + %res15 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v15, + <8 x i32> undef, i32 15) + %res16 = call <4 x i32> @llvm.SI.imageload.(<4 x i32> %v16, + <8 x i32> undef, i32 16) + %e1 = extractelement <4 x i32> %res1, i32 0 + %e2 = extractelement <4 x i32> %res2, i32 1 + %e3 = extractelement <4 x i32> %res3, i32 2 + %e4 = extractelement <4 x i32> %res4, i32 3 + %t0 = extractelement <4 x i32> %res5, i32 0 + %t1 = extractelement <4 x i32> %res5, i32 1 + %e5 = add i32 %t0, %t1 + %t2 = extractelement <4 x i32> %res6, i32 0 + %t3 = extractelement <4 x i32> %res6, i32 2 + %e6 = add i32 %t2, %t3 + %t10 = extractelement <4 x i32> %res10, i32 2 + %t11 = extractelement <4 x i32> %res10, i32 3 + %e10 = add i32 %t10, %t11 + %t12 = extractelement <4 x i32> %res11, i32 0 + %t13 = extractelement <4 x i32> %res11, i32 1 + %t14 = extractelement <4 x i32> %res11, i32 2 + %t15 = add i32 %t12, %t13 + %e11 = add i32 %t14, %t15 + %t28 = extractelement <4 x i32> %res15, i32 0 + %t29 = extractelement <4 x i32> %res15, i32 1 + %t30 = extractelement <4 x i32> %res15, i32 2 + %t31 = extractelement <4 x i32> %res15, i32 3 + %t32 = add i32 %t28, %t29 + %t33 = add i32 %t30, %t31 + %e15 = add i32 %t32, %t33 + %e16 = extractelement <4 x i32> %res16, i32 3 + %s1 = add i32 %e1, %e2 + %s2 = add i32 %s1, %e3 + %s3 = add i32 %s2, %e4 + %s4 = add i32 %s3, %e5 + %s5 = add i32 %s4, %e6 + %s9 = add i32 %s5, %e10 + %s10 = add i32 %s9, %e11 + %s14 = add i32 %s10, %e15 + %s15 = add i32 %s14, %e16 + %s16 = bitcast i32 %s15 to float + call void @llvm.SI.export(i32 15, i32 0, i32 1, i32 12, i32 0, float %s16, float %s16, float %s16, float %s16) + ret void +} + +declare <4 x i32> @llvm.SI.imageload.(<4 x i32>, <8 x i32>, i32) readnone + +declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float) diff --git a/llvm/test/CodeGen/R600/llvm.SI.resinfo.ll b/llvm/test/CodeGen/R600/llvm.SI.resinfo.ll new file mode 100644 index 000000000000..eb315149cb29 --- /dev/null +++ b/llvm/test/CodeGen/R600/llvm.SI.resinfo.ll @@ -0,0 +1,110 @@ +;RUN: llc < %s -march=r600 -mcpu=verde | FileCheck %s + +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 15, 0, 0, -1 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+}}, 3, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+}}, 2, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+}}, 1, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+}}, 4, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+}}, 8, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+}}, 5, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+}}, 9, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+}}, 6, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+}}, 10, 0, 0, -1 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+}}, 12, 0, 0, -1 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 7, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 11, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 13, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+_VGPR[0-9]+_VGPR[0-9]+}}, 14, 0, 0, 0 +;CHECK: IMAGE_GET_RESINFO {{VGPR[0-9]+}}, 8, 0, 0, -1 + +define void @test(i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8, + i32 %a9, i32 %a10, i32 %a11, i32 %a12, i32 %a13, i32 %a14, i32 %a15, i32 %a16) { + %res1 = call <4 x i32> @llvm.SI.resinfo(i32 %a1, <8 x i32> undef, i32 1) + %res2 = call <4 x i32> @llvm.SI.resinfo(i32 %a2, <8 x i32> undef, i32 2) + %res3 = call <4 x i32> @llvm.SI.resinfo(i32 %a3, <8 x i32> undef, i32 3) + %res4 = call <4 x i32> @llvm.SI.resinfo(i32 %a4, <8 x i32> undef, i32 4) + %res5 = call <4 x i32> @llvm.SI.resinfo(i32 %a5, <8 x i32> undef, i32 5) + %res6 = call <4 x i32> @llvm.SI.resinfo(i32 %a6, <8 x i32> undef, i32 6) + %res7 = call <4 x i32> @llvm.SI.resinfo(i32 %a7, <8 x i32> undef, i32 7) + %res8 = call <4 x i32> @llvm.SI.resinfo(i32 %a8, <8 x i32> undef, i32 8) + %res9 = call <4 x i32> @llvm.SI.resinfo(i32 %a9, <8 x i32> undef, i32 9) + %res10 = call <4 x i32> @llvm.SI.resinfo(i32 %a10, <8 x i32> undef, i32 10) + %res11 = call <4 x i32> @llvm.SI.resinfo(i32 %a11, <8 x i32> undef, i32 11) + %res12 = call <4 x i32> @llvm.SI.resinfo(i32 %a12, <8 x i32> undef, i32 12) + %res13 = call <4 x i32> @llvm.SI.resinfo(i32 %a13, <8 x i32> undef, i32 13) + %res14 = call <4 x i32> @llvm.SI.resinfo(i32 %a14, <8 x i32> undef, i32 14) + %res15 = call <4 x i32> @llvm.SI.resinfo(i32 %a15, <8 x i32> undef, i32 15) + %res16 = call <4 x i32> @llvm.SI.resinfo(i32 %a16, <8 x i32> undef, i32 16) + %e1 = extractelement <4 x i32> %res1, i32 0 + %e2 = extractelement <4 x i32> %res2, i32 1 + %e3 = extractelement <4 x i32> %res3, i32 2 + %e4 = extractelement <4 x i32> %res4, i32 3 + %t0 = extractelement <4 x i32> %res5, i32 0 + %t1 = extractelement <4 x i32> %res5, i32 1 + %e5 = add i32 %t0, %t1 + %t2 = extractelement <4 x i32> %res6, i32 0 + %t3 = extractelement <4 x i32> %res6, i32 2 + %e6 = add i32 %t2, %t3 + %t4 = extractelement <4 x i32> %res7, i32 0 + %t5 = extractelement <4 x i32> %res7, i32 3 + %e7 = add i32 %t4, %t5 + %t6 = extractelement <4 x i32> %res8, i32 1 + %t7 = extractelement <4 x i32> %res8, i32 2 + %e8 = add i32 %t6, %t7 + %t8 = extractelement <4 x i32> %res9, i32 1 + %t9 = extractelement <4 x i32> %res9, i32 3 + %e9 = add i32 %t8, %t9 + %t10 = extractelement <4 x i32> %res10, i32 2 + %t11 = extractelement <4 x i32> %res10, i32 3 + %e10 = add i32 %t10, %t11 + %t12 = extractelement <4 x i32> %res11, i32 0 + %t13 = extractelement <4 x i32> %res11, i32 1 + %t14 = extractelement <4 x i32> %res11, i32 2 + %t15 = add i32 %t12, %t13 + %e11 = add i32 %t14, %t15 + %t16 = extractelement <4 x i32> %res12, i32 0 + %t17 = extractelement <4 x i32> %res12, i32 1 + %t18 = extractelement <4 x i32> %res12, i32 3 + %t19 = add i32 %t16, %t17 + %e12 = add i32 %t18, %t19 + %t20 = extractelement <4 x i32> %res13, i32 0 + %t21 = extractelement <4 x i32> %res13, i32 2 + %t22 = extractelement <4 x i32> %res13, i32 3 + %t23 = add i32 %t20, %t21 + %e13 = add i32 %t22, %t23 + %t24 = extractelement <4 x i32> %res14, i32 1 + %t25 = extractelement <4 x i32> %res14, i32 2 + %t26 = extractelement <4 x i32> %res14, i32 3 + %t27 = add i32 %t24, %t25 + %e14 = add i32 %t26, %t27 + %t28 = extractelement <4 x i32> %res15, i32 0 + %t29 = extractelement <4 x i32> %res15, i32 1 + %t30 = extractelement <4 x i32> %res15, i32 2 + %t31 = extractelement <4 x i32> %res15, i32 3 + %t32 = add i32 %t28, %t29 + %t33 = add i32 %t30, %t31 + %e15 = add i32 %t32, %t33 + %e16 = extractelement <4 x i32> %res16, i32 3 + %s1 = add i32 %e1, %e2 + %s2 = add i32 %s1, %e3 + %s3 = add i32 %s2, %e4 + %s4 = add i32 %s3, %e5 + %s5 = add i32 %s4, %e6 + %s6 = add i32 %s5, %e7 + %s7 = add i32 %s6, %e8 + %s8 = add i32 %s7, %e9 + %s9 = add i32 %s8, %e10 + %s10 = add i32 %s9, %e11 + %s11 = add i32 %s10, %e12 + %s12 = add i32 %s11, %e13 + %s13 = add i32 %s12, %e14 + %s14 = add i32 %s13, %e15 + %s15 = add i32 %s14, %e16 + %s16 = bitcast i32 %s15 to float + call void @llvm.SI.export(i32 15, i32 0, i32 1, i32 12, i32 0, float %s16, float %s16, float %s16, float %s16) + ret void +} + +declare <4 x i32> @llvm.SI.resinfo(i32, <8 x i32>, i32) readnone + +declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float) -- GitLab From e43f0fea153bd67e39f085d92d9e12ada915bb99 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 8 May 2013 13:44:39 +0000 Subject: [PATCH 009/467] Forward #pragma comment(lib/linker) through as flags metadata Summary: Most of this change is wiring the pragma all the way through from the lexer, parser, and sema to codegen. I considered adding a Decl AST node for this, but it seemed too heavyweight. Mach-O already uses a metadata flag called "Linker Options" to do this kind of auto-linking. This change follows that pattern. LLVM knows how to forward the "Linker Options" metadata into the COFF .drectve section where these flags belong. ELF support is not implemented, but possible. This is related to auto-linking, which is http://llvm.org/PR13016. CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D723 llvm-svn: 181426 --- clang/include/clang/AST/ASTConsumer.h | 11 +++++++ clang/include/clang/Parse/Parser.h | 4 +++ clang/include/clang/Sema/Sema.h | 13 ++++++++ clang/lib/CodeGen/CodeGenAction.cpp | 8 +++++ clang/lib/CodeGen/CodeGenModule.cpp | 45 ++++++++++++++++++--------- clang/lib/CodeGen/CodeGenModule.h | 9 ++++++ clang/lib/CodeGen/ModuleBuilder.cpp | 9 ++++++ clang/lib/CodeGen/TargetInfo.cpp | 32 +++++++++++++++++-- clang/lib/CodeGen/TargetInfo.h | 6 ++++ clang/lib/Parse/ParsePragma.cpp | 23 +++++++++----- clang/lib/Parse/ParsePragma.h | 5 ++- clang/lib/Parse/Parser.cpp | 2 +- clang/lib/Sema/SemaAttr.cpp | 21 +++++++++++++ clang/test/Modules/autolink.m | 2 +- 14 files changed, 163 insertions(+), 27 deletions(-) diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index ae779436a9da..33e9bd92a476 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -14,6 +14,8 @@ #ifndef LLVM_CLANG_AST_ASTCONSUMER_H #define LLVM_CLANG_AST_ASTCONSUMER_H +#include "llvm/ADT/StringRef.h" + namespace clang { class ASTContext; class CXXRecordDecl; @@ -86,6 +88,15 @@ public: /// The default implementation passes it to HandleTopLevelDecl. virtual void HandleImplicitImportDecl(ImportDecl *D); + /// \brief Handle a pragma that appends to Linker Options. Currently this + /// only exists to support Microsoft's #pragma comment(linker, "/foo"). + virtual void HandleLinkerOptionPragma(llvm::StringRef Opts) {} + + /// \brief Handle a dependent library created by a pragma in the source. + /// Currently this only exists to support Microsoft's + /// #pragma comment(lib, "/foo"). + virtual void HandleDependentLibrary(llvm::StringRef Lib) {} + /// CompleteTentativeDefinition - Callback invoked at the end of a translation /// unit to notify the consumer that the given tentative definition should be /// completed. diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 1029a90c55c8..72acacf5ae61 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -418,6 +418,10 @@ private: /// #pragma ms_struct... void HandlePragmaMSStruct(); + /// \brief Handle the annotation token produced for + /// #pragma comment... + void HandlePragmaMSComment(); + /// \brief Handle the annotation token produced for /// #pragma align... void HandlePragmaAlign(); diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d7c80f2e4f91..f75ac93a908f 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -49,6 +49,7 @@ #include "llvm/MC/MCParser/MCAsmParser.h" #include #include +#include namespace llvm { class APSInt; @@ -6584,6 +6585,15 @@ public: PMSST_ON // #pragms ms_struct on }; + enum PragmaMSCommentKind { + PCK_Unknown, + PCK_Linker, // #pragma comment(linker, ...) + PCK_Lib, // #pragma comment(lib, ...) + PCK_Compiler, // #pragma comment(compiler, ...) + PCK_ExeStr, // #pragma comment(exestr, ...) + PCK_User // #pragma comment(user, ...) + }; + /// ActOnPragmaPack - Called on well formed \#pragma pack(...). void ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name, @@ -6595,6 +6605,9 @@ public: /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off]. void ActOnPragmaMSStruct(PragmaMSStructKind Kind); + /// ActOnPragmaMSStruct - Called on well formed \#pragma comment(kind, "arg"). + void ActOnPragmaMSComment(PragmaMSCommentKind Kind, StringRef Arg); + /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'. void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 679cfeb6ed3c..9570076574cb 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -179,6 +179,14 @@ namespace clang { Gen->HandleVTable(RD, DefinitionRequired); } + virtual void HandleLinkerOptionPragma(llvm::StringRef Opts) { + Gen->HandleLinkerOptionPragma(Opts); + } + + virtual void HandleDependentLibrary(llvm::StringRef Opts) { + Gen->HandleDependentLibrary(Opts); + } + static void InlineAsmDiagHandler(const llvm::SMDiagnostic &SM,void *Context, unsigned LocCookie) { SourceLocation Loc = SourceLocation::getFromRawEncoding(LocCookie); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 0b03a3c4b67d..1da4e87c0a52 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -186,7 +186,8 @@ void CodeGenModule::Release() { EmitStaticExternCAliases(); EmitLLVMUsed(); - if (CodeGenOpts.Autolink && Context.getLangOpts().Modules) { + if (CodeGenOpts.Autolink && + (Context.getLangOpts().Modules || !LinkerOptionsMetadata.empty())) { EmitModuleLinkOptions(); } @@ -762,31 +763,41 @@ void CodeGenModule::EmitLLVMUsed() { GV->setSection("llvm.metadata"); } +void CodeGenModule::AppendLinkerOptions(StringRef Opts) { + llvm::Value *MDOpts = llvm::MDString::get(getLLVMContext(), Opts); + LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts)); +} + +void CodeGenModule::AddDependentLib(StringRef Lib) { + llvm::SmallString<24> Opt; + getTargetCodeGenInfo().getDependentLibraryOption(Lib, Opt); + llvm::Value *MDOpts = llvm::MDString::get(getLLVMContext(), Opt); + LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts)); +} + /// \brief Add link options implied by the given module, including modules /// it depends on, using a postorder walk. -static void addLinkOptionsPostorder(llvm::LLVMContext &Context, +static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod, SmallVectorImpl &Metadata, llvm::SmallPtrSet &Visited) { // Import this module's parent. if (Mod->Parent && Visited.insert(Mod->Parent)) { - addLinkOptionsPostorder(Context, Mod->Parent, Metadata, Visited); + addLinkOptionsPostorder(CGM, Mod->Parent, Metadata, Visited); } // Import this module's dependencies. for (unsigned I = Mod->Imports.size(); I > 0; --I) { if (Visited.insert(Mod->Imports[I-1])) - addLinkOptionsPostorder(Context, Mod->Imports[I-1], Metadata, Visited); + addLinkOptionsPostorder(CGM, Mod->Imports[I-1], Metadata, Visited); } // Add linker options to link against the libraries/frameworks // described by this module. + llvm::LLVMContext &Context = CGM.getLLVMContext(); for (unsigned I = Mod->LinkLibraries.size(); I > 0; --I) { - // FIXME: -lfoo is Unix-centric and -framework Foo is Darwin-centric. - // We need to know more about the linker to know how to encode these - // options propertly. - - // Link against a framework. + // Link against a framework. Frameworks are currently Darwin only, so we + // don't to ask TargetCodeGenInfo for the spelling of the linker option. if (Mod->LinkLibraries[I-1].IsFramework) { llvm::Value *Args[2] = { llvm::MDString::get(Context, "-framework"), @@ -798,9 +809,10 @@ static void addLinkOptionsPostorder(llvm::LLVMContext &Context, } // Link against a library. - llvm::Value *OptString - = llvm::MDString::get(Context, - "-l" + Mod->LinkLibraries[I-1].Library); + llvm::SmallString<24> Opt; + CGM.getTargetCodeGenInfo().getDependentLibraryOption( + Mod->LinkLibraries[I-1].Library, Opt); + llvm::Value *OptString = llvm::MDString::get(Context, Opt); Metadata.push_back(llvm::MDNode::get(Context, OptString)); } } @@ -852,20 +864,23 @@ void CodeGenModule::EmitModuleLinkOptions() { } // Add link options for all of the imported modules in reverse topological - // order. + // order. We don't do anything to try to order import link flags with respect + // to linker options inserted by things like #pragma comment(). SmallVector MetadataArgs; Visited.clear(); for (llvm::SetVector::iterator M = LinkModules.begin(), MEnd = LinkModules.end(); M != MEnd; ++M) { if (Visited.insert(*M)) - addLinkOptionsPostorder(getLLVMContext(), *M, MetadataArgs, Visited); + addLinkOptionsPostorder(*this, *M, MetadataArgs, Visited); } std::reverse(MetadataArgs.begin(), MetadataArgs.end()); + LinkerOptionsMetadata.append(MetadataArgs.begin(), MetadataArgs.end()); // Add the linker options metadata flag. getModule().addModuleFlag(llvm::Module::AppendUnique, "Linker Options", - llvm::MDNode::get(getLLVMContext(), MetadataArgs)); + llvm::MDNode::get(getLLVMContext(), + LinkerOptionsMetadata)); } void CodeGenModule::EmitDeferred() { diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 91138c607c36..1d6c7e98e5c6 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -355,6 +355,9 @@ class CodeGenModule : public CodeGenTypeCache { /// \brief The complete set of modules that has been imported. llvm::SetVector ImportedModules; + /// \brief A vector of metadata strings. + SmallVector LinkerOptionsMetadata; + /// @name Cache for Objective-C runtime types /// @{ @@ -906,6 +909,12 @@ public: void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired); + /// \brief Appends Opts to the "Linker Options" metadata value. + void AppendLinkerOptions(StringRef Opts); + + /// \brief Appends a dependent lib to the "Linker Options" metadata value. + void AddDependentLib(StringRef Lib); + llvm::GlobalVariable::LinkageTypes getFunctionLinkage(const FunctionDecl *FD); diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 69e5b323045c..56067a47bbdc 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -20,6 +20,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" @@ -115,6 +116,14 @@ namespace { Builder->EmitVTable(RD, DefinitionRequired); } + + virtual void HandleLinkerOptionPragma(llvm::StringRef Opts) { + Builder->AppendLinkerOptions(Opts); + } + + virtual void HandleDependentLibrary(llvm::StringRef Lib) { + Builder->AddDependentLib(Lib); + } }; } diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 32b27b3172a6..45fc475e341b 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -143,6 +143,16 @@ bool TargetCodeGenInfo::isNoProtoCallVariadic(const CallArgList &args, return false; } +void +TargetCodeGenInfo::getDependentLibraryOption(llvm::StringRef Lib, + llvm::SmallString<24> &Opt) const { + // This assumes the user is passing a library name like "rt" instead of a + // filename like "librt.a/so", and that they don't care whether it's static or + // dynamic. + Opt = "-l"; + Opt += Lib; +} + static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays); /// isEmptyField - Return true iff a the field is "empty", that is it @@ -1256,6 +1266,18 @@ public: }; +class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { +public: + WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, unsigned RegParms) + : X86_32TargetCodeGenInfo(CGT, false, true, true, RegParms) {} + + void getDependentLibraryOption(llvm::StringRef Lib, + llvm::SmallString<24> &Opt) const { + Opt = "/DEFAULTLIB:"; + Opt += Lib; + } +}; + class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { public: WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT) @@ -1274,6 +1296,12 @@ public: AssignToArrayRange(CGF.Builder, Address, Eight8, 0, 16); return false; } + + void getDependentLibraryOption(llvm::StringRef Lib, + llvm::SmallString<24> &Opt) const { + Opt = "/DEFAULTLIB:"; + Opt += Lib; + } }; } @@ -5173,8 +5201,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() { case llvm::Triple::Win32: return *(TheTargetCodeGenInfo = - new X86_32TargetCodeGenInfo(Types, false, true, true, - CodeGenOpts.NumRegisterParameters)); + new WinX86_32TargetCodeGenInfo(Types, + CodeGenOpts.NumRegisterParameters)); default: return *(TheTargetCodeGenInfo = diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index bb50ce69e312..dee7fd8dd403 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -18,6 +18,7 @@ #include "clang/AST/Type.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/SmallString.h" namespace llvm { class GlobalValue; @@ -167,6 +168,11 @@ namespace clang { /// that unprototyped calls to varargs functions still succeed. virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args, const FunctionNoProtoType *fnType) const; + + /// Gets the linker options necessary to link a dependent library on this + /// platform. + virtual void getDependentLibraryOption(llvm::StringRef Lib, + llvm::SmallString<24> &Opt) const; }; } diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp index 3d1249aa684a..3c6f96ac2be3 100644 --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/lib/Parse/ParsePragma.cpp @@ -821,10 +821,16 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP, } // Verify that this is one of the 5 whitelisted options. - // FIXME: warn that 'exestr' is deprecated. - const IdentifierInfo *II = Tok.getIdentifierInfo(); - if (!II->isStr("compiler") && !II->isStr("exestr") && !II->isStr("lib") && - !II->isStr("linker") && !II->isStr("user")) { + IdentifierInfo *II = Tok.getIdentifierInfo(); + Sema::PragmaMSCommentKind Kind = + llvm::StringSwitch(II->getName()) + .Case("linker", Sema::PCK_Linker) + .Case("lib", Sema::PCK_Lib) + .Case("compiler", Sema::PCK_Compiler) + .Case("exestr", Sema::PCK_ExeStr) + .Case("user", Sema::PCK_User) + .Default(Sema::PCK_Unknown); + if (Kind == Sema::PCK_Unknown) { PP.Diag(Tok.getLocation(), diag::err_pragma_comment_unknown_kind); return; } @@ -837,11 +843,12 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP, /*MacroExpansion=*/true)) return; + // FIXME: warn that 'exestr' is deprecated. // FIXME: If the kind is "compiler" warn if the string is present (it is // ignored). - // FIXME: 'lib' requires a comment string. - // FIXME: 'linker' requires a comment string, and has a specific list of - // things that are allowable. + // The MSDN docs say that "lib" and "linker" require a string and have a short + // whitelist of linker options they support, but in practice MSVC doesn't + // issue a diagnostic. Therefore neither does clang. if (Tok.isNot(tok::r_paren)) { PP.Diag(Tok.getLocation(), diag::err_pragma_comment_malformed); @@ -857,4 +864,6 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP, // If the pragma is lexically sound, notify any interested PPCallbacks. if (PP.getPPCallbacks()) PP.getPPCallbacks()->PragmaComment(CommentLoc, II, ArgumentString); + + Actions.ActOnPragmaMSComment(Kind, ArgumentString); } diff --git a/clang/lib/Parse/ParsePragma.h b/clang/lib/Parse/ParsePragma.h index d9560f3181d6..3c6f3434ad0e 100644 --- a/clang/lib/Parse/ParsePragma.h +++ b/clang/lib/Parse/ParsePragma.h @@ -116,9 +116,12 @@ public: /// PragmaCommentHandler - "\#pragma comment ...". class PragmaCommentHandler : public PragmaHandler { public: - PragmaCommentHandler() : PragmaHandler("comment") {} + PragmaCommentHandler(Sema &Actions) + : PragmaHandler("comment"), Actions(Actions) {} virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &FirstToken); +private: + Sema &Actions; }; } // end namespace clang diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 455139b881aa..2117df45f3aa 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -103,7 +103,7 @@ Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies) PP.AddPragmaHandler(OpenMPHandler.get()); if (getLangOpts().MicrosoftExt) { - MSCommentHandler.reset(new PragmaCommentHandler()); + MSCommentHandler.reset(new PragmaCommentHandler(actions)); PP.AddPragmaHandler(MSCommentHandler.get()); } diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index e12bbde0d0dd..bc19b382989a 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Sema/SemaInternal.h" +#include "clang/AST/ASTConsumer.h" #include "clang/AST/Attr.h" #include "clang/AST/Expr.h" #include "clang/Basic/TargetInfo.h" @@ -263,6 +264,26 @@ void Sema::ActOnPragmaMSStruct(PragmaMSStructKind Kind) { MSStructPragmaOn = (Kind == PMSST_ON); } +void Sema::ActOnPragmaMSComment(PragmaMSCommentKind Kind, llvm::StringRef Arg) { + // FIXME: Serialize this. + switch (Kind) { + case PCK_Unknown: + llvm_unreachable("unexpected pragma comment kind"); + case PCK_Linker: + Consumer.HandleLinkerOptionPragma(Arg); + return; + case PCK_Lib: { + Consumer.HandleDependentLibrary(Arg); + return; + } + case PCK_Compiler: + case PCK_ExeStr: + case PCK_User: + return; // We ignore all of these. + } + llvm_unreachable("invalid pragma comment kind"); +} + void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope, SourceLocation PragmaLoc) { diff --git a/clang/test/Modules/autolink.m b/clang/test/Modules/autolink.m index 4bf9d592a8f2..2b31fe515420 100644 --- a/clang/test/Modules/autolink.m +++ b/clang/test/Modules/autolink.m @@ -35,7 +35,7 @@ int use_no_umbrella() { // CHECK: !4 = metadata !{i32 6, metadata !"Linker Options", metadata ![[AUTOLINK_OPTIONS:[0-9]+]]} // CHECK: ![[AUTOLINK_OPTIONS]] = metadata !{metadata ![[AUTOLINK_FRAMEWORK:[0-9]+]], metadata ![[AUTOLINK:[0-9]+]], metadata ![[DEPENDSONMODULE:[0-9]+]], metadata ![[MODULE:[0-9]+]], metadata ![[NOUMBRELLA:[0-9]+]]} // CHECK: ![[AUTOLINK_FRAMEWORK]] = metadata !{metadata !"-framework", metadata !"autolink_framework"} -// CHECK: ![[AUTOLINK]] = metadata !{metadata !"-lautolink"} +// CHECK: ![[AUTOLINK]] = metadata !{metadata !"{{(-l|/DEFAULTLIB:)}}autolink"} // CHECK: ![[DEPENDSONMODULE]] = metadata !{metadata !"-framework", metadata !"DependsOnModule"} // CHECK: ![[MODULE]] = metadata !{metadata !"-framework", metadata !"Module"} // CHECK: ![[NOUMBRELLA]] = metadata !{metadata !"-framework", metadata !"NoUmbrella"} -- GitLab From 0d8cc4a2d271ca41c1121f189d95c498681f7938 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 8 May 2013 13:59:30 +0000 Subject: [PATCH 010/467] [sanitizer] Fix build breakage in Go TSan. llvm-svn: 181428 --- compiler-rt/lib/sanitizer_common/sanitizer_posix.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc index 7fec5cf4c366..fffd0314ddd3 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc @@ -229,6 +229,7 @@ int internal_isatty(fd_t fd) { return isatty(fd); } +#ifndef SANITIZER_GO void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, uptr stack_top, uptr stack_bottom, bool fast) { #if !SANITIZER_CAN_FAST_UNWIND @@ -248,6 +249,7 @@ void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, stack->FastUnwindStack(pc, bp, stack_top, stack_bottom); } } +#endif // SANITIZER_GO } // namespace __sanitizer -- GitLab From ffe38d267c765f8e5876831d9e26eec9b7b24946 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 8 May 2013 14:11:12 +0000 Subject: [PATCH 011/467] Quick fix for ASan test build on Android. llvm-svn: 181429 --- .../lib/asan/tests/asan_noinst_test.cc | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/compiler-rt/lib/asan/tests/asan_noinst_test.cc b/compiler-rt/lib/asan/tests/asan_noinst_test.cc index e0100933560d..54fdd1979b8e 100644 --- a/compiler-rt/lib/asan/tests/asan_noinst_test.cc +++ b/compiler-rt/lib/asan/tests/asan_noinst_test.cc @@ -15,7 +15,6 @@ #include "asan_allocator.h" #include "asan_internal.h" #include "asan_mapping.h" -#include "asan_stack.h" #include "asan_test_utils.h" #include @@ -33,17 +32,17 @@ TEST(AddressSanitizer, InternalSimpleDeathTest) { static void MallocStress(size_t n) { u32 seed = my_rand(); - __asan::StackTrace stack1; + StackTrace stack1; stack1.trace[0] = 0xa123; stack1.trace[1] = 0xa456; stack1.size = 2; - __asan::StackTrace stack2; + StackTrace stack2; stack2.trace[0] = 0xb123; stack2.trace[1] = 0xb456; stack2.size = 2; - __asan::StackTrace stack3; + StackTrace stack3; stack3.trace[0] = 0xc123; stack3.trace[1] = 0xc456; stack3.size = 2; @@ -216,16 +215,16 @@ void CompressStackTraceTest(size_t n_iter) { for (size_t iter = 0; iter < n_iter; iter++) { std::random_shuffle(pc_array, pc_array + kNumPcs); - __asan::StackTrace stack0, stack1; + StackTrace stack0, stack1; stack0.CopyFrom(pc_array, kNumPcs); stack0.size = std::max((size_t)1, (size_t)(my_rand_r(&seed) % stack0.size)); size_t compress_size = std::max((size_t)2, (size_t)my_rand_r(&seed) % (2 * kNumPcs)); size_t n_frames = - __asan::StackTrace::CompressStack(&stack0, compressed, compress_size); + StackTrace::CompressStack(&stack0, compressed, compress_size); Ident(n_frames); assert(n_frames <= stack0.size); - __asan::StackTrace::UncompressStack(&stack1, compressed, compress_size); + StackTrace::UncompressStack(&stack1, compressed, compress_size); assert(stack1.size == n_frames); for (size_t i = 0; i < stack1.size; i++) { assert(stack0.trace[i] == stack1.trace[i]); @@ -242,13 +241,13 @@ void CompressStackTraceBenchmark(size_t n_iter) { u32 compressed[2 * kNumPcs]; std::random_shuffle(pc_array, pc_array + kNumPcs); - __asan::StackTrace stack0; + StackTrace stack0; stack0.CopyFrom(pc_array, kNumPcs); stack0.size = kNumPcs; for (size_t iter = 0; iter < n_iter; iter++) { size_t compress_size = kNumPcs; size_t n_frames = - __asan::StackTrace::CompressStack(&stack0, compressed, compress_size); + StackTrace::CompressStack(&stack0, compressed, compress_size); Ident(n_frames); } } @@ -258,7 +257,7 @@ TEST(AddressSanitizer, CompressStackTraceBenchmark) { } TEST(AddressSanitizer, QuarantineTest) { - __asan::StackTrace stack; + StackTrace stack; stack.trace[0] = 0x890; stack.size = 1; @@ -279,7 +278,7 @@ TEST(AddressSanitizer, QuarantineTest) { void *ThreadedQuarantineTestWorker(void *unused) { (void)unused; u32 seed = my_rand(); - __asan::StackTrace stack; + StackTrace stack; stack.trace[0] = 0x890; stack.size = 1; @@ -306,7 +305,7 @@ TEST(AddressSanitizer, ThreadedQuarantineTest) { void *ThreadedOneSizeMallocStress(void *unused) { (void)unused; - __asan::StackTrace stack; + StackTrace stack; stack.trace[0] = 0x890; stack.size = 1; const size_t kNumMallocs = 1000; -- GitLab From d69fc77b9e391364c842f706117a42bbbaf2ea48 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 8 May 2013 14:12:04 +0000 Subject: [PATCH 012/467] Improve line breaking in binary expressions. If the LHS of a binary expression is broken, clang-format should also break after the operator as otherwise: - The RHS can be easy to miss - It can look as if clang-format doesn't understand operator precedence Before: bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb && ccccccccc == ddddddddddd; After: bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb && ccccccccc == ddddddddddd; As an additional note, clang-format would also be ok with the following formatting, it just has a higher penalty (IMO correctly so). bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb && ccccccccc == ddddddddddd; llvm-svn: 181430 --- clang/lib/Format/Format.cpp | 62 +++++++++++++++------------ clang/lib/Format/TokenAnnotator.cpp | 5 ++- clang/unittests/Format/FormatTest.cpp | 18 ++++++++ 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 814017a51272..2413e43b138e 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -467,8 +467,9 @@ private: if (Current.is(tok::question)) State.Stack.back().BreakBeforeParameter = true; - if (Previous.isOneOf(tok::comma, tok::semi) && - !State.Stack.back().AvoidBinPacking) + if ((Previous.isOneOf(tok::comma, tok::semi) && + !State.Stack.back().AvoidBinPacking) || + Previous.Type == TT_BinaryOperator) State.Stack.back().BreakBeforeParameter = false; if (!DryRun) { @@ -495,7 +496,7 @@ private: } const AnnotatedToken *TokenBefore = Current.getPreviousNoneComment(); if (TokenBefore && !TokenBefore->isOneOf(tok::comma, tok::semi) && - !TokenBefore->opensScope()) + TokenBefore->Type != TT_BinaryOperator && !TokenBefore->opensScope()) State.Stack.back().BreakBeforeParameter = true; // If we break after {, we should also break before the corresponding }. @@ -565,9 +566,9 @@ private: State.Stack.back().LastSpace = State.Column; else if (Previous.Type == TT_InheritanceColon) State.Stack.back().Indent = State.Column; - else if (Previous.opensScope() && Previous.ParameterCount > 1) - // If this function has multiple parameters, indent nested calls from - // the start of the first parameter. + else if (Previous.opensScope() && !Current.FakeLParens.empty()) + // If this function has multiple parameters or a binary expression + // parameter, indent nested calls from the start of the first parameter. State.Stack.back().LastSpace = State.Column; } @@ -906,40 +907,45 @@ private: /// \brief Returns \c true, if a line break after \p State is mandatory. bool mustBreak(const LineState &State) { - if (State.NextToken->MustBreakBefore) + const AnnotatedToken &Current = *State.NextToken; + const AnnotatedToken &Previous = *Current.Parent; + if (Current.MustBreakBefore || Current.Type == TT_InlineASMColon) return true; - if (State.NextToken->is(tok::r_brace) && - State.Stack.back().BreakBeforeClosingBrace) + if (Current.is(tok::r_brace) && State.Stack.back().BreakBeforeClosingBrace) return true; - if (State.NextToken->Parent->is(tok::semi) && - State.LineContainsContinuedForLoopSection) + if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection) return true; - if ((State.NextToken->Parent->isOneOf(tok::comma, tok::semi) || - State.NextToken->is(tok::question) || - State.NextToken->Type == TT_ConditionalExpr) && + if ((Previous.isOneOf(tok::comma, tok::semi) || Current.is(tok::question) || + Current.Type == TT_ConditionalExpr) && State.Stack.back().BreakBeforeParameter && - !State.NextToken->isTrailingComment() && - State.NextToken->isNot(tok::r_paren) && - State.NextToken->isNot(tok::r_brace)) + !Current.isTrailingComment() && + !Current.isOneOf(tok::r_paren, tok::r_brace)) + return true; + + // If we need to break somewhere inside the LHS of a binary expression, we + // should also break after the operator. + if (Previous.Type == TT_BinaryOperator && + !Previous.isOneOf(tok::lessless, tok::question) && + getPrecedence(Previous) != prec::Assignment && + State.Stack.back().BreakBeforeParameter) return true; + // FIXME: Comparing LongestObjCSelectorName to 0 is a hacky way of finding // out whether it is the first parameter. Clean this up. - if (State.NextToken->Type == TT_ObjCSelectorName && - State.NextToken->LongestObjCSelectorName == 0 && + if (Current.Type == TT_ObjCSelectorName && + Current.LongestObjCSelectorName == 0 && State.Stack.back().BreakBeforeParameter) return true; - if ((State.NextToken->Type == TT_CtorInitializerColon || - (State.NextToken->Parent->ClosesTemplateDeclaration && - State.ParenLevel == 0))) - return true; - if (State.NextToken->Type == TT_InlineASMColon) + if ((Current.Type == TT_CtorInitializerColon || + (Previous.ClosesTemplateDeclaration && State.ParenLevel == 0))) return true; + // This prevents breaks like: // ... // SomeParameter, OtherParameter).DoSomething( // ... // As they hide "DoSomething" and generally bad for readability. - if (State.NextToken->isOneOf(tok::period, tok::arrow) && + if (Current.isOneOf(tok::period, tok::arrow) && getRemainingLength(State) + State.Column > getColumnLimit() && State.ParenLevel < State.StartOfLineLevel) return true; @@ -1166,8 +1172,10 @@ public: Lex.MeasureTokenLength(LastLoc, SourceMgr, Lex.getLangOpts()) - 1; PreviousLineWasTouched = false; if (TheLine.Last->is(tok::comment)) - Whitespaces.addUntouchableComment(SourceMgr.getSpellingColumnNumber( - TheLine.Last->FormatTok.Tok.getLocation()) - 1); + Whitespaces.addUntouchableComment( + SourceMgr.getSpellingColumnNumber( + TheLine.Last->FormatTok.Tok.getLocation()) - + 1); else Whitespaces.alignComments(); } diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 3ac5a07884e3..c736e9012f66 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -320,7 +320,7 @@ private: Tok->Type = TT_ObjCMethodExpr; Tok->Parent->Type = TT_ObjCSelectorName; if (Tok->Parent->FormatTok.TokenLength > - Contexts.back().LongestObjCSelectorName) + Contexts.back().LongestObjCSelectorName) Contexts.back().LongestObjCSelectorName = Tok->Parent->FormatTok.TokenLength; if (Contexts.back().FirstObjCSelectorName == NULL) @@ -606,7 +606,8 @@ private: if (Current.Parent && Current.is(tok::identifier) && ((Current.Parent->is(tok::identifier) && Current.Parent->FormatTok.Tok.getIdentifierInfo() - ->getPPKeywordID() == tok::pp_not_keyword) || + ->getPPKeywordID() == + tok::pp_not_keyword) || isSimpleTypeSpecifier(*Current.Parent) || Current.Parent->Type == TT_PointerOrReference || Current.Parent->Type == TT_TemplateCloser)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 2a11f80eaa59..3a97abe5b20a 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1606,6 +1606,24 @@ TEST_F(FormatTest, PreventConfusingIndents) { " ddd);"); } +TEST_F(FormatTest, LineBreakingInBinaryExpressions) { + verifyFormat( + "bool aaaaaaa =\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaa).aaaaaaaaaaaaaaaaaaa() ||\n" + " bbbbbbbb();"); + verifyFormat("bool aaaaaaaaaaaaaaaaaaaaa =\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb &&\n" + " ccccccccc == ddddddddddd;"); + + verifyFormat("aaaaaa = aaaaaaa(aaaaaaa, // break\n" + " aaaaaa) &&\n" + " bbbbbb && cccccc;"); + verifyFormat("Whitespaces.addUntouchableComment(\n" + " SourceMgr.getSpellingColumnNumber(\n" + " TheLine.Last->FormatTok.Tok.getLocation()) -\n" + " 1);"); +} + TEST_F(FormatTest, ExpressionIndentation) { verifyFormat("bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" -- GitLab From ef494aa8570f1ac35f259a71d187b97ff12d62a6 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 8 May 2013 14:23:43 +0000 Subject: [PATCH 013/467] Add SystemZ feats to CodeGenerator.rst llvm-svn: 181431 --- llvm/docs/CodeGenerator.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/llvm/docs/CodeGenerator.rst b/llvm/docs/CodeGenerator.rst index 20c99ced93b6..10ca307b7869 100644 --- a/llvm/docs/CodeGenerator.rst +++ b/llvm/docs/CodeGenerator.rst @@ -1794,6 +1794,7 @@ Here is the table: :raw-html:`NVPTX` :raw-html:`PowerPC` :raw-html:`Sparc` +:raw-html:`SystemZ` :raw-html:`X86` :raw-html:`XCore` :raw-html:`` @@ -1808,6 +1809,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:`` @@ -1822,6 +1824,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:`` @@ -1835,6 +1838,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:` ` @@ -1850,6 +1854,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:`` @@ -1864,6 +1869,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:`` @@ -1878,6 +1884,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:`` @@ -1892,6 +1899,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:` ` :raw-html:` ` :raw-html:`` @@ -1906,6 +1914,7 @@ Here is the table: :raw-html:` ` :raw-html:` ` :raw-html:` ` +:raw-html:` ` :raw-html:`* ` :raw-html:` ` :raw-html:`` -- GitLab From 78fb10f1947fbb69028913fc359240778f0b335e Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 8 May 2013 14:40:51 +0000 Subject: [PATCH 014/467] Document Clang's support for #pragma comment(lib/linker) with -fms-extensions As suggested by Dmitri Gribenko. llvm-svn: 181433 --- clang/docs/UsersManual.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 3dc07aba9013..e881f158257a 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -1202,6 +1202,12 @@ Windows targets. record layout. GCC also contains support for this feature, however where MSVC and GCC are incompatible clang follows the MSVC definition. +- clang supports the Microsoft ``#pragma comment(lib, "foo.lib")`` feature for + automatically linking against the specified library. Currently this feature + only works with the Visual C++ linker. +- clang supports the Microsoft ``#pragma comment(linker, "/flag:foo")`` feature + for adding linker flags to COFF object files. The user is responsible for + ensuring that the linker understands the flags. - clang defaults to C++11 for Windows targets. .. _cxx: -- GitLab From 4307282de6cd6e1f2f24871361248eec136ce2c7 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 8 May 2013 14:41:29 +0000 Subject: [PATCH 015/467] Add myself as SystemZ code owner llvm-svn: 181434 --- llvm/CODE_OWNERS.TXT | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/CODE_OWNERS.TXT b/llvm/CODE_OWNERS.TXT index 5f57840a03ea..8e13e35f4033 100644 --- a/llvm/CODE_OWNERS.TXT +++ b/llvm/CODE_OWNERS.TXT @@ -109,6 +109,10 @@ N: Nadav Rotem E: nrotem@apple.com D: X86 Backend, Loop Vectorizer +N: Richard Sandiford +E: rsandifo@linux.vnet.ibm.com +D: SystemZ Backend + N: Duncan Sands E: baldrick@free.fr D: DragonEgg -- GitLab From 6f4be19b576fc7eb5f3f573ebedbe2cd4a598ee7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 8 May 2013 14:43:49 +0000 Subject: [PATCH 016/467] [nolibc] Change internal syscall API to remove reliance on libc's errno. This change moves to a model where the error value of a system call is potentially contained in the return value itself rather than being implicit in errno. The helper function internal_iserror can be used to extract the error value from a return value. On platforms other than Linux/x86_64 this still uses errno, but other platforms are free to port their error handling to this new model. Differential Revision: http://llvm-reviews.chandlerc.com/D756 llvm-svn: 181436 --- .../lib/sanitizer_common/sanitizer_common.cc | 11 +- .../lib/sanitizer_common/sanitizer_common.h | 2 +- .../sanitizer_internal_defs.h | 10 +- .../lib/sanitizer_common/sanitizer_libc.h | 35 ++--- .../lib/sanitizer_common/sanitizer_linux.cc | 126 ++++++++++-------- .../lib/sanitizer_common/sanitizer_linux.h | 7 +- .../lib/sanitizer_common/sanitizer_mac.cc | 20 +-- .../lib/sanitizer_common/sanitizer_posix.cc | 48 ++++--- .../sanitizer_stoptheworld_linux.cc | 32 +++-- .../sanitizer_symbolizer_linux.cc | 2 +- .../sanitizer_syscall_generic.inc | 24 ++++ .../sanitizer_syscall_linux_x86_64.inc | 87 ++++++++++++ .../lib/sanitizer_common/sanitizer_win.cc | 16 ++- .../tests/sanitizer_libc_test.cc | 18 +-- .../lib/tsan/rtl/tsan_platform_linux.cc | 11 +- compiler-rt/lib/tsan/rtl/tsan_rtl.cc | 6 +- compiler-rt/lib/tsan/rtl/tsan_suppressions.cc | 5 +- 17 files changed, 309 insertions(+), 151 deletions(-) create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc index 39e52e88083e..3bb8e8118d40 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc @@ -69,8 +69,8 @@ static void MaybeOpenReportFile() { InternalScopedBuffer report_path_full(4096); internal_snprintf(report_path_full.data(), report_path_full.size(), "%s.%d", report_path_prefix, GetPid()); - fd_t fd = OpenFile(report_path_full.data(), true); - if (fd == kInvalidFd) { + uptr openrv = OpenFile(report_path_full.data(), true); + if (internal_iserror(openrv)) { report_fd = kStderrFd; log_to_file = false; Report("ERROR: Can't open file: %s\n", report_path_full.data()); @@ -80,7 +80,7 @@ static void MaybeOpenReportFile() { // We're in the child. Close the parent's log. internal_close(report_fd); } - report_fd = fd; + report_fd = openrv; report_fd_pid = GetPid(); } @@ -108,8 +108,9 @@ uptr ReadFileToBuffer(const char *file_name, char **buff, *buff_size = 0; // The files we usually open are not seekable, so try different buffer sizes. for (uptr size = kMinFileLen; size <= max_len; size *= 2) { - fd_t fd = OpenFile(file_name, /*write*/ false); - if (fd == kInvalidFd) return 0; + uptr openrv = OpenFile(file_name, /*write*/ false); + if (internal_iserror(openrv)) return 0; + fd_t fd = openrv; UnmapOrDie(*buff, *buff_size); *buff = (char*)MmapOrDie(size, __FUNCTION__); *buff_size = size; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index 7c18f1794a70..92ba0d53b994 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -115,7 +115,7 @@ void SetPrintfAndReportCallback(void (*callback)(const char *)); // Can be used to prevent mixing error reports from different sanitizers. extern StaticSpinMutex CommonSanitizerReportMutex; -fd_t OpenFile(const char *filename, bool write); +uptr OpenFile(const char *filename, bool write); // Opens the file 'file_name" and reads up to 'max_len' bytes. // The resulting buffer is mmaped and stored in '*buff'. // The size of the mmaped region is stored in '*buff_size', diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index 6ee21f02fe17..9a7d374bf5ad 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -273,10 +273,12 @@ extern "C" void* _ReturnAddress(void); # define GET_CURRENT_FRAME() (uptr)0xDEADBEEF #endif -#define HANDLE_EINTR(res, f) { \ - do { \ - res = (f); \ - } while (res == -1 && errno == EINTR); \ +#define HANDLE_EINTR(res, f) \ + { \ + int rverrno; \ + do { \ + res = (f); \ + } while (internal_iserror(res, &rverrno) && rverrno == EINTR); \ } #endif // SANITIZER_DEFS_H diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h index 9f4088e02af8..5f77ad1e5cff 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h @@ -53,42 +53,45 @@ bool mem_is_zero(const char *mem, uptr size); // Memory -void *internal_mmap(void *addr, uptr length, int prot, int flags, - int fd, u64 offset); -int internal_munmap(void *addr, uptr length); +uptr internal_mmap(void *addr, uptr length, int prot, int flags, + int fd, u64 offset); +uptr internal_munmap(void *addr, uptr length); // I/O const fd_t kInvalidFd = -1; const fd_t kStdinFd = 0; const fd_t kStdoutFd = 1; const fd_t kStderrFd = 2; -int internal_close(fd_t fd); +uptr internal_close(fd_t fd); int internal_isatty(fd_t fd); // Use __sanitizer::OpenFile() instead. -fd_t internal_open(const char *filename, int flags); -fd_t internal_open(const char *filename, int flags, u32 mode); +uptr internal_open(const char *filename, int flags); +uptr internal_open(const char *filename, int flags, u32 mode); uptr internal_read(fd_t fd, void *buf, uptr count); uptr internal_write(fd_t fd, const void *buf, uptr count); // OS uptr internal_filesize(fd_t fd); // -1 on error. -int internal_stat(const char *path, void *buf); -int internal_lstat(const char *path, void *buf); -int internal_fstat(fd_t fd, void *buf); -int internal_dup2(int oldfd, int newfd); +uptr internal_stat(const char *path, void *buf); +uptr internal_lstat(const char *path, void *buf); +uptr internal_fstat(fd_t fd, void *buf); +uptr internal_dup2(int oldfd, int newfd); uptr internal_readlink(const char *path, char *buf, uptr bufsize); -int internal_unlink(const char *path); +uptr internal_unlink(const char *path); void NORETURN internal__exit(int exitcode); -OFF_T internal_lseek(fd_t fd, OFF_T offset, int whence); +uptr internal_lseek(fd_t fd, OFF_T offset, int whence); -long internal_ptrace(int request, int pid, void *addr, void *data); -int internal_waitpid(int pid, int *status, int options); -int internal_getppid(); +uptr internal_ptrace(int request, int pid, void *addr, void *data); +uptr internal_waitpid(int pid, int *status, int options); +uptr internal_getppid(); // Threading -int internal_sched_yield(); +uptr internal_sched_yield(); + +// Error handling +bool internal_iserror(uptr retval, int *rverrno = 0); } // namespace __sanitizer diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc index 29c67220e65b..46d3a2463aa8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -72,46 +72,52 @@ extern "C" int arch_prctl(int code, __sanitizer::uptr *addr); namespace __sanitizer { +#ifdef __x86_64__ +#include "sanitizer_syscall_linux_x86_64.inc" +#else +#include "sanitizer_syscall_generic.inc" +#endif + // --------------- sanitizer_libc.h -void *internal_mmap(void *addr, uptr length, int prot, int flags, +uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd, u64 offset) { #if SANITIZER_LINUX_USES_64BIT_SYSCALLS - return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset); + return internal_syscall(__NR_mmap, addr, length, prot, flags, fd, offset); #else - return (void *)syscall(__NR_mmap2, addr, length, prot, flags, fd, offset); + return internal_syscall(__NR_mmap2, addr, length, prot, flags, fd, offset); #endif } -int internal_munmap(void *addr, uptr length) { - return syscall(__NR_munmap, addr, length); +uptr internal_munmap(void *addr, uptr length) { + return internal_syscall(__NR_munmap, addr, length); } -int internal_close(fd_t fd) { - return syscall(__NR_close, fd); +uptr internal_close(fd_t fd) { + return internal_syscall(__NR_close, fd); } -fd_t internal_open(const char *filename, int flags) { - return syscall(__NR_open, filename, flags); +uptr internal_open(const char *filename, int flags) { + return internal_syscall(__NR_open, filename, flags); } -fd_t internal_open(const char *filename, int flags, u32 mode) { - return syscall(__NR_open, filename, flags, mode); +uptr internal_open(const char *filename, int flags, u32 mode) { + return internal_syscall(__NR_open, filename, flags, mode); } -fd_t OpenFile(const char *filename, bool write) { +uptr OpenFile(const char *filename, bool write) { return internal_open(filename, write ? O_WRONLY | O_CREAT /*| O_CLOEXEC*/ : O_RDONLY, 0660); } uptr internal_read(fd_t fd, void *buf, uptr count) { sptr res; - HANDLE_EINTR(res, (sptr)syscall(__NR_read, fd, buf, count)); + HANDLE_EINTR(res, (sptr)internal_syscall(__NR_read, fd, buf, count)); return res; } uptr internal_write(fd_t fd, const void *buf, uptr count) { sptr res; - HANDLE_EINTR(res, (sptr)syscall(__NR_write, fd, buf, count)); + HANDLE_EINTR(res, (sptr)internal_syscall(__NR_write, fd, buf, count)); return res; } @@ -135,34 +141,34 @@ static void stat64_to_stat(struct stat64 *in, struct stat *out) { } #endif -int internal_stat(const char *path, void *buf) { +uptr internal_stat(const char *path, void *buf) { #if SANITIZER_LINUX_USES_64BIT_SYSCALLS - return syscall(__NR_stat, path, buf); + return internal_syscall(__NR_stat, path, buf); #else struct stat64 buf64; - int res = syscall(__NR_stat64, path, &buf64); + int res = internal_syscall(__NR_stat64, path, &buf64); stat64_to_stat(&buf64, (struct stat *)buf); return res; #endif } -int internal_lstat(const char *path, void *buf) { +uptr internal_lstat(const char *path, void *buf) { #if SANITIZER_LINUX_USES_64BIT_SYSCALLS - return syscall(__NR_lstat, path, buf); + return internal_syscall(__NR_lstat, path, buf); #else struct stat64 buf64; - int res = syscall(__NR_lstat64, path, &buf64); + int res = internal_syscall(__NR_lstat64, path, &buf64); stat64_to_stat(&buf64, (struct stat *)buf); return res; #endif } -int internal_fstat(fd_t fd, void *buf) { +uptr internal_fstat(fd_t fd, void *buf) { #if SANITIZER_LINUX_USES_64BIT_SYSCALLS - return syscall(__NR_fstat, fd, buf); + return internal_syscall(__NR_fstat, fd, buf); #else struct stat64 buf64; - int res = syscall(__NR_fstat64, fd, &buf64); + int res = internal_syscall(__NR_fstat64, fd, &buf64); stat64_to_stat(&buf64, (struct stat *)buf); return res; #endif @@ -175,27 +181,32 @@ uptr internal_filesize(fd_t fd) { return (uptr)st.st_size; } -int internal_dup2(int oldfd, int newfd) { - return syscall(__NR_dup2, oldfd, newfd); +uptr internal_dup2(int oldfd, int newfd) { + return internal_syscall(__NR_dup2, oldfd, newfd); } uptr internal_readlink(const char *path, char *buf, uptr bufsize) { - return (uptr)syscall(__NR_readlink, path, buf, bufsize); + return internal_syscall(__NR_readlink, path, buf, bufsize); } -int internal_unlink(const char *path) { - return syscall(__NR_unlink, path); +uptr internal_unlink(const char *path) { + return internal_syscall(__NR_unlink, path); } -int internal_sched_yield() { - return syscall(__NR_sched_yield); +uptr internal_sched_yield() { + return internal_syscall(__NR_sched_yield); } void internal__exit(int exitcode) { - syscall(__NR_exit_group, exitcode); + internal_syscall(__NR_exit_group, exitcode); Die(); // Unreachable. } +uptr internal_execve(const char *filename, char *const argv[], + char *const envp[]) { + return internal_syscall(__NR_execve, filename, argv, envp); +} + // ----------------- sanitizer_common.h bool FileExists(const char *filename) { struct stat st; @@ -206,12 +217,12 @@ bool FileExists(const char *filename) { } uptr GetTid() { - return syscall(__NR_gettid); + return internal_syscall(__NR_gettid); } u64 NanoTime() { kernel_timeval tv; - syscall(__NR_gettimeofday, &tv, 0); + internal_syscall(__NR_gettimeofday, &tv, 0); return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000; } @@ -349,8 +360,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { void ReExec() { char **argv, **envp; GetArgsAndEnv(&argv, &envp); - execve("/proc/self/exe", argv, envp); - Printf("execve failed, errno %d\n", errno); + uptr rv = internal_execve("/proc/self/exe", argv, envp); + int rverrno; + CHECK_EQ(internal_iserror(rv, &rverrno), true); + Printf("execve failed, errno %d\n", rverrno); Die(); } @@ -616,7 +629,7 @@ void BlockingMutex::Lock() { if (atomic_exchange(m, MtxLocked, memory_order_acquire) == MtxUnlocked) return; while (atomic_exchange(m, MtxSleeping, memory_order_acquire) != MtxUnlocked) - syscall(__NR_futex, m, FUTEX_WAIT, MtxSleeping, 0, 0, 0); + internal_syscall(__NR_futex, m, FUTEX_WAIT, MtxSleeping, 0, 0, 0); } void BlockingMutex::Unlock() { @@ -624,7 +637,7 @@ void BlockingMutex::Unlock() { u32 v = atomic_exchange(m, MtxUnlocked, memory_order_relaxed); CHECK_NE(v, MtxUnlocked); if (v == MtxSleeping) - syscall(__NR_futex, m, FUTEX_WAKE, 1, 0, 0, 0); + internal_syscall(__NR_futex, m, FUTEX_WAKE, 1, 0, 0, 0); } void BlockingMutex::CheckLocked() { @@ -644,33 +657,37 @@ struct linux_dirent { }; // Syscall wrappers. -long internal_ptrace(int request, int pid, void *addr, void *data) { - return syscall(__NR_ptrace, request, pid, addr, data); +uptr internal_ptrace(int request, int pid, void *addr, void *data) { + return internal_syscall(__NR_ptrace, request, pid, addr, data); +} + +uptr internal_waitpid(int pid, int *status, int options) { + return internal_syscall(__NR_wait4, pid, status, options, 0 /* rusage */); } -int internal_waitpid(int pid, int *status, int options) { - return syscall(__NR_wait4, pid, status, options, NULL /* rusage */); +uptr internal_getpid() { + return internal_syscall(__NR_getpid); } -int internal_getppid() { - return syscall(__NR_getppid); +uptr internal_getppid() { + return internal_syscall(__NR_getppid); } -int internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) { - return syscall(__NR_getdents, fd, dirp, count); +uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) { + return internal_syscall(__NR_getdents, fd, dirp, count); } -OFF_T internal_lseek(fd_t fd, OFF_T offset, int whence) { - return syscall(__NR_lseek, fd, offset, whence); +uptr internal_lseek(fd_t fd, OFF_T offset, int whence) { + return internal_syscall(__NR_lseek, fd, offset, whence); } -int internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) { - return syscall(__NR_prctl, option, arg2, arg3, arg4, arg5); +uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) { + return internal_syscall(__NR_prctl, option, arg2, arg3, arg4, arg5); } -int internal_sigaltstack(const struct sigaltstack *ss, +uptr internal_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss) { - return syscall(__NR_sigaltstack, ss, oss); + return internal_syscall(__NR_sigaltstack, ss, oss); } // ThreadLister implementation. @@ -684,12 +701,13 @@ ThreadLister::ThreadLister(int pid) char task_directory_path[80]; internal_snprintf(task_directory_path, sizeof(task_directory_path), "/proc/%d/task/", pid); - descriptor_ = internal_open(task_directory_path, O_RDONLY | O_DIRECTORY); - if (descriptor_ < 0) { + uptr openrv = internal_open(task_directory_path, O_RDONLY | O_DIRECTORY); + if (internal_iserror(openrv)) { error_ = true; Report("Can't open /proc/%d/task for reading.\n", pid); } else { error_ = false; + descriptor_ = openrv; } } @@ -729,7 +747,7 @@ bool ThreadLister::GetDirectoryEntries() { bytes_read_ = internal_getdents(descriptor_, (struct linux_dirent *)buffer_.data(), buffer_.size()); - if (bytes_read_ < 0) { + if (internal_iserror(bytes_read_)) { Report("Can't read directory entries from /proc/%d/task.\n", pid_); error_ = true; return false; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h index 2545e631f289..ec2d94889aad 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h @@ -24,9 +24,10 @@ namespace __sanitizer { struct linux_dirent; // Syscall wrappers. -int internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); -int internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5); -int internal_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss); +uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); +uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5); +uptr internal_sigaltstack(const struct sigaltstack* ss, + struct sigaltstack* oss); // This class reads thread IDs from /proc//task using only syscalls. class ThreadLister { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc index 08d48bca34e7..8134f894c60e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc @@ -42,6 +42,8 @@ namespace __sanitizer { +#include "sanitizer_syscall_generic.inc" + // ---------------------- sanitizer_libc.h void *internal_mmap(void *addr, size_t length, int prot, int flags, int fd, u64 offset) { @@ -52,19 +54,19 @@ int internal_munmap(void *addr, uptr length) { return munmap(addr, length); } -int internal_close(fd_t fd) { +uptr internal_close(fd_t fd) { return close(fd); } -fd_t internal_open(const char *filename, int flags) { +uptr internal_open(const char *filename, int flags) { return open(filename, flags); } -fd_t internal_open(const char *filename, int flags, u32 mode) { +uptr internal_open(const char *filename, int flags, u32 mode) { return open(filename, flags, mode); } -fd_t OpenFile(const char *filename, bool write) { +uptr OpenFile(const char *filename, bool write) { return internal_open(filename, write ? O_WRONLY | O_CREAT : O_RDONLY, 0660); } @@ -77,15 +79,15 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) { return write(fd, buf, count); } -int internal_stat(const char *path, void *buf) { +uptr internal_stat(const char *path, void *buf) { return stat(path, (struct stat *)buf); } -int internal_lstat(const char *path, void *buf) { +uptr internal_lstat(const char *path, void *buf) { return lstat(path, (struct stat *)buf); } -int internal_fstat(fd_t fd, void *buf) { +uptr internal_fstat(fd_t fd, void *buf) { return fstat(fd, (struct stat *)buf); } @@ -96,7 +98,7 @@ uptr internal_filesize(fd_t fd) { return (uptr)st.st_size; } -int internal_dup2(int oldfd, int newfd) { +uptr internal_dup2(int oldfd, int newfd) { return dup2(oldfd, newfd); } @@ -104,7 +106,7 @@ uptr internal_readlink(const char *path, char *buf, uptr bufsize) { return readlink(path, buf, bufsize); } -int internal_sched_yield() { +uptr internal_sched_yield() { return sched_yield(); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc index fffd0314ddd3..1bc99081a6b4 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc @@ -57,10 +57,11 @@ uptr GetThreadSelf() { void *MmapOrDie(uptr size, const char *mem_type) { size = RoundUpTo(size, GetPageSizeCached()); - void *res = internal_mmap(0, size, + uptr res = internal_mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); - if (res == (void*)-1) { + int reserrno; + if (internal_iserror(res, &reserrno)) { static int recursion_count; if (recursion_count) { // The Report() and CHECK calls below may call mmap recursively and fail. @@ -70,17 +71,17 @@ void *MmapOrDie(uptr size, const char *mem_type) { } recursion_count++; Report("ERROR: %s failed to allocate 0x%zx (%zd) bytes of %s: %d\n", - SanitizerToolName, size, size, mem_type, errno); + SanitizerToolName, size, size, mem_type, reserrno); DumpProcessMap(); CHECK("unable to mmap" && 0); } - return res; + return (void *)res; } void UnmapOrDie(void *addr, uptr size) { if (!addr || !size) return; - int res = internal_munmap(addr, size); - if (res != 0) { + uptr res = internal_munmap(addr, size); + if (internal_iserror(res)) { Report("ERROR: %s failed to deallocate 0x%zx (%zd) bytes at address %p\n", SanitizerToolName, size, size, addr); CHECK("unable to unmap" && 0); @@ -89,39 +90,41 @@ void UnmapOrDie(void *addr, uptr size) { void *MmapFixedNoReserve(uptr fixed_addr, uptr size) { uptr PageSize = GetPageSizeCached(); - void *p = internal_mmap((void*)(fixed_addr & ~(PageSize - 1)), + uptr p = internal_mmap((void*)(fixed_addr & ~(PageSize - 1)), RoundUpTo(size, PageSize), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, -1, 0); - if (p == (void*)-1) + int reserrno; + if (internal_iserror(p, &reserrno)) Report("ERROR: " "%s failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n", - SanitizerToolName, size, size, fixed_addr, errno); - return p; + SanitizerToolName, size, size, fixed_addr, reserrno); + return (void *)p; } void *MmapFixedOrDie(uptr fixed_addr, uptr size) { uptr PageSize = GetPageSizeCached(); - void *p = internal_mmap((void*)(fixed_addr & ~(PageSize - 1)), + uptr p = internal_mmap((void*)(fixed_addr & ~(PageSize - 1)), RoundUpTo(size, PageSize), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); - if (p == (void*)-1) { + int reserrno; + if (internal_iserror(p, &reserrno)) { Report("ERROR:" " %s failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n", - SanitizerToolName, size, size, fixed_addr, errno); + SanitizerToolName, size, size, fixed_addr, reserrno); CHECK("unable to mmap" && 0); } - return p; + return (void *)p; } void *Mprotect(uptr fixed_addr, uptr size) { - return internal_mmap((void*)fixed_addr, size, - PROT_NONE, - MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, - -1, 0); + return (void *)internal_mmap((void*)fixed_addr, size, + PROT_NONE, + MAP_PRIVATE | MAP_ANON | MAP_FIXED | + MAP_NORESERVE, -1, 0); } void FlushUnneededShadowMemory(uptr addr, uptr size) { @@ -129,14 +132,15 @@ void FlushUnneededShadowMemory(uptr addr, uptr size) { } void *MapFileToMemory(const char *file_name, uptr *buff_size) { - fd_t fd = OpenFile(file_name, false); - CHECK_NE(fd, kInvalidFd); + uptr openrv = OpenFile(file_name, false); + CHECK(!internal_iserror(openrv)); + fd_t fd = openrv; uptr fsize = internal_filesize(fd); CHECK_NE(fsize, (uptr)-1); CHECK_GT(fsize, 0); *buff_size = RoundUpTo(fsize, GetPageSizeCached()); - void *map = internal_mmap(0, *buff_size, PROT_READ, MAP_PRIVATE, fd, 0); - return (map == MAP_FAILED) ? 0 : map; + uptr map = internal_mmap(0, *buff_size, PROT_READ, MAP_PRIVATE, fd, 0); + return internal_iserror(map) ? 0 : (void *)map; } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc index 8bb155588cdc..fe3d4e395013 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc @@ -101,23 +101,26 @@ bool ThreadSuspender::SuspendThread(SuspendedThreadID thread_id) { // usually small. if (suspended_threads_list_.Contains(thread_id)) return false; - if (internal_ptrace(PTRACE_ATTACH, thread_id, NULL, NULL) != 0) { + int pterrno; + if (internal_iserror(internal_ptrace(PTRACE_ATTACH, thread_id, NULL, NULL), + &pterrno)) { // Either the thread is dead, or something prevented us from attaching. // Log this event and move on. - Report("Could not attach to thread %d (errno %d).\n", thread_id, errno); + Report("Could not attach to thread %d (errno %d).\n", thread_id, pterrno); return false; } else { if (SanitizerVerbosity > 0) Report("Attached to thread %d.\n", thread_id); // The thread is not guaranteed to stop before ptrace returns, so we must // wait on it. - int waitpid_status; + uptr waitpid_status; HANDLE_EINTR(waitpid_status, internal_waitpid(thread_id, NULL, __WALL)); - if (waitpid_status < 0) { + int wperrno; + if (internal_iserror(waitpid_status, &wperrno)) { // Got a ECHILD error. I don't think this situation is possible, but it // doesn't hurt to report it. Report("Waiting on thread %d failed, detaching (errno %d).\n", thread_id, - errno); + wperrno); internal_ptrace(PTRACE_DETACH, thread_id, NULL, NULL); return false; } @@ -129,14 +132,16 @@ bool ThreadSuspender::SuspendThread(SuspendedThreadID thread_id) { void ThreadSuspender::ResumeAllThreads() { for (uptr i = 0; i < suspended_threads_list_.thread_count(); i++) { pid_t tid = suspended_threads_list_.GetThreadID(i); - if (internal_ptrace(PTRACE_DETACH, tid, NULL, NULL) == 0) { + int pterrno; + if (!internal_iserror(internal_ptrace(PTRACE_DETACH, tid, NULL, NULL), + &pterrno)) { if (SanitizerVerbosity > 0) Report("Detached from thread %d.\n", tid); } else { // Either the thread is dead, or we are already detached. // The latter case is possible, for instance, if this function was called // from a signal handler. - Report("Could not detach from thread %d (errno %d).\n", tid, errno); + Report("Could not detach from thread %d (errno %d).\n", tid, pterrno); } } } @@ -330,9 +335,10 @@ void StopTheWorld(StopTheWorldCallback callback, void *argument) { // must avoid using errno while the tracer thread is running. // At this point, any signal will either be blocked or kill us, so waitpid // should never return (and set errno) while the tracer thread is alive. - int waitpid_status = internal_waitpid(tracer_pid, NULL, __WALL); - if (waitpid_status < 0) - Report("Waiting on the tracer thread failed (errno %d).\n", errno); + uptr waitpid_status = internal_waitpid(tracer_pid, NULL, __WALL); + int wperrno; + if (internal_iserror(waitpid_status, &wperrno)) + Report("Waiting on the tracer thread failed (errno %d).\n", wperrno); } // Restore the dumpable flag. if (!process_was_dumpable) @@ -358,9 +364,11 @@ int SuspendedThreadsList::GetRegistersAndSP(uptr index, uptr *sp) const { pid_t tid = GetThreadID(index); regs_struct regs; - if (internal_ptrace(PTRACE_GETREGS, tid, NULL, ®s) != 0) { + int pterrno; + if (internal_iserror(internal_ptrace(PTRACE_GETREGS, tid, NULL, ®s), + &pterrno)) { Report("Could not get registers from thread %d (errno %d).\n", - tid, errno); + tid, pterrno); return -1; } #if defined(__arm__) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc index 14a682bd99ec..fc3299c0f4e4 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc @@ -148,7 +148,7 @@ static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) { // First module is the binary itself. uptr module_name_len = internal_readlink( "/proc/self/exe", module_name.data(), module_name.size()); - if (module_name_len == (uptr)-1) { + if (internal_iserror(module_name_len)) { // We can't read /proc/self/exe for some reason, assume the name of the // binary is unknown. module_name_len = internal_snprintf(module_name.data(), diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc b/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc new file mode 100644 index 000000000000..aac20a5f2d69 --- /dev/null +++ b/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc @@ -0,0 +1,24 @@ +//===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Generic implementations of internal_syscall and internal_iserror. +// +//===----------------------------------------------------------------------===// + +#define internal_syscall syscall + +bool internal_iserror(uptr retval, int *rverrno) { + if (retval == (uptr)-1) { + if (rverrno) + *rverrno = errno; + return true; + } else { + return false; + } +} diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc b/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc new file mode 100644 index 000000000000..e084b84ab118 --- /dev/null +++ b/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc @@ -0,0 +1,87 @@ +//===-- sanitizer_syscall_linux_x86_64.inc ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Implementations of internal_syscall and internal_iserror for Linux/x86_64. +// +//===----------------------------------------------------------------------===// + +static uptr internal_syscall(u64 nr) { + u64 retval; + asm volatile("syscall" : "=a"(retval) : "a"(nr) : "rcx", "r11"); + return retval; +} + +template +static uptr internal_syscall(u64 nr, T1 arg1) { + u64 retval; + asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1) : + "rcx", "r11"); + return retval; +} + +template +static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2) { + u64 retval; + asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), + "S"((u64)arg2) : "rcx", "r11"); + return retval; +} + +template +static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3) { + u64 retval; + asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), + "S"((u64)arg2), "d"((u64)arg3) : "rcx", "r11"); + return retval; +} + +template +static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { + u64 retval; + asm volatile("mov %5, %%r10;" + "syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), + "S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4) : + "rcx", "r11", "r10"); + return retval; +} + +template +static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3, T4 arg4, + T5 arg5) { + u64 retval; + asm volatile("mov %5, %%r10;" + "mov %6, %%r8;" + "syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), + "S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4), "r"((u64)arg5) : + "rcx", "r11", "r10", "r8"); + return retval; +} + +template +static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3, T4 arg4, + T5 arg5, T6 arg6) { + u64 retval; + asm volatile("mov %5, %%r10;" + "mov %6, %%r8;" + "mov %7, %%r9;" + "syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), + "S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4), "r"((u64)arg5), + "r"((u64)arg6) : "rcx", "r11", "r10", "r8", "r9"); + return retval; +} + +bool internal_iserror(uptr retval, int *rverrno) { + if (retval >= (uptr)-4095) { + if (rverrno) + *rverrno = -retval; + return true; + } + return false; +} diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc index 95445be65461..ab0d78dc45d7 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc @@ -29,6 +29,8 @@ namespace __sanitizer { +#include "sanitizer_syscall_generic.inc" + // --------------------- sanitizer_common.h uptr GetPageSize() { return 1U << 14; // FIXME: is this configurable? @@ -217,7 +219,7 @@ int internal_munmap(void *addr, uptr length) { UNIMPLEMENTED(); } -int internal_close(fd_t fd) { +uptr internal_close(fd_t fd) { UNIMPLEMENTED(); } @@ -233,7 +235,7 @@ fd_t internal_open(const char *filename, int flags, u32 mode) { UNIMPLEMENTED(); } -fd_t OpenFile(const char *filename, bool write) { +uptr OpenFile(const char *filename, bool write) { UNIMPLEMENTED(); } @@ -253,15 +255,15 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) { return ret; } -int internal_stat(const char *path, void *buf) { +uptr internal_stat(const char *path, void *buf) { UNIMPLEMENTED(); } -int internal_lstat(const char *path, void *buf) { +uptr internal_lstat(const char *path, void *buf) { UNIMPLEMENTED(); } -int internal_fstat(fd_t fd, void *buf) { +uptr internal_fstat(fd_t fd, void *buf) { UNIMPLEMENTED(); } @@ -269,7 +271,7 @@ uptr internal_filesize(fd_t fd) { UNIMPLEMENTED(); } -int internal_dup2(int oldfd, int newfd) { +uptr internal_dup2(int oldfd, int newfd) { UNIMPLEMENTED(); } @@ -277,7 +279,7 @@ uptr internal_readlink(const char *path, char *buf, uptr bufsize) { UNIMPLEMENTED(); } -int internal_sched_yield() { +uptr internal_sched_yield() { Sleep(0); return 0; } diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc index 51cd66cf0cd4..459fa39d5789 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc @@ -74,29 +74,31 @@ TEST(SanitizerCommon, FileOps) { internal_snprintf(temp_filename, sizeof(temp_filename), "/tmp/sanitizer_common.tmp.%d", uid); #endif - fd_t fd = OpenFile(temp_filename, true); - EXPECT_NE(fd, kInvalidFd); + uptr openrv = OpenFile(temp_filename, true); + EXPECT_EQ(false, internal_iserror(openrv)); + fd_t fd = openrv; EXPECT_EQ(len1, internal_write(fd, str1, len1)); EXPECT_EQ(len2, internal_write(fd, str2, len2)); internal_close(fd); - fd = OpenFile(temp_filename, false); - EXPECT_NE(fd, kInvalidFd); + openrv = OpenFile(temp_filename, false); + EXPECT_EQ(false, internal_iserror(openrv)); + fd = openrv; uptr fsize = internal_filesize(fd); EXPECT_EQ(len1 + len2, fsize); #if SANITIZER_TEST_HAS_STAT_H struct stat st1, st2, st3; - EXPECT_EQ(0, internal_stat(temp_filename, &st1)); - EXPECT_EQ(0, internal_lstat(temp_filename, &st2)); - EXPECT_EQ(0, internal_fstat(fd, &st3)); + EXPECT_EQ(0u, internal_stat(temp_filename, &st1)); + EXPECT_EQ(0u, internal_lstat(temp_filename, &st2)); + EXPECT_EQ(0u, internal_fstat(fd, &st3)); EXPECT_EQ(fsize, (uptr)st3.st_size); // Verify that internal_fstat does not write beyond the end of the supplied // buffer. struct stat_and_more sam; memset(&sam, 0xAB, sizeof(sam)); - EXPECT_EQ(0, internal_fstat(fd, &sam.st)); + EXPECT_EQ(0u, internal_fstat(fd, &sam.st)); EXPECT_EQ(0xAB, sam.z); EXPECT_NE(0xAB, sam.st.st_size); EXPECT_NE(0, sam.st.st_size); diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc index df07ac6383db..5ccdc49d37d2 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc @@ -178,9 +178,10 @@ static void MapRodata() { char filename[256]; internal_snprintf(filename, sizeof(filename), "%s/tsan.rodata.%u", tmpdir, GetPid()); - fd_t fd = internal_open(filename, O_RDWR | O_CREAT | O_EXCL, 0600); - if (fd == kInvalidFd) + uptr openrv = internal_open(filename, O_RDWR | O_CREAT | O_EXCL, 0600); + if (internal_iserror(openrv)) return; + fd_t fd = openrv; // Fill the file with kShadowRodata. const uptr kMarkerSize = 512 * 1024 / sizeof(u64); InternalScopedBuffer marker(kMarkerSize); @@ -188,9 +189,9 @@ static void MapRodata() { *p = kShadowRodata; internal_write(fd, marker.data(), marker.size()); // Map the file into memory. - void *page = internal_mmap(0, kPageSize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, fd, 0); - if (page == MAP_FAILED) { + uptr page = internal_mmap(0, kPageSize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, fd, 0); + if (internal_iserror(page)) { internal_close(fd); internal_unlink(filename); return; diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc index 1205028e3c38..c51a5669060e 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc @@ -121,10 +121,12 @@ static void BackgroundThread(void *arg) { InternalScopedBuffer filename(4096); internal_snprintf(filename.data(), filename.size(), "%s.%d", flags()->profile_memory, GetPid()); - mprof_fd = OpenFile(filename.data(), true); - if (mprof_fd == kInvalidFd) { + uptr openrv = OpenFile(filename.data(), true); + if (internal_iserror(openrv)) { Printf("ThreadSanitizer: failed to open memory profile file '%s'\n", &filename[0]); + } else { + mprof_fd = openrv; } } diff --git a/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc b/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc index 47fe7b2d4f38..14b6a3acaccd 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc @@ -38,12 +38,13 @@ static char *ReadFile(const char *filename) { internal_snprintf(tmp.data(), tmp.size(), "%s", filename); else internal_snprintf(tmp.data(), tmp.size(), "%s/%s", GetPwd(), filename); - fd_t fd = OpenFile(tmp.data(), false); - if (fd == kInvalidFd) { + uptr openrv = OpenFile(tmp.data(), false); + if (internal_iserror(openrv)) { Printf("ThreadSanitizer: failed to open suppressions file '%s'\n", tmp.data()); Die(); } + fd_t fd = openrv; const uptr fsize = internal_filesize(fd); if (fsize == (uptr)-1) { Printf("ThreadSanitizer: failed to stat suppressions file '%s'\n", -- GitLab From 2703bcaad36340e3d55fe3f9ef00460ab0730ad3 Mon Sep 17 00:00:00 2001 From: Stepan Dyatkovskiy Date: Wed, 8 May 2013 14:51:27 +0000 Subject: [PATCH 017/467] For r181148: fixed warning 'enumeral and non-enumeral type in conditional expression'. llvm-svn: 181437 --- llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 0f7beb1e3b3d..fd7773236423 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -1795,7 +1795,7 @@ ARMTargetLowering::HandleByVal( // else parameter would be splitted between registers and stack, // end register would be r4 in this case. unsigned ByValRegBegin = reg; - unsigned ByValRegEnd = (size < excess) ? reg + size/4 : ARM::R4; + unsigned ByValRegEnd = (size < excess) ? reg + size/4 : (unsigned)ARM::R4; State->addInRegsParamInfo(ByValRegBegin, ByValRegEnd); // Note, first register is allocated in the beginning of function already, // allocate remained amount of registers we need. -- GitLab From cfda517ea8f70edd3f7925f8ad38e2ff0d47c637 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 8 May 2013 14:58:20 +0000 Subject: [PATCH 018/467] Fix formatting of pointers to members. Before: int(S::*func)(void *); After: int (S::*func)(void *); llvm-svn: 181438 --- clang/lib/Format/TokenAnnotator.cpp | 13 ++++++------- clang/lib/Format/TokenAnnotator.h | 5 ++++- clang/unittests/Format/FormatTest.cpp | 17 +++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index c736e9012f66..ab9c8c88597f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -173,6 +173,9 @@ private: } if (CurrentToken->isOneOf(tok::r_square, tok::r_brace)) return false; + if (CurrentToken->Parent->Type == TT_PointerOrReference && + CurrentToken->Parent->Parent->isOneOf(tok::l_paren, tok::coloncolon)) + Left->DefinesFunctionType = true; updateParameterCount(Left, CurrentToken); if (!consumeToken()) return false; @@ -1025,6 +1028,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return Left.FormatTok.Tok.isLiteral() || ((Left.Type != TT_PointerOrReference) && Left.isNot(tok::l_paren) && !Style.PointerBindsToType); + if (Right.DefinesFunctionType && + (Left.Type != TT_PointerOrReference || Style.PointerBindsToType)) + return true; if (Left.Type == TT_PointerOrReference) return Right.FormatTok.Tok.isLiteral() || ((Right.Type != TT_PointerOrReference) && @@ -1091,13 +1097,6 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Tok.is(tok::colon)) return !Line.First.isOneOf(tok::kw_case, tok::kw_default) && Tok.getNextNoneComment() != NULL && Tok.Type != TT_ObjCMethodExpr; - if (Tok.is(tok::l_paren) && !Tok.Children.empty() && - Tok.Children[0].Type == TT_PointerOrReference && - !Tok.Children[0].Children.empty() && - Tok.Children[0].Children[0].isNot(tok::r_paren) && - Tok.Parent->isNot(tok::l_paren) && - (Tok.Parent->Type != TT_PointerOrReference || Style.PointerBindsToType)) - return true; if (Tok.Parent->Type == TT_UnaryOperator || Tok.Parent->Type == TT_CastRParen) return false; if (Tok.Type == TT_UnaryOperator) diff --git a/clang/lib/Format/TokenAnnotator.h b/clang/lib/Format/TokenAnnotator.h index b364082391f8..a2080b5b6f30 100644 --- a/clang/lib/Format/TokenAnnotator.h +++ b/clang/lib/Format/TokenAnnotator.h @@ -75,7 +75,7 @@ public: CanBreakBefore(false), MustBreakBefore(false), ClosesTemplateDeclaration(false), MatchingParen(NULL), ParameterCount(0), BindingStrength(0), SplitPenalty(0), - LongestObjCSelectorName(0), Parent(NULL), + LongestObjCSelectorName(0), DefinesFunctionType(false), Parent(NULL), FakeRParens(0), LastInChainOfCalls(false), PartOfMultiVariableDeclStmt(false), NoMoreTokensOnLevel(false) {} @@ -164,6 +164,9 @@ public: /// definition or call, this contains the length of the longest name. unsigned LongestObjCSelectorName; + /// \brief \c true if this is a "(" that starts a function type definition. + bool DefinesFunctionType; + std::vector Children; AnnotatedToken *Parent; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3a97abe5b20a..715c55fd48bf 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2417,14 +2417,15 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) { TEST_F(FormatTest, UnderstandsPointersToMembers) { verifyFormat("int A::*x;"); - // FIXME: Recognize pointers to member functions. - //verifyFormat("int (S::*func)(void *);"); - verifyFormat("int(S::*func)(void *);"); - verifyFormat("(a->*f)();"); - verifyFormat("a->*x;"); - verifyFormat("(a.*f)();"); - verifyFormat("((*a).*f)();"); - verifyFormat("a.*x;"); + verifyFormat("int (S::*func)(void *);"); + verifyFormat("typedef bool (Class::*Member)() const;"); + verifyFormat("void f() {\n" + " (a->*f)();\n" + " a->*x;\n" + " (a.*f)();\n" + " ((*a).*f)();\n" + " a.*x;\n" + "}"); } TEST_F(FormatTest, UnderstandsUnaryOperators) { -- GitLab From 2f34cacc3b3e06ca8f87154244daf75ef078cf3d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 8 May 2013 15:06:58 +0000 Subject: [PATCH 019/467] Further fix to pointer to member formatting. With style where the *s go with the type: Before: typedef bool* (Class:: *Member)() const; After: typedef bool* (Class::*Member)() const; llvm-svn: 181439 --- clang/lib/Format/TokenAnnotator.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ab9c8c88597f..75b173ef4f46 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1035,7 +1035,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return Right.FormatTok.Tok.isLiteral() || ((Right.Type != TT_PointerOrReference) && Right.isNot(tok::l_paren) && Style.PointerBindsToType && - Left.Parent && Left.Parent->isNot(tok::l_paren)); + Left.Parent && + !Left.Parent->isOneOf(tok::l_paren, tok::coloncolon)); if (Right.is(tok::star) && Left.is(tok::l_paren)) return false; if (Left.is(tok::l_square)) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 715c55fd48bf..9e6a60961bce 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2418,7 +2418,7 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) { TEST_F(FormatTest, UnderstandsPointersToMembers) { verifyFormat("int A::*x;"); verifyFormat("int (S::*func)(void *);"); - verifyFormat("typedef bool (Class::*Member)() const;"); + verifyFormat("typedef bool *(Class::*Member)() const;"); verifyFormat("void f() {\n" " (a->*f)();\n" " a->*x;\n" @@ -2426,6 +2426,9 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) { " ((*a).*f)();\n" " a.*x;\n" "}"); + FormatStyle Style = getLLVMStyle(); + Style.PointerBindsToType = true; + verifyFormat("typedef bool* (Class::*Member)() const;", Style); } TEST_F(FormatTest, UnderstandsUnaryOperators) { -- GitLab From 8e110ce57c8a9a90a2cfd49956337d642b231572 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 8 May 2013 15:07:12 +0000 Subject: [PATCH 020/467] Try to fix the mac buildbots llvm-svn: 181440 --- compiler-rt/lib/sanitizer_common/sanitizer_mac.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc index 8134f894c60e..0181b69e8026 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc @@ -39,18 +39,19 @@ #include #include #include +#include namespace __sanitizer { #include "sanitizer_syscall_generic.inc" // ---------------------- sanitizer_libc.h -void *internal_mmap(void *addr, size_t length, int prot, int flags, - int fd, u64 offset) { - return mmap(addr, length, prot, flags, fd, offset); +uptr internal_mmap(void *addr, size_t length, int prot, int flags, + int fd, u64 offset) { + return (uptr)mmap(addr, length, prot, flags, fd, offset); } -int internal_munmap(void *addr, uptr length) { +uptr internal_munmap(void *addr, uptr length) { return munmap(addr, length); } -- GitLab From 32052b62aea070ffaea723092261054d5b87ec6e Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 15:07:24 +0000 Subject: [PATCH 021/467] Fix rdar-13338477 test-case for Linux. - Using __builtin_trap confuses the stack unwinder - __builtin_trap specific test will be added shortly llvm-svn: 181441 --- .../functionalities/data-formatter/rdar-13338477/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp b/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp index b05c7d4d837a..15fa5614d7fd 100644 --- a/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp +++ b/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// -void bar(int const *foo) { - __builtin_trap(); // Set break point at this line. +bool bar(int const *foo) { + return foo != 0; // Set break point at this line. } int main() { int foo[] = {1,2,3}; - bar(foo); + return bar(foo); } -- GitLab From ee6481273e0fe5bbea2bbf28ea9d352becdd5eb5 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 15:09:30 +0000 Subject: [PATCH 022/467] Adding test-case for llvm.org/pr15936 (known failure with GCC 4.6/4.7) - verify that backtraces for stacks that include functions which contain illegal instructions are correct, and that variables in said functions can be printed. llvm-svn: 181442 --- lldb/test/linux/builtin_trap/Makefile | 5 ++ .../linux/builtin_trap/TestBuiltinTrap.py | 70 +++++++++++++++++++ lldb/test/linux/builtin_trap/main.cpp | 17 +++++ 3 files changed, 92 insertions(+) create mode 100644 lldb/test/linux/builtin_trap/Makefile create mode 100644 lldb/test/linux/builtin_trap/TestBuiltinTrap.py create mode 100644 lldb/test/linux/builtin_trap/main.cpp diff --git a/lldb/test/linux/builtin_trap/Makefile b/lldb/test/linux/builtin_trap/Makefile new file mode 100644 index 000000000000..8a7102e347af --- /dev/null +++ b/lldb/test/linux/builtin_trap/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/lldb/test/linux/builtin_trap/TestBuiltinTrap.py b/lldb/test/linux/builtin_trap/TestBuiltinTrap.py new file mode 100644 index 000000000000..2e807fa507d2 --- /dev/null +++ b/lldb/test/linux/builtin_trap/TestBuiltinTrap.py @@ -0,0 +1,70 @@ +""" +Test lldb ability to unwind a stack with a function containing a call to the +'__builtin_trap' intrinsic, which GCC (4.6) encodes to an illegal opcode. +""" + +import os +import unittest2 +import lldb +from lldbtest import * +import lldbutil + +class BuiltinTrapTestCase(TestBase): + + mydir = os.path.join("linux", "builtin_trap") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @dsym_test + def test_with_dsym_and_run_command(self): + """Test that LLDB handles a function with __builtin_trap correctly.""" + self.buildDsym() + self.builtin_trap_unwind() + + @dwarf_test + @expectedFailureGcc # PR-15936: LLDB is omits a function that contains an + # illegal opcode from backtraces. This + # failure is GCC 4.6 specific. + def test_with_dwarf_and_run_command(self): + """Test that LLDB handles a function with __builtin_trap correctly.""" + self.buildDwarf() + self.builtin_trap_unwind() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.cpp', '// Set break point at this line.') + + def builtin_trap_unwind(self): + """Test that LLDB handles unwinding a frame that contains a function + with a __builtin_trap intrinsic. + """ + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, + num_expected_locations=1, + loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # print backtrace, expect both 'bar' and 'main' functions to be listed + self.expect('bt', substrs = ['bar', 'main']) + + # go up one frame + self.runCmd("up", RUN_SUCCEEDED) + + # evaluate a local + self.expect('p foo', substrs = ['= 5']) + + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/linux/builtin_trap/main.cpp b/lldb/test/linux/builtin_trap/main.cpp new file mode 100644 index 000000000000..84156ef2ac4f --- /dev/null +++ b/lldb/test/linux/builtin_trap/main.cpp @@ -0,0 +1,17 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +void bar(int const *foo) { + __builtin_trap(); // Set break point at this line. +} + +int main() { + int foo = 5; + bar(&foo); +} -- GitLab From 5d3e8a62e01292412badaa6fa7489229f44092b7 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 15:46:04 +0000 Subject: [PATCH 023/467] Remove distinction between Apple/Linux for Process run locks: - Played with the current dual run lock implementation for a few days, noticed no regressions, so enabling in trunk so we see if any problems are detected by buildbots. llvm-svn: 181446 --- lldb/include/lldb/Target/Process.h | 6 ------ lldb/source/Target/Process.cpp | 13 ------------- 2 files changed, 19 deletions(-) diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index dd8ccedade75..9190ec80eef5 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -3507,7 +3507,6 @@ public: ReadWriteLock & GetRunLock () { -#if defined(__APPLE__) // The "m_private_run_lock" causes problems for other platforms // right now, so we are leaving this in for Apple builds only // until we can get the kinks worked out. @@ -3515,9 +3514,6 @@ public: return m_private_run_lock; else return m_public_run_lock; -#else - return m_public_run_lock; -#endif } protected: @@ -3667,9 +3663,7 @@ protected: std::unique_ptr m_next_event_action_ap; std::vector m_pre_resume_actions; ReadWriteLock m_public_run_lock; -#if defined(__APPLE__) ReadWriteLock m_private_run_lock; -#endif Predicate m_currently_handling_event; // This predicate is set in HandlePrivateEvent while all its business is being done. bool m_currently_handling_do_on_removals; bool m_resume_requested; // If m_currently_handling_event or m_currently_handling_do_on_removals are true, Resume will only request a resume, using this flag to check. diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index e5a92c615ac1..93fd93a71de4 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -559,7 +559,6 @@ ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error, shell_command.PutCString ("exec"); -#if defined(__APPLE__) // Only Apple supports /usr/bin/arch being able to specify the architecture if (GetArchitecture().IsValid()) { @@ -577,12 +576,6 @@ ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error, // 2 - then we will stop in our program SetResumeCount(1); } -#else - // Set the resume count to 1: - // 1 - stop in shell - // 2 - then we will stop in our program - SetResumeCount(1); -#endif } if (first_arg_is_full_shell_command) @@ -1038,9 +1031,7 @@ Process::Process(Target &target, Listener &listener) : m_should_detach (false), m_next_event_action_ap(), m_public_run_lock (), -#if defined(__APPLE__) m_private_run_lock (), -#endif m_currently_handling_event(false), m_finalize_called(false), m_last_broadcast_state (eStateInvalid), @@ -1166,10 +1157,8 @@ Process::Finalize() m_private_state_listener.Clear(); m_public_run_lock.WriteTryLock(); // This will do nothing if already locked m_public_run_lock.WriteUnlock(); -#if defined(__APPLE__) m_private_run_lock.WriteTryLock(); // This will do nothing if already locked m_private_run_lock.WriteUnlock(); -#endif m_finalize_called = true; } @@ -1718,7 +1707,6 @@ Process::SetPrivateState (StateType new_state) // the private process state with another run lock. Right now it doesn't // seem like we need to do this, but if we ever do, we can uncomment and // use this code. -#if defined(__APPLE__) const bool old_state_is_stopped = StateIsStoppedState(old_state, false); const bool new_state_is_stopped = StateIsStoppedState(new_state, false); if (old_state_is_stopped != new_state_is_stopped) @@ -1728,7 +1716,6 @@ Process::SetPrivateState (StateType new_state) else m_private_run_lock.WriteLock(); } -#endif if (state_changed) { -- GitLab From 667f12b53d84ccdfdd334c45fba021e710734019 Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Wed, 8 May 2013 16:10:09 +0000 Subject: [PATCH 024/467] Attempt to fix failing watchpoints for debian os buildbot. llvm-svn: 181447 --- lldb/source/Plugins/Process/POSIX/POSIXThread.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp index 8e8f0c0024e0..1d43201a08db 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp @@ -363,6 +363,20 @@ POSIXThread::WatchNotify(const ProcessMessage &message) void POSIXThread::TraceNotify(const ProcessMessage &message) { + RegisterContextPOSIX* reg_ctx = GetRegisterContextPOSIX(); + if (reg_ctx) + { + uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints(); + uint32_t wp_idx; + for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++) + { + if (reg_ctx->IsWatchpointHit(wp_idx)) + { + WatchNotify(message); + return; + } + } + } SetStopInfo (StopInfo::CreateStopReasonToTrace(*this)); } -- GitLab From 52c8476a4705e483f5d260ba5e88aab66cde8a70 Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Wed, 8 May 2013 16:52:34 +0000 Subject: [PATCH 025/467] Fix assertion from previous fix for debian os watchpoints. Also mark one of the tests as expected fail on Linux due to the debian fix. llvm-svn: 181448 --- lldb/source/Plugins/Process/POSIX/ProcessMessage.h | 2 +- .../variable_out_of_scope/TestWatchedVarHitWhenInScope.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Process/POSIX/ProcessMessage.h b/lldb/source/Plugins/Process/POSIX/ProcessMessage.h index 2a4c6121453a..2107e92a1304 100644 --- a/lldb/source/Plugins/Process/POSIX/ProcessMessage.h +++ b/lldb/source/Plugins/Process/POSIX/ProcessMessage.h @@ -149,7 +149,7 @@ public: } lldb::addr_t GetHWAddress() const { - assert(GetKind() == eWatchpointMessage); + assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage); return m_addr; } diff --git a/lldb/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py b/lldb/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py index 6af5f1a8507f..81a1e0b88c7c 100644 --- a/lldb/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py +++ b/lldb/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py @@ -20,7 +20,7 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): # clearer API to express this. # - @expectedFailureDarwin + @unittest2.expectedFailure @dsym_test def test_watched_var_should_only_hit_when_in_scope_with_dsym(self): """Test that a variable watchpoint should only hit when in scope.""" @@ -28,7 +28,7 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): self.setTearDownCleanup(dictionary=self.d) self.watched_var() - @expectedFailureDarwin + @unittest2.expectedFailure @dwarf_test def test_watched_var_should_only_hit_when_in_scope_with_dwarf(self): """Test that a variable watchpoint should only hit when in scope.""" -- GitLab From 38b6cb51bc3b941038863d5cef50f9d9a8b2b3ce Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Wed, 8 May 2013 17:22:33 +0000 Subject: [PATCH 026/467] Fix handling of anonymous aggregate parameters for powerpc*-apple-darwin8. This fixes bug 15821 similarly to the powerpc64-linux fix for bug 14779. Patch by David Fang. llvm-svn: 181449 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 8 +- llvm/test/CodeGen/PowerPC/anon_aggr.ll | 90 +++++++++++++++++++++ 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 3fcafdcbca44..3764b7fac359 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -2600,17 +2600,17 @@ PPCTargetLowering::LowerFormalArguments_Darwin( SmallVector MemOps; unsigned nAltivecParamsAtEnd = 0; - // FIXME: FuncArg and Ins[ArgNo] must reference the same argument. - // When passing anonymous aggregates, this is currently not true. - // See LowerFormalArguments_64SVR4 for a fix. Function::const_arg_iterator FuncArg = MF.getFunction()->arg_begin(); - for (unsigned ArgNo = 0, e = Ins.size(); ArgNo != e; ++ArgNo, ++FuncArg) { + unsigned CurArgIdx = 0; + for (unsigned ArgNo = 0, e = Ins.size(); ArgNo != e; ++ArgNo) { SDValue ArgVal; bool needsLoad = false; EVT ObjectVT = Ins[ArgNo].VT; unsigned ObjSize = ObjectVT.getSizeInBits()/8; unsigned ArgSize = ObjSize; ISD::ArgFlagsTy Flags = Ins[ArgNo].Flags; + std::advance(FuncArg, Ins[ArgNo].OrigArgIndex - CurArgIdx); + CurArgIdx = Ins[ArgNo].OrigArgIndex; unsigned CurArgOffset = ArgOffset; diff --git a/llvm/test/CodeGen/PowerPC/anon_aggr.ll b/llvm/test/CodeGen/PowerPC/anon_aggr.ll index 52587e2c0b87..78c0911ca767 100644 --- a/llvm/test/CodeGen/PowerPC/anon_aggr.ll +++ b/llvm/test/CodeGen/PowerPC/anon_aggr.ll @@ -1,6 +1,9 @@ ; RUN: llc -O0 -mcpu=pwr7 -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -O0 -mcpu=g4 -mtriple=powerpc-apple-darwin8 < %s | FileCheck -check-prefix=DARWIN32 %s +; RUN: llc -O0 -mcpu=ppc970 -mtriple=powerpc64-apple-darwin8 < %s | FileCheck -check-prefix=DARWIN64 %s ; Test case for PR 14779: anonymous aggregates are not handled correctly. +; Darwin bug report PR 15821 is similar. ; The bug is triggered by passing a byval structure after an anonymous ; aggregate. @@ -24,6 +27,26 @@ unequal: ; CHECK: ld 3, -[[OFFSET1]](1) ; CHECK: ld 3, -[[OFFSET2]](1) +; DARWIN32: _func1: +; DARWIN32: mr +; DARWIN32: mr r[[REG1:[0-9]+]], r[[REGA:[0-9]+]] +; DARWIN32: mr r[[REG2:[0-9]+]], r[[REGB:[0-9]+]] +; DARWIN32: cmplw cr{{[0-9]+}}, r[[REGA]], r[[REGB]] +; DARWIN32: stw r[[REG1]], -[[OFFSET1:[0-9]+]] +; DARWIN32: stw r[[REG2]], -[[OFFSET2:[0-9]+]] +; DARWIN32: lwz r3, -[[OFFSET1]] +; DARWIN32: lwz r3, -[[OFFSET2]] + +; DARWIN64: _func1: +; DARWIN64: mr +; DARWIN64: mr r[[REG1:[0-9]+]], r[[REGA:[0-9]+]] +; DARWIN64: mr r[[REG2:[0-9]+]], r[[REGB:[0-9]+]] +; DARWIN64: cmpld cr{{[0-9]+}}, r[[REGA]], r[[REGB]] +; DARWIN64: std r[[REG1]], -[[OFFSET1:[0-9]+]] +; DARWIN64: std r[[REG2]], -[[OFFSET2:[0-9]+]] +; DARWIN64: ld r3, -[[OFFSET1]] +; DARWIN64: ld r3, -[[OFFSET2]] + define i8* @func2({ i64, i8* } %array1, %tarray* byval %array2) { entry: @@ -47,6 +70,29 @@ unequal: ; CHECK: ld 3, -[[OFFSET2]](1) ; CHECK: ld 3, -[[OFFSET1]](1) +; DARWIN32: _func2: +; DARWIN32: addi r[[REG1:[0-9]+]], r[[REGSP:[0-9]+]], 36 +; DARWIN32: lwz r[[REG2:[0-9]+]], 44(r[[REGSP]]) +; DARWIN32: mr +; DARWIN32: mr r[[REG3:[0-9]+]], r[[REGA:[0-9]+]] +; DARWIN32: cmplw cr{{[0-9]+}}, r[[REGA]], r[[REG2]] +; DARWIN32: stw r[[REG3]], -[[OFFSET1:[0-9]+]] +; DARWIN32: stw r[[REG2]], -[[OFFSET2:[0-9]+]] +; DARWIN32: lwz r3, -[[OFFSET1]] +; DARWIN32: lwz r3, -[[OFFSET2]] + +; DARWIN64: _func2: +; DARWIN64: addi r[[REG1:[0-9]+]], r1, 64 +; DARWIN64: ld r[[REG2:[0-9]+]], 8(r[[REG1]]) +; DARWIN64: mr +; DARWIN64: mr r[[REG3:[0-9]+]], r[[REGA:[0-9]+]] +; DARWIN64: cmpld cr{{[0-9]+}}, r[[REGA]], r[[REG2]] +; DARWIN64: std r[[REG3]], -[[OFFSET1:[0-9]+]] +; DARWIN64: std r[[REG2]], -[[OFFSET2:[0-9]+]] +; DARWIN64: ld r3, -[[OFFSET1]] +; DARWIN64: ld r3, -[[OFFSET2]] + + define i8* @func3({ i64, i8* }* byval %array1, %tarray* byval %array2) { entry: %tmp1 = getelementptr inbounds { i64, i8* }* %array1, i32 0, i32 1 @@ -72,6 +118,29 @@ unequal: ; CHECK: ld 3, -[[OFFSET2]](1) ; CHECK: ld 3, -[[OFFSET1]](1) +; DARWIN32: _func3: +; DARWIN32: addi r[[REG1:[0-9]+]], r[[REGSP:[0-9]+]], 40 +; DARWIN32: addi r[[REG2:[0-9]+]], r[[REGSP]], 24 +; DARWIN32: lwz r[[REG3:[0-9]+]], 48(r[[REGSP]]) +; DARWIN32: lwz r[[REG4:[0-9]+]], 32(r[[REGSP]]) +; DARWIN32: cmplw cr{{[0-9]+}}, r[[REG4]], r[[REG3]] +; DARWIN32: stw r[[REG3]], -[[OFFSET1:[0-9]+]] +; DARWIN32: stw r[[REG4]], -[[OFFSET2:[0-9]+]] +; DARWIN32: lwz r3, -[[OFFSET2]] +; DARWIN32: lwz r3, -[[OFFSET1]] + +; DARWIN64: _func3: +; DARWIN64: addi r[[REG1:[0-9]+]], r1, 64 +; DARWIN64: addi r[[REG2:[0-9]+]], r1, 48 +; DARWIN64: ld r[[REG3:[0-9]+]], 8(r[[REG1]]) +; DARWIN64: ld r[[REG4:[0-9]+]], 8(r[[REG2]]) +; DARWIN64: cmpld cr{{[0-9]+}}, r[[REG4]], r[[REG3]] +; DARWIN64: std r[[REG3]], -[[OFFSET1:[0-9]+]] +; DARWIN64: std r[[REG4]], -[[OFFSET2:[0-9]+]] +; DARWIN64: ld r3, -[[OFFSET2]] +; DARWIN64: ld r3, -[[OFFSET1]] + + define i8* @func4(i64 %p1, i64 %p2, i64 %p3, i64 %p4, i64 %p5, i64 %p6, i64 %p7, i64 %p8, { i64, i8* } %array1, %tarray* byval %array2) { @@ -97,3 +166,24 @@ unequal: ; CHECK: ld 3, -[[OFFSET1]](1) ; CHECK: ld 3, -[[OFFSET2]](1) +; DARWIN32: _func4: +; DARWIN32: lwz r[[REG4:[0-9]+]], 96(r1) +; DARWIN32: addi r[[REG1:[0-9]+]], r1, 100 +; DARWIN32: lwz r[[REG3:[0-9]+]], 108(r1) +; DARWIN32: mr r[[REG2:[0-9]+]], r[[REG4]] +; DARWIN32: cmplw cr{{[0-9]+}}, r[[REG4]], r[[REG3]] +; DARWIN32: stw r[[REG4]], -[[OFFSET1:[0-9]+]] +; DARWIN32: stw r[[REG3]], -[[OFFSET2:[0-9]+]] +; DARWIN32: lwz r[[REG1]], -[[OFFSET1]] +; DARWIN32: lwz r[[REG1]], -[[OFFSET2]] + +; DARWIN64: _func4: +; DARWIN64: addi r[[REG1:[0-9]+]], r1, 128 +; DARWIN64: ld r[[REG2:[0-9]+]], 120(r1) +; DARWIN64: ld r[[REG3:[0-9]+]], 8(r[[REG1]]) +; DARWIN64: mr r[[REG4:[0-9]+]], r[[REG2]] +; DARWIN64: cmpld cr{{[0-9]+}}, r[[REG2]], r[[REG3]] +; DARWIN64: std r[[REG4]], -[[OFFSET1:[0-9]+]] +; DARWIN64: std r[[REG3]], -[[OFFSET2:[0-9]+]] +; DARWIN64: ld r3, -[[OFFSET1]] +; DARWIN64: ld r3, -[[OFFSET2]] -- GitLab From e462053f64ba62c9c18d8feb5dfe3ba0c0a136ca Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Wed, 8 May 2013 17:50:07 +0000 Subject: [PATCH 027/467] [PowerPC] Fix regression in generating @ha/@l relocs The patch I committed as revision 167864 introduced a regression that causes LLVM to no longer generate appropriate relocs for @ha/@l symbol references (but fail an assertion instead). This is fixed here by re-enabling support for the VK_PPC_GAS_HA16/ VK_PPC_GAS_LO16 variant kinds (and their Darwin variants) in PPCELFObjectWriter.cpp. Tested by running projects/test-suite in -m32 mode with the integrated assembler forced on. A standalone test case will be committed shortly as well. llvm-svn: 181450 --- .../PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp index 81a86dc5b781..7a84723ed56a 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp @@ -107,7 +107,8 @@ unsigned PPCELFObjectWriter::getRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_PPC_DTPREL16_HA: Type = ELF::R_PPC64_DTPREL16_HA; break; - case MCSymbolRefExpr::VK_None: + case MCSymbolRefExpr::VK_PPC_GAS_HA16: + case MCSymbolRefExpr::VK_PPC_DARWIN_HA16: Type = ELF::R_PPC_ADDR16_HA; break; case MCSymbolRefExpr::VK_PPC_TOC16_HA: @@ -134,6 +135,10 @@ unsigned PPCELFObjectWriter::getRelocTypeInner(const MCValue &Target, Type = ELF::R_PPC64_DTPREL16_LO; break; case MCSymbolRefExpr::VK_None: + Type = ELF::R_PPC_ADDR16; + break; + case MCSymbolRefExpr::VK_PPC_GAS_LO16: + case MCSymbolRefExpr::VK_PPC_DARWIN_LO16: Type = ELF::R_PPC_ADDR16_LO; break; case MCSymbolRefExpr::VK_PPC_TOC_ENTRY: @@ -156,6 +161,10 @@ unsigned PPCELFObjectWriter::getRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_None: Type = ELF::R_PPC64_ADDR16_DS; break; + case MCSymbolRefExpr::VK_PPC_GAS_LO16: + case MCSymbolRefExpr::VK_PPC_DARWIN_LO16: + Type = ELF::R_PPC64_ADDR16_LO_DS; + break; case MCSymbolRefExpr::VK_PPC_TOC_ENTRY: Type = ELF::R_PPC64_TOC16_DS; break; -- GitLab From 81e7bf743ce285528e981df2daa3df3d304a5a16 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Wed, 8 May 2013 17:50:57 +0000 Subject: [PATCH 028/467] [PowerPC] Add some missing PPC64 relocs All R_PPC_... relocs should also be present (using the same number) under the corresponding R_PPC64_... name. The latter were missing for a couple of cases, which this patch adds. This is not a big problem when emitting the reloc, because we can just use the R_PPC_... define instead. But it is a problem when *dumping* relocations e.g. using llvm-readobj, because this will expect only R_PPC64_... values when inspecting a ppc64 ELF file. llvm-svn: 181451 --- llvm/include/llvm/Object/ELF.h | 8 ++++++++ llvm/include/llvm/Support/ELF.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index eb2390ab5d4c..e554f4a45fc2 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -2069,10 +2069,18 @@ StringRef ELFObjectFile::getRelocationTypeName(uint32_t Type) const { switch (Type) { LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_NONE); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR24); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_LO); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HI); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HA); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR14); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR14_BRTAKEN); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR14_BRNTAKEN); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL24); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14_BRTAKEN); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14_BRNTAKEN); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL32); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR64); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHER); diff --git a/llvm/include/llvm/Support/ELF.h b/llvm/include/llvm/Support/ELF.h index c46dfebd3795..bf5a650e6225 100644 --- a/llvm/include/llvm/Support/ELF.h +++ b/llvm/include/llvm/Support/ELF.h @@ -468,10 +468,18 @@ enum { enum { R_PPC64_NONE = 0, R_PPC64_ADDR32 = 1, + R_PPC64_ADDR24 = 2, + R_PPC64_ADDR16 = 3, R_PPC64_ADDR16_LO = 4, R_PPC64_ADDR16_HI = 5, + R_PPC64_ADDR16_HA = 6, R_PPC64_ADDR14 = 7, + R_PPC64_ADDR14_BRTAKEN = 8, + R_PPC64_ADDR14_BRNTAKEN = 9, R_PPC64_REL24 = 10, + R_PPC64_REL14 = 11, + R_PPC64_REL14_BRTAKEN = 12, + R_PPC64_REL14_BRNTAKEN = 13, R_PPC64_REL32 = 26, R_PPC64_ADDR64 = 38, R_PPC64_ADDR16_HIGHER = 39, -- GitLab From 2d26e8e56b0ba9bd32fa95bde24d8a61b643b8ef Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Wed, 8 May 2013 17:51:39 +0000 Subject: [PATCH 029/467] Remove unused isLegalAddressImmediate() method. llvm-svn: 181452 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 12 ------------ llvm/lib/Target/PowerPC/PPCISelLowering.h | 9 --------- 2 files changed, 21 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 3764b7fac359..3819bc8f15c4 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -7406,18 +7406,6 @@ bool PPCTargetLowering::isLegalAddressingMode(const AddrMode &AM, return true; } -/// isLegalAddressImmediate - Return true if the integer value can be used -/// as the offset of the target addressing mode for load / store of the -/// given type. -bool PPCTargetLowering::isLegalAddressImmediate(int64_t V,Type *Ty) const{ - // PPC allows a sign-extended 16-bit immediate field. - return (V > -(1 << 16) && V < (1 << 16)-1); -} - -bool PPCTargetLowering::isLegalAddressImmediate(GlobalValue* GV) const { - return false; -} - SDValue PPCTargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.h b/llvm/lib/Target/PowerPC/PPCISelLowering.h index 423e9839807b..b219de38d5d4 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.h +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.h @@ -436,15 +436,6 @@ namespace llvm { /// by AM is legal for this target, for a load/store of the specified type. virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty)const; - /// isLegalAddressImmediate - Return true if the integer value can be used - /// as the offset of the target addressing mode for load / store of the - /// given type. - virtual bool isLegalAddressImmediate(int64_t V, Type *Ty) const; - - /// isLegalAddressImmediate - Return true if the GlobalValue can be used as - /// the offset of the target addressing mode. - virtual bool isLegalAddressImmediate(GlobalValue *GV) const; - virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; /// getOptimalMemOpType - Returns the target specific optimal type for load -- GitLab From 689e34a82435093d0592bdf0c10cc64a35c210bc Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Wed, 8 May 2013 17:51:44 +0000 Subject: [PATCH 030/467] [PowerPC] Add ELF relocation tests This patch extends test/MC/PowerPC/ppc64-fixups.s to not only check for the correct fixup type in the --show-encoding output, but also runs the generated object file through llvm-readobj -r and verifies that the correct ELF relocation records were generated. llvm-svn: 181453 --- llvm/test/MC/PowerPC/ppc64-fixups.s | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/llvm/test/MC/PowerPC/ppc64-fixups.s b/llvm/test/MC/PowerPC/ppc64-fixups.s index 1dcbca8f8189..281dce3f9e7d 100644 --- a/llvm/test/MC/PowerPC/ppc64-fixups.s +++ b/llvm/test/MC/PowerPC/ppc64-fixups.s @@ -1,50 +1,65 @@ # RUN: llvm-mc -triple powerpc64-unknown-unknown --show-encoding %s | FileCheck %s +# RUN: llvm-mc -triple powerpc64-unknown-unknown -filetype=obj %s | \ +# RUN: llvm-readobj -r | FileCheck %s -check-prefix=REL + + # FIXME: .TOC.@tocbase # CHECK: li 3, target@l # encoding: [0x38,0x60,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_ADDR16_LO target 0x0 li 3, target@l # CHECK: addis 3, 3, target@ha # encoding: [0x3c,0x63,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_ADDR16_HA target 0x0 addis 3, 3, target@ha # CHECK: lis 3, target@ha # encoding: [0x3c,0x60,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_ADDR16_HA target 0x0 lis 3, target@ha # CHECK: addi 4, 3, target@l # encoding: [0x38,0x83,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_ADDR16_LO target 0x0 addi 4, 3, target@l # CHECK: lwz 1, target@l(3) # encoding: [0x80,0x23,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_ADDR16_LO target 0x0 lwz 1, target@l(3) # CHECK: ld 1, target@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00] # CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16_ds +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_ADDR16_LO_DS target 0x0 ld 1, target@l(3) # CHECK: ld 1, target@toc(2) # encoding: [0xe8,0x22,A,0bAAAAAA00] # CHECK-NEXT: # fixup A - offset: 0, value: target@toc, kind: fixup_ppc_lo16_ds +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TOC16_DS target 0x0 ld 1, target@toc(2) # CHECK: addis 3, 2, target@toc@ha # encoding: [0x3c,0x62,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@toc@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TOC16_HA target 0x0 addis 3, 2, target@toc@ha # CHECK: addi 4, 3, target@toc@l # encoding: [0x38,0x83,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@toc@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TOC16_LO target 0x0 addi 4, 3, target@toc@l # CHECK: lwz 1, target@toc@l(3) # encoding: [0x80,0x23,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@toc@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TOC16_LO target 0x0 lwz 1, target@toc@l(3) # CHECK: ld 1, target@toc@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00] # CHECK-NEXT: # fixup A - offset: 0, value: target@toc@l, kind: fixup_ppc_lo16_ds +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TOC16_LO_DS target 0x0 ld 1, target@toc@l(3) # FIXME: @tls @@ -52,44 +67,54 @@ # CHECK: addis 3, 2, target@tprel@ha # encoding: [0x3c,0x62,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@tprel@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TPREL16_HA target 0x0 addis 3, 2, target@tprel@ha # CHECK: addi 3, 3, target@tprel@l # encoding: [0x38,0x63,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@tprel@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_TPREL16_LO target 0x0 addi 3, 3, target@tprel@l # CHECK: addis 3, 2, target@dtprel@ha # encoding: [0x3c,0x62,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@dtprel@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_DTPREL16_HA target 0x0 addis 3, 2, target@dtprel@ha # CHECK: addi 3, 3, target@dtprel@l # encoding: [0x38,0x63,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@dtprel@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_DTPREL16_LO target 0x0 addi 3, 3, target@dtprel@l # CHECK: addis 3, 2, target@got@tprel@ha # encoding: [0x3c,0x62,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@got@tprel@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_GOT_TPREL16_HA target 0x0 addis 3, 2, target@got@tprel@ha # CHECK: ld 1, target@got@tprel@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00] # CHECK-NEXT: # fixup A - offset: 0, value: target@got@tprel@l, kind: fixup_ppc_lo16_ds +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_GOT_TPREL16_LO_DS target 0x0 ld 1, target@got@tprel@l(3) # CHECK: addis 3, 2, target@got@tlsgd@ha # encoding: [0x3c,0x62,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsgd@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_GOT_TLSGD16_HA target 0x0 addis 3, 2, target@got@tlsgd@ha # CHECK: addi 3, 3, target@got@tlsgd@l # encoding: [0x38,0x63,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsgd@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_GOT_TLSGD16_LO target 0x0 addi 3, 3, target@got@tlsgd@l # CHECK: addis 3, 2, target@got@tlsld@ha # encoding: [0x3c,0x62,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsld@ha, kind: fixup_ppc_ha16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_GOT_TLSLD16_HA target 0x0 addis 3, 2, target@got@tlsld@ha # CHECK: addi 3, 3, target@got@tlsld@l # encoding: [0x38,0x63,A,A] # CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsld@l, kind: fixup_ppc_lo16 +# CHECK-REL: 0x{{[0-9,A-F]+}} R_PPC64_GOT_TLSLD16_LO target 0x0 addi 3, 3, target@got@tlsld@l -- GitLab From 4fadea28d1742e575f6fc5d2f563a87b4369dadf Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Wed, 8 May 2013 17:52:17 +0000 Subject: [PATCH 031/467] Mark multi-threaded watchpoint test as skip on Linux due to lldb assertions in the debian buildbot. llvm-svn: 181454 --- .../multiple_threads/TestWatchpointMultipleThreads.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py b/lldb/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py index 48c8d5af7bfa..7eced9dfcd3e 100644 --- a/lldb/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py +++ b/lldb/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py @@ -21,7 +21,7 @@ class WatchpointForMultipleThreadsTestCase(TestBase): self.setTearDownCleanup(dictionary=self.d) self.hello_multiple_threads() - @expectedFailureLinux # bugzilla 14416 + @skipOnLinux # bugzilla 14323 - skip due to incomplete multi-threaded debug support @dwarf_test def test_watchpoint_multiple_threads_with_dwarf(self): """Test that lldb watchpoint works for multiple threads.""" @@ -37,7 +37,7 @@ class WatchpointForMultipleThreadsTestCase(TestBase): self.setTearDownCleanup(dictionary=self.d) self.hello_multiple_threads_wp_set_and_then_delete() - @expectedFailureLinux # bugzilla 14416 + @skipOnLinux # bugzilla 14323 - skip due to incomplete multi-threaded debug support @dwarf_test def test_watchpoint_multiple_threads_wp_set_and_then_delete_with_dwarf(self): """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires.""" -- GitLab From 53caf563a9934088d39b008bd9b0de6adcc003c7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 8 May 2013 18:15:01 +0000 Subject: [PATCH 032/467] Try to fix Windows build too llvm-svn: 181457 --- compiler-rt/lib/sanitizer_common/sanitizer_win.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc index ab0d78dc45d7..b826cb2f4287 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc @@ -210,12 +210,12 @@ int Atexit(void (*function)(void)) { #endif // ------------------ sanitizer_libc.h -void *internal_mmap(void *addr, uptr length, int prot, int flags, - int fd, u64 offset) { +uptr internal_mmap(void *addr, uptr length, int prot, int flags, + int fd, u64 offset) { UNIMPLEMENTED(); } -int internal_munmap(void *addr, uptr length) { +uptr internal_munmap(void *addr, uptr length) { UNIMPLEMENTED(); } @@ -227,11 +227,11 @@ int internal_isatty(fd_t fd) { return _isatty(fd); } -fd_t internal_open(const char *filename, int flags) { +uptr internal_open(const char *filename, int flags) { UNIMPLEMENTED(); } -fd_t internal_open(const char *filename, int flags, u32 mode) { +uptr internal_open(const char *filename, int flags, u32 mode) { UNIMPLEMENTED(); } -- GitLab From 6c7a16666dbba49b9ef41c28ff7cbddf3e250213 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 8 May 2013 19:21:00 +0000 Subject: [PATCH 033/467] documentation parsing. Patch to do typo correction for documentation commands. Patch was reviewed, along with great suggestions for improvement, by Doug. // rdar://12381408 llvm-svn: 181458 --- .../include/clang/AST/CommentCommandTraits.h | 2 ++ .../clang/Basic/DiagnosticCommentKinds.td | 4 +++ clang/lib/AST/CommentCommandTraits.cpp | 27 +++++++++++++++++++ clang/lib/AST/CommentLexer.cpp | 14 ++++++++-- clang/test/Sema/warn-documentation-fixits.cpp | 8 +++++- 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/CommentCommandTraits.h b/clang/include/clang/AST/CommentCommandTraits.h index d1f5209d1eef..629329dc1bf9 100644 --- a/clang/include/clang/AST/CommentCommandTraits.h +++ b/clang/include/clang/AST/CommentCommandTraits.h @@ -142,6 +142,8 @@ public: llvm_unreachable("the command should be known"); } + const CommandInfo *getTypoCorrectCommandInfo(StringRef Typo) const; + const CommandInfo *getCommandInfo(unsigned CommandID) const; const CommandInfo *registerUnknownCommand(StringRef CommandName); diff --git a/clang/include/clang/Basic/DiagnosticCommentKinds.td b/clang/include/clang/Basic/DiagnosticCommentKinds.td index 3df03cdb3315..4619e8a6b0b7 100644 --- a/clang/include/clang/Basic/DiagnosticCommentKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommentKinds.td @@ -159,5 +159,9 @@ def warn_verbatim_block_end_without_start : Warning< def warn_unknown_comment_command_name : Warning< "unknown command tag name">, InGroup, DefaultIgnore; +def warn_correct_comment_command_name : Warning< + "unknown command tag name '%0'; did you mean '%1'?">, + InGroup; + } // end of documentation issue category } // end of AST component diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp index e24d542c9623..e4cc84afb78e 100644 --- a/clang/lib/AST/CommentCommandTraits.cpp +++ b/clang/lib/AST/CommentCommandTraits.cpp @@ -43,6 +43,33 @@ const CommandInfo *CommandTraits::getCommandInfo(unsigned CommandID) const { return getRegisteredCommandInfo(CommandID); } +const CommandInfo * +CommandTraits::getTypoCorrectCommandInfo(StringRef Typo) const { + const unsigned MaxEditDistance = 1; + unsigned BestEditDistance = MaxEditDistance + 1; + SmallVector BestCommand; + + int NumOfCommands = sizeof(Commands) / sizeof(CommandInfo); + for (int i = 0; i < NumOfCommands; i++) { + StringRef Name = Commands[i].Name; + unsigned MinPossibleEditDistance = abs((int)Name.size() - (int)Typo.size()); + if (MinPossibleEditDistance > 0 && + Typo.size() / MinPossibleEditDistance < 1) + continue; + unsigned EditDistance = Typo.edit_distance(Name, true, MaxEditDistance); + if (EditDistance > MaxEditDistance) + continue; + if (EditDistance == BestEditDistance) + BestCommand.push_back(&Commands[i]); + else if (EditDistance < BestEditDistance) { + BestCommand.clear(); + BestCommand.push_back(&Commands[i]); + BestEditDistance = EditDistance; + } + } + return (BestCommand.size() != 1) ? NULL : BestCommand[0]; +} + CommandInfo *CommandTraits::createCommandInfoWithName(StringRef CommandName) { char *Name = Allocator.Allocate(CommandName.size() + 1); memcpy(Name, CommandName.data(), CommandName.size()); diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp index 70410d61085d..a59badaeaf11 100644 --- a/clang/lib/AST/CommentLexer.cpp +++ b/clang/lib/AST/CommentLexer.cpp @@ -265,6 +265,7 @@ const char *findCCommentEnd(const char *BufferPtr, const char *BufferEnd) { } llvm_unreachable("buffer end hit before '*/' was seen"); } + } // unnamed namespace void Lexer::lexCommentText(Token &T) { @@ -354,8 +355,17 @@ void Lexer::lexCommentText(Token &T) { if (!Info) { formTokenWithChars(T, TokenPtr, tok::unknown_command); T.setUnknownCommandName(CommandName); - Diag(T.getLocation(), diag::warn_unknown_comment_command_name); - return; + if (Info = Traits.getTypoCorrectCommandInfo(CommandName)) { + StringRef CorrectedName = Info->Name; + SourceRange CommandRange(T.getLocation().getLocWithOffset(1), + T.getEndLocation()); + Diag(T.getLocation(), diag::warn_correct_comment_command_name) + << CommandName << CorrectedName + << FixItHint::CreateReplacement(CommandRange, CorrectedName); + } else { + Diag(T.getLocation(), diag::warn_unknown_comment_command_name); + return; + } } if (Info->IsVerbatimBlockCommand) { setupAndLexVerbatimBlock(T, TokenPtr, *BufferPtr, Info); diff --git a/clang/test/Sema/warn-documentation-fixits.cpp b/clang/test/Sema/warn-documentation-fixits.cpp index a47b77637506..79bf7698a91e 100644 --- a/clang/test/Sema/warn-documentation-fixits.cpp +++ b/clang/test/Sema/warn-documentation-fixits.cpp @@ -57,6 +57,12 @@ struct test_deprecated_6 { /// \deprecated void test_deprecated_9(int a); +// rdar://12381408 +// expected-warning@+2 {{unknown command tag name 'retur'; did you mean 'return'?}} +/// \brief testing fixit +/// \retur int in FooBar +int FooBar(); + // CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a" // CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa" // CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T" @@ -68,4 +74,4 @@ void test_deprecated_9(int a); // CHECK: fix-it:"{{.*}}":{46:27-46:27}:" __attribute__((deprecated))" // CHECK: fix-it:"{{.*}}":{50:27-50:27}:" __attribute__((deprecated))" // CHECK: fix-it:"{{.*}}":{58:30-58:30}:" MY_ATTR_DEPRECATED" - +// CHECK: fix-it:"{{.*}}":{63:6-63:11}:"return" -- GitLab From b4526ea132420aede87ed1bb511a03537e2f907b Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Wed, 8 May 2013 19:38:04 +0000 Subject: [PATCH 034/467] [mips] Add instruction selection pattern for (seteq $LHS, 0). llvm-svn: 181459 --- llvm/lib/Target/Mips/MipsInstrInfo.td | 2 ++ llvm/test/CodeGen/Mips/setcc-se.ll | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 llvm/test/CodeGen/Mips/setcc-se.ll diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td index 86ec72982b33..3d319373fe4d 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MipsInstrInfo.td @@ -1263,6 +1263,8 @@ defm : BrcondPats; // setcc patterns multiclass SeteqPats { + def : MipsPat<(seteq RC:$lhs, 0), + (SLTiuOp RC:$lhs, 1)>; def : MipsPat<(seteq RC:$lhs, RC:$rhs), (SLTiuOp (XOROp RC:$lhs, RC:$rhs), 1)>; def : MipsPat<(setne RC:$lhs, RC:$rhs), diff --git a/llvm/test/CodeGen/Mips/setcc-se.ll b/llvm/test/CodeGen/Mips/setcc-se.ll new file mode 100644 index 000000000000..6679536164b5 --- /dev/null +++ b/llvm/test/CodeGen/Mips/setcc-se.ll @@ -0,0 +1,11 @@ +; RUN: llc -march=mipsel < %s | FileCheck %s + +; CHECK: seteq0: +; CHECK: sltiu ${{[0-9]+}}, $4, 1 + +define i32 @seteq0(i32 %a) { +entry: + %cmp = icmp eq i32 %a, 0 + %conv = zext i1 %cmp to i32 + ret i32 %conv +} -- GitLab From 23f23f4b7a5a84688c63280115523a0109192b9c Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Wed, 8 May 2013 19:45:07 +0000 Subject: [PATCH 035/467] Update lldb status page to reflect watchpoint support on Linux. llvm-svn: 181460 --- lldb/www/status.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/www/status.html b/lldb/www/status.html index c648e09dedda..db2cd999d916 100755 --- a/lldb/www/status.html +++ b/lldb/www/status.html @@ -146,7 +146,7 @@ Watchpoints - Broken + OK OK -- GitLab From e1432cfe4cee7483ce7b48fc50c3c9293b126ff5 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 8 May 2013 20:25:10 +0000 Subject: [PATCH 036/467] Improvements to the package importing feature - test case will follow llvm-svn: 181461 --- .../Interpreter/ScriptInterpreterPython.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 3206154224ba..5a4fa625a0af 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2602,13 +2602,23 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, Locker::AcquireLock | (init_session ? Locker::InitSession : 0), Locker::FreeAcquiredLock | (init_session ? Locker::TearDownSession : 0)); - if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || - target_file.GetFileType() == FileSpec::eFileTypeUnknown || - target_file.GetFileType() == FileSpec::eFileTypeDirectory ) + if (target_file.GetFileType() == FileSpec::eFileTypeDirectory) { - // if not a filename, try to just plain import + // for directories, just import basename = pathname; } + else if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || + target_file.GetFileType() == FileSpec::eFileTypeUnknown) + { + // if not a valid file of any sort, check if it might be a filename still + // dot can't be used but / and \ can, and if either is found, reject + if (strchr(pathname,'\\') || strchr(pathname,'/')) + { + error.SetErrorString("invalid pathname"); + return false; + } + basename = pathname; // not a filename, probably a package of some sort, let it go through + } else { const char* directory = target_file.GetDirectory().GetCString(); -- GitLab From cc7f9bf51e79fb33bd1d3af90234ff80ad6ffc8a Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 8 May 2013 20:27:37 +0000 Subject: [PATCH 037/467] This commit changes the ${function.name-with-args} prompt keyword to also tackle structs Previously, since aggregates have no values, this would show up as foo=(null) This checkin changes that to instead print foo=(Foo at 0x123) (i.e. typename at address) There are other potential choices here (summary, one-liner printout of all members, ...) and I would love to hear feedback about better options, if any llvm-svn: 181462 --- lldb/include/lldb/Symbol/VariableList.h | 5 +++++ lldb/source/Core/Debugger.cpp | 18 +++++++----------- lldb/source/Symbol/VariableList.cpp | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h index a5189d261202..2ce6146f4627 100644 --- a/lldb/include/lldb/Symbol/VariableList.h +++ b/lldb/include/lldb/Symbol/VariableList.h @@ -62,6 +62,11 @@ public: AppendVariablesIfUnique (const RegularExpression& regex, VariableList &var_list, size_t& total_matches); + + size_t + AppendVariablesWithScope (lldb::ValueType type, + VariableList &var_list, + bool if_unique = true); uint32_t FindIndexForVariable (Variable* variable); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 89c82ea76a5a..9e6fc2369deb 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2251,16 +2251,7 @@ Debugger::FormatPrompt VariableList args; if (variable_list_sp) - { - const size_t num_variables = variable_list_sp->GetSize(); - for (size_t var_idx = 0; var_idx < num_variables; ++var_idx) - { - VariableSP var_sp (variable_list_sp->GetVariableAtIndex(var_idx)); - if (var_sp->GetScope() == eValueTypeVariableArgument) - args.AddVariable (var_sp); - } - - } + variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args); if (args.GetSize() > 0) { const char *open_paren = strchr (cstr, '('); @@ -2294,7 +2285,12 @@ Debugger::FormatPrompt if (arg_idx > 0) s.PutCString (", "); if (var_value_sp->GetError().Success()) - s.Printf ("%s=%s", var_name, var_value); + { + if (var_value) + s.Printf ("%s=%s", var_name, var_value); + else + s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString()); + } else s.Printf ("%s=", var_name); } diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp index b34ea3a42c93..3451166e52d4 100644 --- a/lldb/source/Symbol/VariableList.cpp +++ b/lldb/source/Symbol/VariableList.cpp @@ -134,6 +134,27 @@ VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableL return var_list.GetSize() - initial_size; } +size_t +VariableList::AppendVariablesWithScope (lldb::ValueType type, + VariableList &var_list, + bool if_unique) +{ + const size_t initial_size = var_list.GetSize(); + iterator pos, end = m_variables.end(); + for (pos = m_variables.begin(); pos != end; ++pos) + { + if ((*pos)->GetScope() == type) + { + if (if_unique) + var_list.AddVariableIfUnique (*pos); + else + var_list.AddVariable(*pos); + } + } + // Return the number of new unique variables added to "var_list" + return var_list.GetSize() - initial_size; +} + uint32_t VariableList::FindIndexForVariable (Variable* variable) { -- GitLab From f83beab4bd56214f1fdb45a566feec3dc39ab7b6 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 20:29:10 +0000 Subject: [PATCH 038/467] Add line tracking support to FormattedStream - previously formatted_raw_ostream tracked columns, now it tracks lines too - used by (upcoming) DebugIR pass to know the line number to connect to each IR instruction llvm-svn: 181463 --- llvm/include/llvm/Support/FormattedStream.h | 26 +++++++----- llvm/lib/Support/FormattedStream.cpp | 45 ++++++++++++--------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/llvm/include/llvm/Support/FormattedStream.h b/llvm/include/llvm/Support/FormattedStream.h index 2e4bd5aeca2d..18ee04839695 100644 --- a/llvm/include/llvm/Support/FormattedStream.h +++ b/llvm/include/llvm/Support/FormattedStream.h @@ -16,11 +16,13 @@ #define LLVM_SUPPORT_FORMATTEDSTREAM_H #include "llvm/Support/raw_ostream.h" +#include namespace llvm { /// formatted_raw_ostream - A raw_ostream that wraps another one and keeps track -/// of column position, allowing padding out to specific column boundaries. +/// of line and column position, allowing padding out to specific column +/// boundaries and querying the number of lines written to the stream. /// class formatted_raw_ostream : public raw_ostream { public: @@ -44,11 +46,11 @@ private: /// bool DeleteStream; - /// ColumnScanned - The current output column of the data that's + /// Position - The current output column and line of the data that's /// been flushed and the portion of the buffer that's been - /// scanned. The column scheme is zero-based. + /// scanned. The line and column scheme is zero-based. /// - unsigned ColumnScanned; + std::pair Position; /// Scanned - This points to one past the last character in the /// buffer we've scanned. @@ -66,10 +68,10 @@ private: return TheStream->tell(); } - /// ComputeColumn - Examine the given output buffer and figure out which - /// column we end up in after output. + /// ComputePosition - Examine the given output buffer and figure out the new + /// position after output. /// - void ComputeColumn(const char *Ptr, size_t size); + void ComputePosition(const char *Ptr, size_t size); public: /// formatted_raw_ostream - Open the specified file for @@ -83,11 +85,11 @@ public: /// underneath it. /// formatted_raw_ostream(raw_ostream &Stream, bool Delete = false) - : raw_ostream(), TheStream(0), DeleteStream(false), ColumnScanned(0) { + : raw_ostream(), TheStream(0), DeleteStream(false), Position(0, 0) { setStream(Stream, Delete); } explicit formatted_raw_ostream() - : raw_ostream(), TheStream(0), DeleteStream(false), ColumnScanned(0) { + : raw_ostream(), TheStream(0), DeleteStream(false), Position(0, 0) { Scanned = 0; } @@ -122,6 +124,12 @@ public: /// \param NewCol - The column to move to. formatted_raw_ostream &PadToColumn(unsigned NewCol); + /// getColumn - Return the column number + unsigned getColumn() { return Position.first; } + + /// getLine - Return the line number + unsigned getLine() { return Position.second; } + private: void releaseStream() { // Delete the stream if needed. Otherwise, transfer the buffer diff --git a/llvm/lib/Support/FormattedStream.cpp b/llvm/lib/Support/FormattedStream.cpp index 231ae48759e2..9febf664f2be 100644 --- a/llvm/lib/Support/FormattedStream.cpp +++ b/llvm/lib/Support/FormattedStream.cpp @@ -17,38 +17,43 @@ using namespace llvm; -/// CountColumns - Examine the given char sequence and figure out which -/// column we end up in after output. +/// UpdatePosition - Examine the given char sequence and figure out which +/// column we end up in after output, and how many line breaks are contained. /// -static unsigned CountColumns(unsigned Column, const char *Ptr, size_t Size) { - // Keep track of the current column by scanning the string for - // special characters +static void UpdatePosition(std::pair &Position, const char *Ptr, size_t Size) { + unsigned &Column = Position.first; + unsigned &Line = Position.second; + // Keep track of the current column and line by scanning the string for + // special characters for (const char *End = Ptr + Size; Ptr != End; ++Ptr) { ++Column; - if (*Ptr == '\n' || *Ptr == '\r') + switch (*Ptr) { + case '\n': + Line += 1; + case '\r': Column = 0; - else if (*Ptr == '\t') + break; + case '\t': // Assumes tab stop = 8 characters. Column += (8 - (Column & 0x7)) & 0x7; + break; + } } - - return Column; } -/// ComputeColumn - Examine the current output and figure out which -/// column we end up in after output. -void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) { +/// ComputePosition - Examine the current output and update line and column +/// counts. +void formatted_raw_ostream::ComputePosition(const char *Ptr, size_t Size) { // If our previous scan pointer is inside the buffer, assume we already // scanned those bytes. This depends on raw_ostream to not change our buffer // in unexpected ways. - if (Ptr <= Scanned && Scanned <= Ptr + Size) { + if (Ptr <= Scanned && Scanned <= Ptr + Size) // Scan all characters added since our last scan to determine the new // column. - ColumnScanned = CountColumns(ColumnScanned, Scanned, - Size - (Scanned - Ptr)); - } else - ColumnScanned = CountColumns(ColumnScanned, Ptr, Size); + UpdatePosition(Position, Scanned, Size - (Scanned - Ptr)); + else + UpdatePosition(Position, Ptr, Size); // Update the scanning pointer. Scanned = Ptr + Size; @@ -60,16 +65,16 @@ void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) { /// formatted_raw_ostream &formatted_raw_ostream::PadToColumn(unsigned NewCol) { // Figure out what's in the buffer and add it to the column count. - ComputeColumn(getBufferStart(), GetNumBytesInBuffer()); + ComputePosition(getBufferStart(), GetNumBytesInBuffer()); // Output spaces until we reach the desired column. - indent(std::max(int(NewCol - ColumnScanned), 1)); + indent(std::max(int(NewCol - getColumn()), 1)); return *this; } void formatted_raw_ostream::write_impl(const char *Ptr, size_t Size) { // Figure out what's in the buffer and add it to the column count. - ComputeColumn(Ptr, Size); + ComputePosition(Ptr, Size); // Write the data to the underlying stream (which is unbuffered, so // the data will be immediately written out). -- GitLab From ebb262f79c376a7b54b3db6a76f30cd46ade4c13 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 8 May 2013 20:29:57 +0000 Subject: [PATCH 039/467] Turn off a warning caused by my last patch. llvm-svn: 181464 --- clang/lib/AST/CommentLexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp index a59badaeaf11..b195d52e8ef1 100644 --- a/clang/lib/AST/CommentLexer.cpp +++ b/clang/lib/AST/CommentLexer.cpp @@ -355,7 +355,7 @@ void Lexer::lexCommentText(Token &T) { if (!Info) { formTokenWithChars(T, TokenPtr, tok::unknown_command); T.setUnknownCommandName(CommandName); - if (Info = Traits.getTypoCorrectCommandInfo(CommandName)) { + if ((Info = Traits.getTypoCorrectCommandInfo(CommandName))) { StringRef CorrectedName = Info->Name; SourceRange CommandRange(T.getLocation().getLocWithOffset(1), T.getEndLocation()); -- GitLab From 469a74772a78c23294c8c7daa8a0c45bbd420714 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 8 May 2013 20:32:14 +0000 Subject: [PATCH 040/467] Add missing triple to unit test. llvm-svn: 181465 --- clang/test/CodeGenCXX/throw-expressions.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/test/CodeGenCXX/throw-expressions.cpp b/clang/test/CodeGenCXX/throw-expressions.cpp index 22d784106527..ba8a86881a63 100644 --- a/clang/test/CodeGenCXX/throw-expressions.cpp +++ b/clang/test/CodeGenCXX/throw-expressions.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -Wno-unreachable-code -Werror -emit-llvm -o - %s | FileCheck %s -// expected-no-diagnostics +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -Wno-unreachable-code -Werror -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s int val = 42; int& test1() { -- GitLab From ded9f932489936c8342590c2570ff28d93ba42af Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 20:38:31 +0000 Subject: [PATCH 041/467] Pull up AssemblyWriter interface into header to allow subclassing - made all functions virtual so that subclasses can specialize them - add printInstructionLine so that subclasses can choose whether or not to print the newline character (without having to implement printBasicBlock() - added a second constructor to AssemblyWriter that does not require a SlotTracker, as required in order to keep the SlotTracker helper class outside AsmWriter.h and buried in the implementation. llvm-svn: 181466 --- llvm/include/llvm/IR/AsmWriter.h | 118 +++++++++++++++++++++++++++++ llvm/lib/IR/AsmWriter.cpp | 126 +++++++++++-------------------- 2 files changed, 160 insertions(+), 84 deletions(-) create mode 100644 llvm/include/llvm/IR/AsmWriter.h diff --git a/llvm/include/llvm/IR/AsmWriter.h b/llvm/include/llvm/IR/AsmWriter.h new file mode 100644 index 000000000000..aac7975ee682 --- /dev/null +++ b/llvm/include/llvm/IR/AsmWriter.h @@ -0,0 +1,118 @@ +//===-- llvm/IR/AsmWriter.h - Printing LLVM IR as an assembly file - C++ --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This files defines the interface for the AssemblyWriter class used to print +// LLVM IR and various helper classes that are used in printing. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_IR_ASSEMBLYWRITER_H +#define LLVM_IR_ASSEMBLYWRITER_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/OwningPtr.h" +#include "llvm/IR/Attributes.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/TypeFinder.h" +#include "llvm/Support/FormattedStream.h" + +namespace llvm { + +class BasicBlock; +class Function; +class GlobalValue; +class Module; +class NamedMDNode; +class Value; +class SlotTracker; + +/// Create a new SlotTracker for a Module +SlotTracker *createSlotTracker(const Module *M); + +//===----------------------------------------------------------------------===// +// TypePrinting Class: Type printing machinery +//===----------------------------------------------------------------------===// + +class TypePrinting { + TypePrinting(const TypePrinting &) LLVM_DELETED_FUNCTION; + void operator=(const TypePrinting&) LLVM_DELETED_FUNCTION; +public: + + /// NamedTypes - The named types that are used by the current module. + TypeFinder NamedTypes; + + /// NumberedTypes - The numbered types, along with their value. + DenseMap NumberedTypes; + + + TypePrinting() {} + ~TypePrinting() {} + + void incorporateTypes(const Module &M); + + void print(Type *Ty, raw_ostream &OS); + + void printStructBody(StructType *Ty, raw_ostream &OS); +}; + +class AssemblyWriter { +protected: + formatted_raw_ostream &Out; + const Module *TheModule; + +private: + OwningPtr ModuleSlotTracker; + SlotTracker &Machine; + TypePrinting TypePrinter; + AssemblyAnnotationWriter *AnnotationWriter; + +public: + /// Construct an AssemblyWriter with an external SlotTracker + AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, + const Module *M, AssemblyAnnotationWriter *AAW); + + /// Construct an AssemblyWriter with an internally allocated SlotTracker + AssemblyWriter(formatted_raw_ostream &o, const Module *M, + AssemblyAnnotationWriter *AAW); + + virtual ~AssemblyWriter(); + + virtual void printMDNodeBody(const MDNode *MD); + virtual void printNamedMDNode(const NamedMDNode *NMD); + + virtual void printModule(const Module *M); + + virtual void writeOperand(const Value *Op, bool PrintType); + virtual void writeParamOperand(const Value *Operand, AttributeSet Attrs,unsigned Idx); + virtual void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope); + + virtual void writeAllMDNodes(); + virtual void writeMDNode(unsigned Slot, const MDNode *Node); + virtual void writeAllAttributeGroups(); + + virtual void printTypeIdentities(); + virtual void printGlobal(const GlobalVariable *GV); + virtual void printAlias(const GlobalAlias *GV); + virtual void printFunction(const Function *F); + virtual void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx); + virtual void printBasicBlock(const BasicBlock *BB); + virtual void printInstructionLine(const Instruction &I); + virtual void printInstruction(const Instruction &I); + +private: + void init(); + + // printInfoComment - Print a little comment after the instruction indicating + // which slot it occupies. + void printInfoComment(const Value &V); +}; + +} // namespace llvm + +#endif //LLVM_IR_ASMWRITER_H diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 7761127d5574..c94620372a23 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -22,6 +22,7 @@ #include "llvm/Assembly/AssemblyAnnotationWriter.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/DebugInfo.h" +#include "llvm/IR/AsmWriter.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" @@ -153,35 +154,8 @@ static void PrintLLVMName(raw_ostream &OS, const Value *V) { isa(V) ? GlobalPrefix : LocalPrefix); } -//===----------------------------------------------------------------------===// -// TypePrinting Class: Type printing machinery -//===----------------------------------------------------------------------===// - -/// TypePrinting - Type printing machinery. -namespace { -class TypePrinting { - TypePrinting(const TypePrinting &) LLVM_DELETED_FUNCTION; - void operator=(const TypePrinting&) LLVM_DELETED_FUNCTION; -public: - - /// NamedTypes - The named types that are used by the current module. - TypeFinder NamedTypes; - - /// NumberedTypes - The numbered types, along with their value. - DenseMap NumberedTypes; - - - TypePrinting() {} - ~TypePrinting() {} - - void incorporateTypes(const Module &M); - - void print(Type *Ty, raw_ostream &OS); - - void printStructBody(StructType *Ty, raw_ostream &OS); -}; -} // end anonymous namespace. +namespace llvm { void TypePrinting::incorporateTypes(const Module &M) { NamedTypes.run(M, false); @@ -313,14 +287,9 @@ void TypePrinting::printStructBody(StructType *STy, raw_ostream &OS) { OS << '>'; } - - //===----------------------------------------------------------------------===// // SlotTracker Class: Enumerate slot numbers for unnamed values //===----------------------------------------------------------------------===// - -namespace { - /// This class provides computation of slot numbers for LLVM Assembly writing. /// class SlotTracker { @@ -418,8 +387,9 @@ private: void operator=(const SlotTracker &) LLVM_DELETED_FUNCTION; }; -} // end anonymous namespace - +SlotTracker *createSlotTracker(const Module *M) { + return new SlotTracker(M); +} static SlotTracker *createSlotTracker(const Value *V) { if (const Argument *FA = dyn_cast(V)) @@ -1200,8 +1170,8 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V, Out << ""; } -void llvm::WriteAsOperand(raw_ostream &Out, const Value *V, - bool PrintType, const Module *Context) { +void WriteAsOperand(raw_ostream &Out, const Value *V, + bool PrintType, const Module *Context) { // Fast path: Don't construct and populate a TypePrinting object if we // won't be needing any types printed. @@ -1225,50 +1195,27 @@ void llvm::WriteAsOperand(raw_ostream &Out, const Value *V, WriteAsOperandInternal(Out, V, &TypePrinter, 0, Context); } -namespace { - -class AssemblyWriter { - formatted_raw_ostream &Out; - SlotTracker &Machine; - const Module *TheModule; - TypePrinting TypePrinter; - AssemblyAnnotationWriter *AnnotationWriter; - -public: - inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, - const Module *M, - AssemblyAnnotationWriter *AAW) - : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) { - if (M) - TypePrinter.incorporateTypes(*M); - } - - void printMDNodeBody(const MDNode *MD); - void printNamedMDNode(const NamedMDNode *NMD); +void AssemblyWriter::init() { + if (TheModule) + TypePrinter.incorporateTypes(*TheModule); +} - void printModule(const Module *M); - void writeOperand(const Value *Op, bool PrintType); - void writeParamOperand(const Value *Operand, AttributeSet Attrs,unsigned Idx); - void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope); +AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, + const Module *M, + AssemblyAnnotationWriter *AAW) + : Out(o), TheModule(M), Machine(Mac), AnnotationWriter(AAW) { + init(); +} - void writeAllMDNodes(); - void writeAllAttributeGroups(); +AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, const Module *M, + AssemblyAnnotationWriter *AAW) + : Out(o), TheModule(M), ModuleSlotTracker(createSlotTracker(M)), + Machine(*ModuleSlotTracker), AnnotationWriter(AAW) { + init(); +} - void printTypeIdentities(); - void printGlobal(const GlobalVariable *GV); - void printAlias(const GlobalAlias *GV); - void printFunction(const Function *F); - void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx); - void printBasicBlock(const BasicBlock *BB); - void printInstruction(const Instruction &I); - -private: - // printInfoComment - Print a little comment after the instruction indicating - // which slot it occupies. - void printInfoComment(const Value &V); -}; -} // end of anonymous namespace +AssemblyWriter::~AssemblyWriter() { } void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) { if (Operand == 0) { @@ -1772,13 +1719,18 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { // Output all of the instructions in the basic block... for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) { - printInstruction(*I); - Out << '\n'; + printInstructionLine(*I); } if (AnnotationWriter) AnnotationWriter->emitBasicBlockEndAnnot(BB, Out); } +/// printInstructionLine - Print an instruction and a newline character. +void AssemblyWriter::printInstructionLine(const Instruction &I) { + printInstruction(I); + Out << '\n'; +} + /// printInfoComment - Print a little comment after the instruction indicating /// which slot it occupies. /// @@ -2093,9 +2045,9 @@ void AssemblyWriter::printInstruction(const Instruction &I) { unsigned Kind = InstMD[i].first; if (Kind < MDNames.size()) { Out << ", !" << MDNames[Kind]; - } else { - Out << ", !"; - } + } else { + Out << ", !"; + } Out << ' '; WriteAsOperandInternal(Out, InstMD[i].second, &TypePrinter, &Machine, TheModule); @@ -2127,6 +2079,11 @@ static void WriteMDNodeComment(const MDNode *Node, } } +void AssemblyWriter::writeMDNode(unsigned Slot, const MDNode *Node) { + Out << '!' << Slot << " = metadata "; + printMDNodeBody(Node); +} + void AssemblyWriter::writeAllMDNodes() { SmallVector Nodes; Nodes.resize(Machine.mdn_size()); @@ -2135,8 +2092,7 @@ void AssemblyWriter::writeAllMDNodes() { Nodes[I->second] = cast(I->first); for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { - Out << '!' << i << " = metadata "; - printMDNodeBody(Nodes[i]); + writeMDNode(i, Nodes[i]); } } @@ -2160,6 +2116,8 @@ void AssemblyWriter::writeAllAttributeGroups() { << I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n"; } +} // namespace llvm + //===----------------------------------------------------------------------===// // External Interface declarations //===----------------------------------------------------------------------===// -- GitLab From 3c5bed167085d74389b1f27cb6d358c62d4ed599 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 20:44:14 +0000 Subject: [PATCH 042/467] Add DebugIR pass -- emits IR file and replace source lines with IR lines in MD - requires existing debug information to be present - fixes up file name and line number information in metadata - emits a "-debug.ll" succinct IR file (without !dbg metadata or debug intrinsics) that can be read by a debugger - initialize pass in opt tool to enable the "-debug-ir" flag - lit tests to follow llvm-svn: 181467 --- llvm/include/llvm/DebugInfo.h | 3 + llvm/include/llvm/InitializePasses.h | 1 + .../include/llvm/Transforms/Instrumentation.h | 4 + llvm/lib/IR/DebugInfo.cpp | 7 + .../Transforms/Instrumentation/CMakeLists.txt | 1 + .../Transforms/Instrumentation/DebugIR.cpp | 246 ++++++++++++++++++ llvm/tools/opt/opt.cpp | 1 + 7 files changed, 263 insertions(+) create mode 100644 llvm/lib/Transforms/Instrumentation/DebugIR.cpp diff --git a/llvm/include/llvm/DebugInfo.h b/llvm/include/llvm/DebugInfo.h index 1c7edc971b68..5f92ca22ecc4 100644 --- a/llvm/include/llvm/DebugInfo.h +++ b/llvm/include/llvm/DebugInfo.h @@ -166,6 +166,9 @@ namespace llvm { public: explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {} + /// Set the filename by allocating a new string MDNode for + /// it and attaching it to the underlying node. + void setFilename(StringRef Name, LLVMContext &Context); StringRef getFilename() const; StringRef getDirectory() const; }; diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index 5b2cd603c3f9..072c2e4895b3 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -100,6 +100,7 @@ void initializeDAEPass(PassRegistry&); void initializeDAHPass(PassRegistry&); void initializeDCEPass(PassRegistry&); void initializeDSEPass(PassRegistry&); +void initializeDebugIRPass(PassRegistry&); void initializeDeadInstEliminationPass(PassRegistry&); void initializeDeadMachineInstructionElimPass(PassRegistry&); void initializeDependenceAnalysisPass(PassRegistry&); diff --git a/llvm/include/llvm/Transforms/Instrumentation.h b/llvm/include/llvm/Transforms/Instrumentation.h index 4aae200dd083..142b40f1eaa9 100644 --- a/llvm/include/llvm/Transforms/Instrumentation.h +++ b/llvm/include/llvm/Transforms/Instrumentation.h @@ -78,6 +78,10 @@ FunctionPass *createThreadSanitizerPass(StringRef BlacklistFile = StringRef()); // checking on loads, stores, and other memory intrinsics. FunctionPass *createBoundsCheckingPass(); +/// createDebugIRPass - Create and return a pass that modifies a module's +/// debug metadata to point back to IR instead of the original source file +ModulePass *createDebugIRPass(StringRef FilenamePostfix); + } // End llvm namespace #endif diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 3be5e0f8496e..38fc90f865ee 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -695,6 +695,13 @@ DIArray DISubprogram::getVariables() const { return DIArray(); } +void DIScope::setFilename(StringRef Name, LLVMContext &Context) { + if (!DbgNode) + return; + MDString *MDName(MDString::get(Context, Name)); + const_cast(getNodeField(DbgNode, 1))->replaceOperandWith(0, MDName); +} + StringRef DIScope::getFilename() const { if (!DbgNode) return StringRef(); diff --git a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt index 1c9e0536794a..aa265a49ed19 100644 --- a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt +++ b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt @@ -2,6 +2,7 @@ add_llvm_library(LLVMInstrumentation AddressSanitizer.cpp BlackList.cpp BoundsChecking.cpp + DebugIR.cpp EdgeProfiling.cpp GCOVProfiling.cpp MemorySanitizer.cpp diff --git a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp new file mode 100644 index 000000000000..62a9b8abd8fb --- /dev/null +++ b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp @@ -0,0 +1,246 @@ +//===--- DebugIR.cpp - Transform debug metadata to allow debugging IR -----===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// A Module transform pass that emits a succinct version of the IR and replaces +// the source file metadata to allow debuggers to step through the IR. +// +// The location where the IR file is emitted is the same as the directory +// operand of the !llvm.dbg.cu metadata node present in the input module. The +// file name is constructed from the original file name by stripping the +// extension and replacing it with "-debug.ll" or the Postfix string specified +// at construction. +// +// FIXME: instead of replacing debug metadata, additional metadata should be +// used to point capable debuggers to the IR file without destroying the +// mapping to the original source file. +// +// FIXME: this pass should not depend on the existance of debug metadata in +// the module as it does now. Instead, it should use DIBuilder to create the +// required metadata. +// +//===----------------------------------------------------------------------===// + +#include + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/DebugInfo.h" +#include "llvm/DIBuilder.h" +#include "llvm/IR/AsmWriter.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/Module.h" +#include "llvm/Pass.h" +#include "llvm/Transforms/Instrumentation.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ToolOutputFile.h" +#include "llvm/Support/raw_ostream.h" +using namespace llvm; + +namespace { + +/// Returns true if Node's name contains the string "llvm.dbg" +bool isDebugNamedMetadata(const NamedMDNode *Node) { + return Node->getName().str().find("llvm.dbg") != std::string::npos; +} + +/// Returns true if Inst is a call to llvm.dbg.value or llvm.dbg.declare +bool isDebugIntrinsic(const IntrinsicInst *Inst) { + Intrinsic::ID id = Inst->getIntrinsicID(); + return id == Intrinsic::dbg_value || id == Intrinsic::dbg_declare; +} + +/// An AssemblyWriter which generates a succinct representation of the module +/// (without debug intrinsics or metadata) suitable for debugging. As IR +/// instructions are printed, !dbg metadata nodes are added (or updated) +/// to point to the corresponding line in the generated IR file instead +/// of the original source file. The input module must have been constructed +/// with debug metadata (i.e. clang -g). +class IRDebugInfoHelper : public llvm::AssemblyWriter { + /// Directory of debug metadata + const DebugInfoFinder &Finder; + + /// Flags to control the verbosity of the generated IR file + bool hideDebugIntrinsics; + bool hideDebugMetadata; + + /// Set to track metadata nodes to be printed (used only when + /// printDebugMetadata == false) + SmallSet NonDebugNodes; + +public: + IRDebugInfoHelper( + formatted_raw_ostream &o, const Module *M, + AssemblyAnnotationWriter *AAW, const DebugInfoFinder &Finder, + bool hideDebugIntrinsics = true, bool hideDebugMetadata = true) + : AssemblyWriter(o, M, AAW), Finder(Finder), + hideDebugIntrinsics(hideDebugIntrinsics), + hideDebugMetadata(hideDebugMetadata) {} + +private: + virtual void printInstruction(const Instruction &I) { + DebugLoc Loc(I.getDebugLoc()); + + if (hideDebugMetadata) + removeDebugMetadata(const_cast(I)); + + AssemblyWriter::printInstruction(I); + Out.flush(); + // Adjust line number by 1 because we have not yet printed the \n + unsigned Line = Out.getLine() + 1; + + DebugLoc NewLoc; + if (!Loc.isUnknown()) + // I had a previous debug location: re-use the DebugLoc + NewLoc = DebugLoc::get(Line, /* FIXME: support columns */ 0, + Loc.getScope(I.getContext()), + Loc.getInlinedAt(I.getContext())); + else if (MDNode *scope = findFunctionMD(I.getParent()->getParent())) + // I had no previous debug location, but M has some debug information + NewLoc = DebugLoc::get(Line, 0, scope, /*FIXME: inlined instructions*/ 0); + else + // Neither I nor M has any debug information -- nothing to do here. + // FIXME: support debugging of undecorated IR (generated by clang without + // the -g option) + return; + + if (hideDebugMetadata) + saveNonDebugMetadata(I); + + addDebugLocation(const_cast(I), NewLoc); + } + + virtual void printInstructionLine(const Instruction &I) { + if (hideDebugIntrinsics) + if (const IntrinsicInst *II = dyn_cast(&I)) + if (isDebugIntrinsic(II)) + return; + AssemblyWriter::printInstructionLine(I); + } + + virtual void writeMDNode(unsigned Slot, const MDNode *Node) { + if (hideDebugMetadata == false || isDebugMetadata(Node) == false) + AssemblyWriter::writeMDNode(Slot, Node); + } + + virtual void printNamedMDNode(const NamedMDNode *NMD) { + if (hideDebugMetadata == false || isDebugNamedMetadata(NMD) == false) + AssemblyWriter::printNamedMDNode(NMD); + } + + /// Returns the MDNode that corresponds with F + MDNode *findFunctionMD(const Function *F) { + for (DebugInfoFinder::iterator i = Finder.subprogram_begin(), + e = Finder.subprogram_end(); + i != e; ++i) { + DISubprogram S(*i); + if (S.getFunction() == F) + return *i; + } + // cannot find F -- likely means there is no debug information + return 0; + } + + /// Saves all non-debug metadata attached to I + void saveNonDebugMetadata(const Instruction &I) { + typedef SmallVector, 4> MDNodeVector; + MDNodeVector Others; + I.getAllMetadataOtherThanDebugLoc(Others); + for (MDNodeVector::iterator i = Others.begin(), e = Others.end(); i != e; + ++i) + NonDebugNodes.insert(i->second); + } + + /// Returns true if Node was not saved as non-debug metadata with + /// saveNonDebugMetadata(), false otherwise. + bool isDebugMetadata(const MDNode *Node) { + return NonDebugNodes.count(Node) == 0; + } + + void removeDebugMetadata(Instruction &I) { + if (I.getMetadata(LLVMContext::MD_dbg)) + I.setMetadata(LLVMContext::MD_dbg, 0); + } + + void addDebugLocation(Instruction &I, DebugLoc Loc) { + MDNode *MD = Loc.getAsMDNode(I.getContext()); + I.setMetadata(LLVMContext::MD_dbg, MD); + } +}; + +class DebugIR : public ModulePass { + std::string Postfix; + std::string Filename; + DebugInfoFinder Finder; + +public: + static char ID; + + DebugIR() : ModulePass(ID), Postfix("-debug.ll") {} + + /// Customize the postfix string used to replace the extension of the + /// original filename that appears in the !llvm.dbg.cu metadata node. + DebugIR(StringRef postfix) : ModulePass(ID), Postfix(postfix) {} + +private: + // Modify the filename embedded in the Compilation-Unit debug information of M + bool replaceFilename(Module &M) { + bool changed = false; + + // Sanity check -- if llvm.dbg.cu node exists, the DebugInfoFinder + // better have found at least one CU! + if (M.getNamedMetadata("llvm.dbg.cu")) + assert(Finder.compile_unit_count() > 0 && + "Found no compile units but llvm.dbg.cu node exists"); + + for (DebugInfoFinder::iterator i = Finder.compile_unit_begin(), + e = Finder.compile_unit_end(); + i != e; ++i) { + DICompileUnit CU(*i); + Filename = CU.getFilename(); + + // Replace extension with postfix + size_t dot = Filename.find_last_of("."); + if (dot != std::string::npos) + Filename.erase(dot); + Filename += Postfix; + + CU.setFilename(Filename, M.getContext()); + changed = true; + } + return changed; + } + + void writeAndUpdateDebugIRFile(Module *M) { + std::string error; + tool_output_file OutFile(Filename.c_str(), error); + OutFile.keep(); + formatted_raw_ostream OS; + OS.setStream(OutFile.os(), false); + + IRDebugInfoHelper W(OS, M, 0, Finder); + W.printModule(M); + } + + bool runOnModule(Module &M) { + Finder.processModule(M); + bool changed = replaceFilename(M); + if (changed) + writeAndUpdateDebugIRFile(&M); + return changed; + } +}; + +} // anonymous namespace + +char DebugIR::ID = 0; +INITIALIZE_PASS(DebugIR, "debug-ir", "Enable debugging IR", false, false) + ModulePass *llvm::createDebugIRPass(StringRef FilenamePostfix) { + return new DebugIR(FilenamePostfix); +} diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index e385d7f57716..57b03b4c48cb 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -567,6 +567,7 @@ int main(int argc, char **argv) { // Initialize passes PassRegistry &Registry = *PassRegistry::getPassRegistry(); initializeCore(Registry); + initializeDebugIRPass(Registry); initializeScalarOpts(Registry); initializeObjCARCOpts(Registry); initializeVectorization(Registry); -- GitLab From d142ce7068b839cb1ea6ca4254734ae8ba4ed666 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Wed, 8 May 2013 20:58:01 +0000 Subject: [PATCH 043/467] Fix test in two ways: remove incorrect comment (the intrinsic generated now is of the llvm.sjlj.* flavore) and convert grep->FileCheck llvm-svn: 181468 --- clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c b/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c index 12bce268cfac..3aa5c003973f 100644 --- a/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c +++ b/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c @@ -1,9 +1,10 @@ -/* RUN: %clang_cc1 %s -emit-llvm -o - | not grep __builtin_ +/* RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s * - * __builtin_longjmp/setjmp should get transformed into llvm.setjmp/longjmp - * just like explicit setjmp/longjmp calls are. + * __builtin_longjmp/setjmp should get transformed into intrinsics. */ +// CHECK-NOT: builtin_longjmp + void jumpaway(int *ptr) { __builtin_longjmp(ptr,1); } -- GitLab From 0233db70f04cee3f295cc93f398fb576b7341bec Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 8 May 2013 21:03:00 +0000 Subject: [PATCH 044/467] DebugIR tests -- lit tests for the line number transform - simple one-function case - function-calling case - external function calling case - exception throwing case - vector case Note: these tests are somewhat coupled to the current format of debug metadata. llvm-svn: 181469 --- llvm/test/Transforms/DebugIR/README.txt | 6 + llvm/test/Transforms/DebugIR/crash.ll | 63 +++++++++ llvm/test/Transforms/DebugIR/crash.ll.check | 23 ++++ llvm/test/Transforms/DebugIR/exception.ll | 120 +++++++++++++++++ .../Transforms/DebugIR/exception.ll.check | 95 ++++++++++++++ llvm/test/Transforms/DebugIR/function.ll | 73 +++++++++++ .../test/Transforms/DebugIR/function.ll.check | 36 +++++ llvm/test/Transforms/DebugIR/lit.local.cfg | 1 + llvm/test/Transforms/DebugIR/simple.ll | 45 +++++++ llvm/test/Transforms/DebugIR/simple.ll.check | 13 ++ llvm/test/Transforms/DebugIR/struct.ll | 51 ++++++++ llvm/test/Transforms/DebugIR/struct.ll.check | 12 ++ llvm/test/Transforms/DebugIR/vector.ll | 123 ++++++++++++++++++ llvm/test/Transforms/DebugIR/vector.ll.check | 39 ++++++ 14 files changed, 700 insertions(+) create mode 100644 llvm/test/Transforms/DebugIR/README.txt create mode 100644 llvm/test/Transforms/DebugIR/crash.ll create mode 100644 llvm/test/Transforms/DebugIR/crash.ll.check create mode 100644 llvm/test/Transforms/DebugIR/exception.ll create mode 100644 llvm/test/Transforms/DebugIR/exception.ll.check create mode 100644 llvm/test/Transforms/DebugIR/function.ll create mode 100644 llvm/test/Transforms/DebugIR/function.ll.check create mode 100644 llvm/test/Transforms/DebugIR/lit.local.cfg create mode 100644 llvm/test/Transforms/DebugIR/simple.ll create mode 100644 llvm/test/Transforms/DebugIR/simple.ll.check create mode 100644 llvm/test/Transforms/DebugIR/struct.ll create mode 100644 llvm/test/Transforms/DebugIR/struct.ll.check create mode 100644 llvm/test/Transforms/DebugIR/vector.ll create mode 100644 llvm/test/Transforms/DebugIR/vector.ll.check diff --git a/llvm/test/Transforms/DebugIR/README.txt b/llvm/test/Transforms/DebugIR/README.txt new file mode 100644 index 000000000000..146db682ce4a --- /dev/null +++ b/llvm/test/Transforms/DebugIR/README.txt @@ -0,0 +1,6 @@ + +This directory contains tests for the DebugIR pass which modifies source-level +debug metadata so as to allow debugging LLVM IR in a debugger. Becaue of a +limitation in the current implementation, existing debug metadata is required +for the pass to work, and as such, these tests (and the pass) are highly +coupled with the current format of debug information. diff --git a/llvm/test/Transforms/DebugIR/crash.ll b/llvm/test/Transforms/DebugIR/crash.ll new file mode 100644 index 000000000000..732115165994 --- /dev/null +++ b/llvm/test/Transforms/DebugIR/crash.ll @@ -0,0 +1,63 @@ +; ModuleID = 'crash.c' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@.str = private unnamed_addr constant [18 x i8] c"Hello, segfault!\0A\00", align 1 +@.str1 = private unnamed_addr constant [14 x i8] c"Now crash %d\0A\00", align 1 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + %null_ptr = alloca i32*, align 8 + store i32 0, i32* %retval + store i32 %argc, i32* %argc.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !13), !dbg !14 + store i8** %argv, i8*** %argv.addr, align 8 + call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !15), !dbg !14 + call void @llvm.dbg.declare(metadata !{i32** %null_ptr}, metadata !16), !dbg !18 + store i32* null, i32** %null_ptr, align 8, !dbg !18 + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0)), !dbg !19 + %0 = load i32** %null_ptr, align 8, !dbg !20 + %1 = load i32* %0, align 4, !dbg !20 + %call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str1, i32 0, i32 0), i32 %1), !dbg !20 + %2 = load i32* %argc.addr, align 4, !dbg !21 + ret i32 %2, !dbg !21 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +declare i32 @printf(i8*, ...) #2 + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/crash.c] [DW_LANG_C99] +!1 = metadata !{metadata !"crash.c", metadata !""} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 12, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 12] [def] [scope 13] [main] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/crash.c] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{metadata !8, metadata !8, metadata !9} +!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!11 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] +!12 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +!13 = metadata !{i32 786689, metadata !4, metadata !"argc", metadata !5, i32 16777228, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 12] +!14 = metadata !{i32 12, i32 0, metadata !4, null} +!15 = metadata !{i32 786689, metadata !4, metadata !"argv", metadata !5, i32 33554444, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 12] +!16 = metadata !{i32 786688, metadata !4, metadata !"null_ptr", metadata !5, i32 14, metadata !17, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [null_ptr] [line 14] +!17 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !8} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +!18 = metadata !{i32 14, i32 0, metadata !4, null} +!19 = metadata !{i32 15, i32 0, metadata !4, null} +!20 = metadata !{i32 16, i32 0, metadata !4, null} +!21 = metadata !{i32 17, i32 0, metadata !4, null} +; RUN: opt < %s -debug-ir -S | FileCheck %s.check diff --git a/llvm/test/Transforms/DebugIR/crash.ll.check b/llvm/test/Transforms/DebugIR/crash.ll.check new file mode 100644 index 000000000000..09f2ccc02c0e --- /dev/null +++ b/llvm/test/Transforms/DebugIR/crash.ll.check @@ -0,0 +1,23 @@ +; CHECK: store i32 0, i32* %retval, !dbg ! +; CHECK: store i32 %argc, i32* %argc.addr, align 4, !dbg ! +; CHECK: store i8** %argv, i8*** %argv.addr, align 8, !dbg ! +; CHECK: store i32* null, i32** %null_ptr, align 8, !dbg ! +; CHECK: %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0)), !dbg ! +; CHECK: %0 = load i32** %null_ptr, align 8, !dbg ! +; CHECK: %1 = load i32* %0, align 4, !dbg ! +; CHECK: %call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str1, i32 0, i32 0), i32 %1), !dbg ! +; CHECK: %2 = load i32* %argc.addr, align 4, !dbg ! +; CHECK: ret i32 %2, !dbg ! + +; CHECK: !1 = metadata !{metadata !"crash-debug.ll", metadata !""} + +; CHECK: = metadata !{i32 14, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 15, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 16, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 17, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 18, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 19, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 20, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 21, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 22, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 23, i32 0, metadata !4, null} diff --git a/llvm/test/Transforms/DebugIR/exception.ll b/llvm/test/Transforms/DebugIR/exception.ll new file mode 100644 index 000000000000..100946380b4b --- /dev/null +++ b/llvm/test/Transforms/DebugIR/exception.ll @@ -0,0 +1,120 @@ +; ModuleID = 'exception.cpp' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@_ZTIi = external constant i8* + +; Function Attrs: uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + %exn.slot = alloca i8* + %ehselector.slot = alloca i32 + %e = alloca i32, align 4 + %cleanup.dest.slot = alloca i32 + store i32 0, i32* %retval + store i32 %argc, i32* %argc.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !13), !dbg !14 + store i8** %argv, i8*** %argv.addr, align 8 + call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !15), !dbg !14 + %exception = call i8* @__cxa_allocate_exception(i64 4) #2, !dbg !16 + %0 = bitcast i8* %exception to i32*, !dbg !16 + %1 = load i32* %argc.addr, align 4, !dbg !16 + store i32 %1, i32* %0, !dbg !16 + invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3 + to label %unreachable unwind label %lpad, !dbg !16 + +lpad: ; preds = %entry + %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* bitcast (i8** @_ZTIi to i8*), !dbg !16 + %3 = extractvalue { i8*, i32 } %2, 0, !dbg !16 + store i8* %3, i8** %exn.slot, !dbg !16 + %4 = extractvalue { i8*, i32 } %2, 1, !dbg !16 + store i32 %4, i32* %ehselector.slot, !dbg !16 + br label %catch.dispatch, !dbg !16 + +catch.dispatch: ; preds = %lpad + %sel = load i32* %ehselector.slot, !dbg !18 + %5 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2, !dbg !18 + %matches = icmp eq i32 %sel, %5, !dbg !18 + br i1 %matches, label %catch, label %eh.resume, !dbg !18 + +catch: ; preds = %catch.dispatch + call void @llvm.dbg.declare(metadata !{i32* %e}, metadata !19), !dbg !20 + %exn = load i8** %exn.slot, !dbg !18 + %6 = call i8* @__cxa_begin_catch(i8* %exn) #2, !dbg !18 + %7 = bitcast i8* %6 to i32*, !dbg !18 + %8 = load i32* %7, align 4, !dbg !18 + store i32 %8, i32* %e, align 4, !dbg !18 + %9 = load i32* %e, align 4, !dbg !21 + store i32 %9, i32* %retval, !dbg !21 + store i32 1, i32* %cleanup.dest.slot + call void @__cxa_end_catch() #2, !dbg !23 + br label %try.cont + +try.cont: ; preds = %catch + %10 = load i32* %retval, !dbg !24 + ret i32 %10, !dbg !24 + +eh.resume: ; preds = %catch.dispatch + %exn1 = load i8** %exn.slot, !dbg !18 + %sel2 = load i32* %ehselector.slot, !dbg !18 + %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0, !dbg !18 + %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1, !dbg !18 + resume { i8*, i32 } %lpad.val3, !dbg !18 + +unreachable: ; preds = %entry + unreachable +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +declare i8* @__cxa_allocate_exception(i64) + +declare void @__cxa_throw(i8*, i8*, i8*) + +declare i32 @__gxx_personality_v0(...) + +; Function Attrs: nounwind readnone +declare i32 @llvm.eh.typeid.for(i8*) #1 + +declare i8* @__cxa_begin_catch(i8*) + +declare void @__cxa_end_catch() + +attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { nounwind } +attributes #3 = { noreturn } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/exception.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"exception.cpp", metadata !""} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 10, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 10] [def] [scope 11] [main] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/exception.cpp] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{metadata !8, metadata !8, metadata !9} +!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!11 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] +!12 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +!13 = metadata !{i32 786689, metadata !4, metadata !"argc", metadata !5, i32 16777226, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 10] +!14 = metadata !{i32 10, i32 0, metadata !4, null} +!15 = metadata !{i32 786689, metadata !4, metadata !"argv", metadata !5, i32 33554442, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 10] +!16 = metadata !{i32 13, i32 0, metadata !17, null} +!17 = metadata !{i32 786443, metadata !1, metadata !4, i32 12, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/exception.cpp] +!18 = metadata !{i32 14, i32 0, metadata !17, null} +!19 = metadata !{i32 786688, metadata !4, metadata !"e", metadata !5, i32 14, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [e] [line 14] +!20 = metadata !{i32 14, i32 0, metadata !4, null} +!21 = metadata !{i32 15, i32 0, metadata !22, null} +!22 = metadata !{i32 786443, metadata !1, metadata !4, i32 14, i32 0, i32 1} ; [ DW_TAG_lexical_block ] [/exception.cpp] +!23 = metadata !{i32 16, i32 0, metadata !22, null} +!24 = metadata !{i32 17, i32 0, metadata !4, null} +; RUN: opt < %s -debug-ir -S | FileCheck %s.check diff --git a/llvm/test/Transforms/DebugIR/exception.ll.check b/llvm/test/Transforms/DebugIR/exception.ll.check new file mode 100644 index 000000000000..3d3659393a7e --- /dev/null +++ b/llvm/test/Transforms/DebugIR/exception.ll.check @@ -0,0 +1,95 @@ +; CHECK: store i32 0, i32* %retval, !dbg ! +; CHECK: store i32 %argc, i32* %argc.addr, align 4, !dbg ! +; CHECK: store i8** %argv, i8*** %argv.addr, align 8, !dbg ! +; CHECK: %exception = call i8* @__cxa_allocate_exception(i64 4) #2, !dbg ! +; CHECK: %0 = bitcast i8* %exception to i32*, !dbg ! +; CHECK: %1 = load i32* %argc.addr, align 4, !dbg ! +; CHECK: store i32 %1, i32* %0, !dbg ! +; CHECK: invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3 +; CHECK: to label %unreachable unwind label %lpad, !dbg ! + +lpad: ; preds = %entry +; CHECK: %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) +; CHECK: catch i8* bitcast (i8** @_ZTIi to i8*), !dbg ! +; CHECK: %3 = extractvalue { i8*, i32 } %2, 0, !dbg ! +; CHECK: store i8* %3, i8** %exn.slot, !dbg ! +; CHECK: %4 = extractvalue { i8*, i32 } %2, 1, !dbg ! +; CHECK: store i32 %4, i32* %ehselector.slot, !dbg ! +; CHECK: br label %catch.dispatch, !dbg ! + +catch.dispatch: ; preds = %lpad +; CHECK: %sel = load i32* %ehselector.slot, !dbg ! +; CHECK: %5 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2, !dbg ! +; CHECK: %matches = icmp eq i32 %sel, %5, !dbg ! +; CHECK: br i1 %matches, label %catch, label %eh.resume, !dbg ! + +catch: ; preds = %catch.dispatch +; CHECK: %exn = load i8** %exn.slot, !dbg ! +; CHECK: %6 = call i8* @__cxa_begin_catch(i8* %exn) #2, !dbg ! +; CHECK: %7 = bitcast i8* %6 to i32*, !dbg ! +; CHECK: %8 = load i32* %7, align 4, !dbg ! +; CHECK: store i32 %8, i32* %e, align 4, !dbg ! +; CHECK: %9 = load i32* %e, align 4, !dbg ! +; CHECK: store i32 %9, i32* %retval, !dbg ! +; CHECK: store i32 1, i32* %cleanup.dest.slot +; CHECK: call void @__cxa_end_catch() #2, !dbg ! +; CHECK: br label %try.cont, !dbg ! + +try.cont: ; preds = %catch +; CHECK: %10 = load i32* %retval, !dbg ! +; CHECK: ret i32 %10, !dbg ! + +eh.resume: ; preds = %catch.dispatch +; CHECK: %exn1 = load i8** %exn.slot, !dbg ! +; CHECK: %sel2 = load i32* %ehselector.slot, !dbg ! +; CHECK: %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0, !dbg ! +; CHECK: %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1, !dbg ! +; CHECK: resume { i8*, i32 } %lpad.val3, !dbg ! + +; CHECK: = metadata !{metadata !"exception-debug.ll", metadata !""} + +; CHECK: = metadata !{i32 16, i32 0, metadata ! +; CHECK: = metadata !{i32 17, i32 0, metadata ! +; CHECK: = metadata !{i32 18, i32 0, metadata ! +; CHECK: = metadata !{i32 19, i32 0, metadata ! +; CHECK: = metadata !{i32 20, i32 0, metadata ! +; CHECK: = metadata !{i32 21, i32 0, metadata ! +; CHECK: = metadata !{i32 22, i32 0, metadata ! +; CHECK: = metadata !{i32 25, i32 0, metadata ! + +lpad +; CHECK: = metadata !{i32 29, i32 0, metadata ! +; CHECK: = metadata !{i32 30, i32 0, metadata ! +; CHECK: = metadata !{i32 31, i32 0, metadata ! +; CHECK: = metadata !{i32 32, i32 0, metadata ! +; CHECK: = metadata !{i32 33, i32 0, metadata ! +; CHECK: = metadata !{i32 34, i32 0, metadata ! + +catch.dispatch +; CHECK: = metadata !{i32 37, i32 0, metadata ! +; CHECK: = metadata !{i32 38, i32 0, metadata ! +; CHECK: = metadata !{i32 39, i32 0, metadata ! +; CHECK: = metadata !{i32 40, i32 0, metadata ! + +catch +; CHECK: = metadata !{i32 43, i32 0, metadata ! +; CHECK: = metadata !{i32 44, i32 0, metadata ! +; CHECK: = metadata !{i32 45, i32 0, metadata ! +; CHECK: = metadata !{i32 46, i32 0, metadata ! +; CHECK: = metadata !{i32 47, i32 0, metadata ! +; CHECK: = metadata !{i32 48, i32 0, metadata ! +; CHECK: = metadata !{i32 49, i32 0, metadata ! +; CHECK: = metadata !{i32 50, i32 0, metadata ! +; CHECK: = metadata !{i32 51, i32 0, metadata ! +; CHECK: = metadata !{i32 52, i32 0, metadata ! + +try.cont +; CHECK: = metadata !{i32 55, i32 0, metadata ! +; CHECK: = metadata !{i32 56, i32 0, metadata ! + +eh.resume +; CHECK: = metadata !{i32 59, i32 0, metadata ! +; CHECK: = metadata !{i32 60, i32 0, metadata ! +; CHECK: = metadata !{i32 61, i32 0, metadata ! +; CHECK: = metadata !{i32 62, i32 0, metadata ! +; CHECK: = metadata !{i32 63, i32 0, metadata ! diff --git a/llvm/test/Transforms/DebugIR/function.ll b/llvm/test/Transforms/DebugIR/function.ll new file mode 100644 index 000000000000..19e5e5393abc --- /dev/null +++ b/llvm/test/Transforms/DebugIR/function.ll @@ -0,0 +1,73 @@ +; ModuleID = 'function.c' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: nounwind uwtable +define void @blah(i32* %i) #0 { +entry: + %i.addr = alloca i32*, align 8 + store i32* %i, i32** %i.addr, align 8 + call void @llvm.dbg.declare(metadata !{i32** %i.addr}, metadata !17), !dbg !18 + %0 = load i32** %i.addr, align 8, !dbg !19 + %1 = load i32* %0, align 4, !dbg !19 + %add = add nsw i32 %1, 1, !dbg !19 + store i32 %add, i32* %0, align 4, !dbg !19 + ret void, !dbg !20 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + %i = alloca i32, align 4 + store i32 0, i32* %retval + store i32 %argc, i32* %argc.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !21), !dbg !22 + store i8** %argv, i8*** %argv.addr, align 8 + call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !23), !dbg !22 + call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !24), !dbg !25 + store i32 7, i32* %i, align 4, !dbg !25 + call void @blah(i32* %i), !dbg !26 + %0 = load i32* %i, align 4, !dbg !27 + ret i32 %0, !dbg !27 +} + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/function.c] [DW_LANG_C99] +!1 = metadata !{metadata !"function.c", metadata !""} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4, metadata !10} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"blah", metadata !"blah", metadata !"", i32 10, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32*)* @blah, null, null, metadata !2, i32 10} ; [ DW_TAG_subprogram ] [line 10] [def] [blah] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/function.c] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{null, metadata !8} +!8 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +!9 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!10 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 14, metadata !11, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 15} ; [ DW_TAG_subprogram ] [line 14] [def] [scope 15] [main] +!11 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!12 = metadata !{metadata !9, metadata !9, metadata !13} +!13 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !14} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!14 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !15} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!15 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !16} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] +!16 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +!17 = metadata !{i32 786689, metadata !4, metadata !"i", metadata !5, i32 16777226, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [i] [line 10] +!18 = metadata !{i32 10, i32 0, metadata !4, null} +!19 = metadata !{i32 11, i32 0, metadata !4, null} +!20 = metadata !{i32 12, i32 0, metadata !4, null} +!21 = metadata !{i32 786689, metadata !10, metadata !"argc", metadata !5, i32 16777230, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 14] +!22 = metadata !{i32 14, i32 0, metadata !10, null} +!23 = metadata !{i32 786689, metadata !10, metadata !"argv", metadata !5, i32 33554446, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 14] +!24 = metadata !{i32 786688, metadata !10, metadata !"i", metadata !5, i32 16, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [i] [line 16] +!25 = metadata !{i32 16, i32 0, metadata !10, null} +!26 = metadata !{i32 17, i32 0, metadata !10, null} +!27 = metadata !{i32 18, i32 0, metadata !10, null} +; RUN: opt < %s -debug-ir -S | FileCheck %s.check diff --git a/llvm/test/Transforms/DebugIR/function.ll.check b/llvm/test/Transforms/DebugIR/function.ll.check new file mode 100644 index 000000000000..df795386097a --- /dev/null +++ b/llvm/test/Transforms/DebugIR/function.ll.check @@ -0,0 +1,36 @@ +; CHECK: %i.addr = alloca i32*, align 8, !dbg ! +; CHECK: store i32* %i, i32** %i.addr, align 8, !dbg ! +; CHECK: %0 = load i32** %i.addr, align 8, !dbg ! +; CHECK: %1 = load i32* %0, align 4, !dbg ! +; CHECK: %add = add nsw i32 %1, 1, !dbg ! +; CHECK: store i32 %add, i32* %0, align 4, !dbg ! +; CHECK: ret void, !dbg ! + +; CHECK: %retval = alloca i32, align 4, !dbg ! +; CHECK: %argc.addr = alloca i32, align 4, !dbg ! +; CHECK: %argv.addr = alloca i8**, align 8, !dbg ! +; CHECK: %i = alloca i32, align 4, !dbg ! +; CHECK: store i32 0, i32* %retval, !dbg ! +; CHECK: store i32 %argc, i32* %argc.addr, align 4, !dbg ! +; CHECK: store i8** %argv, i8*** %argv.addr, align 8, !dbg ! +; CHECK: store i32 7, i32* %i, align 4, !dbg ! +; CHECK: call void @blah(i32* %i), !dbg ! +; CHECK: %0 = load i32* %i, align 4, !dbg ! +; CHECK: ret i32 %0, !dbg ! + +; CHECK: !1 = metadata !{metadata !"function-debug.ll", metadata !""} + +; CHECK: = metadata !{i32 8, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 9, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 10, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 11, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 12, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 13, i32 0, metadata !4, null} + +; CHECK: = metadata !{i32 24, i32 0, metadata !10, null} +; CHECK: = metadata !{i32 25, i32 0, metadata !10, null} +; CHECK: = metadata !{i32 26, i32 0, metadata !10, null} +; CHECK: = metadata !{i32 27, i32 0, metadata !10, null} +; CHECK: = metadata !{i32 28, i32 0, metadata !10, null} +; CHECK: = metadata !{i32 29, i32 0, metadata !10, null} +; CHECK: = metadata !{i32 30, i32 0, metadata !10, null} diff --git a/llvm/test/Transforms/DebugIR/lit.local.cfg b/llvm/test/Transforms/DebugIR/lit.local.cfg new file mode 100644 index 000000000000..c6106e4746f2 --- /dev/null +++ b/llvm/test/Transforms/DebugIR/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll'] diff --git a/llvm/test/Transforms/DebugIR/simple.ll b/llvm/test/Transforms/DebugIR/simple.ll new file mode 100644 index 000000000000..e2e8b2f7c205 --- /dev/null +++ b/llvm/test/Transforms/DebugIR/simple.ll @@ -0,0 +1,45 @@ +; ModuleID = 'simple.c' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + store i32 0, i32* %retval + store i32 %argc, i32* %argc.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !13), !dbg !14 + store i8** %argv, i8*** %argv.addr, align 8 + call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !15), !dbg !14 + %0 = load i32* %argc.addr, align 4, !dbg !16 + ret i32 %0, !dbg !16 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/simple.c] [DW_LANG_C99] +!1 = metadata !{metadata !"simple.c", metadata !""} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 10, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 10] [def] [scope 11] [main] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/simple.c] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{metadata !8, metadata !8, metadata !9} +!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +!11 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] +!12 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +!13 = metadata !{i32 786689, metadata !4, metadata !"argc", metadata !5, i32 16777226, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 10] +!14 = metadata !{i32 10, i32 0, metadata !4, null} +!15 = metadata !{i32 786689, metadata !4, metadata !"argv", metadata !5, i32 33554442, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 10] +!16 = metadata !{i32 12, i32 0, metadata !4, null} +; RUN: opt < %s -debug-ir -S | FileCheck %s.check diff --git a/llvm/test/Transforms/DebugIR/simple.ll.check b/llvm/test/Transforms/DebugIR/simple.ll.check new file mode 100644 index 000000000000..14be4eff07dd --- /dev/null +++ b/llvm/test/Transforms/DebugIR/simple.ll.check @@ -0,0 +1,13 @@ +; CHECK: store i32 0, i32* %retval, !dbg ! +; CHECK: store i32 %argc, i32* %argc.addr, align 4, !dbg ! +; CHECK: store i8** %argv, i8*** %argv.addr, align 8, !dbg ! +; CHECK: %0 = load i32* %argc.addr, align 4, !dbg ! +; CHECK: ret i32 %0, !dbg ! + +; CHECK: !1 = metadata !{metadata !"simple-debug.ll", metadata !""} + +; CHECK: = metadata !{i32 10, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 11, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 12, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 13, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 14, i32 0, metadata !4, null} diff --git a/llvm/test/Transforms/DebugIR/struct.ll b/llvm/test/Transforms/DebugIR/struct.ll new file mode 100644 index 000000000000..460ef3b5df7e --- /dev/null +++ b/llvm/test/Transforms/DebugIR/struct.ll @@ -0,0 +1,51 @@ +; ModuleID = 'struct.cpp' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.blah = type { i32, float, i8 } + +; Function Attrs: nounwind uwtable +define i32 @main() #0 { +entry: + %retval = alloca i32, align 4 + %b = alloca %struct.blah, align 4 + store i32 0, i32* %retval + call void @llvm.dbg.declare(metadata !{%struct.blah* %b}, metadata !9), !dbg !22 + %a = getelementptr inbounds %struct.blah* %b, i32 0, i32 0, !dbg !23 + %0 = load i32* %a, align 4, !dbg !23 + ret i32 %0, !dbg !23 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/struct.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"struct.cpp", metadata !""} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 8, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !2, i32 8} ; [ DW_TAG_subprogram ] [line 8] [def] [main] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/struct.cpp] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{metadata !8} +!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!9 = metadata !{i32 786688, metadata !4, metadata !"b", metadata !5, i32 9, metadata !10, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [b] [line 9] +!10 = metadata !{i32 786451, metadata !1, null, metadata !"blah", i32 2, i64 96, i64 32, i32 0, i32 0, null, metadata !11, i32 0, null, null} ; [ DW_TAG_structure_type ] [blah] [line 2, size 96, align 32, offset 0] [from ] +!11 = metadata !{metadata !12, metadata !13, metadata !15, metadata !17} +!12 = metadata !{i32 786445, metadata !1, metadata !10, metadata !"a", i32 3, i64 32, i64 32, i64 0, i32 0, metadata !8} ; [ DW_TAG_member ] [a] [line 3, size 32, align 32, offset 0] [from int] +!13 = metadata !{i32 786445, metadata !1, metadata !10, metadata !"b", i32 4, i64 32, i64 32, i64 32, i32 0, metadata !14} ; [ DW_TAG_member ] [b] [line 4, size 32, align 32, offset 32] [from float] +!14 = metadata !{i32 786468, null, null, metadata !"float", i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float] +!15 = metadata !{i32 786445, metadata !1, metadata !10, metadata !"c", i32 5, i64 8, i64 8, i64 64, i32 0, metadata !16} ; [ DW_TAG_member ] [c] [line 5, size 8, align 8, offset 64] [from char] +!16 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +!17 = metadata !{i32 786478, metadata !1, metadata !10, metadata !"blah", metadata !"blah", metadata !"", i32 2, metadata !18, i1 false, i1 false, i32 0, i32 0, null, i32 320, i1 false, null, null, i32 0, metadata !21, i32 2} ; [ DW_TAG_subprogram ] [line 2] [blah] +!18 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !19, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!19 = metadata !{null, metadata !20} +!20 = metadata !{i32 786447, i32 0, i32 0, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from blah] +!21 = metadata !{i32 786468} +!22 = metadata !{i32 9, i32 0, metadata !4, null} +!23 = metadata !{i32 10, i32 0, metadata !4, null} +; RUN: opt < %s -debug-ir -S | FileCheck %s.check diff --git a/llvm/test/Transforms/DebugIR/struct.ll.check b/llvm/test/Transforms/DebugIR/struct.ll.check new file mode 100644 index 000000000000..f7b7149eed97 --- /dev/null +++ b/llvm/test/Transforms/DebugIR/struct.ll.check @@ -0,0 +1,12 @@ +; CHECK: %retval = alloca i32, align 4, !dbg ! +; CHECK: %b = alloca %struct.blah, align 4, !dbg ! +; CHECK: store i32 0, i32* %retval, !dbg ! +; CHECK: %a = getelementptr inbounds %struct.blah* %b, i32 0, i32 0, !dbg ! +; CHECK: %0 = load i32* %a, align 4, !dbg ! +; CHECK: ret i32 %0, !dbg ! + +; CHECK: = metadata !{metadata !"struct-debug.ll", metadata !""} +; CHECK: = metadata !{i32 11, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 12, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 13, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 14, i32 0, metadata !4, null} diff --git a/llvm/test/Transforms/DebugIR/vector.ll b/llvm/test/Transforms/DebugIR/vector.ll new file mode 100644 index 000000000000..8f2a63f8dc61 --- /dev/null +++ b/llvm/test/Transforms/DebugIR/vector.ll @@ -0,0 +1,123 @@ +; ModuleID = 'vector.cpp' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: noinline nounwind uwtable +define <4 x float> @_Z3fooDv2_fS_(double %a.coerce, double %b.coerce) #0 { +entry: + %a = alloca <2 x float>, align 8 + %a.addr = alloca <2 x float>, align 8 + %b = alloca <2 x float>, align 8 + %b.addr = alloca <2 x float>, align 8 + %c = alloca <4 x float>, align 16 + %0 = bitcast <2 x float>* %a to double* + store double %a.coerce, double* %0, align 1 + %a1 = load <2 x float>* %a, align 8 + store <2 x float> %a1, <2 x float>* %a.addr, align 8 + call void @llvm.dbg.declare(metadata !{<2 x float>* %a.addr}, metadata !21), !dbg !22 + %1 = bitcast <2 x float>* %b to double* + store double %b.coerce, double* %1, align 1 + %b2 = load <2 x float>* %b, align 8 + store <2 x float> %b2, <2 x float>* %b.addr, align 8 + call void @llvm.dbg.declare(metadata !{<2 x float>* %b.addr}, metadata !23), !dbg !22 + call void @llvm.dbg.declare(metadata !{<4 x float>* %c}, metadata !24), !dbg !25 + %2 = load <2 x float>* %a.addr, align 8, !dbg !26 + %3 = load <4 x float>* %c, align 16, !dbg !26 + %4 = shufflevector <2 x float> %2, <2 x float> undef, <4 x i32> , !dbg !26 + %5 = shufflevector <4 x float> %3, <4 x float> %4, <4 x i32> , !dbg !26 + store <4 x float> %5, <4 x float>* %c, align 16, !dbg !26 + %6 = load <2 x float>* %b.addr, align 8, !dbg !27 + %7 = load <4 x float>* %c, align 16, !dbg !27 + %8 = shufflevector <2 x float> %6, <2 x float> undef, <4 x i32> , !dbg !27 + %9 = shufflevector <4 x float> %7, <4 x float> %8, <4 x i32> , !dbg !27 + store <4 x float> %9, <4 x float>* %c, align 16, !dbg !27 + %10 = load <4 x float>* %c, align 16, !dbg !28 + ret <4 x float> %10, !dbg !28 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) #1 + +; Function Attrs: nounwind uwtable +define i32 @main() #2 { +entry: + %retval = alloca i32, align 4 + %a = alloca <2 x float>, align 8 + %b = alloca <2 x float>, align 8 + %x = alloca <4 x float>, align 16 + %coerce = alloca <2 x float>, align 8 + %coerce1 = alloca <2 x float>, align 8 + store i32 0, i32* %retval + call void @llvm.dbg.declare(metadata !{<2 x float>* %a}, metadata !29), !dbg !30 + store <2 x float> , <2 x float>* %a, align 8, !dbg !30 + call void @llvm.dbg.declare(metadata !{<2 x float>* %b}, metadata !31), !dbg !32 + store <2 x float> , <2 x float>* %b, align 8, !dbg !32 + call void @llvm.dbg.declare(metadata !{<4 x float>* %x}, metadata !33), !dbg !34 + %0 = load <2 x float>* %a, align 8, !dbg !34 + %1 = load <2 x float>* %b, align 8, !dbg !34 + store <2 x float> %0, <2 x float>* %coerce, align 8, !dbg !34 + %2 = bitcast <2 x float>* %coerce to double*, !dbg !34 + %3 = load double* %2, align 1, !dbg !34 + store <2 x float> %1, <2 x float>* %coerce1, align 8, !dbg !34 + %4 = bitcast <2 x float>* %coerce1 to double*, !dbg !34 + %5 = load double* %4, align 1, !dbg !34 + %call = call <4 x float> @_Z3fooDv2_fS_(double %3, double %5), !dbg !34 + store <4 x float> %call, <4 x float>* %x, align 16, !dbg !34 + %6 = load <4 x float>* %x, align 16, !dbg !35 + %7 = extractelement <4 x float> %6, i32 0, !dbg !35 + %8 = load <4 x float>* %x, align 16, !dbg !35 + %9 = extractelement <4 x float> %8, i32 1, !dbg !35 + %add = fadd float %7, %9, !dbg !35 + %10 = load <4 x float>* %x, align 16, !dbg !35 + %11 = extractelement <4 x float> %10, i32 2, !dbg !35 + %add2 = fadd float %add, %11, !dbg !35 + %12 = load <4 x float>* %x, align 16, !dbg !35 + %13 = extractelement <4 x float> %12, i32 3, !dbg !35 + %add3 = fadd float %add2, %13, !dbg !35 + %conv = fptosi float %add3 to i32, !dbg !35 + ret i32 %conv, !dbg !35 +} + +attributes #0 = { noinline nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/vector.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"vector.cpp", metadata !""} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4, metadata !17} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"foo", metadata !"foo", metadata !"_Z3fooDv2_fS_", i32 6, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, <4 x float> (double, double)* @_Z3fooDv2_fS_, null, null, metadata !2, i32 6} ; [ DW_TAG_subprogram ] [line 6] [def] [foo] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/vector.cpp] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{metadata !8, metadata !13, metadata !13} +!8 = metadata !{i32 786454, metadata !1, null, metadata !"float4", i32 2, i64 0, i64 0, i64 0, i32 0, metadata !9} ; [ DW_TAG_typedef ] [float4] [line 2, size 0, align 0, offset 0] [from ] +!9 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 128, i64 128, i32 0, i32 2048, metadata !10, metadata !11, i32 0, i32 0} ; [ DW_TAG_array_type ] [line 0, size 128, align 128, offset 0] [vector] [from float] +!10 = metadata !{i32 786468, null, null, metadata !"float", i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float] +!11 = metadata !{metadata !12} +!12 = metadata !{i32 786465, i64 0, i64 4} ; [ DW_TAG_subrange_type ] [0, 3] +!13 = metadata !{i32 786454, metadata !1, null, metadata !"float2", i32 3, i64 0, i64 0, i64 0, i32 0, metadata !14} ; [ DW_TAG_typedef ] [float2] [line 3, size 0, align 0, offset 0] [from ] +!14 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 64, i64 64, i32 0, i32 2048, metadata !10, metadata !15, i32 0, i32 0} ; [ DW_TAG_array_type ] [line 0, size 64, align 64, offset 0] [vector] [from float] +!15 = metadata !{metadata !16} +!16 = metadata !{i32 786465, i64 0, i64 2} ; [ DW_TAG_subrange_type ] [0, 1] +!17 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 13, metadata !18, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [main] +!18 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !19, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!19 = metadata !{metadata !20} +!20 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!21 = metadata !{i32 786689, metadata !4, metadata !"a", metadata !5, i32 16777222, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 6] +!22 = metadata !{i32 6, i32 0, metadata !4, null} +!23 = metadata !{i32 786689, metadata !4, metadata !"b", metadata !5, i32 33554438, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [b] [line 6] +!24 = metadata !{i32 786688, metadata !4, metadata !"c", metadata !5, i32 7, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [c] [line 7] +!25 = metadata !{i32 7, i32 0, metadata !4, null} +!26 = metadata !{i32 8, i32 0, metadata !4, null} ; [ DW_TAG_imported_declaration ] +!27 = metadata !{i32 9, i32 0, metadata !4, null} +!28 = metadata !{i32 10, i32 0, metadata !4, null} +!29 = metadata !{i32 786688, metadata !17, metadata !"a", metadata !5, i32 14, metadata !13, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 14] +!30 = metadata !{i32 14, i32 0, metadata !17, null} +!31 = metadata !{i32 786688, metadata !17, metadata !"b", metadata !5, i32 15, metadata !13, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [b] [line 15] +!32 = metadata !{i32 15, i32 0, metadata !17, null} +!33 = metadata !{i32 786688, metadata !17, metadata !"x", metadata !5, i32 16, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [x] [line 16] +!34 = metadata !{i32 16, i32 0, metadata !17, null} +!35 = metadata !{i32 18, i32 0, metadata !17, null} +; RUN: opt < %s -debug-ir -S | FileCheck %s.check diff --git a/llvm/test/Transforms/DebugIR/vector.ll.check b/llvm/test/Transforms/DebugIR/vector.ll.check new file mode 100644 index 000000000000..1de68c4de0a0 --- /dev/null +++ b/llvm/test/Transforms/DebugIR/vector.ll.check @@ -0,0 +1,39 @@ +; CHECK: store double %a.coerce, double* %0, align 1, !dbg ! +; CHECK: %a1 = load <2 x float>* %a, align 8, !dbg ! +; CHECK: store <2 x float> %a1, <2 x float>* %a.addr, align 8, !dbg ! +; CHECK: store double %b.coerce, double* %1, align 1, !dbg ! +; CHECK: %b2 = load <2 x float>* %b, align 8, !dbg ! +; CHECK: store <2 x float> %b2, <2 x float>* %b.addr, align 8, !dbg ! +; CHECK: %2 = load <2 x float>* %a.addr, align 8, !dbg ! +; CHECK: %3 = load <4 x float>* %c, align 16, !dbg ! +; CHECK: %4 = shufflevector <2 x float> %2, <2 x float> undef, <4 x i32> , !dbg ! +; CHECK: %5 = shufflevector <4 x float> %3, <4 x float> %4, <4 x i32> , !dbg ! +; CHECK: store <4 x float> %5, <4 x float>* %c, align 16, !dbg ! +; CHECK: %6 = load <2 x float>* %b.addr, align 8, !dbg ! +; CHECK: %7 = load <4 x float>* %c, align 16, !dbg ! +; CHECK: %8 = shufflevector <2 x float> %6, <2 x float> undef, <4 x i32> , !dbg ! +; CHECK: %9 = shufflevector <4 x float> %7, <4 x float> %8, <4 x i32> , !dbg ! +; CHECK: store <4 x float> %9, <4 x float>* %c, align 16, !dbg ! +; CHECK: %10 = load <4 x float>* %c, align 16, !dbg ! +; CHECK: ret <4 x float> %10, !dbg ! + +; CHECK: = metadata !{metadata !"vector-debug.ll", metadata !""} +; CHECK: = metadata !{i32 13, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 14, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 15, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 16, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 17, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 18, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 19, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 20, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 21, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 22, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 23, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 24, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 25, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 26, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 27, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 28, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 29, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 30, i32 0, metadata !4, null} +; CHECK: = metadata !{i32 31, i32 0, metadata !4, null} -- GitLab From 266abefed004e468842fc4ccf680cac999265d78 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 8 May 2013 21:18:42 +0000 Subject: [PATCH 045/467] Put a 1-character unget buffer into cin. This fixes http://llvm.org/bugs/show_bug.cgi?id=15867 llvm-svn: 181470 --- libcxx/include/__std_stream | 69 ++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/libcxx/include/__std_stream b/libcxx/include/__std_stream index 8ca413eb6a1e..2148f05767ec 100644 --- a/libcxx/include/__std_stream +++ b/libcxx/include/__std_stream @@ -55,6 +55,8 @@ private: const codecvt* __cv_; state_type* __st_; int __encoding_; + int_type __last_consumed_; + bool __last_consumed_is_next_; bool __always_noconv_; __stdinbuf(const __stdinbuf&); @@ -66,7 +68,9 @@ private: template __stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st) : __file_(__fp), - __st_(__st) + __st_(__st), + __last_consumed_(traits_type::eof()), + __last_consumed_is_next_(false) { imbue(this->getloc()); } @@ -100,6 +104,16 @@ template typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::__getchar(bool __consume) { + if (__last_consumed_is_next_) + { + int_type __result = __last_consumed_; + if (__consume) + { + __last_consumed_ = traits_type::eof(); + __last_consumed_is_next_ = false; + } + return __result; + } char __extbuf[__limit]; int __nread = _VSTD::max(1, __encoding_); for (int __i = 0; __i < __nread; ++__i) @@ -154,6 +168,8 @@ __stdinbuf<_CharT>::__getchar(bool __consume) return traits_type::eof(); } } + else + __last_consumed_ = traits_type::to_int_type(__1buf); return traits_type::to_int_type(__1buf); } @@ -162,28 +178,41 @@ typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::pbackfail(int_type __c) { if (traits_type::eq_int_type(__c, traits_type::eof())) - return __c; - char __extbuf[__limit]; - char* __enxt; - const char_type __ci = traits_type::to_char_type(__c); - const char_type* __inxt; - switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt, - __extbuf, __extbuf + sizeof(__extbuf), __enxt)) { - case _VSTD::codecvt_base::ok: - break; - case _VSTD::codecvt_base::noconv: - __extbuf[0] = static_cast(__c); - __enxt = __extbuf + 1; - break; - case codecvt_base::partial: - case codecvt_base::error: - return traits_type::eof(); + if (!__last_consumed_is_next_) + { + __c = __last_consumed_; + __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_, + traits_type::eof()); + } + return __c; } - while (__enxt > __extbuf) - if (ungetc(*--__enxt, __file_) == EOF) + if (__last_consumed_is_next_) + { + char __extbuf[__limit]; + char* __enxt; + const char_type __ci = traits_type::to_char_type(__last_consumed_); + const char_type* __inxt; + switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt, + __extbuf, __extbuf + sizeof(__extbuf), __enxt)) + { + case _VSTD::codecvt_base::ok: + break; + case _VSTD::codecvt_base::noconv: + __extbuf[0] = static_cast(__last_consumed_); + __enxt = __extbuf + 1; + break; + case codecvt_base::partial: + case codecvt_base::error: return traits_type::eof(); - return traits_type::not_eof(__c); + } + while (__enxt > __extbuf) + if (ungetc(*--__enxt, __file_) == EOF) + return traits_type::eof(); + } + __last_consumed_ = __c; + __last_consumed_is_next_ = true; + return __c; } // __stdoutbuf -- GitLab From 697fa1c8be6c52a5f1c72b35bb9fe3004e3e40e2 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 8 May 2013 21:23:22 +0000 Subject: [PATCH 046/467] Make sure debug info contains linkage names (DW_AT_MIPS_linkage_name) for constructors and destructors since the original declaration given by the AT_specification both won't and can't. Patch by Yacine Belkadi, I've cleaned up the testcases. llvm-svn: 181471 --- .../CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 26 ++-- .../DebugInfo/X86/concrete_out_of_line.ll | 3 +- .../DebugInfo/X86/linkage-name-ctor-dtor.ll | 118 ++++++++++++++++++ 3 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index c38ada6b66be..b56255cb9b13 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1150,20 +1150,24 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) { // Add function template parameters. addTemplateParams(*SPDie, SP.getTemplateParams()); - // Unfortunately this code needs to stay here instead of below the - // AT_specification code in order to work around a bug in older - // gdbs that requires the linkage name to resolve multiple template - // functions. - // TODO: Remove this set of code when we get rid of the old gdb - // compatibility. StringRef LinkageName = SP.getLinkageName(); - if (!LinkageName.empty() && DD->useDarwinGDBCompat()) - addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, - getRealLinkageName(LinkageName)); // If this DIE is going to refer declaration info using AT_specification - // then there is no need to add other attributes. + // then there is no need to add other attributes, except + // DW_AT_MIPS_linkage_name in two cases: + // 1) The current DIE has a linkage name but the referred-to declaration + // doesn't have one (e.g. constructor/destructor). + // 2) To work around a bug in older gdbs that requires the linkage name to + // resolve multiple template functions. TODO: Remove this case (the + // DD->useDarwinGDBCompat() condition) when we get rid of the old gdb + // compatibility. + if (DeclDie) { + if (!LinkageName.empty() + && (SPDecl.getLinkageName().empty() || DD->useDarwinGDBCompat())) + addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, + getRealLinkageName(LinkageName)); + // Refer function declaration directly. addDIEEntry(SPDie, dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, DeclDie); @@ -1172,7 +1176,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) { } // Add the linkage name if we have one. - if (!LinkageName.empty() && !DD->useDarwinGDBCompat()) + if (!LinkageName.empty()) addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, getRealLinkageName(LinkageName)); diff --git a/llvm/test/DebugInfo/X86/concrete_out_of_line.ll b/llvm/test/DebugInfo/X86/concrete_out_of_line.ll index 3b9aefc38f56..35b2e67c8569 100644 --- a/llvm/test/DebugInfo/X86/concrete_out_of_line.ll +++ b/llvm/test/DebugInfo/X86/concrete_out_of_line.ll @@ -8,13 +8,14 @@ ; AT_inline. ; CHECK: 0x0000011e: DW_TAG_subprogram [18] +; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_specification ; CHECK-NEXT: DW_AT_inline ; and then that a TAG_subprogram refers to it with AT_abstract_origin. -; CHECK: 0x0000015f: DW_TAG_subprogram [20] +; CHECK: 0x00000167: DW_TAG_subprogram [21] ; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x011e => {0x0000011e}) define i32 @_ZN17nsAutoRefCnt7ReleaseEv() { diff --git a/llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll b/llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll new file mode 100644 index 000000000000..ce9ef8daa80e --- /dev/null +++ b/llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll @@ -0,0 +1,118 @@ +; RUN: llc -O0 %s -o %t -filetype=obj +; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s + +; Check that the linkage name is present for constructors/destructors. + +; CHECK: DW_AT_MIPS_linkage_name {{.*}}"_ZN3FooD1Ev" +; CHECK: DW_AT_MIPS_linkage_name {{.*}}"_ZN3FooC1Ev" +; END + +; $ cat test.cpp +; class Foo { +; public: +; Foo() {} +; ~Foo() {} +; }; +; +; void bar() +; { +; Foo F; +; } + +; $ clang++ -g -O0 -c test.cpp -S -emit-llvm -o test.ll +; $ cat test.ll + +; ModuleID = 'test.cpp' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%class.Foo = type { i8 } + +; Function Attrs: +define void @_Z3barv() #0 { +entry: + %F = alloca %class.Foo, align 1 + call void @llvm.dbg.declare(metadata !{%class.Foo* %F}, metadata !21), !dbg !22 + call void @_ZN3FooC1Ev(%class.Foo* %F), !dbg !22 + call void @_ZN3FooD1Ev(%class.Foo* %F), !dbg !23 + ret void, !dbg !23 +} + +declare void @llvm.dbg.declare(metadata, metadata) #1 + +define linkonce_odr void @_ZN3FooC1Ev(%class.Foo* %this) unnamed_addr #0 align 2 { +entry: + %this.addr = alloca %class.Foo*, align 8 + store %class.Foo* %this, %class.Foo** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !24), !dbg !26 + %this1 = load %class.Foo** %this.addr + call void @_ZN3FooC2Ev(%class.Foo* %this1), !dbg !26 + ret void, !dbg !26 +} + +define linkonce_odr void @_ZN3FooD1Ev(%class.Foo* %this) unnamed_addr #0 align 2 { +entry: + %this.addr = alloca %class.Foo*, align 8 + store %class.Foo* %this, %class.Foo** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !27), !dbg !28 + %this1 = load %class.Foo** %this.addr + call void @_ZN3FooD2Ev(%class.Foo* %this1), !dbg !28 + ret void, !dbg !28 +} + +define linkonce_odr void @_ZN3FooD2Ev(%class.Foo* %this) unnamed_addr #0 align 2 { +entry: + %this.addr = alloca %class.Foo*, align 8 + store %class.Foo* %this, %class.Foo** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !29), !dbg !30 + %this1 = load %class.Foo** %this.addr + ret void, !dbg !30 +} + +define linkonce_odr void @_ZN3FooC2Ev(%class.Foo* %this) unnamed_addr #0 align 2 { +entry: + %this.addr = alloca %class.Foo*, align 8 + store %class.Foo* %this, %class.Foo** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !31), !dbg !32 + %this1 = load %class.Foo** %this.addr + ret void, !dbg !32 +} + +attributes #0 = { nounwind } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.3 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/test.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"test.cpp", metadata !"/tmp"} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4, metadata !8, metadata !18, metadata !19, metadata !20} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"bar", metadata !"bar", metadata !"_Z3barv", i32 7, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_Z3barv, null, null, metadata !2, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [bar] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/test.cpp] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{null} +!8 = metadata !{i32 786478, metadata !1, null, metadata !"~Foo", metadata !"~Foo", metadata !"_ZN3FooD1Ev", i32 4, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooD1Ev, null, metadata !16, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [~Foo] +!9 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!10 = metadata !{null, metadata !11} +!11 = metadata !{i32 786447, i32 0, i32 0, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !12} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from Foo] +!12 = metadata !{i32 786434, metadata !1, null, metadata !"Foo", i32 1, i64 8, i64 8, i32 0, i32 0, null, metadata !13, i32 0, null, null} ; [ DW_TAG_class_type ] [Foo] [line 1, size 8, align 8, offset 0] [from ] +!13 = metadata !{metadata !14, metadata !16} +!14 = metadata !{i32 786478, metadata !1, metadata !12, metadata !"Foo", metadata !"Foo", metadata !"", i32 3, metadata !9, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !15, i32 3} ; [ DW_TAG_subprogram ] [line 3] [Foo] +!15 = metadata !{i32 786468} +!16 = metadata !{i32 786478, metadata !1, metadata !12, metadata !"~Foo", metadata !"~Foo", metadata !"", i32 4, metadata !9, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !17, i32 4} ; [ DW_TAG_subprogram ] [line 4] [~Foo] +!17 = metadata !{i32 786468} +!18 = metadata !{i32 786478, metadata !1, null, metadata !"~Foo", metadata !"~Foo", metadata !"_ZN3FooD2Ev", i32 4, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooD2Ev, null, metadata !16, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [~Foo] +!19 = metadata !{i32 786478, metadata !1, null, metadata !"Foo", metadata !"Foo", metadata !"_ZN3FooC1Ev", i32 3, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooC1Ev, null, metadata !14, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [Foo] +!20 = metadata !{i32 786478, metadata !1, null, metadata !"Foo", metadata !"Foo", metadata !"_ZN3FooC2Ev", i32 3, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooC2Ev, null, metadata !14, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [Foo] +!21 = metadata !{i32 786688, metadata !4, metadata !"F", metadata !5, i32 9, metadata !12, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [F] [line 9] +!22 = metadata !{i32 9, i32 0, metadata !4, null} +!23 = metadata !{i32 10, i32 0, metadata !4, null} +!24 = metadata !{i32 786689, metadata !19, metadata !"this", metadata !5, i32 16777219, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 3] +!25 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !12} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from Foo] +!26 = metadata !{i32 3, i32 0, metadata !19, null} +!27 = metadata !{i32 786689, metadata !8, metadata !"this", metadata !5, i32 16777220, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 4] +!28 = metadata !{i32 4, i32 0, metadata !8, null} +!29 = metadata !{i32 786689, metadata !18, metadata !"this", metadata !5, i32 16777220, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 4] +!30 = metadata !{i32 4, i32 0, metadata !18, null} +!31 = metadata !{i32 786689, metadata !20, metadata !"this", metadata !5, i32 16777219, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 3] +!32 = metadata !{i32 3, i32 0, metadata !20, null} -- GitLab From b7d6e2a4e0e62d5022c8a6a77d34911e2dbede6d Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 8 May 2013 21:26:37 +0000 Subject: [PATCH 047/467] Test case added for importing packages llvm-svn: 181472 --- .../Interpreter/ScriptInterpreterPython.cpp | 18 ++++++++++-------- .../command_script/import/TestImport.py | 6 ++++++ .../import/thepackage/TPunitA.py | 3 +++ .../import/thepackage/TPunitB.py | 3 +++ .../import/thepackage/__init__.py | 6 ++++++ 5 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 lldb/test/functionalities/command_script/import/thepackage/TPunitA.py create mode 100644 lldb/test/functionalities/command_script/import/thepackage/TPunitB.py create mode 100644 lldb/test/functionalities/command_script/import/thepackage/__init__.py diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 5a4fa625a0af..5b6e0f5d80e8 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2602,13 +2602,8 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, Locker::AcquireLock | (init_session ? Locker::InitSession : 0), Locker::FreeAcquiredLock | (init_session ? Locker::TearDownSession : 0)); - if (target_file.GetFileType() == FileSpec::eFileTypeDirectory) - { - // for directories, just import - basename = pathname; - } - else if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || - target_file.GetFileType() == FileSpec::eFileTypeUnknown) + if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || + target_file.GetFileType() == FileSpec::eFileTypeUnknown) { // if not a valid file of any sort, check if it might be a filename still // dot can't be used but / and \ can, and if either is found, reject @@ -2619,7 +2614,9 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, } basename = pathname; // not a filename, probably a package of some sort, let it go through } - else + else if (target_file.GetFileType() == FileSpec::eFileTypeDirectory || + target_file.GetFileType() == FileSpec::eFileTypeRegular || + target_file.GetFileType() == FileSpec::eFileTypeSymbolicLink) { const char* directory = target_file.GetDirectory().GetCString(); @@ -2645,6 +2642,11 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, basename.resize(basename.length()-4); } } + else + { + error.SetErrorString("no known way to import this module specification"); + return false; + } // check if the module is already import-ed command_stream.Clear(); diff --git a/lldb/test/functionalities/command_script/import/TestImport.py b/lldb/test/functionalities/command_script/import/TestImport.py index d97011fb2751..b4accc07db79 100644 --- a/lldb/test/functionalities/command_script/import/TestImport.py +++ b/lldb/test/functionalities/command_script/import/TestImport.py @@ -30,6 +30,8 @@ class ImportTestCase(TestBase): self.runCmd('command script delete foobarcmd', check=False) self.runCmd('command script delete barcmd', check=False) self.runCmd('command script delete barothercmd', check=False) + self.runCmd('command script delete TPcommandA', check=False) + self.runCmd('command script delete TPcommandB', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -46,6 +48,10 @@ class ImportTestCase(TestBase): self.expect("command script import ./foo/foo.py", error=True, startstr='error: module importing failed') + self.runCmd("command script import --allow-reload ./thepackage") + self.expect("TPcommandA",substrs=["hello world A"]) + self.expect("TPcommandB",substrs=["hello world B"]) + self.runCmd("script import dummymodule") self.expect("command script import ./dummymodule.py", error=True, startstr='error: module importing failed') diff --git a/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py b/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py new file mode 100644 index 000000000000..86381a1acc25 --- /dev/null +++ b/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py @@ -0,0 +1,3 @@ +def command(debugger, command, result, internal_dict): + result.PutCString(u"hello world A") + return None diff --git a/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py b/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py new file mode 100644 index 000000000000..52db603e5123 --- /dev/null +++ b/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py @@ -0,0 +1,3 @@ +def command(debugger, command, result, internal_dict): + result.PutCString(u"hello world B") + return None diff --git a/lldb/test/functionalities/command_script/import/thepackage/__init__.py b/lldb/test/functionalities/command_script/import/thepackage/__init__.py new file mode 100644 index 000000000000..faa4e3b0cbff --- /dev/null +++ b/lldb/test/functionalities/command_script/import/thepackage/__init__.py @@ -0,0 +1,6 @@ +import TPunitA +import TPunitB + +def __lldb_init_module(debugger,*args): + debugger.HandleCommand("command script add -f thepackage.TPunitA.command TPcommandA") + debugger.HandleCommand("command script add -f thepackage.TPunitB.command TPcommandB") -- GitLab From 80d8308b5707b92626ef6f7adda976327507adaa Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Wed, 8 May 2013 21:34:11 +0000 Subject: [PATCH 048/467] Use anonymous namespace for local classes. Patch by Rui Ueyama llvm-svn: 181473 --- lld/lib/Core/Resolver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 8e94929340f7..c8d80343fd12 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -27,10 +27,12 @@ namespace lld { +namespace { + /// This is used as a filter function to std::remove_if to dead strip atoms. class NotLive { public: - NotLive(const llvm::DenseSet& la) : _liveAtoms(la) { } + explicit NotLive(const llvm::DenseSet& la) : _liveAtoms(la) { } bool operator()(const Atom *atom) const { // don't remove if live @@ -53,7 +55,7 @@ private: /// This is used as a filter function to std::remove_if to coalesced atoms. class AtomCoalescedAway { public: - AtomCoalescedAway(SymbolTable &sym) : _symbolTable(sym) {} + explicit AtomCoalescedAway(SymbolTable &sym) : _symbolTable(sym) {} bool operator()(const Atom *atom) const { const Atom *rep = _symbolTable.replacement(atom); @@ -64,6 +66,8 @@ private: SymbolTable &_symbolTable; }; +} // namespace + // add all atoms from all initial .o files void Resolver::buildInitialAtomList() { -- GitLab From 610f9260fa07436fbefbfcbfa71d6bd721122ea6 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 8 May 2013 21:35:24 +0000 Subject: [PATCH 049/467] Quiet g++-4.7 warnings about const issues and fix the scope of the "if (IsValid())". llvm-svn: 181474 --- lldb/include/lldb/Core/Value.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 128bdb742d07..3ca7301a5dfa 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -100,15 +100,17 @@ public: { Scalar scalar; if (IsValid()) - if (length == 1) scalar = *(uint8_t *)bytes; - if (length == 2) scalar = *(uint16_t *)bytes; - if (length == 4) scalar = *(uint32_t *)bytes; - if (length == 8) scalar = *(uint64_t *)bytes; + { + if (length == 1) scalar = *(const uint8_t *)bytes; + else if (length == 2) scalar = *(const uint16_t *)bytes; + else if (length == 4) scalar = *(const uint32_t *)bytes; + else if (length == 8) scalar = *(const uint64_t *)bytes; #if defined (ENABLE_128_BIT_SUPPORT) - if (length >= 16) scalar = *(__uint128_t *)bytes; + else if (length >= 16) scalar = *(const __uint128_t *)bytes; #else - if (length >= 16) scalar = *(__uint64_t *)bytes; + else if (length >= 16) scalar = *(const __uint64_t *)bytes; #endif + } return scalar; } }; -- GitLab From 068c11096abad36e5e2f501d9687506f30c3169c Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 8 May 2013 21:39:19 +0000 Subject: [PATCH 050/467] Now that you can "command script import" packages, the docs should reflect the best practice llvm-svn: 181475 --- lldb/www/lldb-gdb.html | 8 ++++---- lldb/www/symbolication.html | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/www/lldb-gdb.html b/lldb/www/lldb-gdb.html index 8e58a9a822fc..7e8a11851371 100755 --- a/lldb/www/lldb-gdb.html +++ b/lldb/www/lldb-gdb.html @@ -942,7 +942,7 @@ (gdb) info malloc 0x10010d680 - (lldb) script import lldb.macosx.heap
+ (lldb) command script import lldb.macosx.heap
(lldb) process launch --environment MallocStackLogging=1 -- [ARGS]
(lldb) malloc_info --stack-history 0x10010d680
@@ -952,7 +952,7 @@ - (lldb) script import lldb.macosx.heap
+ (lldb) command script import lldb.macosx.heap
(lldb) malloc_info --type 0x10010d680
@@ -961,7 +961,7 @@ - (lldb) script import lldb.macosx.heap
+ (lldb) command script import lldb.macosx.heap
(lldb) ptr_refs EXPR
@@ -970,7 +970,7 @@ - (lldb) script import lldb.macosx.heap
+ (lldb) command script import lldb.macosx.heap
(lldb) cstr_refs CSTRING
diff --git a/lldb/www/symbolication.html b/lldb/www/symbolication.html index 66c5db9d9fe5..877c1f10bd49 100755 --- a/lldb/www/symbolication.html +++ b/lldb/www/symbolication.html @@ -108,9 +108,9 @@

It is often much easier to specify the actual load location of each section by name. Crash logs on Mac OS X have a Binary Images section that specifies - that address of the __TEXT segment for each binary. Specifying a slide requires - requires that you first find the original (file) address for the __TEXT - segment, and subtract the two values. + that address of the __TEXT segment for each binary. Specifying a slide requires + requires that you first find the original (file) address for the __TEXT + segment, and subtract the two values. If you specify the address of the __TEXT segment with "target modules load section address", you don't need to do any calculations. To specify the load addresses of sections we can specify one or more section name + address pairs @@ -298,7 +298,7 @@ if target:

This module installs a new "crashlog" command into the lldb command interpreter so that you can use it to parse and symbolicate Mac OS X crash logs:

-
(lldb) script import lldb.macosx.crashlog
+
(lldb) command script import lldb.macosx.crashlog
 "crashlog" and "save_crashlog" command installed, use the "--help" option for detailed help
 (lldb) crashlog /tmp/crash.log
 ...
-- 
GitLab


From abdd7f197a9cbca7d4001ee0f19152ac509676ee Mon Sep 17 00:00:00 2001
From: Daniel Malea 
Date: Wed, 8 May 2013 21:55:31 +0000
Subject: [PATCH 051/467] Revert 181475 as the DebugIR tests are breaking
 (automake) buildbots that re-use build dirs - the temporaries "-debug.ll"
 files generated by DebugIR pass are considered tests, even though they are
 not

llvm-svn: 181476
---
 llvm/test/Transforms/DebugIR/README.txt       |   6 -
 llvm/test/Transforms/DebugIR/crash.ll         |  63 ---------
 llvm/test/Transforms/DebugIR/crash.ll.check   |  23 ----
 llvm/test/Transforms/DebugIR/exception.ll     | 120 -----------------
 .../Transforms/DebugIR/exception.ll.check     |  95 --------------
 llvm/test/Transforms/DebugIR/function.ll      |  73 -----------
 .../test/Transforms/DebugIR/function.ll.check |  36 -----
 llvm/test/Transforms/DebugIR/lit.local.cfg    |   1 -
 llvm/test/Transforms/DebugIR/simple.ll        |  45 -------
 llvm/test/Transforms/DebugIR/simple.ll.check  |  13 --
 llvm/test/Transforms/DebugIR/struct.ll        |  51 --------
 llvm/test/Transforms/DebugIR/struct.ll.check  |  12 --
 llvm/test/Transforms/DebugIR/vector.ll        | 123 ------------------
 llvm/test/Transforms/DebugIR/vector.ll.check  |  39 ------
 14 files changed, 700 deletions(-)
 delete mode 100644 llvm/test/Transforms/DebugIR/README.txt
 delete mode 100644 llvm/test/Transforms/DebugIR/crash.ll
 delete mode 100644 llvm/test/Transforms/DebugIR/crash.ll.check
 delete mode 100644 llvm/test/Transforms/DebugIR/exception.ll
 delete mode 100644 llvm/test/Transforms/DebugIR/exception.ll.check
 delete mode 100644 llvm/test/Transforms/DebugIR/function.ll
 delete mode 100644 llvm/test/Transforms/DebugIR/function.ll.check
 delete mode 100644 llvm/test/Transforms/DebugIR/lit.local.cfg
 delete mode 100644 llvm/test/Transforms/DebugIR/simple.ll
 delete mode 100644 llvm/test/Transforms/DebugIR/simple.ll.check
 delete mode 100644 llvm/test/Transforms/DebugIR/struct.ll
 delete mode 100644 llvm/test/Transforms/DebugIR/struct.ll.check
 delete mode 100644 llvm/test/Transforms/DebugIR/vector.ll
 delete mode 100644 llvm/test/Transforms/DebugIR/vector.ll.check

diff --git a/llvm/test/Transforms/DebugIR/README.txt b/llvm/test/Transforms/DebugIR/README.txt
deleted file mode 100644
index 146db682ce4a..000000000000
--- a/llvm/test/Transforms/DebugIR/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-
-This directory contains tests for the DebugIR pass which modifies source-level
-debug metadata so as to allow debugging LLVM IR in a debugger. Becaue of a
-limitation in the current implementation, existing debug metadata is required
-for the pass to work, and as such, these tests (and the pass) are highly
-coupled with the current format of debug information.
diff --git a/llvm/test/Transforms/DebugIR/crash.ll b/llvm/test/Transforms/DebugIR/crash.ll
deleted file mode 100644
index 732115165994..000000000000
--- a/llvm/test/Transforms/DebugIR/crash.ll
+++ /dev/null
@@ -1,63 +0,0 @@
-; ModuleID = 'crash.c'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-@.str = private unnamed_addr constant [18 x i8] c"Hello, segfault!\0A\00", align 1
-@.str1 = private unnamed_addr constant [14 x i8] c"Now crash %d\0A\00", align 1
-
-; Function Attrs: nounwind uwtable
-define i32 @main(i32 %argc, i8** %argv) #0 {
-entry:
-  %retval = alloca i32, align 4
-  %argc.addr = alloca i32, align 4
-  %argv.addr = alloca i8**, align 8
-  %null_ptr = alloca i32*, align 8
-  store i32 0, i32* %retval
-  store i32 %argc, i32* %argc.addr, align 4
-  call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !13), !dbg !14
-  store i8** %argv, i8*** %argv.addr, align 8
-  call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !15), !dbg !14
-  call void @llvm.dbg.declare(metadata !{i32** %null_ptr}, metadata !16), !dbg !18
-  store i32* null, i32** %null_ptr, align 8, !dbg !18
-  %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0)), !dbg !19
-  %0 = load i32** %null_ptr, align 8, !dbg !20
-  %1 = load i32* %0, align 4, !dbg !20
-  %call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str1, i32 0, i32 0), i32 %1), !dbg !20
-  %2 = load i32* %argc.addr, align 4, !dbg !21
-  ret i32 %2, !dbg !21
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-declare i32 @printf(i8*, ...) #2
-
-attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/crash.c] [DW_LANG_C99]
-!1 = metadata !{metadata !"crash.c", metadata !""}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 12, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 12] [def] [scope 13] [main]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/crash.c]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{metadata !8, metadata !8, metadata !9}
-!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!11 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char]
-!12 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char]
-!13 = metadata !{i32 786689, metadata !4, metadata !"argc", metadata !5, i32 16777228, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 12]
-!14 = metadata !{i32 12, i32 0, metadata !4, null}
-!15 = metadata !{i32 786689, metadata !4, metadata !"argv", metadata !5, i32 33554444, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 12]
-!16 = metadata !{i32 786688, metadata !4, metadata !"null_ptr", metadata !5, i32 14, metadata !17, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [null_ptr] [line 14]
-!17 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !8} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
-!18 = metadata !{i32 14, i32 0, metadata !4, null}
-!19 = metadata !{i32 15, i32 0, metadata !4, null}
-!20 = metadata !{i32 16, i32 0, metadata !4, null}
-!21 = metadata !{i32 17, i32 0, metadata !4, null}
-; RUN: opt < %s -debug-ir -S | FileCheck %s.check
diff --git a/llvm/test/Transforms/DebugIR/crash.ll.check b/llvm/test/Transforms/DebugIR/crash.ll.check
deleted file mode 100644
index 09f2ccc02c0e..000000000000
--- a/llvm/test/Transforms/DebugIR/crash.ll.check
+++ /dev/null
@@ -1,23 +0,0 @@
-; CHECK:  store i32 0, i32* %retval, !dbg !
-; CHECK:  store i32 %argc, i32* %argc.addr, align 4, !dbg !
-; CHECK:  store i8** %argv, i8*** %argv.addr, align 8, !dbg !
-; CHECK:  store i32* null, i32** %null_ptr, align 8, !dbg !
-; CHECK:  %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0)), !dbg !
-; CHECK:  %0 = load i32** %null_ptr, align 8, !dbg !
-; CHECK:  %1 = load i32* %0, align 4, !dbg !
-; CHECK:  %call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str1, i32 0, i32 0), i32 %1), !dbg !
-; CHECK:  %2 = load i32* %argc.addr, align 4, !dbg !
-; CHECK:  ret i32 %2, !dbg !
-
-; CHECK: !1 = metadata !{metadata !"crash-debug.ll", metadata !""}
-
-; CHECK: = metadata !{i32 14, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 15, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 16, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 17, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 18, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 19, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 20, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 21, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 22, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 23, i32 0, metadata !4, null}
diff --git a/llvm/test/Transforms/DebugIR/exception.ll b/llvm/test/Transforms/DebugIR/exception.ll
deleted file mode 100644
index 100946380b4b..000000000000
--- a/llvm/test/Transforms/DebugIR/exception.ll
+++ /dev/null
@@ -1,120 +0,0 @@
-; ModuleID = 'exception.cpp'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-@_ZTIi = external constant i8*
-
-; Function Attrs: uwtable
-define i32 @main(i32 %argc, i8** %argv) #0 {
-entry:
-  %retval = alloca i32, align 4
-  %argc.addr = alloca i32, align 4
-  %argv.addr = alloca i8**, align 8
-  %exn.slot = alloca i8*
-  %ehselector.slot = alloca i32
-  %e = alloca i32, align 4
-  %cleanup.dest.slot = alloca i32
-  store i32 0, i32* %retval
-  store i32 %argc, i32* %argc.addr, align 4
-  call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !13), !dbg !14
-  store i8** %argv, i8*** %argv.addr, align 8
-  call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !15), !dbg !14
-  %exception = call i8* @__cxa_allocate_exception(i64 4) #2, !dbg !16
-  %0 = bitcast i8* %exception to i32*, !dbg !16
-  %1 = load i32* %argc.addr, align 4, !dbg !16
-  store i32 %1, i32* %0, !dbg !16
-  invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3
-          to label %unreachable unwind label %lpad, !dbg !16
-
-lpad:                                             ; preds = %entry
-  %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
-          catch i8* bitcast (i8** @_ZTIi to i8*), !dbg !16
-  %3 = extractvalue { i8*, i32 } %2, 0, !dbg !16
-  store i8* %3, i8** %exn.slot, !dbg !16
-  %4 = extractvalue { i8*, i32 } %2, 1, !dbg !16
-  store i32 %4, i32* %ehselector.slot, !dbg !16
-  br label %catch.dispatch, !dbg !16
-
-catch.dispatch:                                   ; preds = %lpad
-  %sel = load i32* %ehselector.slot, !dbg !18
-  %5 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2, !dbg !18
-  %matches = icmp eq i32 %sel, %5, !dbg !18
-  br i1 %matches, label %catch, label %eh.resume, !dbg !18
-
-catch:                                            ; preds = %catch.dispatch
-  call void @llvm.dbg.declare(metadata !{i32* %e}, metadata !19), !dbg !20
-  %exn = load i8** %exn.slot, !dbg !18
-  %6 = call i8* @__cxa_begin_catch(i8* %exn) #2, !dbg !18
-  %7 = bitcast i8* %6 to i32*, !dbg !18
-  %8 = load i32* %7, align 4, !dbg !18
-  store i32 %8, i32* %e, align 4, !dbg !18
-  %9 = load i32* %e, align 4, !dbg !21
-  store i32 %9, i32* %retval, !dbg !21
-  store i32 1, i32* %cleanup.dest.slot
-  call void @__cxa_end_catch() #2, !dbg !23
-  br label %try.cont
-
-try.cont:                                         ; preds = %catch
-  %10 = load i32* %retval, !dbg !24
-  ret i32 %10, !dbg !24
-
-eh.resume:                                        ; preds = %catch.dispatch
-  %exn1 = load i8** %exn.slot, !dbg !18
-  %sel2 = load i32* %ehselector.slot, !dbg !18
-  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0, !dbg !18
-  %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1, !dbg !18
-  resume { i8*, i32 } %lpad.val3, !dbg !18
-
-unreachable:                                      ; preds = %entry
-  unreachable
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-declare i8* @__cxa_allocate_exception(i64)
-
-declare void @__cxa_throw(i8*, i8*, i8*)
-
-declare i32 @__gxx_personality_v0(...)
-
-; Function Attrs: nounwind readnone
-declare i32 @llvm.eh.typeid.for(i8*) #1
-
-declare i8* @__cxa_begin_catch(i8*)
-
-declare void @__cxa_end_catch()
-
-attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-attributes #2 = { nounwind }
-attributes #3 = { noreturn }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/exception.cpp] [DW_LANG_C_plus_plus]
-!1 = metadata !{metadata !"exception.cpp", metadata !""}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 10, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 10] [def] [scope 11] [main]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/exception.cpp]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{metadata !8, metadata !8, metadata !9}
-!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!11 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char]
-!12 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char]
-!13 = metadata !{i32 786689, metadata !4, metadata !"argc", metadata !5, i32 16777226, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 10]
-!14 = metadata !{i32 10, i32 0, metadata !4, null}
-!15 = metadata !{i32 786689, metadata !4, metadata !"argv", metadata !5, i32 33554442, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 10]
-!16 = metadata !{i32 13, i32 0, metadata !17, null}
-!17 = metadata !{i32 786443, metadata !1, metadata !4, i32 12, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/exception.cpp]
-!18 = metadata !{i32 14, i32 0, metadata !17, null}
-!19 = metadata !{i32 786688, metadata !4, metadata !"e", metadata !5, i32 14, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [e] [line 14]
-!20 = metadata !{i32 14, i32 0, metadata !4, null}
-!21 = metadata !{i32 15, i32 0, metadata !22, null}
-!22 = metadata !{i32 786443, metadata !1, metadata !4, i32 14, i32 0, i32 1} ; [ DW_TAG_lexical_block ] [/exception.cpp]
-!23 = metadata !{i32 16, i32 0, metadata !22, null}
-!24 = metadata !{i32 17, i32 0, metadata !4, null}
-; RUN: opt < %s -debug-ir -S | FileCheck %s.check
diff --git a/llvm/test/Transforms/DebugIR/exception.ll.check b/llvm/test/Transforms/DebugIR/exception.ll.check
deleted file mode 100644
index 3d3659393a7e..000000000000
--- a/llvm/test/Transforms/DebugIR/exception.ll.check
+++ /dev/null
@@ -1,95 +0,0 @@
-; CHECK:  store i32 0, i32* %retval, !dbg !
-; CHECK:  store i32 %argc, i32* %argc.addr, align 4, !dbg !
-; CHECK:  store i8** %argv, i8*** %argv.addr, align 8, !dbg !
-; CHECK:  %exception = call i8* @__cxa_allocate_exception(i64 4) #2, !dbg !
-; CHECK:  %0 = bitcast i8* %exception to i32*, !dbg !
-; CHECK:  %1 = load i32* %argc.addr, align 4, !dbg !
-; CHECK:  store i32 %1, i32* %0, !dbg !
-; CHECK:  invoke void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3
-; CHECK:          to label %unreachable unwind label %lpad, !dbg !
-
-lpad:                                             ; preds = %entry
-; CHECK:  %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
-; CHECK:          catch i8* bitcast (i8** @_ZTIi to i8*), !dbg !
-; CHECK:  %3 = extractvalue { i8*, i32 } %2, 0, !dbg !
-; CHECK:  store i8* %3, i8** %exn.slot, !dbg !
-; CHECK:  %4 = extractvalue { i8*, i32 } %2, 1, !dbg !
-; CHECK:  store i32 %4, i32* %ehselector.slot, !dbg !
-; CHECK:  br label %catch.dispatch, !dbg !
-
-catch.dispatch:                                   ; preds = %lpad
-; CHECK:  %sel = load i32* %ehselector.slot, !dbg !
-; CHECK:  %5 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2, !dbg !
-; CHECK:  %matches = icmp eq i32 %sel, %5, !dbg !
-; CHECK:  br i1 %matches, label %catch, label %eh.resume, !dbg !
-
-catch:                                            ; preds = %catch.dispatch
-; CHECK:  %exn = load i8** %exn.slot, !dbg !
-; CHECK:  %6 = call i8* @__cxa_begin_catch(i8* %exn) #2, !dbg !
-; CHECK:  %7 = bitcast i8* %6 to i32*, !dbg !
-; CHECK:  %8 = load i32* %7, align 4, !dbg !
-; CHECK:  store i32 %8, i32* %e, align 4, !dbg !
-; CHECK:  %9 = load i32* %e, align 4, !dbg !
-; CHECK:  store i32 %9, i32* %retval, !dbg !
-; CHECK:  store i32 1, i32* %cleanup.dest.slot
-; CHECK:  call void @__cxa_end_catch() #2, !dbg !
-; CHECK:  br label %try.cont, !dbg !
-
-try.cont:                                         ; preds = %catch
-; CHECK:  %10 = load i32* %retval, !dbg !
-; CHECK:  ret i32 %10, !dbg !
-
-eh.resume:                                        ; preds = %catch.dispatch
-; CHECK:  %exn1 = load i8** %exn.slot, !dbg !
-; CHECK:  %sel2 = load i32* %ehselector.slot, !dbg !
-; CHECK:  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0, !dbg !
-; CHECK:  %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1, !dbg !
-; CHECK:  resume { i8*, i32 } %lpad.val3, !dbg !
-
-; CHECK: = metadata !{metadata !"exception-debug.ll", metadata !""}
-
-; CHECK: = metadata !{i32 16, i32 0, metadata !
-; CHECK: = metadata !{i32 17, i32 0, metadata !
-; CHECK: = metadata !{i32 18, i32 0, metadata !
-; CHECK: = metadata !{i32 19, i32 0, metadata !
-; CHECK: = metadata !{i32 20, i32 0, metadata !
-; CHECK: = metadata !{i32 21, i32 0, metadata !
-; CHECK: = metadata !{i32 22, i32 0, metadata !
-; CHECK: = metadata !{i32 25, i32 0, metadata !
-
-lpad
-; CHECK: = metadata !{i32 29, i32 0, metadata !
-; CHECK: = metadata !{i32 30, i32 0, metadata !
-; CHECK: = metadata !{i32 31, i32 0, metadata !
-; CHECK: = metadata !{i32 32, i32 0, metadata !
-; CHECK: = metadata !{i32 33, i32 0, metadata !
-; CHECK: = metadata !{i32 34, i32 0, metadata !
-
-catch.dispatch
-; CHECK: = metadata !{i32 37, i32 0, metadata !
-; CHECK: = metadata !{i32 38, i32 0, metadata !
-; CHECK: = metadata !{i32 39, i32 0, metadata !
-; CHECK: = metadata !{i32 40, i32 0, metadata !
-
-catch
-; CHECK: = metadata !{i32 43, i32 0, metadata !
-; CHECK: = metadata !{i32 44, i32 0, metadata !
-; CHECK: = metadata !{i32 45, i32 0, metadata !
-; CHECK: = metadata !{i32 46, i32 0, metadata !
-; CHECK: = metadata !{i32 47, i32 0, metadata !
-; CHECK: = metadata !{i32 48, i32 0, metadata !
-; CHECK: = metadata !{i32 49, i32 0, metadata !
-; CHECK: = metadata !{i32 50, i32 0, metadata !
-; CHECK: = metadata !{i32 51, i32 0, metadata !
-; CHECK: = metadata !{i32 52, i32 0, metadata !
-
-try.cont
-; CHECK: = metadata !{i32 55, i32 0, metadata !
-; CHECK: = metadata !{i32 56, i32 0, metadata !
-
-eh.resume
-; CHECK: = metadata !{i32 59, i32 0, metadata !
-; CHECK: = metadata !{i32 60, i32 0, metadata !
-; CHECK: = metadata !{i32 61, i32 0, metadata !
-; CHECK: = metadata !{i32 62, i32 0, metadata !
-; CHECK: = metadata !{i32 63, i32 0, metadata !
diff --git a/llvm/test/Transforms/DebugIR/function.ll b/llvm/test/Transforms/DebugIR/function.ll
deleted file mode 100644
index 19e5e5393abc..000000000000
--- a/llvm/test/Transforms/DebugIR/function.ll
+++ /dev/null
@@ -1,73 +0,0 @@
-; ModuleID = 'function.c'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-; Function Attrs: nounwind uwtable
-define void @blah(i32* %i) #0 {
-entry:
-  %i.addr = alloca i32*, align 8
-  store i32* %i, i32** %i.addr, align 8
-  call void @llvm.dbg.declare(metadata !{i32** %i.addr}, metadata !17), !dbg !18
-  %0 = load i32** %i.addr, align 8, !dbg !19
-  %1 = load i32* %0, align 4, !dbg !19
-  %add = add nsw i32 %1, 1, !dbg !19
-  store i32 %add, i32* %0, align 4, !dbg !19
-  ret void, !dbg !20
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-; Function Attrs: nounwind uwtable
-define i32 @main(i32 %argc, i8** %argv) #0 {
-entry:
-  %retval = alloca i32, align 4
-  %argc.addr = alloca i32, align 4
-  %argv.addr = alloca i8**, align 8
-  %i = alloca i32, align 4
-  store i32 0, i32* %retval
-  store i32 %argc, i32* %argc.addr, align 4
-  call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !21), !dbg !22
-  store i8** %argv, i8*** %argv.addr, align 8
-  call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !23), !dbg !22
-  call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !24), !dbg !25
-  store i32 7, i32* %i, align 4, !dbg !25
-  call void @blah(i32* %i), !dbg !26
-  %0 = load i32* %i, align 4, !dbg !27
-  ret i32 %0, !dbg !27
-}
-
-attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/function.c] [DW_LANG_C99]
-!1 = metadata !{metadata !"function.c", metadata !""}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4, metadata !10}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"blah", metadata !"blah", metadata !"", i32 10, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32*)* @blah, null, null, metadata !2, i32 10} ; [ DW_TAG_subprogram ] [line 10] [def] [blah]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/function.c]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{null, metadata !8}
-!8 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
-!9 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-!10 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 14, metadata !11, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 15} ; [ DW_TAG_subprogram ] [line 14] [def] [scope 15] [main]
-!11 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!12 = metadata !{metadata !9, metadata !9, metadata !13}
-!13 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !14} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!14 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !15} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!15 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !16} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char]
-!16 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char]
-!17 = metadata !{i32 786689, metadata !4, metadata !"i", metadata !5, i32 16777226, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [i] [line 10]
-!18 = metadata !{i32 10, i32 0, metadata !4, null}
-!19 = metadata !{i32 11, i32 0, metadata !4, null}
-!20 = metadata !{i32 12, i32 0, metadata !4, null}
-!21 = metadata !{i32 786689, metadata !10, metadata !"argc", metadata !5, i32 16777230, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 14]
-!22 = metadata !{i32 14, i32 0, metadata !10, null}
-!23 = metadata !{i32 786689, metadata !10, metadata !"argv", metadata !5, i32 33554446, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 14]
-!24 = metadata !{i32 786688, metadata !10, metadata !"i", metadata !5, i32 16, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [i] [line 16]
-!25 = metadata !{i32 16, i32 0, metadata !10, null}
-!26 = metadata !{i32 17, i32 0, metadata !10, null}
-!27 = metadata !{i32 18, i32 0, metadata !10, null}
-; RUN: opt < %s -debug-ir -S | FileCheck %s.check
diff --git a/llvm/test/Transforms/DebugIR/function.ll.check b/llvm/test/Transforms/DebugIR/function.ll.check
deleted file mode 100644
index df795386097a..000000000000
--- a/llvm/test/Transforms/DebugIR/function.ll.check
+++ /dev/null
@@ -1,36 +0,0 @@
-; CHECK:  %i.addr = alloca i32*, align 8, !dbg !
-; CHECK:  store i32* %i, i32** %i.addr, align 8, !dbg !
-; CHECK:  %0 = load i32** %i.addr, align 8, !dbg !
-; CHECK:  %1 = load i32* %0, align 4, !dbg !
-; CHECK:  %add = add nsw i32 %1, 1, !dbg !
-; CHECK:  store i32 %add, i32* %0, align 4, !dbg !
-; CHECK:  ret void, !dbg !
-
-; CHECK:  %retval = alloca i32, align 4, !dbg !
-; CHECK:  %argc.addr = alloca i32, align 4, !dbg !
-; CHECK:  %argv.addr = alloca i8**, align 8, !dbg !
-; CHECK:  %i = alloca i32, align 4, !dbg !
-; CHECK:  store i32 0, i32* %retval, !dbg !
-; CHECK:  store i32 %argc, i32* %argc.addr, align 4, !dbg !
-; CHECK:  store i8** %argv, i8*** %argv.addr, align 8, !dbg !
-; CHECK:  store i32 7, i32* %i, align 4, !dbg !
-; CHECK:  call void @blah(i32* %i), !dbg !
-; CHECK:  %0 = load i32* %i, align 4, !dbg !
-; CHECK:  ret i32 %0, !dbg !
-
-; CHECK: !1 = metadata !{metadata !"function-debug.ll", metadata !""}
-
-; CHECK: = metadata !{i32 8, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 9, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 10, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 11, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 12, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 13, i32 0, metadata !4, null}
-
-; CHECK: = metadata !{i32 24, i32 0, metadata !10, null}
-; CHECK: = metadata !{i32 25, i32 0, metadata !10, null}
-; CHECK: = metadata !{i32 26, i32 0, metadata !10, null}
-; CHECK: = metadata !{i32 27, i32 0, metadata !10, null}
-; CHECK: = metadata !{i32 28, i32 0, metadata !10, null}
-; CHECK: = metadata !{i32 29, i32 0, metadata !10, null}
-; CHECK: = metadata !{i32 30, i32 0, metadata !10, null}
diff --git a/llvm/test/Transforms/DebugIR/lit.local.cfg b/llvm/test/Transforms/DebugIR/lit.local.cfg
deleted file mode 100644
index c6106e4746f2..000000000000
--- a/llvm/test/Transforms/DebugIR/lit.local.cfg
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.ll']
diff --git a/llvm/test/Transforms/DebugIR/simple.ll b/llvm/test/Transforms/DebugIR/simple.ll
deleted file mode 100644
index e2e8b2f7c205..000000000000
--- a/llvm/test/Transforms/DebugIR/simple.ll
+++ /dev/null
@@ -1,45 +0,0 @@
-; ModuleID = 'simple.c'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-; Function Attrs: nounwind uwtable
-define i32 @main(i32 %argc, i8** %argv) #0 {
-entry:
-  %retval = alloca i32, align 4
-  %argc.addr = alloca i32, align 4
-  %argv.addr = alloca i8**, align 8
-  store i32 0, i32* %retval
-  store i32 %argc, i32* %argc.addr, align 4
-  call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !13), !dbg !14
-  store i8** %argv, i8*** %argv.addr, align 8
-  call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !15), !dbg !14
-  %0 = load i32* %argc.addr, align 4, !dbg !16
-  ret i32 %0, !dbg !16
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/simple.c] [DW_LANG_C99]
-!1 = metadata !{metadata !"simple.c", metadata !""}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 10, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, i8**)* @main, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 10] [def] [scope 11] [main]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/simple.c]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{metadata !8, metadata !8, metadata !9}
-!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
-!11 = metadata !{i32 786470, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char]
-!12 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char]
-!13 = metadata !{i32 786689, metadata !4, metadata !"argc", metadata !5, i32 16777226, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argc] [line 10]
-!14 = metadata !{i32 10, i32 0, metadata !4, null}
-!15 = metadata !{i32 786689, metadata !4, metadata !"argv", metadata !5, i32 33554442, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [argv] [line 10]
-!16 = metadata !{i32 12, i32 0, metadata !4, null}
-; RUN: opt < %s -debug-ir -S | FileCheck %s.check
diff --git a/llvm/test/Transforms/DebugIR/simple.ll.check b/llvm/test/Transforms/DebugIR/simple.ll.check
deleted file mode 100644
index 14be4eff07dd..000000000000
--- a/llvm/test/Transforms/DebugIR/simple.ll.check
+++ /dev/null
@@ -1,13 +0,0 @@
-; CHECK: store i32 0, i32* %retval, !dbg !
-; CHECK: store i32 %argc, i32* %argc.addr, align 4, !dbg !
-; CHECK: store i8** %argv, i8*** %argv.addr, align 8, !dbg !
-; CHECK: %0 = load i32* %argc.addr, align 4, !dbg !
-; CHECK: ret i32 %0, !dbg !
-
-; CHECK: !1 = metadata !{metadata !"simple-debug.ll", metadata !""}
-
-; CHECK: = metadata !{i32 10, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 11, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 12, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 13, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 14, i32 0, metadata !4, null}
diff --git a/llvm/test/Transforms/DebugIR/struct.ll b/llvm/test/Transforms/DebugIR/struct.ll
deleted file mode 100644
index 460ef3b5df7e..000000000000
--- a/llvm/test/Transforms/DebugIR/struct.ll
+++ /dev/null
@@ -1,51 +0,0 @@
-; ModuleID = 'struct.cpp'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-%struct.blah = type { i32, float, i8 }
-
-; Function Attrs: nounwind uwtable
-define i32 @main() #0 {
-entry:
-  %retval = alloca i32, align 4
-  %b = alloca %struct.blah, align 4
-  store i32 0, i32* %retval
-  call void @llvm.dbg.declare(metadata !{%struct.blah* %b}, metadata !9), !dbg !22
-  %a = getelementptr inbounds %struct.blah* %b, i32 0, i32 0, !dbg !23
-  %0 = load i32* %a, align 4, !dbg !23
-  ret i32 %0, !dbg !23
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/struct.cpp] [DW_LANG_C_plus_plus]
-!1 = metadata !{metadata !"struct.cpp", metadata !""}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 8, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !2, i32 8} ; [ DW_TAG_subprogram ] [line 8] [def] [main]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/struct.cpp]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{metadata !8}
-!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-!9 = metadata !{i32 786688, metadata !4, metadata !"b", metadata !5, i32 9, metadata !10, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [b] [line 9]
-!10 = metadata !{i32 786451, metadata !1, null, metadata !"blah", i32 2, i64 96, i64 32, i32 0, i32 0, null, metadata !11, i32 0, null, null} ; [ DW_TAG_structure_type ] [blah] [line 2, size 96, align 32, offset 0] [from ]
-!11 = metadata !{metadata !12, metadata !13, metadata !15, metadata !17}
-!12 = metadata !{i32 786445, metadata !1, metadata !10, metadata !"a", i32 3, i64 32, i64 32, i64 0, i32 0, metadata !8} ; [ DW_TAG_member ] [a] [line 3, size 32, align 32, offset 0] [from int]
-!13 = metadata !{i32 786445, metadata !1, metadata !10, metadata !"b", i32 4, i64 32, i64 32, i64 32, i32 0, metadata !14} ; [ DW_TAG_member ] [b] [line 4, size 32, align 32, offset 32] [from float]
-!14 = metadata !{i32 786468, null, null, metadata !"float", i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float]
-!15 = metadata !{i32 786445, metadata !1, metadata !10, metadata !"c", i32 5, i64 8, i64 8, i64 64, i32 0, metadata !16} ; [ DW_TAG_member ] [c] [line 5, size 8, align 8, offset 64] [from char]
-!16 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char]
-!17 = metadata !{i32 786478, metadata !1, metadata !10, metadata !"blah", metadata !"blah", metadata !"", i32 2, metadata !18, i1 false, i1 false, i32 0, i32 0, null, i32 320, i1 false, null, null, i32 0, metadata !21, i32 2} ; [ DW_TAG_subprogram ] [line 2] [blah]
-!18 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !19, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!19 = metadata !{null, metadata !20}
-!20 = metadata !{i32 786447, i32 0, i32 0, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from blah]
-!21 = metadata !{i32 786468}
-!22 = metadata !{i32 9, i32 0, metadata !4, null}
-!23 = metadata !{i32 10, i32 0, metadata !4, null}
-; RUN: opt < %s -debug-ir -S | FileCheck %s.check
diff --git a/llvm/test/Transforms/DebugIR/struct.ll.check b/llvm/test/Transforms/DebugIR/struct.ll.check
deleted file mode 100644
index f7b7149eed97..000000000000
--- a/llvm/test/Transforms/DebugIR/struct.ll.check
+++ /dev/null
@@ -1,12 +0,0 @@
-; CHECK: %retval = alloca i32, align 4, !dbg !
-; CHECK: %b = alloca %struct.blah, align 4, !dbg !
-; CHECK: store i32 0, i32* %retval, !dbg !
-; CHECK: %a = getelementptr inbounds %struct.blah* %b, i32 0, i32 0, !dbg !
-; CHECK: %0 = load i32* %a, align 4, !dbg !
-; CHECK: ret i32 %0, !dbg !
-
-; CHECK: = metadata !{metadata !"struct-debug.ll", metadata !""}
-; CHECK: = metadata !{i32 11, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 12, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 13, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 14, i32 0, metadata !4, null}
diff --git a/llvm/test/Transforms/DebugIR/vector.ll b/llvm/test/Transforms/DebugIR/vector.ll
deleted file mode 100644
index 8f2a63f8dc61..000000000000
--- a/llvm/test/Transforms/DebugIR/vector.ll
+++ /dev/null
@@ -1,123 +0,0 @@
-; ModuleID = 'vector.cpp'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-; Function Attrs: noinline nounwind uwtable
-define <4 x float> @_Z3fooDv2_fS_(double %a.coerce, double %b.coerce) #0 {
-entry:
-  %a = alloca <2 x float>, align 8
-  %a.addr = alloca <2 x float>, align 8
-  %b = alloca <2 x float>, align 8
-  %b.addr = alloca <2 x float>, align 8
-  %c = alloca <4 x float>, align 16
-  %0 = bitcast <2 x float>* %a to double*
-  store double %a.coerce, double* %0, align 1
-  %a1 = load <2 x float>* %a, align 8
-  store <2 x float> %a1, <2 x float>* %a.addr, align 8
-  call void @llvm.dbg.declare(metadata !{<2 x float>* %a.addr}, metadata !21), !dbg !22
-  %1 = bitcast <2 x float>* %b to double*
-  store double %b.coerce, double* %1, align 1
-  %b2 = load <2 x float>* %b, align 8
-  store <2 x float> %b2, <2 x float>* %b.addr, align 8
-  call void @llvm.dbg.declare(metadata !{<2 x float>* %b.addr}, metadata !23), !dbg !22
-  call void @llvm.dbg.declare(metadata !{<4 x float>* %c}, metadata !24), !dbg !25
-  %2 = load <2 x float>* %a.addr, align 8, !dbg !26
-  %3 = load <4 x float>* %c, align 16, !dbg !26
-  %4 = shufflevector <2 x float> %2, <2 x float> undef, <4 x i32> , !dbg !26
-  %5 = shufflevector <4 x float> %3, <4 x float> %4, <4 x i32> , !dbg !26
-  store <4 x float> %5, <4 x float>* %c, align 16, !dbg !26
-  %6 = load <2 x float>* %b.addr, align 8, !dbg !27
-  %7 = load <4 x float>* %c, align 16, !dbg !27
-  %8 = shufflevector <2 x float> %6, <2 x float> undef, <4 x i32> , !dbg !27
-  %9 = shufflevector <4 x float> %7, <4 x float> %8, <4 x i32> , !dbg !27
-  store <4 x float> %9, <4 x float>* %c, align 16, !dbg !27
-  %10 = load <4 x float>* %c, align 16, !dbg !28
-  ret <4 x float> %10, !dbg !28
-}
-
-; Function Attrs: nounwind readnone
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-; Function Attrs: nounwind uwtable
-define i32 @main() #2 {
-entry:
-  %retval = alloca i32, align 4
-  %a = alloca <2 x float>, align 8
-  %b = alloca <2 x float>, align 8
-  %x = alloca <4 x float>, align 16
-  %coerce = alloca <2 x float>, align 8
-  %coerce1 = alloca <2 x float>, align 8
-  store i32 0, i32* %retval
-  call void @llvm.dbg.declare(metadata !{<2 x float>* %a}, metadata !29), !dbg !30
-  store <2 x float> , <2 x float>* %a, align 8, !dbg !30
-  call void @llvm.dbg.declare(metadata !{<2 x float>* %b}, metadata !31), !dbg !32
-  store <2 x float> , <2 x float>* %b, align 8, !dbg !32
-  call void @llvm.dbg.declare(metadata !{<4 x float>* %x}, metadata !33), !dbg !34
-  %0 = load <2 x float>* %a, align 8, !dbg !34
-  %1 = load <2 x float>* %b, align 8, !dbg !34
-  store <2 x float> %0, <2 x float>* %coerce, align 8, !dbg !34
-  %2 = bitcast <2 x float>* %coerce to double*, !dbg !34
-  %3 = load double* %2, align 1, !dbg !34
-  store <2 x float> %1, <2 x float>* %coerce1, align 8, !dbg !34
-  %4 = bitcast <2 x float>* %coerce1 to double*, !dbg !34
-  %5 = load double* %4, align 1, !dbg !34
-  %call = call <4 x float> @_Z3fooDv2_fS_(double %3, double %5), !dbg !34
-  store <4 x float> %call, <4 x float>* %x, align 16, !dbg !34
-  %6 = load <4 x float>* %x, align 16, !dbg !35
-  %7 = extractelement <4 x float> %6, i32 0, !dbg !35
-  %8 = load <4 x float>* %x, align 16, !dbg !35
-  %9 = extractelement <4 x float> %8, i32 1, !dbg !35
-  %add = fadd float %7, %9, !dbg !35
-  %10 = load <4 x float>* %x, align 16, !dbg !35
-  %11 = extractelement <4 x float> %10, i32 2, !dbg !35
-  %add2 = fadd float %add, %11, !dbg !35
-  %12 = load <4 x float>* %x, align 16, !dbg !35
-  %13 = extractelement <4 x float> %12, i32 3, !dbg !35
-  %add3 = fadd float %add2, %13, !dbg !35
-  %conv = fptosi float %add3 to i32, !dbg !35
-  ret i32 %conv, !dbg !35
-}
-
-attributes #0 = { noinline nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone }
-attributes #2 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/vector.cpp] [DW_LANG_C_plus_plus]
-!1 = metadata !{metadata !"vector.cpp", metadata !""}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4, metadata !17}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"foo", metadata !"foo", metadata !"_Z3fooDv2_fS_", i32 6, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, <4 x float> (double, double)* @_Z3fooDv2_fS_, null, null, metadata !2, i32 6} ; [ DW_TAG_subprogram ] [line 6] [def] [foo]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/vector.cpp]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{metadata !8, metadata !13, metadata !13}
-!8 = metadata !{i32 786454, metadata !1, null, metadata !"float4", i32 2, i64 0, i64 0, i64 0, i32 0, metadata !9} ; [ DW_TAG_typedef ] [float4] [line 2, size 0, align 0, offset 0] [from ]
-!9 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 128, i64 128, i32 0, i32 2048, metadata !10, metadata !11, i32 0, i32 0} ; [ DW_TAG_array_type ] [line 0, size 128, align 128, offset 0] [vector] [from float]
-!10 = metadata !{i32 786468, null, null, metadata !"float", i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float]
-!11 = metadata !{metadata !12}
-!12 = metadata !{i32 786465, i64 0, i64 4}        ; [ DW_TAG_subrange_type ] [0, 3]
-!13 = metadata !{i32 786454, metadata !1, null, metadata !"float2", i32 3, i64 0, i64 0, i64 0, i32 0, metadata !14} ; [ DW_TAG_typedef ] [float2] [line 3, size 0, align 0, offset 0] [from ]
-!14 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 64, i64 64, i32 0, i32 2048, metadata !10, metadata !15, i32 0, i32 0} ; [ DW_TAG_array_type ] [line 0, size 64, align 64, offset 0] [vector] [from float]
-!15 = metadata !{metadata !16}
-!16 = metadata !{i32 786465, i64 0, i64 2}        ; [ DW_TAG_subrange_type ] [0, 1]
-!17 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 13, metadata !18, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [main]
-!18 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !19, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!19 = metadata !{metadata !20}
-!20 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-!21 = metadata !{i32 786689, metadata !4, metadata !"a", metadata !5, i32 16777222, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 6]
-!22 = metadata !{i32 6, i32 0, metadata !4, null}
-!23 = metadata !{i32 786689, metadata !4, metadata !"b", metadata !5, i32 33554438, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [b] [line 6]
-!24 = metadata !{i32 786688, metadata !4, metadata !"c", metadata !5, i32 7, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [c] [line 7]
-!25 = metadata !{i32 7, i32 0, metadata !4, null}
-!26 = metadata !{i32 8, i32 0, metadata !4, null} ; [ DW_TAG_imported_declaration ]
-!27 = metadata !{i32 9, i32 0, metadata !4, null}
-!28 = metadata !{i32 10, i32 0, metadata !4, null}
-!29 = metadata !{i32 786688, metadata !17, metadata !"a", metadata !5, i32 14, metadata !13, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 14]
-!30 = metadata !{i32 14, i32 0, metadata !17, null}
-!31 = metadata !{i32 786688, metadata !17, metadata !"b", metadata !5, i32 15, metadata !13, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [b] [line 15]
-!32 = metadata !{i32 15, i32 0, metadata !17, null}
-!33 = metadata !{i32 786688, metadata !17, metadata !"x", metadata !5, i32 16, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [x] [line 16]
-!34 = metadata !{i32 16, i32 0, metadata !17, null}
-!35 = metadata !{i32 18, i32 0, metadata !17, null}
-; RUN: opt < %s -debug-ir -S | FileCheck %s.check
diff --git a/llvm/test/Transforms/DebugIR/vector.ll.check b/llvm/test/Transforms/DebugIR/vector.ll.check
deleted file mode 100644
index 1de68c4de0a0..000000000000
--- a/llvm/test/Transforms/DebugIR/vector.ll.check
+++ /dev/null
@@ -1,39 +0,0 @@
-; CHECK:  store double %a.coerce, double* %0, align 1, !dbg !
-; CHECK:  %a1 = load <2 x float>* %a, align 8, !dbg !
-; CHECK:  store <2 x float> %a1, <2 x float>* %a.addr, align 8, !dbg !
-; CHECK:  store double %b.coerce, double* %1, align 1, !dbg !
-; CHECK:  %b2 = load <2 x float>* %b, align 8, !dbg !
-; CHECK:  store <2 x float> %b2, <2 x float>* %b.addr, align 8, !dbg !
-; CHECK:  %2 = load <2 x float>* %a.addr, align 8, !dbg !
-; CHECK:  %3 = load <4 x float>* %c, align 16, !dbg !
-; CHECK:  %4 = shufflevector <2 x float> %2, <2 x float> undef, <4 x i32> , !dbg !
-; CHECK:  %5 = shufflevector <4 x float> %3, <4 x float> %4, <4 x i32> , !dbg !
-; CHECK:  store <4 x float> %5, <4 x float>* %c, align 16, !dbg !
-; CHECK:  %6 = load <2 x float>* %b.addr, align 8, !dbg !
-; CHECK:  %7 = load <4 x float>* %c, align 16, !dbg !
-; CHECK:  %8 = shufflevector <2 x float> %6, <2 x float> undef, <4 x i32> , !dbg !
-; CHECK:  %9 = shufflevector <4 x float> %7, <4 x float> %8, <4 x i32> , !dbg !
-; CHECK:  store <4 x float> %9, <4 x float>* %c, align 16, !dbg !
-; CHECK:  %10 = load <4 x float>* %c, align 16, !dbg !
-; CHECK:  ret <4 x float> %10, !dbg !
-
-; CHECK: = metadata !{metadata !"vector-debug.ll", metadata !""}
-; CHECK: = metadata !{i32 13, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 14, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 15, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 16, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 17, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 18, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 19, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 20, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 21, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 22, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 23, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 24, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 25, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 26, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 27, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 28, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 29, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 30, i32 0, metadata !4, null}
-; CHECK: = metadata !{i32 31, i32 0, metadata !4, null}
-- 
GitLab


From aa9b280c79bcf4addb3e3d5c70e8fe08110c5e4c Mon Sep 17 00:00:00 2001
From: Fariborz Jahanian 
Date: Wed, 8 May 2013 22:14:28 +0000
Subject: [PATCH 052/467] [doc parsing]: Also do typo correction for
 dynamically registered commands. // rdar://12381408

llvm-svn: 181477
---
 clang/lib/AST/CommentCommandTraits.cpp        | 49 ++++++++++++-------
 clang/test/Sema/warn-documentation-fixits.cpp |  9 +++-
 2 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp
index e4cc84afb78e..dc4744a53c59 100644
--- a/clang/lib/AST/CommentCommandTraits.cpp
+++ b/clang/lib/AST/CommentCommandTraits.cpp
@@ -43,30 +43,41 @@ const CommandInfo *CommandTraits::getCommandInfo(unsigned CommandID) const {
   return getRegisteredCommandInfo(CommandID);
 }
 
-const CommandInfo *
-CommandTraits::getTypoCorrectCommandInfo(StringRef Typo) const {
+static void
+HelperTypoCorrectCommandInfo(SmallVectorImpl &BestCommand,
+                             StringRef Typo, const CommandInfo *Command) {
   const unsigned MaxEditDistance = 1;
   unsigned BestEditDistance = MaxEditDistance + 1;
+  StringRef Name = Command->Name;
+  
+  unsigned MinPossibleEditDistance = abs((int)Name.size() - (int)Typo.size());
+  if (MinPossibleEditDistance > 0 &&
+      Typo.size() / MinPossibleEditDistance < 1)
+    return;
+  unsigned EditDistance = Typo.edit_distance(Name, true, MaxEditDistance);
+  if (EditDistance > MaxEditDistance)
+    return;
+  if (EditDistance == BestEditDistance)
+    BestCommand.push_back(Command);
+  else if (EditDistance < BestEditDistance) {
+    BestCommand.clear();
+    BestCommand.push_back(Command);
+    BestEditDistance = EditDistance;
+  }
+}
+
+const CommandInfo *
+CommandTraits::getTypoCorrectCommandInfo(StringRef Typo) const {
   SmallVector BestCommand;
   
   int NumOfCommands = sizeof(Commands) / sizeof(CommandInfo);
-  for (int i = 0; i < NumOfCommands; i++) {
-    StringRef Name = Commands[i].Name;
-    unsigned MinPossibleEditDistance = abs((int)Name.size() - (int)Typo.size());
-    if (MinPossibleEditDistance > 0 &&
-        Typo.size() / MinPossibleEditDistance < 1)
-      continue;
-    unsigned EditDistance = Typo.edit_distance(Name, true, MaxEditDistance);
-    if (EditDistance > MaxEditDistance)
-      continue;
-    if (EditDistance == BestEditDistance)
-      BestCommand.push_back(&Commands[i]);
-    else if (EditDistance < BestEditDistance) {
-      BestCommand.clear();
-      BestCommand.push_back(&Commands[i]);
-      BestEditDistance = EditDistance;
-    }
-  }
+  for (int i = 0; i < NumOfCommands; i++)
+    HelperTypoCorrectCommandInfo(BestCommand, Typo, &Commands[i]);
+  
+  for (unsigned i = 0, e = RegisteredCommands.size(); i != e; ++i)
+    if (!RegisteredCommands[i]->IsUnknownCommand)
+      HelperTypoCorrectCommandInfo(BestCommand, Typo, RegisteredCommands[i]);
+  
   return (BestCommand.size() != 1) ? NULL : BestCommand[0];
 }
 
diff --git a/clang/test/Sema/warn-documentation-fixits.cpp b/clang/test/Sema/warn-documentation-fixits.cpp
index 79bf7698a91e..707ecb362f86 100644
--- a/clang/test/Sema/warn-documentation-fixits.cpp
+++ b/clang/test/Sema/warn-documentation-fixits.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 // expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
 /// \param ZZZZZZZZZZ Blah blah.
@@ -63,6 +63,10 @@ void test_deprecated_9(int a);
 /// \retur int in FooBar
 int FooBar();
 
+// expected-warning@+1  {{unknown command tag name 'fooba'; did you mean 'foobar'?}}
+/// \fooba bbb IS_DOXYGEN_END
+int gorf();
+
 // CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a"
 // CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa"
 // CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T"
@@ -75,3 +79,4 @@ int FooBar();
 // CHECK: fix-it:"{{.*}}":{50:27-50:27}:" __attribute__((deprecated))"
 // CHECK: fix-it:"{{.*}}":{58:30-58:30}:" MY_ATTR_DEPRECATED"
 // CHECK: fix-it:"{{.*}}":{63:6-63:11}:"return"
+// CHECK: fix-it:"{{.*}}":{67:6-67:11}:"foobar"
-- 
GitLab


From d0b963e8398e1696ce4d9b86c20a2ee9c2402f3d Mon Sep 17 00:00:00 2001
From: Dmitri Gribenko 
Date: Wed, 8 May 2013 22:28:48 +0000
Subject: [PATCH 053/467] Use correct parameter names in comments
 [-Wdocumentation]

llvm-svn: 181478
---
 llvm/include/llvm/Support/CommandLine.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index bfaafda50c17..30c53253b3ec 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -1710,8 +1710,8 @@ void PrintVersionMessage();
 ///
 /// NOTE: THIS FUNCTION TERMINATES THE PROGRAM!
 ///
-/// \param hidden if true will print hidden options
-/// \param categorized if true print options in categories
+/// \param Hidden if true will print hidden options
+/// \param Categorized if true print options in categories
 void PrintHelpMessage(bool Hidden=false, bool Categorized=false);
 
 
@@ -1722,7 +1722,7 @@ void PrintHelpMessage(bool Hidden=false, bool Categorized=false);
 /// \brief Use this to get a StringMap to all registered named options
 /// (e.g. -help). Note \p Map Should be an empty StringMap.
 ///
-/// \param [out] map will be filled with mappings where the key is the
+/// \param [out] Map will be filled with mappings where the key is the
 /// Option argument string (e.g. "help") and value is the corresponding
 /// Option*.
 ///
-- 
GitLab


From 7e548f70e8d19de7ccac02ed74cf4b2cbee46bb9 Mon Sep 17 00:00:00 2001
From: Fariborz Jahanian 
Date: Wed, 8 May 2013 22:52:20 +0000
Subject: [PATCH 054/467] unbreak buildbot.

llvm-svn: 181479
---
 clang/lib/CodeGen/CGBlocks.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index ded019e64ae8..411cc0e30597 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -68,7 +68,7 @@ static llvm::Constant *buildDisposeHelper(CodeGenModule &CGM,
 ///   unsigned long size;  // size of Block_literal metadata in bytes.
 ///   void *copy_func_helper_decl;  // optional copy helper.
 ///   void *destroy_func_decl; // optioanl destructor helper.
-///   void *block_method_encoding_address;//@encode for block literal signature.
+///   void *block_method_encoding_address;// \@encode for block literal signature.
 ///   void *block_layout_info; // encoding of captured block variables.
 /// };
 static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM,
-- 
GitLab


From 352e81ffb5697bcdd6807d73eac9992cd342ed86 Mon Sep 17 00:00:00 2001
From: Dmitri Gribenko 
Date: Wed, 8 May 2013 22:54:41 +0000
Subject: [PATCH 055/467] All -Wdocumentation warnings are DefaultIgnore

llvm-svn: 181480
---
 clang/include/clang/Basic/DiagnosticCommentKinds.td | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommentKinds.td b/clang/include/clang/Basic/DiagnosticCommentKinds.td
index 4619e8a6b0b7..beeb23fcb118 100644
--- a/clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -160,8 +160,8 @@ def warn_unknown_comment_command_name : Warning<
   "unknown command tag name">, InGroup, DefaultIgnore;
 
 def warn_correct_comment_command_name : Warning<
-  "unknown command tag name '%0'; did you mean '%1'?">, 
-  InGroup;
+  "unknown command tag name '%0'; did you mean '%1'?">,
+  InGroup, DefaultIgnore;
 
 } // end of documentation issue category
 } // end of AST component
-- 
GitLab


From 6c96ba2dc0c382fcb8822c13dadab53bd1dcf821 Mon Sep 17 00:00:00 2001
From: Dmitri Gribenko 
Date: Wed, 8 May 2013 23:09:44 +0000
Subject: [PATCH 056/467] Comment: use \code...\endcode for code examples

llvm-svn: 181481
---
 clang/lib/CodeGen/CGBlocks.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 411cc0e30597..8cc4891cc7ff 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -63,14 +63,16 @@ static llvm::Constant *buildDisposeHelper(CodeGenModule &CGM,
 /// buildBlockDescriptor is accessed from 5th field of the Block_literal
 /// meta-data and contains stationary information about the block literal.
 /// Its definition will have 4 (or optinally 6) words.
+/// \code
 /// struct Block_descriptor {
 ///   unsigned long reserved;
 ///   unsigned long size;  // size of Block_literal metadata in bytes.
 ///   void *copy_func_helper_decl;  // optional copy helper.
 ///   void *destroy_func_decl; // optioanl destructor helper.
-///   void *block_method_encoding_address;// \@encode for block literal signature.
+///   void *block_method_encoding_address; // @encode for block literal signature.
 ///   void *block_layout_info; // encoding of captured block variables.
 /// };
+/// \endcode
 static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM,
                                             const CGBlockInfo &blockInfo) {
   ASTContext &C = CGM.getContext();
-- 
GitLab


From 14263f31ae9d03bfb92bdea5cc5961fb5863784a Mon Sep 17 00:00:00 2001
From: Andrew Kaylor 
Date: Wed, 8 May 2013 23:15:46 +0000
Subject: [PATCH 057/467] Adding code to set thread state to stopped when the
 process stops.

llvm-svn: 181482
---
 lldb/include/lldb/Target/Thread.h             |  4 ++++
 lldb/include/lldb/Target/ThreadList.h         |  3 +++
 lldb/source/Target/Process.cpp                | 13 +++++++++++
 lldb/source/Target/Thread.cpp                 |  6 +++++
 lldb/source/Target/ThreadList.cpp             | 22 +++++++++++++++++++
 .../thread/state/TestThreadStates.py          |  2 --
 6 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h
index f1f8439e2a49..1856d63d5ffb 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -277,6 +277,10 @@ public:
     virtual void
     DidResume ();
 
+    // This notifies the thread when a private stop occurs.
+    virtual void
+    DidStop ();
+
     virtual void
     RefreshStateAfterStop() = 0;
 
diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h
index 959091c81bfe..ddf49b002ecf 100644
--- a/lldb/include/lldb/Target/ThreadList.h
+++ b/lldb/include/lldb/Target/ThreadList.h
@@ -119,6 +119,9 @@ public:
     void
     DidResume ();
 
+    void
+    DidStop ();
+
     void
     DiscardThreadPlans();
 
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 93fd93a71de4..f6fdca8a425a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1722,6 +1722,19 @@ Process::SetPrivateState (StateType new_state)
         m_private_state.SetValueNoLock (new_state);
         if (StateIsStoppedState(new_state, false))
         {
+            // Note, this currently assumes that all threads in the list
+            // stop when the process stops.  In the future we will want to
+            // support a debugging model where some threads continue to run
+            // while others are stopped.  When that happens we will either need
+            // a way for the thread list to identify which threads are stopping
+            // or create a special thread list containing only threads which
+            // actually stopped.
+            //
+            // The process plugin is responsible for managing the actual
+            // behavior of the threads and should have stopped any threads
+            // that are going to stop before we get here.
+            m_thread_list.DidStop();
+
             m_mod_id.BumpStopID();
             m_memory_cache.Clear();
             if (log)
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 23c75e3e9ac7..478021ac367d 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -610,6 +610,12 @@ Thread::DidResume ()
     SetResumeSignal (LLDB_INVALID_SIGNAL_NUMBER);
 }
 
+void
+Thread::DidStop ()
+{
+    SetState (eStateStopped);
+}
+
 bool
 Thread::ShouldStop (Event* event_ptr)
 {
diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp
index 4971d6c963f6..8db2b40d2925 100644
--- a/lldb/source/Target/ThreadList.cpp
+++ b/lldb/source/Target/ThreadList.cpp
@@ -11,6 +11,7 @@
 #include 
 
 #include "lldb/Core/Log.h"
+#include "lldb/Core/State.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Target/Thread.h"
@@ -648,6 +649,27 @@ ThreadList::DidResume ()
     }
 }
 
+void
+ThreadList::DidStop ()
+{
+    Mutex::Locker locker(GetMutex());
+    collection::iterator pos, end = m_threads.end();
+    for (pos = m_threads.begin(); pos != end; ++pos)
+    {
+        // Notify threads that the process just stopped.
+        // Note, this currently assumes that all threads in the list
+        // stop when the process stops.  In the future we will want to support
+        // a debugging model where some threads continue to run while others
+        // are stopped.  We either need to handle that somehow here or
+        // create a special thread list containing only threads which will
+        // stop in the code that calls this method (currently
+        // Process::SetPrivateState).
+        ThreadSP thread_sp(*pos);
+        if (StateIsRunningState(thread_sp->GetState()))
+            thread_sp->DidStop ();
+    }
+}
+
 ThreadSP
 ThreadList::GetSelectedThread ()
 {
diff --git a/lldb/test/functionalities/thread/state/TestThreadStates.py b/lldb/test/functionalities/thread/state/TestThreadStates.py
index 7e59b22aaee6..185eb50106ac 100644
--- a/lldb/test/functionalities/thread/state/TestThreadStates.py
+++ b/lldb/test/functionalities/thread/state/TestThreadStates.py
@@ -14,14 +14,12 @@ class StopThreadsTestCase(TestBase):
 
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
-    @unittest2.expectedFailure("PR-15824") # thread states not properly maintained
     def test_state_after_breakpoint_with_dsym(self):
         """Test thread state after breakpoint."""
         self.buildDsym()
         self.thread_state_after_breakpoint_test()
 
     @dwarf_test
-    @unittest2.expectedFailure("PR-15824") # thread states not properly maintained
     def test_state_after_breakpoint_with_dwarf(self):
         """Test thread state after breakpoint."""
         self.buildDwarf()
-- 
GitLab


From ec504cfffdfbeaf17e492dbd5e38922afe4690bf Mon Sep 17 00:00:00 2001
From: Rui Ueyama 
Date: Wed, 8 May 2013 23:20:53 +0000
Subject: [PATCH 058/467] [lld] Add "explicit" to constructors where
 appropriate.

Summary:
Add the explicit keyword to one-parameter
constructors to prevent unintended type conversions.

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D765

llvm-svn: 181483
---
 lld/include/lld/Core/Atom.h                   |  2 +-
 lld/include/lld/Core/Instrumentation.h        |  2 +-
 lld/include/lld/Core/Parallel.h               |  6 +++---
 lld/include/lld/Core/Resolver.h               | 20 +++++++++----------
 lld/include/lld/Core/SharedLibraryFile.h      |  2 +-
 lld/include/lld/Core/SymbolTable.h            |  2 +-
 lld/include/lld/Driver/LinkerInput.h          |  4 ++--
 lld/include/lld/Passes/LayoutPass.h           |  2 +-
 lld/include/lld/ReaderWriter/LinkerScript.h   | 14 +++++++------
 .../lld/ReaderWriter/ReaderLinkerScript.h     |  2 +-
 lld/include/lld/ReaderWriter/Simple.h         |  2 +-
 11 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/lld/include/lld/Core/Atom.h b/lld/include/lld/Core/Atom.h
index fbda9b193ed6..bf1d46bf9cc3 100644
--- a/lld/include/lld/Core/Atom.h
+++ b/lld/include/lld/Core/Atom.h
@@ -67,7 +67,7 @@ public:
 
 protected:
   /// Atom is an abstract base class.  Only subclasses can access constructor.
-  Atom(Definition def) : _definition(def) {}
+  explicit Atom(Definition def) : _definition(def) {}
 
   /// The memory for Atom objects is always managed by the owning File
   /// object.  Therefore, no one but the owning File object should call
diff --git a/lld/include/lld/Core/Instrumentation.h b/lld/include/lld/Core/Instrumentation.h
index 9d2dc02bc41e..582c2123f80f 100644
--- a/lld/include/lld/Core/Instrumentation.h
+++ b/lld/include/lld/Core/Instrumentation.h
@@ -29,7 +29,7 @@ class Domain {
   __itt_domain *_domain;
 
 public:
-  Domain(const char *name) : _domain(__itt_domain_createA(name)) {}
+  explicit Domain(const char *name) : _domain(__itt_domain_createA(name)) {}
 
   operator __itt_domain *() const { return _domain; }
   __itt_domain *operator->() const { return _domain; }
diff --git a/lld/include/lld/Core/Parallel.h b/lld/include/lld/Core/Parallel.h
index b1eb1f1922c6..a385882f3706 100644
--- a/lld/include/lld/Core/Parallel.h
+++ b/lld/include/lld/Core/Parallel.h
@@ -49,7 +49,7 @@ class Latch {
   mutable std::condition_variable _cond;
 
 public:
-  Latch(uint32_t count = 0) : _count(count) {}
+  explicit Latch(uint32_t count = 0) : _count(count) {}
   ~Latch() { sync(); }
   void inc() { ++_count; }
 
@@ -77,8 +77,8 @@ public:
 ///   in filo order.
 class ThreadPoolExecutor : public Executor {
 public:
-  ThreadPoolExecutor(unsigned threadCount =
-                         std::thread::hardware_concurrency())
+  explicit ThreadPoolExecutor(unsigned threadCount =
+                                  std::thread::hardware_concurrency())
       : _stop(false), _done(threadCount) {
     // Spawn all but one of the threads in another thread as spawning threads
     // can take a while.
diff --git a/lld/include/lld/Core/Resolver.h b/lld/include/lld/Core/Resolver.h
index fba9134d436b..29f016b1d0e3 100644
--- a/lld/include/lld/Core/Resolver.h
+++ b/lld/include/lld/Core/Resolver.h
@@ -70,21 +70,21 @@ private:
 
     virtual const atom_collection &defined() const {
       return _definedAtoms;
-  }
-  virtual const atom_collection& undefined() const {
+    }
+    virtual const atom_collection& undefined() const {
       return _undefinedAtoms;
-  }
-  virtual const atom_collection& sharedLibrary() const {
+    }
+    virtual const atom_collection& sharedLibrary() const {
       return _sharedLibraryAtoms;
-  }
-  virtual const atom_collection& absolute() const {
+    }
+    virtual const atom_collection& absolute() const {
       return _absoluteAtoms;
-  }
+    }
 
-  void addAtoms(std::vector& atoms);
+    void addAtoms(std::vector& atoms);
 
-  virtual void addAtom(const Atom& atom);
-  virtual DefinedAtomRange definedAtoms();
+    virtual void addAtom(const Atom& atom);
+    virtual DefinedAtomRange definedAtoms();
 
   private:
     friend class Resolver;
diff --git a/lld/include/lld/Core/SharedLibraryFile.h b/lld/include/lld/Core/SharedLibraryFile.h
index 1b68e741022b..04afe692cc59 100644
--- a/lld/include/lld/Core/SharedLibraryFile.h
+++ b/lld/include/lld/Core/SharedLibraryFile.h
@@ -35,7 +35,7 @@ public:
                                            bool dataSymbolOnly) const = 0;
 protected:
   /// only subclasses of SharedLibraryFile can be instantiated
-  SharedLibraryFile(StringRef path) : File(path, kindSharedLibrary) {}
+  explicit SharedLibraryFile(StringRef path) : File(path, kindSharedLibrary) {}
 };
 
 } // namespace lld
diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h
index 990f9be44d76..79b2856653cd 100644
--- a/lld/include/lld/Core/SymbolTable.h
+++ b/lld/include/lld/Core/SymbolTable.h
@@ -37,7 +37,7 @@ class UndefinedAtom;
 /// if an atom has been coalesced away.
 class SymbolTable {
 public:
-  SymbolTable(const TargetInfo &);
+  explicit SymbolTable(const TargetInfo &);
 
   /// @brief add atom to symbol table
   void add(const DefinedAtom &);
diff --git a/lld/include/lld/Driver/LinkerInput.h b/lld/include/lld/Driver/LinkerInput.h
index cb3437212a0e..8fa53b09a932 100644
--- a/lld/include/lld/Driver/LinkerInput.h
+++ b/lld/include/lld/Driver/LinkerInput.h
@@ -45,9 +45,9 @@ class LinkerInput {
   LinkerInput(const LinkerInput &) LLVM_DELETED_FUNCTION;
 
 public:
-  LinkerInput(StringRef file) : _file(file) {}
+  explicit LinkerInput(StringRef file) : _file(file) {}
 
-  LinkerInput(std::unique_ptr buffer)
+  explicit LinkerInput(std::unique_ptr buffer)
       : _buffer(std::move(buffer)), _file(_buffer->getBufferIdentifier()) {
   }
 
diff --git a/lld/include/lld/Passes/LayoutPass.h b/lld/include/lld/Passes/LayoutPass.h
index 2d46714ed215..5df3a0abe98a 100644
--- a/lld/include/lld/Passes/LayoutPass.h
+++ b/lld/include/lld/Passes/LayoutPass.h
@@ -36,7 +36,7 @@ public:
   // Compare and Sort Atoms by their ordinals
   class CompareAtoms {
   public:
-    CompareAtoms(const LayoutPass &pass) : _layout(pass) {}
+    explicit CompareAtoms(const LayoutPass &pass) : _layout(pass) {}
     bool operator()(const DefinedAtom *left, const DefinedAtom *right);
   private:
     const LayoutPass &_layout;
diff --git a/lld/include/lld/ReaderWriter/LinkerScript.h b/lld/include/lld/ReaderWriter/LinkerScript.h
index dc7020feb223..90a01f35b685 100644
--- a/lld/include/lld/ReaderWriter/LinkerScript.h
+++ b/lld/include/lld/ReaderWriter/LinkerScript.h
@@ -51,7 +51,8 @@ public:
 
 class Lexer {
 public:
-  Lexer(std::unique_ptr mb) : _buffer(mb->getBuffer()) {
+  explicit Lexer(std::unique_ptr mb)
+      : _buffer(mb->getBuffer()) {
     _sourceManager.AddNewSourceBuffer(mb.release(), llvm::SMLoc());
   }
 
@@ -85,7 +86,7 @@ public:
   virtual ~Command() {}
 
 protected:
-  Command(Kind k) : _kind(k) {}
+  explicit Command(Kind k) : _kind(k) {}
 
 private:
   Kind _kind;
@@ -93,7 +94,7 @@ private:
 
 class OutputFormat : public Command {
 public:
-  OutputFormat(StringRef format)
+  explicit OutputFormat(StringRef format)
       : Command(Kind::OutputFormat), _format(format) {}
 
   static bool classof(const Command *c) {
@@ -115,13 +116,14 @@ struct Path {
   bool _asNeeded;
 
   Path() : _asNeeded(false) {}
-  Path(StringRef path, bool asNeeded = false)
+  explicit Path(StringRef path, bool asNeeded = false)
       : _path(path), _asNeeded(asNeeded) {}
 };
 
 class Group : public Command {
 public:
-  template  Group(RangeT range) : Command(Kind::Group) {
+  template 
+  explicit Group(RangeT range) : Command(Kind::Group) {
     using std::begin;
     using std::end;
     std::copy(begin(range), end(range), std::back_inserter(_paths));
@@ -164,7 +166,7 @@ public:
 
 class Parser {
 public:
-  Parser(Lexer &lex) : _lex(lex) {}
+  explicit Parser(Lexer &lex) : _lex(lex) {}
 
   LinkerScript *parse();
 
diff --git a/lld/include/lld/ReaderWriter/ReaderLinkerScript.h b/lld/include/lld/ReaderWriter/ReaderLinkerScript.h
index 0dfa5d3c20aa..18cbb3a7a861 100644
--- a/lld/include/lld/ReaderWriter/ReaderLinkerScript.h
+++ b/lld/include/lld/ReaderWriter/ReaderLinkerScript.h
@@ -21,7 +21,7 @@ class TargetInfo;
 /// \brief ReaderLinkerScript is a class for reading linker scripts
 class ReaderLinkerScript : public Reader {
 public:
-  ReaderLinkerScript(const TargetInfo &ti)
+  explicit ReaderLinkerScript(const TargetInfo &ti)
       : Reader(ti) {}
 
   /// \brief Returns a vector of Files that are contained in the archive file
diff --git a/lld/include/lld/ReaderWriter/Simple.h b/lld/include/lld/ReaderWriter/Simple.h
index fd25f10f7fe2..2baa114bdfba 100644
--- a/lld/include/lld/ReaderWriter/Simple.h
+++ b/lld/include/lld/ReaderWriter/Simple.h
@@ -96,7 +96,7 @@ private:
 
 class SimpleDefinedAtom : public DefinedAtom {
 public:
-  SimpleDefinedAtom(const File &f) : _file(f) {
+  explicit SimpleDefinedAtom(const File &f) : _file(f) {
     static uint32_t lastOrdinal = 0;
     _ordinal = lastOrdinal++;
   }
-- 
GitLab


From 980e52d7aece79c69cf176fb835c5ff5347f7a7b Mon Sep 17 00:00:00 2001
From: Rui Ueyama 
Date: Wed, 8 May 2013 23:29:24 +0000
Subject: [PATCH 059/467] [lld][Core] Fix latch synchronization bug.

We need to acquire a lock before signal a condition.
Otherwise threads waiting on a condition variable can
miss a signal.

Consider two threads: Thread A executing dec() and thread
B executing sync(). The initial value of _count is 1. If
these two threads are interleaved in the following order,
thread B misses the signal sent by thread A, because at the
time thread A sends a signal, B is not waiting for it.

  Thread A                 |   Thread B
                           |   std::unique_lock lock(_condMut);
                           |   while (!(_count == 0)) {
  if (--_count == 0)       |
    _cond_notify_all()     |
                           |     _cond.wait();
                           |   }

Note that "wait(lock, pred)" is equivalent to "while(!pred())
wait(lock)", so I expanded it in the above example.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D764

llvm-svn: 181484
---
 lld/include/lld/Core/Parallel.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lld/include/lld/Core/Parallel.h b/lld/include/lld/Core/Parallel.h
index a385882f3706..82fa30ead70f 100644
--- a/lld/include/lld/Core/Parallel.h
+++ b/lld/include/lld/Core/Parallel.h
@@ -44,16 +44,21 @@ namespace lld {
 ///
 /// Calling dec() on a Latch with a count of 0 has undefined behaivor.
 class Latch {
-  std::atomic _count;
+  uint32_t _count;
   mutable std::mutex _condMut;
   mutable std::condition_variable _cond;
 
 public:
   explicit Latch(uint32_t count = 0) : _count(count) {}
   ~Latch() { sync(); }
-  void inc() { ++_count; }
+
+  void inc() {
+    std::unique_lock lock(_condMut);
+    ++_count;
+  }
 
   void dec() {
+    std::unique_lock lock(_condMut);
     if (--_count == 0)
       _cond.notify_all();
   }
-- 
GitLab


From c20237d21f50a1912fa4c3ffeab5253223aed624 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 8 May 2013 23:37:22 +0000
Subject: [PATCH 060/467] typo

llvm-svn: 181485
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f6bb9168ab5e..f6ee4b8446d2 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1843,7 +1843,7 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) {
     // Interface types may have elements added to them by a
     // subsequent implementation or extension, so we keep them in
     // the ObjCInterfaceCache together with a checksum. Instead of
-    // the (possibly) incomplete interace type, we return a forward
+    // the (possibly) incomplete interface type, we return a forward
     // declaration that gets RAUW'd in CGDebugInfo::finalize().
     llvm::DenseMap >
       ::iterator it = ObjCInterfaceCache.find(TyPtr);
-- 
GitLab


From dbe445fdd8ba62276b63c7cbcbea7872975bfc78 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Wed, 8 May 2013 23:37:59 +0000
Subject: [PATCH 061/467] Remove debug print statement.

llvm-svn: 181486
---
 lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
index 045565a42d9d..bd77aa3a974e 100644
--- a/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
+++ b/lldb/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
@@ -129,7 +129,6 @@ class ObjCDynamicValueTestCase(TestBase):
         threads = lldbutil.get_stopped_threads (process, lldb.eStopReasonPlanComplete)
         self.assertTrue (len(threads) == 1)
         line_entry = threads[0].GetFrameAtIndex(0).GetLineEntry()
-        print "Line entry is: ", line_entry
 
         self.assertTrue (line_entry.GetLine() == self.set_property_line)
         self.assertTrue (line_entry.GetFileSpec().GetFilename() == self.source_name) 
-- 
GitLab


From d3d3d270037b4c69eb131c9a8ac26df857185bae Mon Sep 17 00:00:00 2001
From: Fariborz Jahanian 
Date: Wed, 8 May 2013 23:38:56 +0000
Subject: [PATCH 062/467] put noisy "unknown command tag name"  warning under
 -Wdocumentation-unknown-command and off by default. patch by Dmitri Gribenko.

llvm-svn: 181487
---
 clang/include/clang/Basic/DiagnosticCommentKinds.td | 3 ++-
 clang/include/clang/Basic/DiagnosticGroups.td       | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommentKinds.td b/clang/include/clang/Basic/DiagnosticCommentKinds.td
index beeb23fcb118..49781fec9a9c 100644
--- a/clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -157,7 +157,8 @@ def warn_verbatim_block_end_without_start : Warning<
   InGroup, DefaultIgnore;
 
 def warn_unknown_comment_command_name : Warning<
-  "unknown command tag name">, InGroup, DefaultIgnore;
+  "unknown command tag name">,
+  InGroup, DefaultIgnore;
 
 def warn_correct_comment_command_name : Warning<
   "unknown command tag name '%0'; did you mean '%1'?">,
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index d7d20feb4d14..d5f777d3d715 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -68,7 +68,9 @@ def : DiagGroup<"discard-qual">;
 def : DiagGroup<"div-by-zero">;
 
 def DocumentationHTML : DiagGroup<"documentation-html">;
-def DocumentationPedantic : DiagGroup<"documentation-pedantic">;
+def DocumentationUnknownCommand : DiagGroup<"documentation-unknown-command">;
+def DocumentationPedantic : DiagGroup<"documentation-pedantic",
+                                      [DocumentationUnknownCommand]>;
 def DocumentationDeprecatedSync : DiagGroup<"documentation-deprecated-sync">;
 def Documentation : DiagGroup<"documentation",
                               [DocumentationHTML,
-- 
GitLab


From 65c163529d2328cc8dad0b370307800452e42e2c Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Wed, 8 May 2013 23:45:06 +0000
Subject: [PATCH 063/467] Fixed the process attach by name test to get the
 target _after_ doing process attach. Otherwise the target isn't valid. This
 fixes 2 test suite failures on darwin.

llvm-svn: 181488
---
 lldb/test/functionalities/process_attach/TestProcessAttach.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/functionalities/process_attach/TestProcessAttach.py b/lldb/test/functionalities/process_attach/TestProcessAttach.py
index 74841bfee0a7..b6431f6ad02e 100644
--- a/lldb/test/functionalities/process_attach/TestProcessAttach.py
+++ b/lldb/test/functionalities/process_attach/TestProcessAttach.py
@@ -69,10 +69,10 @@ class ProcessAttachTestCase(TestBase):
         popen = self.spawnSubprocess(exe)
         self.addTearDownHook(self.cleanupSubprocesses)
 
-        target = self.dbg.GetSelectedTarget()
-
         self.runCmd("process attach -n a.out")
 
+        target = self.dbg.GetSelectedTarget()
+
         process = target.GetProcess()
         self.assertTrue(process, PROCESS_IS_VALID)
 
-- 
GitLab


From 6f722b4eb9368df2b03fe3449dd91e7bb12147cf Mon Sep 17 00:00:00 2001
From: Argyrios Kyrtzidis 
Date: Wed, 8 May 2013 23:46:46 +0000
Subject: [PATCH 064/467] [modules] When building a module, make sure we don't
 serialize out HeaderFileInfo for headers not belonging to the module.

After r180934 we may initiate module map parsing for modules not related to the module what we are building,
make sure we ignore the header file info of headers from such modules.

First part of rdar://13840148

llvm-svn: 181489
---
 clang/include/clang/Lex/HeaderSearch.h               |  9 ++++++---
 clang/include/clang/Lex/ModuleMap.h                  |  3 +++
 clang/lib/Lex/HeaderSearch.cpp                       |  4 +++-
 clang/lib/Lex/ModuleMap.cpp                          | 12 +++++++++---
 clang/lib/Serialization/ASTWriter.cpp                |  2 ++
 .../self-import-header/af.framework/Headers/a1.h     |  4 ++++
 .../self-import-header/af.framework/Headers/a2.h     |  1 +
 .../self-import-header/af.framework/module.map       |  4 ++++
 .../Modules/self-import-header/depend_builtin/h1.h   |  1 +
 .../self-import-header/depend_builtin/module.map     |  5 +++++
 clang/test/Modules/self-import-header/test.m         |  7 +++++++
 11 files changed, 45 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Modules/self-import-header/af.framework/Headers/a1.h
 create mode 100644 clang/test/Modules/self-import-header/af.framework/Headers/a2.h
 create mode 100644 clang/test/Modules/self-import-header/af.framework/module.map
 create mode 100644 clang/test/Modules/self-import-header/depend_builtin/h1.h
 create mode 100644 clang/test/Modules/self-import-header/depend_builtin/module.map
 create mode 100644 clang/test/Modules/self-import-header/test.m

diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 8a5a798560de..5c748a538f6f 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -53,6 +53,9 @@ struct HeaderFileInfo {
 
   /// \brief Whether this header is part of a module.
   unsigned isModuleHeader : 1;
+
+  /// \brief Whether this header is part of the module that we are building.
+  unsigned isCompilingModuleHeader : 1;
   
   /// \brief Whether this structure is considered to already have been
   /// "resolved", meaning that it was loaded from the external source.
@@ -93,8 +96,8 @@ struct HeaderFileInfo {
   
   HeaderFileInfo()
     : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), 
-      External(false), isModuleHeader(false), Resolved(false),
-      IndexHeaderMapHeader(false),
+      External(false), isModuleHeader(false), isCompilingModuleHeader(false),
+      Resolved(false), IndexHeaderMapHeader(false),
       NumIncludes(0), ControllingMacroID(0), ControllingMacro(0)  {}
 
   /// \brief Retrieve the controlling macro for this header file, if
@@ -405,7 +408,7 @@ public:
   }
 
   /// \brief Mark the specified file as part of a module.
-  void MarkFileModuleHeader(const FileEntry *File);
+  void MarkFileModuleHeader(const FileEntry *File, bool IsCompiledModuleHeader);
 
   /// \brief Increment the count for the number of times the specified
   /// FileEntry has been entered.
diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h
index dc75f1803cb7..9fe97d01110b 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -52,6 +52,9 @@ class ModuleMap {
   /// These are always simple C language options.
   LangOptions MMapLangOpts;
 
+  // The module that we are building; related to \c LangOptions::CurrentModule.
+  Module *CompilingModule;
+
   /// \brief The top-level modules that are known.
   llvm::StringMap Modules;
 
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 304bd6969a68..5e56e3d11309 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -866,12 +866,14 @@ bool HeaderSearch::isFileMultipleIncludeGuarded(const FileEntry *File) {
       HFI.ControllingMacro || HFI.ControllingMacroID;
 }
 
-void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE) {
+void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
+                                        bool isCompilingModuleHeader) {
   if (FE->getUID() >= FileInfo.size())
     FileInfo.resize(FE->getUID()+1);
 
   HeaderFileInfo &HFI = FileInfo[FE->getUID()];
   HFI.isModuleHeader = true;
+  HFI.isCompilingModuleHeader = isCompilingModuleHeader;
 }
 
 void HeaderSearch::setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID) {
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 3e7a44c0e35d..de234853fbf3 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -87,7 +87,7 @@ ModuleMap::ModuleMap(FileManager &FileMgr, DiagnosticConsumer &DC,
                      const LangOptions &LangOpts, const TargetInfo *Target,
                      HeaderSearch &HeaderInfo)
   : LangOpts(LangOpts), Target(Target), HeaderInfo(HeaderInfo),
-    BuiltinIncludeDir(0)
+    BuiltinIncludeDir(0), CompilingModule(0)
 {
   IntrusiveRefCntPtr DiagIDs(new DiagnosticIDs);
   Diags = IntrusiveRefCntPtr(
@@ -388,8 +388,13 @@ ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
   // Create a new module with this name.
   Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework, 
                               IsExplicit);
-  if (!Parent)
+  if (!Parent) {
     Modules[Name] = Result;
+    if (!LangOpts.CurrentModule.empty() && !CompilingModule &&
+        Name == LangOpts.CurrentModule) {
+      CompilingModule = Result;
+    }
+  }
   return std::make_pair(Result, true);
 }
 
@@ -605,7 +610,8 @@ void ModuleMap::addHeader(Module *Mod, const FileEntry *Header,
     Mod->ExcludedHeaders.push_back(Header);
   } else {
     Mod->Headers.push_back(Header);
-    HeaderInfo.MarkFileModuleHeader(Header);
+    bool isCompilingModuleHeader = Mod->getTopLevelModule() == CompilingModule;
+    HeaderInfo.MarkFileModuleHeader(Header, isCompilingModuleHeader);
   }
   Headers[Header] = KnownHeader(Mod, Excluded);
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index b8ada04e5d8a..a96ecd7b86c2 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1542,6 +1542,8 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot) {
     const HeaderFileInfo &HFI = HS.getFileInfo(File);
     if (HFI.External && Chain)
       continue;
+    if (HFI.isModuleHeader && !HFI.isCompilingModuleHeader)
+      continue;
 
     // Turn the file name into an absolute path, if it isn't already.
     const char *Filename = File->getName();
diff --git a/clang/test/Modules/self-import-header/af.framework/Headers/a1.h b/clang/test/Modules/self-import-header/af.framework/Headers/a1.h
new file mode 100644
index 000000000000..31ae279bde2d
--- /dev/null
+++ b/clang/test/Modules/self-import-header/af.framework/Headers/a1.h
@@ -0,0 +1,4 @@
+@import DepBuiltin;
+
+@interface Foo
+@end
diff --git a/clang/test/Modules/self-import-header/af.framework/Headers/a2.h b/clang/test/Modules/self-import-header/af.framework/Headers/a2.h
new file mode 100644
index 000000000000..cc7e6e20b667
--- /dev/null
+++ b/clang/test/Modules/self-import-header/af.framework/Headers/a2.h
@@ -0,0 +1 @@
+#import "a1.h"
diff --git a/clang/test/Modules/self-import-header/af.framework/module.map b/clang/test/Modules/self-import-header/af.framework/module.map
new file mode 100644
index 000000000000..87176831df2d
--- /dev/null
+++ b/clang/test/Modules/self-import-header/af.framework/module.map
@@ -0,0 +1,4 @@
+framework module af {
+  header "a1.h"
+  header "a2.h"
+}
diff --git a/clang/test/Modules/self-import-header/depend_builtin/h1.h b/clang/test/Modules/self-import-header/depend_builtin/h1.h
new file mode 100644
index 000000000000..13298efce877
--- /dev/null
+++ b/clang/test/Modules/self-import-header/depend_builtin/h1.h
@@ -0,0 +1 @@
+#include 
diff --git a/clang/test/Modules/self-import-header/depend_builtin/module.map b/clang/test/Modules/self-import-header/depend_builtin/module.map
new file mode 100644
index 000000000000..a736ad85c136
--- /dev/null
+++ b/clang/test/Modules/self-import-header/depend_builtin/module.map
@@ -0,0 +1,5 @@
+module DepBuiltin {
+header "h1.h"
+  export *
+}
+
diff --git a/clang/test/Modules/self-import-header/test.m b/clang/test/Modules/self-import-header/test.m
new file mode 100644
index 000000000000..52cae7ebff11
--- /dev/null
+++ b/clang/test/Modules/self-import-header/test.m
@@ -0,0 +1,7 @@
+// rdar://13840148
+
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -isysroot %S/../Inputs/System/usr/include -fmodules -fmodules-cache-path=%t \
+// RUN:    -F %S -I %S %s -D__need_wint_t -Werror=implicit-function-declaration
+
+@import af;
-- 
GitLab


From 1054bbf08d171e3d39d4a8589f149f638eda07ed Mon Sep 17 00:00:00 2001
From: Argyrios Kyrtzidis 
Date: Wed, 8 May 2013 23:46:55 +0000
Subject: [PATCH 065/467] [PCH] Remove the
 ASTReaderListener::ReadHeaderFileInfo callback.

This made sense in pre-module era, before merging of HeaderFileInfos was introduced.

Final part of rdar://13840148.

llvm-svn: 181490
---
 clang/include/clang/Lex/HeaderSearch.h        |  3 ---
 clang/include/clang/Serialization/ASTReader.h |  8 +-------
 clang/lib/Frontend/ASTUnit.cpp                | 14 +++-----------
 clang/lib/Lex/HeaderSearch.cpp                |  7 -------
 clang/lib/Serialization/ASTReader.cpp         | 11 +----------
 5 files changed, 5 insertions(+), 38 deletions(-)

diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 5c748a538f6f..446a3810461f 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -519,9 +519,6 @@ public:
   
   unsigned header_file_size() const { return FileInfo.size(); }
 
-  // Used by ASTReader.
-  void setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID);
-
   /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
   const HeaderFileInfo &getFileInfo(const FileEntry *FE) const {
     return const_cast(this)->getFileInfo(FE);
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index 2c0102e3410f..bb59784dff96 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -166,9 +166,6 @@ public:
     return false;
   }
 
-  /// \brief Receives a HeaderFileInfo entry.
-  virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID) {}
-
   /// \brief Receives __COUNTER__ value.
   virtual void ReadCounter(const serialization::ModuleFile &M,
                            unsigned Value) {}
@@ -190,11 +187,9 @@ class PCHValidator : public ASTReaderListener {
   Preprocessor &PP;
   ASTReader &Reader;
 
-  unsigned NumHeaderInfos;
-
 public:
   PCHValidator(Preprocessor &PP, ASTReader &Reader)
-    : PP(PP), Reader(Reader), NumHeaderInfos(0) {}
+    : PP(PP), Reader(Reader) {}
 
   virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
                                    bool Complain);
@@ -203,7 +198,6 @@ public:
   virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
                                        bool Complain,
                                        std::string &SuggestedPredefines);
-  virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID);
   virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value);
 
 private:
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 8bd5172454ca..f05d7225465c 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -509,23 +509,19 @@ class ASTInfoCollector : public ASTReaderListener {
   Preprocessor &PP;
   ASTContext &Context;
   LangOptions &LangOpt;
-  HeaderSearch &HSI;
   IntrusiveRefCntPtr &TargetOpts;
   IntrusiveRefCntPtr &Target;
   unsigned &Counter;
 
-  unsigned NumHeaderInfos;
-
   bool InitializedLanguage;
 public:
   ASTInfoCollector(Preprocessor &PP, ASTContext &Context, LangOptions &LangOpt, 
-                   HeaderSearch &HSI, 
                    IntrusiveRefCntPtr &TargetOpts,
                    IntrusiveRefCntPtr &Target,
                    unsigned &Counter)
-    : PP(PP), Context(Context), LangOpt(LangOpt), HSI(HSI), 
+    : PP(PP), Context(Context), LangOpt(LangOpt),
       TargetOpts(TargetOpts), Target(Target),
-      Counter(Counter), NumHeaderInfos(0),
+      Counter(Counter),
       InitializedLanguage(false) {}
 
   virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
@@ -554,10 +550,6 @@ public:
     return false;
   }
 
-  virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID) {
-    HSI.setHeaderFileInfoForUID(HFI, NumHeaderInfos++);
-  }
-
   virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value) {
     Counter = Value;
   }
@@ -798,7 +790,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
     ReaderCleanup(Reader.get());
 
   Reader->setListener(new ASTInfoCollector(*AST->PP, Context,
-                                           AST->ASTFileLangOpts, HeaderInfo, 
+                                           AST->ASTFileLangOpts,
                                            AST->TargetOpts, AST->Target, 
                                            Counter));
 
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 5e56e3d11309..b8556dde0b20 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -876,13 +876,6 @@ void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
   HFI.isCompilingModuleHeader = isCompilingModuleHeader;
 }
 
-void HeaderSearch::setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID) {
-  if (UID >= FileInfo.size())
-    FileInfo.resize(UID+1);
-  HFI.Resolved = true;
-  FileInfo[UID] = HFI;
-}
-
 bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){
   ++NumIncluded; // Count # of attempted #includes.
 
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 22caeb8656b5..4a1ad260e329 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -377,12 +377,6 @@ bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
                                   PP.getLangOpts());
 }
 
-void PCHValidator::ReadHeaderFileInfo(const HeaderFileInfo &HFI,
-                                      unsigned ID) {
-  PP.getHeaderSearchInfo().setHeaderFileInfoForUID(HFI, ID);
-  ++NumHeaderInfos;
-}
-
 void PCHValidator::ReadCounter(const ModuleFile &M, unsigned Value) {
   PP.setCounterValue(Value);
 }
@@ -4394,11 +4388,8 @@ namespace {
 HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
   HeaderFileInfoVisitor Visitor(FE);
   ModuleMgr.visit(&HeaderFileInfoVisitor::visit, &Visitor);
-  if (Optional HFI = Visitor.getHeaderFileInfo()) {
-    if (Listener)
-      Listener->ReadHeaderFileInfo(*HFI, FE->getUID());
+  if (Optional HFI = Visitor.getHeaderFileInfo())
     return *HFI;
-  }
   
   return HeaderFileInfo();
 }
-- 
GitLab


From 4e8626f708df60abd71a205b4abbd3be04f121ee Mon Sep 17 00:00:00 2001
From: Nico Weber 
Date: Wed, 8 May 2013 23:47:40 +0000
Subject: [PATCH 066/467] Objective-C: Correctly encode 'retain' and 'copy' for
 readonly properties.

clang would omit 'C' for 'copy' properties and '&' for 'retain' properties if
the property was also 'readonly'. Fix this, which makes clang match gcc4.2's
behavior.

Fixes PR15928.

llvm-svn: 181491
---
 clang/lib/AST/ASTContext.cpp                         |  4 ++++
 .../test/Rewriter/objc-modern-property-attributes.mm | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 176aec53a252..ffcf6b5d7a92 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4910,6 +4910,10 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
 
   if (PD->isReadOnly()) {
     S += ",R";
+    if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy)
+      S += ",C";
+    if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain)
+      S += ",&";
   } else {
     switch (PD->getSetterKind()) {
     case ObjCPropertyDecl::Assign: break;
diff --git a/clang/test/Rewriter/objc-modern-property-attributes.mm b/clang/test/Rewriter/objc-modern-property-attributes.mm
index abebb2c0feff..f0d002caf61c 100644
--- a/clang/test/Rewriter/objc-modern-property-attributes.mm
+++ b/clang/test/Rewriter/objc-modern-property-attributes.mm
@@ -16,6 +16,10 @@ typedef void (^void_block_t)(void);
 
 @property (copy) void_block_t completionBlock;
 @property (retain) PropertyClass* Yblock;
+@property (readonly) PropertyClass* readonlyAttr;
+@property (readonly,copy) PropertyClass* readonlyCopyAttr;
+@property (readonly,retain) PropertyClass* readonlyRetainAttr;
+@property (readonly,retain,nonatomic) PropertyClass* readonlyNonatomicAttr;
 @property (copy) id ID;
 
 @end
@@ -25,6 +29,10 @@ typedef void (^void_block_t)(void);
 @dynamic r;     // attributes should be "Ti,D"
 @synthesize completionBlock=__completion; // "T@?,C,V__completion"
 @synthesize Yblock = YVAR; // "T@\"PropertyClass\",&,VYVAR"
+@synthesize readonlyAttr;
+@synthesize readonlyCopyAttr;
+@synthesize readonlyRetainAttr;
+@synthesize readonlyNonatomicAttr;
 @synthesize  ID; // "T@,C,VID"
 @end
 
@@ -32,6 +40,10 @@ typedef void (^void_block_t)(void);
 // CHECK: Ti,D
 // CHECK: T@?,C,V__completion
 // CHECK: T@\"PropertyClass\",&,VYVAR
+// CHECK: T@\"PropertyClass\",R,VreadonlyAttr
+// CHECK: T@\"PropertyClass\",R,C,VreadonlyCopyAttr
+// CHECK: T@\"PropertyClass\",R,&,VreadonlyRetainAttr
+// CHECK: T@\"PropertyClass\",R,&,N,VreadonlyNonatomicAttr
 
 @interface Test @end
 @interface Test (Category)
-- 
GitLab


From 60f5f3068797ac372394c980e32b33c7f92edbb8 Mon Sep 17 00:00:00 2001
From: Rui Ueyama 
Date: Wed, 8 May 2013 23:54:10 +0000
Subject: [PATCH 067/467] [lld] Add comments to InputFiles::searchLibraries()
 arguments.

llvm-svn: 181492
---
 lld/lib/Core/Resolver.cpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index c8d80343fd12..1cc18e006793 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -200,7 +200,11 @@ void Resolver::resolveUndefines() {
       StringRef undefName = undefAtom->name();
       // load for previous undefine may also have loaded this undefine
       if (!_symbolTable.isDefined(undefName)) {
-        _inputFiles.searchLibraries(undefName, true, true, false, *this);
+        _inputFiles.searchLibraries(undefName,
+                                    true,   // searchSharedLibs
+                                    true,   // searchArchives
+                                    false,  // dataSymbolOnly
+                                    *this);
       }
     }
     // search libraries for overrides of common symbols
@@ -213,10 +217,13 @@ void Resolver::resolveUndefines() {
         const Atom *curAtom = _symbolTable.findByName(tentDefName);
         assert(curAtom != nullptr);
         if (const DefinedAtom* curDefAtom = dyn_cast(curAtom)) {
-          if (curDefAtom->merge() == DefinedAtom::mergeAsTentative ) {
+          if (curDefAtom->merge() == DefinedAtom::mergeAsTentative) {
             // Still tentative definition, so look for override.
-            _inputFiles.searchLibraries(tentDefName, searchSharedLibs,
-                                        searchArchives, true, *this);
+            _inputFiles.searchLibraries(tentDefName,
+                                        searchSharedLibs,
+                                        searchArchives,
+                                        true,  // dataSymbolOnly
+                                        *this);
           }
         }
       }
-- 
GitLab


From 77e82d1ebd3cef78fb4a50a246356b188167a60e Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 9 May 2013 00:05:35 +0000
Subject: [PATCH 068/467] Fix the error reporting for ProcessKDP::DoDetach.

llvm-svn: 181493
---
 .../Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index ef88dd305861..afa18dacc7db 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -541,15 +541,20 @@ ProcessKDP::DoDetach(bool keep_stopped)
         if (!keep_stopped && m_comm.IsConnected())
         {
 
-            m_comm.SendRequestDisconnect();
+            bool disconnect_success = m_comm.SendRequestDisconnect();
+            if (!disconnect_success)
+            {
+                if (log)
+                    log->PutCString ("ProcessKDP::DoDetach(): send disconnect request failed");
+            }
 
-            size_t response_size = m_comm.Disconnect ();
+            ConnectionStatus comm_disconnect_result = m_comm.Disconnect ();
             if (log)
             {
-                if (response_size)
-                    log->PutCString ("ProcessKDP::DoDetach() detach packet sent successfully");
+                if (comm_disconnect_result == eConnectionStatusSuccess)
+                    log->PutCString ("ProcessKDP::DoDetach() conncection channel shutdown successfully");
                 else
-                    log->PutCString ("ProcessKDP::DoDetach() detach packet send failed");
+                    log->PutCString ("ProcessKDP::DoDetach() connection channel shutdown failed");
             }
         }
     }
-- 
GitLab


From b613dfadcbfda86c0e681038269ebac0829fc1e5 Mon Sep 17 00:00:00 2001
From: Ted Kremenek 
Date: Thu, 9 May 2013 00:07:27 +0000
Subject: [PATCH 069/467] Put some diagnostics in DiagnosticCommonKinds.td in a
 category, mirroring what they are in other .td files.

I really dislike the copy-pasting of the category strings.  If there is a better
way to do this with TableGen, please advise.

llvm-svn: 181494
---
 clang/include/clang/Basic/DiagnosticCommonKinds.td | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 7ff6ae13b4ef..775d40fed16c 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -37,6 +37,9 @@ def note_possibility : Note<"one possibility">;
 def note_also_found : Note<"also found">;
 
 // Parse && Lex
+
+let CategoryName = "Lexical or Preprocessor Issue" in {
+
 def err_expected_colon : Error<"expected ':'">;
 def err_expected_colon_after_setter_name : Error<
   "method name referenced in property setter attribute "
@@ -51,7 +54,12 @@ def err_invalid_character_udl : Error<
 def err_invalid_numeric_udl : Error<
   "numeric literal with user-defined suffix cannot be used here">;
 
+}
+
 // Parse && Sema
+
+let CategoryName = "Parse Issue" in {
+
 def err_param_redefinition : Error<"redefinition of parameter %0">;
 def warn_method_param_redefinition : Warning<"redefinition of method parameter %0">;
 def warn_method_param_declaration : Warning<"redeclaration of method parameter %0">,
@@ -79,6 +87,8 @@ def err_attribute_not_type_attr : Error<
   "%0 attribute cannot be applied to types">;
 def err_enum_template : Error<"enumeration cannot be a template">;
 
+}
+
 // Sema && Lex
 def ext_c99_longlong : Extension<
   "'long long' is an extension when C99 mode is not enabled">,
-- 
GitLab


From 2e8c69cf9732726f6b9dbfa56fbddd5e4130bfa5 Mon Sep 17 00:00:00 2001
From: Arnold Schwaighofer 
Date: Thu, 9 May 2013 00:32:18 +0000
Subject: [PATCH 070/467] LoopVectorizer: Don't assert on the absence of
 induction variables

A computable loop exit count does not imply the presence of an induction
variable. Scalar evolution can return a value for an infinite loop.

Fixes PR15926.

llvm-svn: 181495
---
 .../Transforms/Vectorize/LoopVectorize.cpp    |  3 +-
 .../Transforms/LoopVectorize/infiniteloop.ll  | 34 +++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Transforms/LoopVectorize/infiniteloop.ll

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e7da695d5030..b16b371878b1 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2523,7 +2523,8 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
 
   if (!Induction) {
     DEBUG(dbgs() << "LV: Did not find one integer induction var.\n");
-    assert(getInductionVars()->size() && "No induction variables");
+    if (Inductions.empty())
+      return false;
   }
 
   return true;
diff --git a/llvm/test/Transforms/LoopVectorize/infiniteloop.ll b/llvm/test/Transforms/LoopVectorize/infiniteloop.ll
new file mode 100644
index 000000000000..f6ab56436e58
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/infiniteloop.ll
@@ -0,0 +1,34 @@
+; RUN: opt -S -indvars -loop-vectorize -force-vector-width=2  < %s | FileCheck %s
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
+
+@a = common global i64 0, align 8
+@x = common global i32 0, align 4
+
+; We used to assert on this loop because we could not find an induction
+; variable but assumed there must be one. Scalar evolution returned a exit
+; count for the loop below and from there on we assumed that there must be an
+; induction variable. This is not a valid assumption:
+;   // getExitCount - Get the expression for the number of loop iterations for
+;   // which this loop is *guaranteed not to exit* via ExitingBlock. Otherwise
+;   // return SCEVCouldNotCompute.
+; For an infinite loop SE can return any number.
+
+; CHECK: fn1
+define void @fn1()  {
+entry:
+  store i64 0, i64* @a, align 8
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %inc1 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
+  store volatile i32 0, i32* @x, align 4
+  %inc = add nsw i64 %inc1, 1
+  %cmp = icmp sgt i64 %inc1, -2
+  br i1 %cmp, label %for.body, label %for.end
+
+for.end:                                          ; preds = %for.body
+  %inc.lcssa = phi i64 [ %inc, %for.body ]
+  store i64 %inc.lcssa, i64* @a, align 8
+  ret void
+}
-- 
GitLab


From f20ff979e9e812f63439f2d22feccb75dad6b359 Mon Sep 17 00:00:00 2001
From: Eric Christopher 
Date: Thu, 9 May 2013 00:42:33 +0000
Subject: [PATCH 071/467] Revert "Make sure debug info contains linkage names
 (DW_AT_MIPS_linkage_name)" temporarily while investigating
 gdb.cp/templates.exp.

This reverts commit r181471.

llvm-svn: 181496
---
 .../CodeGen/AsmPrinter/DwarfCompileUnit.cpp   |  26 ++--
 .../DebugInfo/X86/concrete_out_of_line.ll     |   3 +-
 .../DebugInfo/X86/linkage-name-ctor-dtor.ll   | 118 ------------------
 3 files changed, 12 insertions(+), 135 deletions(-)
 delete mode 100644 llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index b56255cb9b13..c38ada6b66be 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1150,24 +1150,20 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
   // Add function template parameters.
   addTemplateParams(*SPDie, SP.getTemplateParams());
 
+  // Unfortunately this code needs to stay here instead of below the
+  // AT_specification code in order to work around a bug in older
+  // gdbs that requires the linkage name to resolve multiple template
+  // functions.
+  // TODO: Remove this set of code when we get rid of the old gdb
+  // compatibility.
   StringRef LinkageName = SP.getLinkageName();
+  if (!LinkageName.empty() && DD->useDarwinGDBCompat())
+    addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
+              getRealLinkageName(LinkageName));
 
   // If this DIE is going to refer declaration info using AT_specification
-  // then there is no need to add other attributes, except
-  // DW_AT_MIPS_linkage_name in two cases:
-  // 1) The current DIE has a linkage name but the referred-to declaration
-  // doesn't have one (e.g. constructor/destructor).
-  // 2) To work around a bug in older gdbs that requires the linkage name to
-  // resolve multiple template functions. TODO: Remove this case (the
-  // DD->useDarwinGDBCompat() condition) when we get rid of the old gdb
-  // compatibility.
-
+  // then there is no need to add other attributes.
   if (DeclDie) {
-    if (!LinkageName.empty()
-        && (SPDecl.getLinkageName().empty() || DD->useDarwinGDBCompat()))
-      addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
-                getRealLinkageName(LinkageName));
-
     // Refer function declaration directly.
     addDIEEntry(SPDie, dwarf::DW_AT_specification, dwarf::DW_FORM_ref4,
                 DeclDie);
@@ -1176,7 +1172,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
   }
 
   // Add the linkage name if we have one.
-  if (!LinkageName.empty())
+  if (!LinkageName.empty() && !DD->useDarwinGDBCompat())
     addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
               getRealLinkageName(LinkageName));
 
diff --git a/llvm/test/DebugInfo/X86/concrete_out_of_line.ll b/llvm/test/DebugInfo/X86/concrete_out_of_line.ll
index 35b2e67c8569..3b9aefc38f56 100644
--- a/llvm/test/DebugInfo/X86/concrete_out_of_line.ll
+++ b/llvm/test/DebugInfo/X86/concrete_out_of_line.ll
@@ -8,14 +8,13 @@
 ; AT_inline.
 
 ; CHECK: 0x0000011e:   DW_TAG_subprogram [18]
-; CHECK-NEXT:     DW_AT_MIPS_linkage_name
 ; CHECK-NEXT:     DW_AT_specification
 ; CHECK-NEXT:     DW_AT_inline
 
 
 ; and then that a TAG_subprogram refers to it with AT_abstract_origin.
 
-; CHECK: 0x00000167:   DW_TAG_subprogram [21]
+; CHECK: 0x0000015f:   DW_TAG_subprogram [20]
 ; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x011e => {0x0000011e})
 
 define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {
diff --git a/llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll b/llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll
deleted file mode 100644
index ce9ef8daa80e..000000000000
--- a/llvm/test/DebugInfo/X86/linkage-name-ctor-dtor.ll
+++ /dev/null
@@ -1,118 +0,0 @@
-; RUN: llc -O0 %s -o %t -filetype=obj
-; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
-
-; Check that the linkage name is present for constructors/destructors.
-
-; CHECK: DW_AT_MIPS_linkage_name {{.*}}"_ZN3FooD1Ev"
-; CHECK: DW_AT_MIPS_linkage_name {{.*}}"_ZN3FooC1Ev"
-; END
-
-; $ cat test.cpp
-; class Foo {
-; public:
-;   Foo() {}
-;   ~Foo() {}
-; };
-;
-; void bar()
-; {
-;     Foo F;
-; }
-
-; $ clang++ -g -O0 -c test.cpp -S -emit-llvm -o test.ll
-; $ cat test.ll
-
-; ModuleID = 'test.cpp'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-%class.Foo = type { i8 }
-
-; Function Attrs: 
-define void @_Z3barv() #0 {
-entry:
-  %F = alloca %class.Foo, align 1
-  call void @llvm.dbg.declare(metadata !{%class.Foo* %F}, metadata !21), !dbg !22
-  call void @_ZN3FooC1Ev(%class.Foo* %F), !dbg !22
-  call void @_ZN3FooD1Ev(%class.Foo* %F), !dbg !23
-  ret void, !dbg !23
-}
-
-declare void @llvm.dbg.declare(metadata, metadata) #1
-
-define linkonce_odr void @_ZN3FooC1Ev(%class.Foo* %this) unnamed_addr #0 align 2 {
-entry:
-  %this.addr = alloca %class.Foo*, align 8
-  store %class.Foo* %this, %class.Foo** %this.addr, align 8
-  call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !24), !dbg !26
-  %this1 = load %class.Foo** %this.addr
-  call void @_ZN3FooC2Ev(%class.Foo* %this1), !dbg !26
-  ret void, !dbg !26
-}
-
-define linkonce_odr void @_ZN3FooD1Ev(%class.Foo* %this) unnamed_addr #0 align 2 {
-entry:
-  %this.addr = alloca %class.Foo*, align 8
-  store %class.Foo* %this, %class.Foo** %this.addr, align 8
-  call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !27), !dbg !28
-  %this1 = load %class.Foo** %this.addr
-  call void @_ZN3FooD2Ev(%class.Foo* %this1), !dbg !28
-  ret void, !dbg !28
-}
-
-define linkonce_odr void @_ZN3FooD2Ev(%class.Foo* %this) unnamed_addr #0 align 2 {
-entry:
-  %this.addr = alloca %class.Foo*, align 8
-  store %class.Foo* %this, %class.Foo** %this.addr, align 8
-  call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !29), !dbg !30
-  %this1 = load %class.Foo** %this.addr
-  ret void, !dbg !30
-}
-
-define linkonce_odr void @_ZN3FooC2Ev(%class.Foo* %this) unnamed_addr #0 align 2 {
-entry:
-  %this.addr = alloca %class.Foo*, align 8
-  store %class.Foo* %this, %class.Foo** %this.addr, align 8
-  call void @llvm.dbg.declare(metadata !{%class.Foo** %this.addr}, metadata !31), !dbg !32
-  %this1 = load %class.Foo** %this.addr
-  ret void, !dbg !32
-}
-
-attributes #0 = { nounwind }
-attributes #1 = { nounwind readnone }
-
-!llvm.dbg.cu = !{!0}
-
-!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.3 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/test.cpp] [DW_LANG_C_plus_plus]
-!1 = metadata !{metadata !"test.cpp", metadata !"/tmp"}
-!2 = metadata !{i32 0}
-!3 = metadata !{metadata !4, metadata !8, metadata !18, metadata !19, metadata !20}
-!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"bar", metadata !"bar", metadata !"_Z3barv", i32 7, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_Z3barv, null, null, metadata !2, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [bar]
-!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/tmp/test.cpp]
-!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!7 = metadata !{null}
-!8 = metadata !{i32 786478, metadata !1, null, metadata !"~Foo", metadata !"~Foo", metadata !"_ZN3FooD1Ev", i32 4, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooD1Ev, null, metadata !16, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [~Foo]
-!9 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!10 = metadata !{null, metadata !11}
-!11 = metadata !{i32 786447, i32 0, i32 0, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !12} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from Foo]
-!12 = metadata !{i32 786434, metadata !1, null, metadata !"Foo", i32 1, i64 8, i64 8, i32 0, i32 0, null, metadata !13, i32 0, null, null} ; [ DW_TAG_class_type ] [Foo] [line 1, size 8, align 8, offset 0] [from ]
-!13 = metadata !{metadata !14, metadata !16}
-!14 = metadata !{i32 786478, metadata !1, metadata !12, metadata !"Foo", metadata !"Foo", metadata !"", i32 3, metadata !9, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !15, i32 3} ; [ DW_TAG_subprogram ] [line 3] [Foo]
-!15 = metadata !{i32 786468}
-!16 = metadata !{i32 786478, metadata !1, metadata !12, metadata !"~Foo", metadata !"~Foo", metadata !"", i32 4, metadata !9, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !17, i32 4} ; [ DW_TAG_subprogram ] [line 4] [~Foo]
-!17 = metadata !{i32 786468}
-!18 = metadata !{i32 786478, metadata !1, null, metadata !"~Foo", metadata !"~Foo", metadata !"_ZN3FooD2Ev", i32 4, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooD2Ev, null, metadata !16, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [~Foo]
-!19 = metadata !{i32 786478, metadata !1, null, metadata !"Foo", metadata !"Foo", metadata !"_ZN3FooC1Ev", i32 3, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooC1Ev, null, metadata !14, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [Foo]
-!20 = metadata !{i32 786478, metadata !1, null, metadata !"Foo", metadata !"Foo", metadata !"_ZN3FooC2Ev", i32 3, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%class.Foo*)* @_ZN3FooC2Ev, null, metadata !14, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [Foo]
-!21 = metadata !{i32 786688, metadata !4, metadata !"F", metadata !5, i32 9, metadata !12, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [F] [line 9]
-!22 = metadata !{i32 9, i32 0, metadata !4, null}
-!23 = metadata !{i32 10, i32 0, metadata !4, null}
-!24 = metadata !{i32 786689, metadata !19, metadata !"this", metadata !5, i32 16777219, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 3]
-!25 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !12} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from Foo]
-!26 = metadata !{i32 3, i32 0, metadata !19, null}
-!27 = metadata !{i32 786689, metadata !8, metadata !"this", metadata !5, i32 16777220, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 4]
-!28 = metadata !{i32 4, i32 0, metadata !8, null}
-!29 = metadata !{i32 786689, metadata !18, metadata !"this", metadata !5, i32 16777220, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 4]
-!30 = metadata !{i32 4, i32 0, metadata !18, null}
-!31 = metadata !{i32 786689, metadata !20, metadata !"this", metadata !5, i32 16777219, metadata !25, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 3]
-!32 = metadata !{i32 3, i32 0, metadata !20, null}
-- 
GitLab


From da144dc216dd98885f4f9b9b5ac1376039033611 Mon Sep 17 00:00:00 2001
From: Enrico Granata 
Date: Thu, 9 May 2013 01:04:59 +0000
Subject: [PATCH 072/467] Changing the std::map test case to use source
 breakpoints instead of relying on the nexting always "getting it right" to
 stop at the locations of interest This should make us more robust in the face
 of changing compiler line tables and other library modifications

llvm-svn: 181497
---
 .../libcxx/map/TestDataFormatterLibccMap.py   | 35 +++++++---------
 .../data-formatter-stl/libcxx/map/main.cpp    | 40 ++++++++++++++-----
 2 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
index d3630d721a15..d339b7b90520 100644
--- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -29,14 +29,12 @@ class LibcxxMapDataFormatterTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        # Find the line number to break at.
-        self.line = line_number('main.cpp', '// Set break point at this line.')
 
     def data_formatter_commands(self):
         """Test that that file and class static variables display correctly."""
         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
 
-        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+        lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")
 
         self.runCmd("run", RUN_SUCCEEDED)
 
@@ -67,7 +65,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
             substrs = ['map has 0 items',
                        '{}'])
 
-        self.runCmd("n");self.runCmd("n");
+        self.runCmd("continue");
 
         self.expect('frame variable ii',
                     substrs = ['map has 2 items',
@@ -78,7 +76,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                                'first = 1',
                                'second = 1'])
 
-        self.runCmd("n");self.runCmd("n");
+        self.runCmd("continue");
 
         self.expect('frame variable ii',
                     substrs = ['map has 4 items',
@@ -89,9 +87,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                                'first = 3',
                                'second = 1'])
 
-        self.runCmd("n");self.runCmd("n");
-        self.runCmd("n");self.runCmd("n");
-        self.runCmd("frame select 0")
+        self.runCmd("continue");
 
         self.expect("frame variable ii",
                     substrs = ['map has 8 items',
@@ -130,7 +126,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         #self.expect("expression ii[8]", matching=False, error=True,
         #            substrs = ['1234567'])
 
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0')
+        self.runCmd("continue");
         
         self.expect('frame variable ii',
                     substrs = ['map has 0 items',
@@ -142,7 +138,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                     substrs = ['map has 0 items',
                                '{}'])
 
-        self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0')
+        self.runCmd("continue");
 
         self.expect('frame variable si',
                     substrs = ['map has 1 items',
@@ -150,9 +146,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
                                'first = \"zero\"',
                                'second = 0'])
 
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n")
-        self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0')
+        self.runCmd("continue");
 
         self.expect("frame variable si",
                     substrs = ['map has 4 items',
@@ -200,20 +194,20 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         #self.expect("expression si[0]", matching=False, error=True,
         #            substrs = ['first = ', 'zero'])
 
-        self.runCmd("n");self.runCmd("n");
+        self.runCmd("continue");
         
         self.expect('frame variable si',
                     substrs = ['map has 0 items',
                                '{}'])
 
-        self.runCmd("n")
+        self.runCmd("continue");
         self.runCmd("frame variable is --show-types")
         
         self.expect('frame variable is',
                     substrs = ['map has 0 items',
                                '{}'])
 
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
+        self.runCmd("continue");
 
         self.expect("frame variable is",
                     substrs = ['map has 4 items',
@@ -261,21 +255,20 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         #self.expect("expression is[0]", matching=False, error=True,
         #            substrs = ['first = ', 'goofy'])
 
-        self.runCmd("n")
+        self.runCmd("continue");
         
         self.expect('frame variable is',
                     substrs = ['map has 0 items',
                                '{}'])
 
-        self.runCmd("n");self.runCmd("n");
+        self.runCmd("continue");
         self.runCmd("frame variable ss --show-types")
         
         self.expect('frame variable ss',
                     substrs = ['map has 0 items',
                                '{}'])
 
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0')
+        self.runCmd("continue");
 
         self.expect("frame variable ss",
                     substrs = ['map has 3 items',
@@ -316,7 +309,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
         #self.expect("expression ss[3]", matching=False, error=True,
         #            substrs = ['gatto'])
 
-        self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0')
+        self.runCmd("continue");
         
         self.expect('frame variable ss',
                     substrs = ['map has 0 items',
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
index 704d17d52119..6e40b43d810f 100644
--- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
+++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
@@ -10,6 +10,17 @@
 #define intstr_map std::map 
 #define strstr_map std::map 
 
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1)
+{
+	if (arg < 0)
+		arg = 0;
+	if (!arg)
+		arg = 1;
+	g_the_foo += arg;
+	return g_the_foo;
+}
 
 int main()
 {
@@ -17,43 +28,54 @@ int main()
     
     ii[0] = 0; // Set break point at this line.
     ii[1] = 1;
+	thefoo_rw(1);  // Set break point at this line.
     ii[2] = 0;
     ii[3] = 1;
-    ii[4] = 0;
+	thefoo_rw(1);  // Set break point at this line.
+	ii[4] = 0;
     ii[5] = 1;
     ii[6] = 0;
     ii[7] = 1;
+    thefoo_rw(1);  // Set break point at this line.
     ii[85] = 1234567;
-    
+
     ii.clear();
     
     strint_map si;
-    
+    thefoo_rw(1);  // Set break point at this line.
+	
     si["zero"] = 0;
+	thefoo_rw(1);  // Set break point at this line.
     si["one"] = 1;
     si["two"] = 2;
     si["three"] = 3;
+	thefoo_rw(1);  // Set break point at this line.
     si["four"] = 4;
 
     si.clear();
-    
+    thefoo_rw(1);  // Set break point at this line.
+	
     intstr_map is;
-    
+    thefoo_rw(1);  // Set break point at this line.
     is[85] = "goofy";
     is[1] = "is";
     is[2] = "smart";
     is[3] = "!!!";
-    
+    thefoo_rw(1);  // Set break point at this line.
+	
     is.clear();
-    
+    thefoo_rw(1);  // Set break point at this line.
+	
     strstr_map ss;
-    
+    thefoo_rw(1);  // Set break point at this line.
+	
     ss["ciao"] = "hello";
     ss["casa"] = "house";
     ss["gatto"] = "cat";
+    thefoo_rw(1);  // Set break point at this line.
     ss["a Mac.."] = "..is always a Mac!";
     
     ss.clear();
-    
+    thefoo_rw(1);  // Set break point at this line.    
     return 0;
 }
\ No newline at end of file
-- 
GitLab


From 04b2bfa3a965a66d864e51bf388979a8d2955851 Mon Sep 17 00:00:00 2001
From: Sean Callanan 
Date: Thu, 9 May 2013 01:09:49 +0000
Subject: [PATCH 073/467] Add all Decls found through FindExternalLexicalDecls
 to the DeclContext.  This fulfils the contract that we make with Clang by
 returning ELR_AlreadyLoaded.

This is a little aggressive in that it does not allow
the ASTImporter to import the child decls with any
lexical parent other than the Decl that reported them
as children.



llvm-svn: 181498
---
 lldb/source/Expression/ClangASTSource.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 26d34c27495e..d664b1e8587a 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -472,6 +472,18 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
             }
             
             decls.push_back(copied_decl);
+            
+            DeclContext *decl_context_non_const = const_cast(decl_context);
+            
+            if (copied_decl->getDeclContext() != decl_context)
+            {
+                if (copied_decl->getDeclContext()->containsDecl(copied_decl))
+                    copied_decl->getDeclContext()->removeDecl(copied_decl);
+                copied_decl->setDeclContext(decl_context_non_const);
+            }
+            
+            if (!decl_context_non_const->containsDecl(copied_decl))
+                decl_context_non_const->addDeclInternal(copied_decl);
         }
     }
     
-- 
GitLab


From 083fcdb41448362b803c47fe85dfeb830d25220c Mon Sep 17 00:00:00 2001
From: Enrico Granata 
Date: Thu, 9 May 2013 01:32:24 +0000
Subject: [PATCH 074/467] Providing a more interesting command template for
 LLDB This one actually exploits the SB API to obtain information about your
 inferior process

llvm-svn: 181500
---
 lldb/examples/python/cmdtemplate.py | 66 ++++++++++++++++++-----------
 lldb/www/python-reference.html      |  2 +-
 2 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/lldb/examples/python/cmdtemplate.py b/lldb/examples/python/cmdtemplate.py
index 9936d0e68e26..11187b8d9818 100644
--- a/lldb/examples/python/cmdtemplate.py
+++ b/lldb/examples/python/cmdtemplate.py
@@ -14,47 +14,63 @@ import commands
 import optparse
 import shlex
 
-def create_ls_options():
-    usage = "usage: %prog [options]  [PATH ...]"
-    description='''This command lets you run the /bin/ls shell command from
-within lldb. This code is designed to demonstrate the best principles that 
-should be used when creating a new LLDB command through python.
-Creating the options in a separate function allows the parser to be
-created without running the command. The usage string is generated by the
-optparse module and can be used to populate the ls.__doc__ documentation
-string in the command interpreter function prior to registering the
-command with LLDB. The allows the output of "ls --help" to exactly match
-the output of "help ls" when both commands are run from within LLDB.
+def create_framestats_options():
+    usage = "usage: %prog [options]"
+    description='''This command is meant to be an example of how to make an LLDB command that
+does something useful, follows best practices, and exploits the SB API.
+Specifically, this command computes the aggregate and average size of the variables in the current frame
+and allows you to tweak exactly which variables are to be accounted in the computation.
 '''
-    parser = optparse.OptionParser(description=description, prog='ls',usage=usage)
-    parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
+    parser = optparse.OptionParser(description=description, prog='framestats',usage=usage)
+    parser.add_option('-i', '--in-scope', action='store_true', dest='inscope', help='in_scope_only = True', default=False)
+    parser.add_option('-a', '--arguments', action='store_true', dest='arguments', help='arguments = True', default=False)
+    parser.add_option('-l', '--locals', action='store_true', dest='locals', help='locals = True', default=False)
+    parser.add_option('-s', '--statics', action='store_true', dest='statics', help='statics = True', default=False)
     return parser
 
-def ls(debugger, command, result, dict):
+def the_framestats_command(debugger, command, result, dict):
     # Use the Shell Lexer to properly parse up command options just like a 
     # shell would
     command_args = shlex.split(command)
-    parser = create_ls_options()
+    parser = create_framestats_options()
     try:
         (options, args) = parser.parse_args(command_args)
     except:
         # if you don't handle exceptions, passing an incorrect argument to the OptionParser will cause LLDB to exit
         # (courtesy of OptParse dealing with argument errors by throwing SystemExit)
         result.SetStatus (lldb.eReturnStatusFailed)
-        return
+        return "option parsing failed" # returning a string is the same as returning an error whose description is the string
     
-    for arg in args:
-        if options.verbose:
-            result.PutCString(commands.getoutput('/bin/ls "%s"' % arg))
-        else:
-            result.PutCString(commands.getoutput('/bin/ls -lAF "%s"' % arg))
+    # in a command - the lldb.* convenience variables are not to be used
+    # and their values (if any) are undefined
+    # this is the best practice to access those objects from within a command
+    target = debugger.GetSelectedTarget()
+    process = target.GetProcess()
+    thread = process.GetSelectedThread()
+    frame = thread.GetSelectedFrame()
+    if not frame.IsValid():
+        return "no frame here"
+    # from now on, replace lldb..whatever with .whatever
+    variables_list = frame.GetVariables(options.arguments, options.locals, options.statics, options.inscope)
+    variables_count = variables_list.GetSize()
+    if variables_count == 0:
+        result.PutCString("no variables here")
+        return
+    total_size = 0
+    for i in range(0,variables_count):
+        variable = variables_list.GetValueAtIndex(i)
+        variable_type = variable.GetType()
+        total_size = total_size + variable_type.GetByteSize()
+    average_size = float(total_size) / variables_count
+    result.PutCString("Your frame has %d variables. Their total size is %d bytes. The average size is %f bytes" % (variables_count,total_size,average_size))
+    # not returning anything is askin to returning success
 
 def __lldb_init_module (debugger, dict):
     # This initializer is being run from LLDB in the embedded command interpreter    
     # Make the options so we can generate the help text for the new LLDB 
     # command line command prior to registering it with LLDB below
-    parser = create_ls_options()
-    ls.__doc__ = parser.format_help()
+    parser = create_framestats_options()
+    the_framestats_command.__doc__ = parser.format_help()
     # Add any commands contained in this module to LLDB
-    debugger.HandleCommand('command script add -f cmdtemplate.ls ls')
-    print 'The "ls" command has been installed, type "help ls" or "ls --help" for detailed help.'
+    debugger.HandleCommand('command script add -f cmdtemplate.the_framestats_command framestats')
+    print 'The "framestats" command has been installed, type "help framestats" or "framestats --help" for detailed help.'
diff --git a/lldb/www/python-reference.html b/lldb/www/python-reference.html
index daf0b98869df..2a9c529f03df 100755
--- a/lldb/www/python-reference.html
+++ b/lldb/www/python-reference.html
@@ -448,7 +448,7 @@ total 365848
 -rw-r--r--@  1 someuser  wheel         6148 Jan 19 17:27 .DS_Store
 -rw-------   1 someuser  wheel         7331 Jan 19 15:37 crash.log
 
-

A template has been created in the source repository that can help you to create +

A more interesting template has been created in the source repository that can help you to create lldb command quickly:

cmdtemplate.py

-- GitLab From 6e0ff1a3cb5a1719c12ce156c4297d724c20b955 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 9 May 2013 01:55:29 +0000 Subject: [PATCH 075/467] Changed the formerly pure virtual function: namespace lldb_private { class Thread { virtual lldb::StopInfoSP GetPrivateStopReason() = 0; }; } To not be virtual. The lldb_private::Thread now handles the correct caching and will call a new pure virtual function: namespace lldb_private { class Thread { virtual bool CalculateStopInfo() = 0; } } This function must be overridden by thead lldb_private::Thread subclass and the only thing it needs to do is to set the Thread::StopInfo() with the current stop reason and return true, or return false if there is no stop reason. The lldb_private::Thread class will take care of calling this function only when it is required. This allows lldb_private::Thread subclasses to be a bit simpler and not all need to duplicate the cache and invalidation settings. Also renamed: lldb::StopInfoSP lldb_private::Thread::GetPrivateStopReason(); To: lldb::StopInfoSP lldb_private::Thread::GetPrivateStopInfo(); Also cleaned up a case where the ThreadPlanStepOverBreakpoint might not re-set its breakpoint if the thread disappears (which was happening due to a bug when using the OperatingSystem plug-ins with memory threads and real threads). llvm-svn: 181501 --- lldb/include/lldb/Target/Thread.h | 29 ++- lldb/include/lldb/Target/ThreadPlan.h | 9 +- .../Target/ThreadPlanStepOverBreakpoint.h | 3 + .../Python/OperatingSystemPython.cpp | 43 ++-- .../Process/MacOSX-Kernel/ProcessKDP.cpp | 42 ++-- .../Process/MacOSX-Kernel/ThreadKDP.cpp | 23 +- .../Plugins/Process/MacOSX-Kernel/ThreadKDP.h | 9 +- .../Plugins/Process/POSIX/POSIXThread.cpp | 7 +- .../Plugins/Process/POSIX/POSIXThread.h | 4 +- .../Plugins/Process/Utility/ThreadMemory.cpp | 208 ++---------------- .../Plugins/Process/Utility/ThreadMemory.h | 4 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 4 +- .../Process/gdb-remote/ThreadGDBRemote.cpp | 52 +---- .../Process/gdb-remote/ThreadGDBRemote.h | 4 +- .../Process/mach-core/ThreadMachCore.cpp | 33 +-- .../Process/mach-core/ThreadMachCore.h | 7 +- lldb/source/Target/Thread.cpp | 104 ++++++--- lldb/source/Target/ThreadList.cpp | 21 +- .../Target/ThreadPlanStepOverBreakpoint.cpp | 28 ++- 19 files changed, 237 insertions(+), 397 deletions(-) diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 1856d63d5ffb..fc58a6903b6f 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -848,13 +848,7 @@ public: virtual lldb::user_id_t GetProtocolID () const { - return m_protocol_tid.GetID(); - } - - virtual void - SetProtocolID (lldb::user_id_t api_tid) - { - return m_protocol_tid.SetID(api_tid); + return GetID(); } //------------------------------------------------------------------ @@ -905,7 +899,19 @@ public: // valid. The stop info may be a "checkpointed and restored" stop info, so if it is still around it is right // even if you have not calculated this yourself, or if it disagrees with what you might have calculated. virtual lldb::StopInfoSP - GetPrivateStopReason () = 0; + GetPrivateStopInfo (); + + //---------------------------------------------------------------------- + // Ask the thread subclass to set its stop info. + // + // Thread subclasses should call Thread::SetStopInfo(...) with the + // reason the thread stopped. + // + // @return + // True if Thread::SetStopInfo(...) was called, false otherwise. + //---------------------------------------------------------------------- + virtual bool + CalculateStopInfo () = 0; //---------------------------------------------------------------------- // Gets the temporary resume state for a thread. @@ -1002,9 +1008,10 @@ protected: // Classes that inherit from Process can see and modify these //------------------------------------------------------------------ lldb::ProcessWP m_process_wp; ///< The process that owns this thread. - lldb::StopInfoSP m_actual_stop_info_sp; ///< The private stop reason for this thread + lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread + uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is valid. Can use this so you know that + // the thread's m_stop_info_sp is current and you don't have to fetch it again const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access. - UserID m_protocol_tid; ///< The thread ID used in the system level debugging or protocol functions calls. This is usually the same as the Thread::GetID(), but not always. lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state. lldb::StateType m_state; ///< The state of our process. mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state. @@ -1020,8 +1027,6 @@ protected: /// It gets set in Thread::ShoudResume. std::unique_ptr m_unwinder_ap; bool m_destroy_called; // This is used internally to make sure derived Thread classes call DestroyThread. - uint32_t m_thread_stop_reason_stop_id; // This is the stop id for which the StopInfo is valid. Can use this so you know that - // the thread's m_actual_stop_info_sp is current and you don't have to fetch it again LazyBool m_override_should_notify; private: //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Target/ThreadPlan.h b/lldb/include/lldb/Target/ThreadPlan.h index 630fee3a9f2e..5e02ec74489d 100644 --- a/lldb/include/lldb/Target/ThreadPlan.h +++ b/lldb/include/lldb/Target/ThreadPlan.h @@ -410,6 +410,13 @@ public: virtual bool MischiefManaged (); + virtual void + ThreadDestroyed () + { + // Any cleanup that a plan might want to do in case the thread goes away + // in the middle of the plan being queued on a thread can be done here. + } + bool GetPrivate () { @@ -537,7 +544,7 @@ protected: lldb::StopInfoSP GetPrivateStopReason() { - return m_thread.GetPrivateStopReason (); + return m_thread.GetPrivateStopInfo (); } void diff --git a/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index c1c2a41a4d62..41cac5c9b0b4 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -32,6 +32,7 @@ public: virtual lldb::StateType GetPlanRunState (); virtual bool WillStop (); virtual bool MischiefManaged (); + virtual void ThreadDestroyed (); void SetAutoContinue (bool do_it); virtual bool ShouldAutoContinue(Event *event_ptr); @@ -39,11 +40,13 @@ protected: virtual bool DoPlanExplainsStop (Event *event_ptr); virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan); + void ReenableBreakpointSite (); private: lldb::addr_t m_breakpoint_addr; lldb::user_id_t m_breakpoint_site_id; bool m_auto_continue; + bool m_reenabled_breakpoint_site; DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOverBreakpoint); diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 0528033f3b1a..1af044e00e22 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -198,36 +198,39 @@ OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list, { uint32_t i; const uint32_t num_threads = threads_list.GetSize(); - for (i=0; i 0) { - PythonDictionary thread_dict(threads_list.GetItemAtIndex(i)); - if (thread_dict) + for (i=0; i 0; } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index afa18dacc7db..c78aa42da206 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -385,11 +385,16 @@ ProcessKDP::DoResume () if (kernel_thread_sp) { const StateType thread_resume_state = kernel_thread_sp->GetTemporaryResumeState(); + + if (log) + log->Printf ("ProcessKDP::DoResume() thread_resume_state = %s", StateAsCString(thread_resume_state)); switch (thread_resume_state) { case eStateSuspended: // Nothing to do here when a thread will stay suspended // we just leave the CPU mask bit set to zero for the thread + if (log) + log->Printf ("ProcessKDP::DoResume() = suspended???"); break; case eStateStepping: @@ -398,6 +403,8 @@ ProcessKDP::DoResume () if (reg_ctx_sp) { + if (log) + log->Printf ("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (true);"); reg_ctx_sp->HardwareSingleStep (true); resume = true; } @@ -412,15 +419,17 @@ ProcessKDP::DoResume () { lldb::RegisterContextSP reg_ctx_sp (kernel_thread_sp->GetRegisterContext()); - if (reg_ctx_sp) - { - reg_ctx_sp->HardwareSingleStep (false); - resume = true; - } - else - { - error.SetErrorStringWithFormat("KDP thread 0x%llx has no register context", kernel_thread_sp->GetID()); - } + if (reg_ctx_sp) + { + if (log) + log->Printf ("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (false);"); + reg_ctx_sp->HardwareSingleStep (false); + resume = true; + } + else + { + error.SetErrorStringWithFormat("KDP thread 0x%llx has no register context", kernel_thread_sp->GetID()); + } } break; @@ -540,22 +549,15 @@ ProcessKDP::DoDetach(bool keep_stopped) // If we are going to keep the target stopped, then don't send the disconnect message. if (!keep_stopped && m_comm.IsConnected()) { - - bool disconnect_success = m_comm.SendRequestDisconnect(); - if (!disconnect_success) - { - if (log) - log->PutCString ("ProcessKDP::DoDetach(): send disconnect request failed"); - } - - ConnectionStatus comm_disconnect_result = m_comm.Disconnect (); + const bool success = m_comm.SendRequestDisconnect(); if (log) { - if (comm_disconnect_result == eConnectionStatusSuccess) - log->PutCString ("ProcessKDP::DoDetach() conncection channel shutdown successfully"); + if (success) + log->PutCString ("ProcessKDP::DoDetach() detach packet sent successfully"); else log->PutCString ("ProcessKDP::DoDetach() connection channel shutdown failed"); } + m_comm.Disconnect (); } } StopAsyncThread (); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index 6f0116e7f443..94567c87eda4 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -148,26 +148,23 @@ ThreadKDP::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } -lldb::StopInfoSP -ThreadKDP::GetPrivateStopReason () +bool +ThreadKDP::CalculateStopInfo () { ProcessSP process_sp (GetProcess()); if (process_sp) { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id != process_stop_id || - (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) + if (m_cached_stop_info_sp) { - if (IsStillAtLastBreakpointHit()) - return m_actual_stop_info_sp; - - if (m_cached_stop_info_sp) - SetStopInfo (m_cached_stop_info_sp); - else - SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); + SetStopInfo (m_cached_stop_info_sp); + } + else + { + SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); } + return true; } - return m_actual_stop_info_sp; + return false; } void diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h index 5a980f504fcf..7dc373f03550 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h @@ -89,13 +89,10 @@ protected: lldb::addr_t m_thread_dispatch_qaddr; lldb::StopInfoSP m_cached_stop_info_sp; //------------------------------------------------------------------ - // Member variables. + // Protected member functions. //------------------------------------------------------------------ - - virtual lldb::StopInfoSP - GetPrivateStopReason (); - - + virtual bool + CalculateStopInfo (); }; #endif // liblldb_ThreadKDP_h_ diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp index 1d43201a08db..45461c0341d8 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp @@ -138,10 +138,11 @@ POSIXThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) return reg_ctx_sp; } -lldb::StopInfoSP -POSIXThread::GetPrivateStopReason() +bool +POSIXThread::CalculateStopInfo() { - return m_actual_stop_info_sp; + SetStopInfo (m_actual_stop_info_sp); + return true; } Unwind * diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.h b/lldb/source/Plugins/Process/POSIX/POSIXThread.h index 69bca49839a5..fc6c759f0f55 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.h +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.h @@ -97,8 +97,8 @@ private: ProcessMonitor & GetMonitor(); - lldb::StopInfoSP - GetPrivateStopReason(); + virtual bool + CalculateStopInfo(); void BreakNotify(const ProcessMessage &message); void WatchNotify(const ProcessMessage &message); diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp index 3d08026cf989..56e5a9a59fab 100644 --- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp +++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp @@ -99,209 +99,34 @@ ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } - -//class StopInfoThreadMemory : public StopInfo -//{ -//public: -// //------------------------------------------------------------------ -// // Constructors and Destructors -// //------------------------------------------------------------------ -// StopInfoThreadMemory (Thread &thread, -// uint64_t value, -// StopInfoSP &backing_stop_info_sp) : -// StopInfo (thread, value), -// m_backing_stop_info_sp (backing_stop_info_sp) -// { -// } -// -// virtual -// ~StopInfoThreadMemory() -// { -// } -// -// virtual bool -// IsValid () const -// { -// ThreadSP backing_thread_sp (m_thread.GetBackingThread()); -// if (backing_thread_sp) -// return backing_thread_sp->IsValid(); -// return StopInfo::IsValid(); -// } -// -// virtual Thread & -// GetThread() -// { -// return m_thread; -// } -// -// virtual const Thread & -// GetThread() const -// { -// return m_thread; -// } -// -// virtual uint64_t -// GetValue() const -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetValue(); -// return StopInfo::GetValue(); -// } -// -// virtual lldb::StopReason -// GetStopReason () const -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetStopReason(); -// return eStopReasonNone; -// } -// -// // ShouldStopSynchronous will get called before any thread plans are consulted, and if it says we should -// // resume the target, then we will just immediately resume. This should not run any code in or resume the -// // target. -// -// virtual bool -// ShouldStopSynchronous (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->ShouldStopSynchronous(event_ptr); -// return StopInfo::ShouldStopSynchronous (event_ptr); -// } -// -// // If should stop returns false, check if we should notify of this event -// virtual bool -// ShouldNotify (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->ShouldNotify(event_ptr); -// return StopInfo::ShouldNotify (event_ptr); -// } -// -// virtual void -// WillResume (lldb::StateType resume_state) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->WillResume(resume_state); -// return StopInfo::WillResume (resume_state); -// } -// -// virtual const char * -// GetDescription () -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetDescription(); -// return StopInfo::GetDescription(); -// } -// -// virtual void -// SetDescription (const char *desc_cstr) -// { -// if (m_backing_stop_info_sp) -// m_backing_stop_info_sp->SetDescription(desc_cstr); -// StopInfo::SetDescription(desc_cstr); -// } -// -// // Sometimes the thread plan logic will know that it wants a given stop to stop or not, -// // regardless of what the ordinary logic for that StopInfo would dictate. The main example -// // of this is the ThreadPlanCallFunction, which for instance knows - based on how that particular -// // expression was executed - whether it wants all breakpoints to auto-continue or not. -// // Use OverrideShouldStop on the StopInfo to implement this. -// -// virtual void -// OverrideShouldStop (bool override_value) -// { -// if (m_backing_stop_info_sp) -// m_backing_stop_info_sp->OverrideShouldStop(override_value); -// StopInfo::OverrideShouldStop (override_value); -// } -// -// virtual bool -// GetOverrideShouldStop() -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetOverrideShouldStop(); -// return StopInfo::GetOverrideShouldStop(); -// } -// -// virtual bool -// GetOverriddenShouldStopValue () -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetOverriddenShouldStopValue(); -// return StopInfo::GetOverriddenShouldStopValue(); -// } -// -// virtual void -// PerformAction (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->PerformAction(event_ptr); -// return StopInfo::PerformAction(event_ptr); -// } -// -// virtual bool -// ShouldStop (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->ShouldStop(event_ptr); -// return StopInfo::ShouldStop(event_ptr); -// } -// -// -//protected: -// StopInfoSP m_backing_stop_info_sp; -// -//private: -// DISALLOW_COPY_AND_ASSIGN (StopInfoThreadMemory); -//}; - - -lldb::StopInfoSP -ThreadMemory::GetPrivateStopReason () +bool +ThreadMemory::CalculateStopInfo () { - if (m_actual_stop_info_sp) - return m_actual_stop_info_sp; - if (m_backing_thread_sp) { - lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopReason()); + lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopInfo()); if (backing_stop_info_sp) { - m_actual_stop_info_sp = backing_stop_info_sp; - m_actual_stop_info_sp->SetThread (shared_from_this()); - return m_actual_stop_info_sp; + backing_stop_info_sp->SetThread (shared_from_this()); + SetStopInfo (backing_stop_info_sp); + return true; } } - - ProcessSP process_sp (GetProcess()); - - if (process_sp) + else { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id != process_stop_id || - (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) - { - if (IsStillAtLastBreakpointHit()) - return m_actual_stop_info_sp; + ProcessSP process_sp (GetProcess()); - // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason - // for this thread, then m_actual_stop_info_sp will not ever contain - // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" - // check will never be able to tell us if we have the correct stop info - // for this thread and we will continually send qThreadStopInfo packets - // down to the remote GDB server, so we need to keep our own notion - // of the stop ID that m_actual_stop_info_sp is valid for (even if it - // contains nothing). We use m_thread_stop_reason_stop_id for this below. - m_thread_stop_reason_stop_id = process_stop_id; - m_actual_stop_info_sp.reset(); - + if (process_sp) + { OperatingSystem *os = process_sp->GetOperatingSystem (); if (os) - m_actual_stop_info_sp = os->CreateThreadStopReason (this); + { + SetStopInfo (os->CreateThreadStopReason (this)); + return true; + } } } - return m_actual_stop_info_sp; - + return false; } void @@ -309,4 +134,7 @@ ThreadMemory::RefreshStateAfterStop() { if (m_backing_thread_sp) return m_backing_thread_sp->RefreshStateAfterStop(); + + if (m_reg_context_sp) + m_reg_context_sp->InvalidateAllRegisters(); } diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.h b/lldb/source/Plugins/Process/Utility/ThreadMemory.h index 2a1f7d6b67da..07eb45dcb431 100644 --- a/lldb/source/Plugins/Process/Utility/ThreadMemory.h +++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.h @@ -39,8 +39,8 @@ public: virtual lldb::RegisterContextSP CreateRegisterContextForFrame (lldb_private::StackFrame *frame); - virtual lldb::StopInfoSP - GetPrivateStopReason (); + virtual bool + CalculateStopInfo (); virtual const char * GetInfo () diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 0302f9312b70..0008dbfa2888 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1770,7 +1770,7 @@ ProcessGDBRemote::DoDestroy () for (size_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = threads.GetThreadAtIndex(i); - StopInfoSP stop_info_sp = thread_sp->GetPrivateStopReason(); + StopInfoSP stop_info_sp = thread_sp->GetPrivateStopInfo(); StopReason reason = eStopReasonInvalid; if (stop_info_sp) reason = stop_info_sp->GetStopReason(); @@ -1805,7 +1805,7 @@ ProcessGDBRemote::DoDestroy () for (size_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = threads.GetThreadAtIndex(i); - StopInfoSP stop_info_sp = thread_sp->GetPrivateStopReason(); + StopInfoSP stop_info_sp = thread_sp->GetPrivateStopInfo(); StopReason reason = eStopReasonInvalid; if (stop_info_sp) reason = stop_info_sp->GetStopReason(); diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 40b367c39935..38fb84d66ef3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -197,56 +197,18 @@ ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &respons return gdb_reg_ctx->PrivateSetRegisterValue (reg, response); } -lldb::StopInfoSP -ThreadGDBRemote::GetPrivateStopReason () +bool +ThreadGDBRemote::CalculateStopInfo () { ProcessSP process_sp (GetProcess()); if (process_sp) { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id == process_stop_id) - { - // Our stop info is up to date even if it is empty... - return m_actual_stop_info_sp; - } - - if (m_actual_stop_info_sp && m_actual_stop_info_sp->IsValid()) - { - // The stop info is up to date, reset it so everything updates - SetStopInfo (m_actual_stop_info_sp); - } - else - { - if (IsStillAtLastBreakpointHit()) - { - SetStopInfo(m_actual_stop_info_sp); - } - else - { - // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason - // for this thread, then m_actual_stop_info_sp will not ever contain - // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" - // check will never be able to tell us if we have the correct stop info - // for this thread and we will continually send qThreadStopInfo packets - // down to the remote GDB server, so we need to keep our own notion - // of the stop ID that m_actual_stop_info_sp is valid for (even if it - // contains nothing). We use m_thread_stop_reason_stop_id for this below. - m_actual_stop_info_sp.reset(); - - StringExtractorGDBRemote stop_packet; - ProcessGDBRemote *gdb_process = static_cast(process_sp.get()); - if (gdb_process->GetGDBRemote().GetThreadStopInfo(GetProtocolID(), stop_packet)) - { - gdb_process->SetThreadStopInfo (stop_packet); - } - else - { - SetStopInfo (StopInfoSP()); - } - } - } + StringExtractorGDBRemote stop_packet; + ProcessGDBRemote *gdb_process = static_cast(process_sp.get()); + if (gdb_process->GetGDBRemote().GetThreadStopInfo(GetProtocolID(), stop_packet)) + return gdb_process->SetThreadStopInfo (stop_packet) == eStateStopped; } - return m_actual_stop_info_sp; + return false; } diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index 8dfc4bb78cbc..50a3f19c6505 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -98,8 +98,8 @@ protected: void SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id); - virtual lldb::StopInfoSP - GetPrivateStopReason (); + virtual bool + CalculateStopInfo (); }; diff --git a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp index a4e366101faa..85a7a20e0421 100644 --- a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp @@ -117,39 +117,16 @@ ThreadMachCore::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } -lldb::StopInfoSP -ThreadMachCore::GetPrivateStopReason () +bool +ThreadMachCore::CalculateStopInfo () { ProcessSP process_sp (GetProcess()); - if (process_sp) { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id != process_stop_id || - (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) - { - if (IsStillAtLastBreakpointHit()) - return m_actual_stop_info_sp; - - // TODO: can we query the initial state of the thread here? - // For now I am just going to pretend that a SIGSTOP happened. - - SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); - - // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason - // for this thread, then m_actual_stop_info_sp will not ever contain - // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" - // check will never be able to tell us if we have the correct stop info - // for this thread and we will continually send qThreadStopInfo packets - // down to the remote KDP server, so we need to keep our own notion - // of the stop ID that m_actual_stop_info_sp is valid for (even if it - // contains nothing). We use m_thread_stop_reason_stop_id for this below. - // m_thread_stop_reason_stop_id = process_stop_id; - // m_actual_stop_info_sp.reset(); - - } + SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); + return true; } - return m_actual_stop_info_sp; + return false; } diff --git a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h index cc687573c6a7..756a04a3cbd0 100644 --- a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h +++ b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h @@ -79,11 +79,10 @@ protected: lldb::addr_t m_thread_dispatch_qaddr; lldb::RegisterContextSP m_thread_reg_ctx_sp; //------------------------------------------------------------------ - // Member variables. + // Protected member functions. //------------------------------------------------------------------ - - virtual lldb::StopInfoSP - GetPrivateStopReason (); + virtual bool + CalculateStopInfo (); }; #endif // liblldb_ThreadMachCore_h_ diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 478021ac367d..c4aa25446823 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -243,9 +243,9 @@ Thread::Thread (Process &process, lldb::tid_t tid) : UserID (tid), Broadcaster(&process.GetTarget().GetDebugger(), Thread::GetStaticBroadcasterClass().AsCString()), m_process_wp (process.shared_from_this()), - m_actual_stop_info_sp (), + m_stop_info_sp (), + m_stop_info_stop_id (0), m_index_id (process.GetNextThreadIndexID(tid)), - m_protocol_tid (tid), m_reg_context_sp (), m_state (eStateUnloaded), m_state_mutex (Mutex::eMutexTypeRecursive), @@ -259,7 +259,6 @@ Thread::Thread (Process &process, lldb::tid_t tid) : m_temporary_resume_state (eStateRunning), m_unwinder_ap (), m_destroy_called (false), - m_thread_stop_reason_stop_id (0), m_override_should_notify (eLazyBoolCalculate) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); @@ -283,11 +282,17 @@ Thread::~Thread() void Thread::DestroyThread () { + // Tell any plans on the plan stack that the thread is being destroyed since + // any active plans that have a thread go away in the middle of might need + // to do cleanup. + for (auto plan : m_plan_stack) + plan->ThreadDestroyed(); + m_destroy_called = true; m_plan_stack.clear(); m_discarded_plan_stack.clear(); m_completed_plan_stack.clear(); - m_actual_stop_info_sp.reset(); + m_stop_info_sp.reset(); m_reg_context_sp.reset(); m_unwinder_ap.reset(); Mutex::Locker locker(m_frame_mutex); @@ -366,19 +371,58 @@ Thread::GetStopInfo () } else { - if ((m_thread_stop_reason_stop_id == stop_id) || // Stop info is valid, just return what we have (even if empty) - (m_actual_stop_info_sp && m_actual_stop_info_sp->IsValid())) // Stop info is valid, just return what we have + if ((m_stop_info_stop_id == stop_id) || // Stop info is valid, just return what we have (even if empty) + (m_stop_info_sp && m_stop_info_sp->IsValid())) // Stop info is valid, just return what we have { - return m_actual_stop_info_sp; + return m_stop_info_sp; } else { - GetPrivateStopReason (); - return m_actual_stop_info_sp; + GetPrivateStopInfo (); + return m_stop_info_sp; + } + } +} + +lldb::StopInfoSP +Thread::GetPrivateStopInfo () +{ + ProcessSP process_sp (GetProcess()); + if (process_sp) + { + ProcessSP process_sp (GetProcess()); + if (process_sp) + { + const uint32_t process_stop_id = process_sp->GetStopID(); + if (m_stop_info_stop_id != process_stop_id) + { + if (m_stop_info_sp) + { + if (m_stop_info_sp->IsValid()) + { + SetStopInfo (m_stop_info_sp); + } + else + { + if (IsStillAtLastBreakpointHit()) + SetStopInfo(m_stop_info_sp); + else + m_stop_info_sp.reset(); + } + } + + if (!m_stop_info_sp) + { + if (CalculateStopInfo() == false) + SetStopInfo (StopInfoSP()); + } + } } } + return m_stop_info_sp; } + lldb::StopReason Thread::GetStopReason() { @@ -393,20 +437,20 @@ Thread::GetStopReason() void Thread::SetStopInfo (const lldb::StopInfoSP &stop_info_sp) { - m_actual_stop_info_sp = stop_info_sp; - if (m_actual_stop_info_sp) + m_stop_info_sp = stop_info_sp; + if (m_stop_info_sp) { - m_actual_stop_info_sp->MakeStopInfoValid(); + m_stop_info_sp->MakeStopInfoValid(); // If we are overriding the ShouldReportStop, do that here: if (m_override_should_notify != eLazyBoolCalculate) - m_actual_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes); + m_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes); } ProcessSP process_sp (GetProcess()); if (process_sp) - m_thread_stop_reason_stop_id = process_sp->GetStopID(); + m_stop_info_stop_id = process_sp->GetStopID(); else - m_thread_stop_reason_stop_id = UINT32_MAX; + m_stop_info_stop_id = UINT32_MAX; } void @@ -417,8 +461,8 @@ Thread::SetShouldReportStop (Vote vote) else { m_override_should_notify = (vote == eVoteYes ? eLazyBoolYes : eLazyBoolNo); - if (m_actual_stop_info_sp) - m_actual_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes); + if (m_stop_info_sp) + m_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes); } } @@ -433,7 +477,7 @@ Thread::SetStopInfoToNothing() bool Thread::ThreadStoppedForAReason (void) { - return (bool) GetPrivateStopReason (); + return (bool) GetPrivateStopInfo (); } bool @@ -554,18 +598,22 @@ Thread::ShouldResume (StateType resume_state) m_temporary_resume_state = resume_state; - // Make sure m_actual_stop_info_sp is valid - GetPrivateStopReason(); + lldb::ThreadSP backing_thread_sp (GetBackingThread ()); + if (backing_thread_sp) + backing_thread_sp->m_temporary_resume_state = resume_state; + + // Make sure m_stop_info_sp is valid + GetPrivateStopInfo(); // This is a little dubious, but we are trying to limit how often we actually fetch stop info from // the target, 'cause that slows down single stepping. So assume that if we got to the point where // we're about to resume, and we haven't yet had to fetch the stop reason, then it doesn't need to know // about the fact that we are resuming... const uint32_t process_stop_id = GetProcess()->GetStopID(); - if (m_thread_stop_reason_stop_id == process_stop_id && - (m_actual_stop_info_sp && m_actual_stop_info_sp->IsValid())) + if (m_stop_info_stop_id == process_stop_id && + (m_stop_info_sp && m_stop_info_sp->IsValid())) { - StopInfo *stop_info = GetPrivateStopReason().get(); + StopInfo *stop_info = GetPrivateStopInfo().get(); if (stop_info) stop_info->WillResume (resume_state); } @@ -590,7 +638,7 @@ Thread::ShouldResume (StateType resume_state) if (need_to_resume && resume_state != eStateSuspended) { - m_actual_stop_info_sp.reset(); + m_stop_info_sp.reset(); } } @@ -676,7 +724,7 @@ Thread::ShouldStop (Event* event_ptr) // First query the stop info's ShouldStopSynchronous. This handles "synchronous" stop reasons, for example the breakpoint // command on internal breakpoints. If a synchronous stop reason says we should not stop, then we don't have to // do any more work on this stop. - StopInfoSP private_stop_info (GetPrivateStopReason()); + StopInfoSP private_stop_info (GetPrivateStopInfo()); if (private_stop_info && private_stop_info->ShouldStopSynchronous(event_ptr) == false) { if (log) @@ -1906,10 +1954,10 @@ Thread::IsStillAtLastBreakpointHit () // If we are currently stopped at a breakpoint, always return that stopinfo and don't reset it. // This allows threads to maintain their breakpoint stopinfo, such as when thread-stepping in // multithreaded programs. - if (m_actual_stop_info_sp) { - StopReason stop_reason = m_actual_stop_info_sp->GetStopReason(); + if (m_stop_info_sp) { + StopReason stop_reason = m_stop_info_sp->GetStopReason(); if (stop_reason == lldb::eStopReasonBreakpoint) { - uint64_t value = m_actual_stop_info_sp->GetValue(); + uint64_t value = m_stop_info_sp->GetValue(); lldb::RegisterContextSP reg_ctx_sp (GetRegisterContext()); if (reg_ctx_sp) { diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index 8db2b40d2925..1f8b351100a6 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -505,6 +505,8 @@ ThreadList::WillResume () if ((*pos)->GetResumeState() != eStateSuspended && (*pos)->GetCurrentPlan()->StopOthers()) { + if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread()) + continue; wants_solo_run = true; break; } @@ -535,6 +537,8 @@ ThreadList::WillResume () if ((*pos)->GetResumeState() != eStateSuspended && (!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers())) { + if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread()) + continue; (*pos)->SetupForResume (); } } @@ -546,7 +550,6 @@ ThreadList::WillResume () run_me_only_list.SetStopID(m_process->GetStopID()); - ThreadSP immediate_thread_sp; bool run_only_current_thread = false; for (pos = m_threads.begin(); pos != end; ++pos) @@ -555,6 +558,9 @@ ThreadList::WillResume () if (thread_sp->GetResumeState() != eStateSuspended && thread_sp->GetCurrentPlan()->StopOthers()) { + if ((*pos)->IsOperatingSystemPluginThread() && !(*pos)->GetBackingThread()) + continue; + // You can't say "stop others" and also want yourself to be suspended. assert (thread_sp->GetCurrentPlan()->RunState() != eStateSuspended); @@ -573,18 +579,7 @@ ThreadList::WillResume () bool need_to_resume = true; - if (immediate_thread_sp) - { - for (pos = m_threads.begin(); pos != end; ++pos) - { - ThreadSP thread_sp(*pos); - if (thread_sp.get() == immediate_thread_sp.get()) - thread_sp->ShouldResume(thread_sp->GetCurrentPlan()->RunState()); - else - thread_sp->ShouldResume (eStateSuspended); - } - } - else if (run_me_only_list.GetSize (false) == 0) + if (run_me_only_list.GetSize (false) == 0) { // Everybody runs as they wish: for (pos = m_threads.begin(); pos != end; ++pos) diff --git a/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp b/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp index 00a19804b2cd..ff4fee72a3ac 100644 --- a/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp +++ b/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp @@ -34,7 +34,8 @@ ThreadPlanStepOverBreakpoint::ThreadPlanStepOverBreakpoint (Thread &thread) : // first in the thread plan stack when stepping // over a breakpoint m_breakpoint_addr (LLDB_INVALID_ADDRESS), - m_auto_continue(false) + m_auto_continue(false), + m_reenabled_breakpoint_site (false) { m_breakpoint_addr = m_thread.GetRegisterContext()->GetPC(); @@ -105,9 +106,7 @@ ThreadPlanStepOverBreakpoint::DoWillResume (StateType resume_state, bool current bool ThreadPlanStepOverBreakpoint::WillStop () { - BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress (m_breakpoint_addr)); - if (bp_site_sp) - m_thread.GetProcess()->EnableBreakpointSite (bp_site_sp.get()); + ReenableBreakpointSite (); return true; } @@ -128,13 +127,30 @@ ThreadPlanStepOverBreakpoint::MischiefManaged () if (log) log->Printf("Completed step over breakpoint plan."); // Otherwise, re-enable the breakpoint we were stepping over, and we're done. + ReenableBreakpointSite (); + ThreadPlan::MischiefManaged (); + return true; + } +} + +void +ThreadPlanStepOverBreakpoint::ReenableBreakpointSite () +{ + if (!m_reenabled_breakpoint_site) + { + m_reenabled_breakpoint_site = true; BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress (m_breakpoint_addr)); if (bp_site_sp) + { m_thread.GetProcess()->EnableBreakpointSite (bp_site_sp.get()); - ThreadPlan::MischiefManaged (); - return true; + } } } +void +ThreadPlanStepOverBreakpoint::ThreadDestroyed () +{ + ReenableBreakpointSite (); +} void ThreadPlanStepOverBreakpoint::SetAutoContinue (bool do_it) -- GitLab From 0d15f7313f0280e0f3445adc52bbb646a0521057 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 9 May 2013 03:39:05 +0000 Subject: [PATCH 076/467] Change getRelocationAdditionalInfo to be ELF only. It was only implemented for ELF where it collected the Addend, so this patch also renames it to getRelocationAddend. llvm-svn: 181502 --- llvm/include/llvm/Object/COFF.h | 2 - llvm/include/llvm/Object/ELF.h | 34 +++++++++++++-- llvm/include/llvm/Object/MachO.h | 2 - llvm/include/llvm/Object/ObjectFile.h | 12 +++--- llvm/include/llvm/Object/RelocVisitor.h | 43 ++++++++----------- .../RuntimeDyld/RuntimeDyldELF.cpp | 8 ++-- llvm/lib/Object/COFFObjectFile.cpp | 5 --- llvm/lib/Object/MachOObjectFile.cpp | 6 --- llvm/test/Object/relocation-executable.test | 4 +- llvm/tools/llvm-readobj/ELFDumper.cpp | 8 ++-- 10 files changed, 65 insertions(+), 59 deletions(-) diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h index 6f42d76ee996..f70c6de877c6 100644 --- a/llvm/include/llvm/Object/COFF.h +++ b/llvm/include/llvm/Object/COFF.h @@ -149,8 +149,6 @@ protected: uint64_t &Res) const; virtual error_code getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl &Result) const; - virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, - int64_t &Res) const; virtual error_code getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const; diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index e554f4a45fc2..beff6efabbb6 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -677,6 +677,7 @@ public: error_code getSymbolVersion(SymbolRef Symb, StringRef &Version, bool &IsDefault) const; uint64_t getSymbolIndex(const Elf_Sym *sym) const; + error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const; protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; @@ -725,8 +726,6 @@ protected: uint64_t &Res) const; virtual error_code getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl &Result) const; - virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, - int64_t &Res) const; virtual error_code getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const; @@ -2227,7 +2226,7 @@ error_code ELFObjectFile::getRelocationTypeName( } template -error_code ELFObjectFile::getRelocationAdditionalInfo( +error_code ELFObjectFile::getRelocationAddend( DataRefImpl Rel, int64_t &Result) const { const Elf_Shdr *sec = getSection(Rel.w.b); switch (sec->sh_type) { @@ -2949,6 +2948,35 @@ error_code ELFObjectFile::getSymbolVersion(const Elf_Shdr *section, return object_error::success; } +/// FIXME: Maybe we should have a base ElfObjectFile that is not a template +/// and make these member functions? +static inline error_code getELFRelocationAddend(const RelocationRef R, + int64_t &Addend) { + const ObjectFile *Obj = R.getObjectFile(); + DataRefImpl DRI = R.getRawDataRefImpl(); + // Little-endian 32-bit + if (const ELFObjectFile > *ELFObj = + dyn_cast > >(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + // Big-endian 32-bit + if (const ELFObjectFile > *ELFObj = + dyn_cast > >(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + // Little-endian 64-bit + if (const ELFObjectFile > *ELFObj = + dyn_cast > >(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + // Big-endian 64-bit + if (const ELFObjectFile > *ELFObj = + dyn_cast > >(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF"); +} + /// This is a generic interface for retrieving GNU symbol version /// information from an ELFObjectFile. static inline error_code GetELFSymbolVersion(const ObjectFile *Obj, diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h index 14cd4d767d48..bedf5c101e2a 100644 --- a/llvm/include/llvm/Object/MachO.h +++ b/llvm/include/llvm/Object/MachO.h @@ -76,8 +76,6 @@ public: virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const; virtual error_code getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl &Result) const; - virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, - int64_t &Res) const; virtual error_code getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const; virtual error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const; diff --git a/llvm/include/llvm/Object/ObjectFile.h b/llvm/include/llvm/Object/ObjectFile.h index eb53cc0aab58..c73a568c1cad 100644 --- a/llvm/include/llvm/Object/ObjectFile.h +++ b/llvm/include/llvm/Object/ObjectFile.h @@ -119,7 +119,6 @@ public: /// /// This is for display purposes only. error_code getTypeName(SmallVectorImpl &Result) const; - error_code getAdditionalInfo(int64_t &Result) const; /// @brief Get a string that represents the calculation of the value of this /// relocation. @@ -128,6 +127,7 @@ public: error_code getValueString(SmallVectorImpl &Result) const; DataRefImpl getRawDataRefImpl() const; + const ObjectFile *getObjectFile() const; }; typedef content_iterator relocation_iterator; @@ -342,8 +342,6 @@ protected: uint64_t &Res) const = 0; virtual error_code getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl &Result) const = 0; - virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, - int64_t &Res) const = 0; virtual error_code getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const = 0; virtual error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const { @@ -579,10 +577,6 @@ inline error_code RelocationRef::getTypeName(SmallVectorImpl &Result) return OwningObject->getRelocationTypeName(RelocationPimpl, Result); } -inline error_code RelocationRef::getAdditionalInfo(int64_t &Result) const { - return OwningObject->getRelocationAdditionalInfo(RelocationPimpl, Result); -} - inline error_code RelocationRef::getValueString(SmallVectorImpl &Result) const { return OwningObject->getRelocationValueString(RelocationPimpl, Result); @@ -596,6 +590,10 @@ inline DataRefImpl RelocationRef::getRawDataRefImpl() const { return RelocationPimpl; } +inline const ObjectFile *RelocationRef::getObjectFile() const { + return OwningObject; +} + // Inline function definitions. inline LibraryRef::LibraryRef(DataRefImpl LibraryP, const ObjectFile *Owner) : LibraryPimpl(LibraryP) diff --git a/llvm/include/llvm/Object/RelocVisitor.h b/llvm/include/llvm/Object/RelocVisitor.h index 6239ec1796ae..df21e8696ce7 100644 --- a/llvm/include/llvm/Object/RelocVisitor.h +++ b/llvm/include/llvm/Object/RelocVisitor.h @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Object/ELF.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ELF.h" #include "llvm/Support/raw_ostream.h" @@ -123,6 +124,12 @@ private: StringRef FileFormat; bool HasError; + int64_t getAddend(RelocationRef R) { + int64_t Addend; + getELFRelocationAddend(R, Addend); + return Addend; + } + /// Operations /// 386-ELF @@ -133,15 +140,13 @@ private: // Ideally the Addend here will be the addend in the data for // the relocation. It's not actually the case for Rel relocations. RelocToApply visitELF_386_32(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); return RelocToApply(Value + Addend, 4); } RelocToApply visitELF_386_PC32(RelocationRef R, uint64_t Value, uint64_t SecAddr) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); uint64_t Address; R.getOffset(Address); return RelocToApply(Value + Addend - Address, 4); @@ -152,51 +157,44 @@ private: return RelocToApply(0, 0); } RelocToApply visitELF_X86_64_64(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); return RelocToApply(Value + Addend, 8); } RelocToApply visitELF_X86_64_PC32(RelocationRef R, uint64_t Value, uint64_t SecAddr) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); uint64_t Address; R.getOffset(Address); return RelocToApply(Value + Addend - Address, 4); } RelocToApply visitELF_X86_64_32(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } RelocToApply visitELF_X86_64_32S(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); int32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } /// PPC64 ELF RelocToApply visitELF_PPC64_ADDR32(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } /// MIPS ELF RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } // AArch64 ELF RelocToApply visitELF_AARCH64_ABS32(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); int64_t Res = Value + Addend; // Overflow check allows for both signed and unsigned interpretation. @@ -207,15 +205,13 @@ private: } RelocToApply visitELF_AARCH64_ABS64(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); return RelocToApply(Value + Addend, 8); } // SystemZ ELF RelocToApply visitELF_390_32(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); int64_t Res = Value + Addend; // Overflow check allows for both signed and unsigned interpretation. @@ -226,8 +222,7 @@ private: } RelocToApply visitELF_390_64(RelocationRef R, uint64_t Value) { - int64_t Addend; - R.getAdditionalInfo(Addend); + int64_t Addend = getAddend(R); return RelocToApply(Value + Addend, 8); } }; diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index d4d84d31d06e..57676ffaf455 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -519,10 +519,10 @@ void RuntimeDyldELF::findOPDEntrySection(ObjectImage &Obj, SymbolRef TargetSymbol; uint64_t TargetSymbolOffset; - int64_t TargetAdditionalInfo; check(i->getSymbol(TargetSymbol)); check(i->getOffset(TargetSymbolOffset)); - check(i->getAdditionalInfo(TargetAdditionalInfo)); + int64_t Addend; + check(getELFRelocationAddend(*i, Addend)); i = i.increment(err); if (i == e) @@ -544,7 +544,7 @@ void RuntimeDyldELF::findOPDEntrySection(ObjectImage &Obj, section_iterator tsi(Obj.end_sections()); check(TargetSymbol.getSection(tsi)); Rel.SectionID = findOrEmitSection(Obj, (*tsi), true, LocalSections); - Rel.Addend = (intptr_t)TargetAdditionalInfo; + Rel.Addend = (intptr_t)Addend; return; } } @@ -742,7 +742,7 @@ void RuntimeDyldELF::processRelocationRef(unsigned SectionID, uint64_t RelType; Check(RelI.getType(RelType)); int64_t Addend; - Check(RelI.getAdditionalInfo(Addend)); + Check(getELFRelocationAddend(RelI, Addend)); SymbolRef Symbol; Check(RelI.getSymbol(Symbol)); diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 70fec321ba3e..f5b49ab0618d 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -798,11 +798,6 @@ error_code COFFObjectFile::getRelocationTypeName(DataRefImpl Rel, #undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME -error_code COFFObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, - int64_t &Res) const { - Res = 0; - return object_error::success; -} error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const { const coff_relocation *reloc = toRel(Rel); diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index dfd8d3d3dd18..af14c7214591 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -989,12 +989,6 @@ MachOObjectFile::getRelocationTypeName(DataRefImpl Rel, return object_error::success; } -error_code MachOObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, - int64_t &Res) const { - Res = 0; - return object_error::success; -} - error_code MachOObjectFile::getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const { diff --git a/llvm/test/Object/relocation-executable.test b/llvm/test/Object/relocation-executable.test index 98f5b4ee2fd6..7625ec20af69 100644 --- a/llvm/test/Object/relocation-executable.test +++ b/llvm/test/Object/relocation-executable.test @@ -7,12 +7,12 @@ RUN: | FileCheck %s // CHECK-NEXT: Offset: 0x4018F8 // CHECK-NEXT: Type: R_X86_64_JUMP_SLOT (7) // CHECK-NEXT: Symbol: __libc_start_main -// CHECK-NEXT: Info: 0x0 +// CHECK-NEXT: Addend: 0x0 // CHECK-NEXT: } // CHECK-NEXT: Relocation { // CHECK-NEXT: Offset: 0x401900 // CHECK-NEXT: Type: R_X86_64_JUMP_SLOT (7) // CHECK-NEXT: Symbol: puts -// CHECK-NEXT: Info: 0x0 +// CHECK-NEXT: Addend: 0x0 // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index ea1b83f32f13..66cec615ad5d 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -579,7 +579,7 @@ void ELFDumper::printRelocation(section_iterator Sec, uint64_t Offset; uint64_t RelocType; SmallString<32> RelocName; - int64_t Info; + int64_t Addend; StringRef SymbolName; SymbolRef Symbol; if (Obj->getElfHeader()->e_type == ELF::ET_REL){ @@ -589,7 +589,7 @@ void ELFDumper::printRelocation(section_iterator Sec, } if (error(RelI->getType(RelocType))) return; if (error(RelI->getTypeName(RelocName))) return; - if (error(RelI->getAdditionalInfo(Info))) return; + if (error(getELFRelocationAddend(*RelI, Addend))) return; if (error(RelI->getSymbol(Symbol))) return; if (error(Symbol.getName(SymbolName))) return; @@ -598,13 +598,13 @@ void ELFDumper::printRelocation(section_iterator Sec, W.printHex("Offset", Offset); W.printNumber("Type", RelocName, RelocType); W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-"); - W.printHex("Info", Info); + W.printHex("Addend", Addend); } else { raw_ostream& OS = W.startLine(); OS << W.hex(Offset) << " " << RelocName << " " << (SymbolName.size() > 0 ? SymbolName : "-") - << " " << W.hex(Info) + << " " << W.hex(Addend) << "\n"; } } -- GitLab From 90b3b92a8b8f052e36370eb942f245e6c9694ba6 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 9 May 2013 04:00:44 +0000 Subject: [PATCH 077/467] [lld] Use range based for loop instead of explicit iterators (no functionality change) llvm-svn: 181503 --- lld/lib/Core/Resolver.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 1cc18e006793..ccbecd7b3de5 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -176,9 +176,8 @@ void Resolver::doAbsoluteAtom(const AbsoluteAtom& atom) { // utility to add a vector of atoms void Resolver::addAtoms(const std::vector& newAtoms) { - for (std::vector::const_iterator it = newAtoms.begin(); - it != newAtoms.end(); ++it) { - this->doDefinedAtom(**it); + for (const DefinedAtom *newAtom : newAtoms) { + this->doDefinedAtom(*newAtom); } } -- GitLab From b5999f6321bf6b523273340d5ba2f9ff979c12a3 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 9 May 2013 06:55:35 +0000 Subject: [PATCH 078/467] [analyzer;alternate arrows] adapt 'for' loop aesthetic cleanup to 'while' loops. llvm-svn: 181504 --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 41ea0a4e8813..7ce3f9886793 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2011,34 +2011,38 @@ static void adjustLoopEdges(PathPieces &pieces, LocationContextMap &LCM, if (!Dst || !Src) continue; - const ForStmt *FS = 0; + const Stmt *Loop = 0; const Stmt *S = Dst; while (const Stmt *Parent = PM.getParentIgnoreParens(S)) { - FS = dyn_cast(Parent); - if (FS) { - if (FS->getCond()->IgnoreParens() != S) - FS = 0; + if (const ForStmt *FS = dyn_cast(Parent)) { + if (FS->getCond()->IgnoreParens() == S) + Loop = FS; + break; + } + if (const WhileStmt *WS = dyn_cast(Parent)) { + if (WS->getCond()->IgnoreParens() == S) + Loop = WS; break; } S = Parent; } - // If 'FS' is non-null we have found a match where we have an edge - // incident on the condition of a for statement. - if (!FS) + // If 'Loop' is non-null we have found a match where we have an edge + // incident on the condition of a for/while statement. + if (!Loop) continue; - // If the current source of the edge is the 'for', then there is nothing - // left to be done. - if (Src == FS) + // If the current source of the edge is the 'for'/'while', then there is + // nothing left to be done. + if (Src == Loop) continue; // Now look at the previous edge. We want to know if this was in the same // "level" as the for statement. const Stmt *SrcParent = PM.getParentIgnoreParens(Src); - const Stmt *FSParent = PM.getParentIgnoreParens(FS); + const Stmt *FSParent = PM.getParentIgnoreParens(Loop); if (SrcParent && SrcParent == FSParent) { - PathDiagnosticLocation L(FS, SM, LC); + PathDiagnosticLocation L(Loop, SM, LC); bool needsEdge = true; if (Prev != E) { -- GitLab From 399980acf5ffd48feafe43530a16c1d7f75aa114 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 9 May 2013 06:55:41 +0000 Subject: [PATCH 079/467] [analyzer; alternate arrows] for "loop back" edges add back the extra edge to the closing '}' llvm-svn: 181505 --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 7ce3f9886793..b43625f8069b 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1722,6 +1722,12 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, // Are we jumping to the head of a loop? Add a special diagnostic. if (const Stmt *Loop = BE->getSrc()->getLoopTarget()) { PathDiagnosticLocation L(Loop, SM, PDB.LC); + const CompoundStmt *CS = NULL; + + if (const ForStmt *FS = dyn_cast(Loop)) + CS = dyn_cast(FS->getBody()); + else if (const WhileStmt *WS = dyn_cast(Loop)) + CS = dyn_cast(WS->getBody()); PathDiagnosticEventPiece *p = new PathDiagnosticEventPiece(L, "Looping back to the head " @@ -1730,6 +1736,12 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, addEdgeToPath(PD.getActivePath(), PrevLoc, p->getLocation(), PDB.LC); PD.getActivePath().push_front(p); + + if (CS) { + addEdgeToPath(PD.getActivePath(), PrevLoc, + PathDiagnosticLocation::createEndBrace(CS, SM), + PDB.LC); + } } const CFGBlock *BSrc = BE->getSrc(); -- GitLab From 7525ff67f19cad39bda191830e59f82c4d039c91 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 9 May 2013 07:14:00 +0000 Subject: [PATCH 080/467] Implement C++1y constant initializer rules: in a constant initializer for an object x, x's subobjects can be constructed by constexpr constructor even if they are of non-literal type, and can be read and written even though they're not members of a constexpr object or temporary. llvm-svn: 181506 --- clang/lib/AST/ExprConstant.cpp | 79 +++++++++++-------- clang/test/CodeGenCXX/const-init-cxx1y.cpp | 20 +++++ .../cxx1y-initializer-aggregate.cpp | 17 ++-- 3 files changed, 73 insertions(+), 43 deletions(-) create mode 100644 clang/test/CodeGenCXX/const-init-cxx1y.cpp diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 08c26a3ce308..bf967961aa06 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -391,7 +391,7 @@ namespace { /// EvaluatingDecl - This is the declaration whose initializer is being /// evaluated, if any. - const VarDecl *EvaluatingDecl; + APValue::LValueBase EvaluatingDecl; /// EvaluatingDeclValue - This is the value being constructed for the /// declaration whose initializer is being evaluated, if any. @@ -414,12 +414,12 @@ namespace { CallStackDepth(0), NextCallIndex(1), StepsLeft(getLangOpts().ConstexprStepLimit), BottomFrame(*this, SourceLocation(), 0, 0, 0), - EvaluatingDecl(0), EvaluatingDeclValue(0), HasActiveDiagnostic(false), - CheckingPotentialConstantExpression(false), + EvaluatingDecl((const ValueDecl*)0), EvaluatingDeclValue(0), + HasActiveDiagnostic(false), CheckingPotentialConstantExpression(false), IntOverflowCheckMode(OverflowCheckMode) {} - void setEvaluatingDecl(const VarDecl *VD, APValue &Value) { - EvaluatingDecl = VD; + void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value) { + EvaluatingDecl = Base; EvaluatingDeclValue = &Value; } @@ -899,19 +899,11 @@ namespace { return false; return LHS.Path == RHS.Path; } - - /// Kinds of constant expression checking, for diagnostics. - enum CheckConstantExpressionKind { - CCEK_Constant, ///< A normal constant. - CCEK_ReturnValue, ///< A constexpr function return value. - CCEK_MemberInit ///< A constexpr constructor mem-initializer. - }; } static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E); static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This, const Expr *E, - CheckConstantExpressionKind CCEK = CCEK_Constant, bool AllowNonLiteralTypes = false); static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info); static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info); @@ -1079,10 +1071,19 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc, /// Check that this core constant expression is of literal type, and if not, /// produce an appropriate diagnostic. -static bool CheckLiteralType(EvalInfo &Info, const Expr *E) { +static bool CheckLiteralType(EvalInfo &Info, const Expr *E, + const LValue *This = 0) { if (!E->isRValue() || E->getType()->isLiteralType(Info.Ctx)) return true; + // C++1y: A constant initializer for an object o [...] may also invoke + // constexpr constructors for o and its subobjects even if those objects + // are of non-literal class types. + if (Info.getLangOpts().CPlusPlus1y && This && + Info.EvaluatingDecl.getOpaqueValue() == + This->getLValueBase().getOpaqueValue()) + return true; + // Prvalue constant expressions must be of literal types. if (Info.getLangOpts().CPlusPlus11) Info.Diag(E, diag::note_constexpr_nonliteral) @@ -1672,7 +1673,7 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, // If we're currently evaluating the initializer of this declaration, use that // in-flight value. - if (Info.EvaluatingDecl == VD) { + if (Info.EvaluatingDecl.dyn_cast() == VD) { Result = Info.EvaluatingDeclValue; return !Result->isUninit(); } @@ -2134,9 +2135,6 @@ CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E, AccessKinds AK, NoteLValueLocation(Info, LVal.Base); return CompleteObject(); } - } else if (AK != AK_Read) { - Info.Diag(E, diag::note_constexpr_modify_global); - return CompleteObject(); } // C++11 DR1311: An lvalue-to-rvalue conversion on a volatile-qualified type @@ -2190,8 +2188,16 @@ CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E, AccessKinds AK, // Unless we're looking at a local variable or argument in a constexpr call, // the variable we're reading must be const. if (!Frame) { - assert(AK == AK_Read && "can't modify non-local"); - if (VD->isConstexpr()) { + if (Info.getLangOpts().CPlusPlus1y && + VD == Info.EvaluatingDecl.dyn_cast()) { + // OK, we can read and modify an object if we're in the process of + // evaluating its initializer, because its lifetime began in this + // evaluation. + } else if (AK != AK_Read) { + // All the remaining cases only permit reading. + Info.Diag(E, diag::note_constexpr_modify_global); + return CompleteObject(); + } else if (VD->isConstexpr()) { // OK, we can read this variable. } else if (BaseType->isIntegralOrEnumerationType()) { if (!BaseType.isConstQualified()) { @@ -2251,6 +2257,15 @@ CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E, AccessKinds AK, } } + // During the construction of an object, it is not yet 'const'. + // FIXME: We don't set up EvaluatingDecl for local variables or temporaries, + // and this doesn't do quite the right thing for const subobjects of the + // object under construction. + if (LVal.getLValueBase() == Info.EvaluatingDecl) { + BaseType = Info.Ctx.getCanonicalType(BaseType); + BaseType.removeLocalConst(); + } + // In C++1y, we can't safely access any mutable state when checking a // potential constant expression. if (Frame && Info.getLangOpts().CPlusPlus1y && @@ -3210,9 +3225,7 @@ static bool HandleConstructorCall(SourceLocation CallLoc, const LValue &This, llvm_unreachable("unknown base initializer kind"); } - if (!EvaluateInPlace(*Value, Info, Subobject, (*I)->getInit(), - (*I)->isBaseInitializer() - ? CCEK_Constant : CCEK_MemberInit)) { + if (!EvaluateInPlace(*Value, Info, Subobject, (*I)->getInit())) { // If we're checking for a potential constant expression, evaluate all // initializers even if some of them fail. if (!Info.keepEvaluatingAfterFailure()) @@ -7150,9 +7163,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) { /// cases, the in-place evaluation is essential, since later initializers for /// an object can indirectly refer to subobjects which were initialized earlier. static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This, - const Expr *E, CheckConstantExpressionKind CCEK, - bool AllowNonLiteralTypes) { - if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E)) + const Expr *E, bool AllowNonLiteralTypes) { + if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This)) return false; if (E->isRValue()) { @@ -7284,13 +7296,13 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx, if (Ctx.getLangOpts().CPlusPlus && !VD->hasLocalStorage() && !VD->getType()->isReferenceType()) { ImplicitValueInitExpr VIE(VD->getType()); - if (!EvaluateInPlace(Value, InitInfo, LVal, &VIE, CCEK_Constant, + if (!EvaluateInPlace(Value, InitInfo, LVal, &VIE, /*AllowNonLiteralTypes=*/true)) return false; } - if (!EvaluateInPlace(Value, InitInfo, LVal, this, CCEK_Constant, - /*AllowNonLiteralTypes=*/true) || + if (!EvaluateInPlace(Value, InitInfo, LVal, this, + /*AllowNonLiteralTypes=*/true) || EStatus.HasSideEffects) return false; @@ -7834,7 +7846,7 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD, const CXXMethodDecl *MD = dyn_cast(FD); const CXXRecordDecl *RD = MD ? MD->getParent()->getCanonicalDecl() : 0; - // FIXME: Fabricate an arbitrary expression on the stack and pretend that it + // Fabricate an arbitrary expression on the stack and pretend that it // is a temporary being used as the 'this' pointer. LValue This; ImplicitValueInitExpr VIE(RD ? Info.Ctx.getRecordType(RD) : Info.Ctx.IntTy); @@ -7845,9 +7857,12 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD, SourceLocation Loc = FD->getLocation(); APValue Scratch; - if (const CXXConstructorDecl *CD = dyn_cast(FD)) + if (const CXXConstructorDecl *CD = dyn_cast(FD)) { + // Evaluate the call as a constant initializer, to allow the construction + // of objects of non-literal types. + Info.setEvaluatingDecl(This.getLValueBase(), Scratch); HandleConstructorCall(Loc, This, Args, CD, Info, Scratch); - else + } else HandleFunctionCall(Loc, FD, (MD && MD->isInstance()) ? &This : 0, Args, FD->getBody(), Info, Scratch); diff --git a/clang/test/CodeGenCXX/const-init-cxx1y.cpp b/clang/test/CodeGenCXX/const-init-cxx1y.cpp new file mode 100644 index 000000000000..02293c86dd6a --- /dev/null +++ b/clang/test/CodeGenCXX/const-init-cxx1y.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++1y | FileCheck %s + +struct A { + constexpr A() : n(1) {} + ~A(); + int n; +}; +struct B : A { + A a[3]; + constexpr B() { + ++a[0].n; + a[1].n += 2; + a[2].n = n + a[1].n; + } +}; +B b; + +// CHECK: @b = global {{.*}} i32 1, {{.*}} { i32 2 }, {{.*}} { i32 3 }, {{.*}} { i32 4 } +// CHECK-NOT: _ZN1BC +// CHECK: __cxa_atexit diff --git a/clang/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp b/clang/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp index ef78c434e35e..ae49a047f624 100644 --- a/clang/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp +++ b/clang/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp @@ -25,7 +25,11 @@ A b { 4, "bazquux", .x = 42, .c = 9 }; A c { 1, 0, 'A', f(), { 3 } }; // CHECK: @[[STR_A:.*]] = {{.*}} [7 x i8] c"foobar\00" +// CHECK: @a = global {{.*}} zeroinitializer + +// @b has a constant initializer // CHECK: @[[STR_B:.*]] = {{.*}} [8 x i8] c"bazquux\00" +// CHECK: @b = global {{.*}} i32 4, {{.*}} @[[STR_B]], {{.*}} i8 117, i32 42, {{.*}} i8 9 B x; B y {}; @@ -44,18 +48,9 @@ B z { 1 }; // CHECK: store i32 %{{.*}}, i32* getelementptr inbounds ({{.*}}* @a, i32 0, i32 3) // CHECK: call void @{{.*}}C1Ev({{.*}} getelementptr inbounds (%struct.A* @a, i32 0, i32 4)) -// Initialization of 'b': +// No dynamic initialization of 'b': -// CHECK: store i32 4, i32* getelementptr inbounds ({{.*}} @b, i32 0, i32 0) -// CHECK: store i8* {{.*}} @[[STR_B]]{{.*}}, i8** getelementptr inbounds ({{.*}} @b, i32 0, i32 1) -// CHECK: load i32* getelementptr inbounds ({{.*}} @b, i32 0, i32 0) -// CHECK: load i8** getelementptr inbounds ({{.*}} @b, i32 0, i32 1) -// CHECK: getelementptr inbounds i8* %{{.*}}, {{.*}} %{{.*}} -// CHECK: store i8 %{{.*}}, i8* getelementptr inbounds ({{.*}} @b, i32 0, i32 2) -// CHECK-NOT: @_ZN1A1fEv -// CHECK: store i32 42, i32* getelementptr inbounds ({{.*}}* @b, i32 0, i32 3) -// CHECK-NOT: C1Ev -// CHECK: store i8 9, i8* {{.*}} @b, i32 0, i32 4) +// CHECK-NOT: @b // Initialization of 'c': -- GitLab From 852e242b70fc1ab9c8cd3a0aaed74f93c535af34 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Thu, 9 May 2013 12:32:36 +0000 Subject: [PATCH 081/467] Test commit. Add one of my contributions to CREDITS.TXT. llvm-svn: 181508 --- llvm/CREDITS.TXT | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/CREDITS.TXT b/llvm/CREDITS.TXT index 844ad39d03f1..e87f509249dc 100644 --- a/llvm/CREDITS.TXT +++ b/llvm/CREDITS.TXT @@ -300,6 +300,7 @@ D: Added STI Cell SPU backend. N: Kai Nacke E: kai@redstar.de D: Support for implicit TLS model used with MS VC runtime +D: Dumping of Win64 EH structures N: Takumi Nakamura E: geek4civic@gmail.com -- GitLab From 2f44bf236e2c301dcfedfd39a00ff583c47a5e18 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 9 May 2013 13:13:28 +0000 Subject: [PATCH 082/467] Introduce convenience typedefs for the 4 ELF object types. llvm-svn: 181509 --- llvm/include/llvm/Object/ELF.h | 31 ++++++++++---------- llvm/tools/llvm-objdump/ELFDump.cpp | 12 +++----- llvm/tools/llvm-readobj/ELFDumper.cpp | 42 ++++++++++----------------- 3 files changed, 35 insertions(+), 50 deletions(-) diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index beff6efabbb6..22ca201be124 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -839,6 +839,13 @@ public: } }; +// Use an alignment of 2 for the typedefs since that is the worst case for +// ELF files in archives. +typedef ELFObjectFile > ELF32LEObjectFile; +typedef ELFObjectFile > ELF64LEObjectFile; +typedef ELFObjectFile > ELF32BEObjectFile; +typedef ELFObjectFile > ELF64BEObjectFile; + // Iterate through the version definitions, and place each Elf_Verdef // in the VersionMap according to its index. template @@ -2955,23 +2962,19 @@ static inline error_code getELFRelocationAddend(const RelocationRef R, const ObjectFile *Obj = R.getObjectFile(); DataRefImpl DRI = R.getRawDataRefImpl(); // Little-endian 32-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getRelocationAddend(DRI, Addend); // Big-endian 32-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getRelocationAddend(DRI, Addend); // Little-endian 64-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getRelocationAddend(DRI, Addend); // Big-endian 64-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getRelocationAddend(DRI, Addend); llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF"); @@ -2984,23 +2987,19 @@ static inline error_code GetELFSymbolVersion(const ObjectFile *Obj, StringRef &Version, bool &IsDefault) { // Little-endian 32-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getSymbolVersion(Sym, Version, IsDefault); // Big-endian 32-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getSymbolVersion(Sym, Version, IsDefault); // Little-endian 64-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getSymbolVersion(Sym, Version, IsDefault); // Big-endian 64-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) return ELFObj->getSymbolVersion(Sym, Version, IsDefault); llvm_unreachable("Object passed to GetELFSymbolVersion() is not ELF"); diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp b/llvm/tools/llvm-objdump/ELFDump.cpp index bd1523133f55..b9526734c9fa 100644 --- a/llvm/tools/llvm-objdump/ELFDump.cpp +++ b/llvm/tools/llvm-objdump/ELFDump.cpp @@ -79,22 +79,18 @@ void printProgramHeaders( void llvm::printELFFileHeader(const object::ObjectFile *Obj) { // Little-endian 32-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) printProgramHeaders(ELFObj); // Big-endian 32-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) printProgramHeaders(ELFObj); // Little-endian 64-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) printProgramHeaders(ELFObj); // Big-endian 64-bit - if (const ELFObjectFile > *ELFObj = - dyn_cast > >(Obj)) + if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) printProgramHeaders(ELFObj); } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 66cec615ad5d..2427b7d3b140 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -69,42 +69,32 @@ private: namespace llvm { +template +static error_code createELFDumper(const ELFObjectFile *Obj, + StreamWriter &Writer, + OwningPtr &Result) { + Result.reset(new ELFDumper(Obj, Writer)); + return readobj_error::success; +} + error_code createELFDumper(const object::ObjectFile *Obj, StreamWriter& Writer, OwningPtr &Result) { - typedef ELFType Little32ELF; - typedef ELFType Big32ELF; - typedef ELFType Little64ELF; - typedef ELFType Big64ELF; - - typedef ELFObjectFile LittleELF32Obj; - typedef ELFObjectFile BigELF32Obj; - typedef ELFObjectFile LittleELF64Obj; - typedef ELFObjectFile BigELF64Obj; - // Little-endian 32-bit - if (const LittleELF32Obj *ELFObj = dyn_cast(Obj)) { - Result.reset(new ELFDumper(ELFObj, Writer)); - return readobj_error::success; - } + if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) + return createELFDumper(ELFObj, Writer, Result); // Big-endian 32-bit - if (const BigELF32Obj *ELFObj = dyn_cast(Obj)) { - Result.reset(new ELFDumper(ELFObj, Writer)); - return readobj_error::success; - } + if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) + return createELFDumper(ELFObj, Writer, Result); // Little-endian 64-bit - if (const LittleELF64Obj *ELFObj = dyn_cast(Obj)) { - Result.reset(new ELFDumper(ELFObj, Writer)); - return readobj_error::success; - } + if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) + return createELFDumper(ELFObj, Writer, Result); // Big-endian 64-bit - if (const BigELF64Obj *ELFObj = dyn_cast(Obj)) { - Result.reset(new ELFDumper(ELFObj, Writer)); - return readobj_error::success; - } + if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) + return createELFDumper(ELFObj, Writer, Result); return readobj_error::unsupported_obj_file_format; } -- GitLab From 3acc065b63c1a8c5aed4ed40c0456a1eec6c526f Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 9 May 2013 13:48:26 +0000 Subject: [PATCH 083/467] libDebugInfo depends on libObject nowadays. llvm-svn: 181510 --- llvm/lib/DebugInfo/LLVMBuild.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/DebugInfo/LLVMBuild.txt b/llvm/lib/DebugInfo/LLVMBuild.txt index 210b9f9d356e..f347d5ea32e9 100644 --- a/llvm/lib/DebugInfo/LLVMBuild.txt +++ b/llvm/lib/DebugInfo/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Library name = DebugInfo parent = Libraries -required_libraries = Support +required_libraries = Object Support -- GitLab From a91a561571f3cdc25676b4056aae2976ac943bee Mon Sep 17 00:00:00 2001 From: Ashok Thirumurthi Date: Thu, 9 May 2013 13:58:54 +0000 Subject: [PATCH 084/467] Fixed a build failure introduced by r181501. Patch by Yao Qi. llvm-svn: 181511 --- lldb/source/Plugins/Process/POSIX/POSIXThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp index 45461c0341d8..45762ecd9e4f 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp @@ -141,7 +141,7 @@ POSIXThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) bool POSIXThread::CalculateStopInfo() { - SetStopInfo (m_actual_stop_info_sp); + SetStopInfo (m_stop_info_sp); return true; } -- GitLab From 582133e88e80b3906f96f2742c5cb14dfd76df79 Mon Sep 17 00:00:00 2001 From: Ashok Thirumurthi Date: Thu, 9 May 2013 14:46:01 +0000 Subject: [PATCH 085/467] Skipping a test that asserts with gcc and icc to allow the test suite to run to completion on the gcc buildbot. llvm-svn: 181512 --- lldb/test/lang/c/anonymous/TestAnonymous.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/lang/c/anonymous/TestAnonymous.py b/lldb/test/lang/c/anonymous/TestAnonymous.py index 691af49ab486..23cf2f0cd413 100644 --- a/lldb/test/lang/c/anonymous/TestAnonymous.py +++ b/lldb/test/lang/c/anonymous/TestAnonymous.py @@ -49,8 +49,8 @@ class AnonymousTestCase(TestBase): self.buildDwarf() self.expr_child() - @expectedFailureGcc # llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by GCC - @expectedFailureIcc # llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by ICC + @skipIfGcc # llvm.org/pr15036: This particular regression was introduced by r181498 + @skipIfIcc # llvm.org/pr15036: This particular regression was introduced by r181498 @dwarf_test def test_expr_grandchild_with_dwarf(self): self.buildDwarf() -- GitLab From fd57b195a3bbe42c7becdd9622aa70efa058fa98 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 9 May 2013 15:07:39 +0000 Subject: [PATCH 086/467] Add include guards to prfchwintrin.h. llvm-svn: 181513 --- clang/lib/Headers/prfchwintrin.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang/lib/Headers/prfchwintrin.h b/clang/lib/Headers/prfchwintrin.h index 2d529c66349c..9825bd8c9700 100644 --- a/clang/lib/Headers/prfchwintrin.h +++ b/clang/lib/Headers/prfchwintrin.h @@ -25,6 +25,9 @@ #error "Never use directly; include or instead." #endif +#ifndef __PRFCHWINTRIN_H +#define __PRFCHWINTRIN_H + #if defined(__PRFCHW__) || defined(__3dNOW__) static __inline__ void __attribute__((__always_inline__, __nodebug__)) _m_prefetchw(void *__P) @@ -32,3 +35,5 @@ _m_prefetchw(void *__P) __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */); } #endif + +#endif /* __PRFCHWINTRIN_H */ -- GitLab From 4baf67a61bd8b9c906766146bd2bc68910be308c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 9 May 2013 15:07:46 +0000 Subject: [PATCH 087/467] xopintrin.h: Add wrappers for all flavors of _mm_com. GCC defines only the wrappers, MSVC defines both, we define both now too. PR15844. llvm-svn: 181514 --- clang/lib/Headers/xopintrin.h | 393 +++++++++++++++++++++++++++++++++ clang/test/Headers/x86intrin.c | 91 ++++++++ 2 files changed, 484 insertions(+) create mode 100644 clang/test/Headers/x86intrin.c diff --git a/clang/lib/Headers/xopintrin.h b/clang/lib/Headers/xopintrin.h index 9a5824c97105..cc94ca0264c0 100644 --- a/clang/lib/Headers/xopintrin.h +++ b/clang/lib/Headers/xopintrin.h @@ -342,6 +342,399 @@ _mm_sha_epi64(__m128i __A, __m128i __B) __m128i __B = (B); \ (__m128i)__builtin_ia32_vpcomq((__v2di)__A, (__v2di)__B, (N)); }) +#define _MM_PCOMCTRL_LT 0 +#define _MM_PCOMCTRL_LE 1 +#define _MM_PCOMCTRL_GT 2 +#define _MM_PCOMCTRL_GE 3 +#define _MM_PCOMCTRL_EQ 4 +#define _MM_PCOMCTRL_NEQ 5 +#define _MM_PCOMCTRL_FALSE 6 +#define _MM_PCOMCTRL_TRUE 7 + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_TRUE); +} + #define _mm_permute2_pd(X, Y, C, I) __extension__ ({ \ __m128d __X = (X); \ __m128d __Y = (Y); \ diff --git a/clang/test/Headers/x86intrin.c b/clang/test/Headers/x86intrin.c new file mode 100644 index 000000000000..d095c00674e0 --- /dev/null +++ b/clang/test/Headers/x86intrin.c @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify +// RUN: %clang_cc1 -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s -verify +// RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify +// expected-no-diagnostics + +#if defined(i386) || defined(__x86_64__) + +// Pretend to enable all features. +#ifndef __3dNOW__ +#define __3dNOW__ +#endif +#ifndef __BMI__ +#define __BMI__ +#endif +#ifndef __BMI2__ +#define __BMI2__ +#endif +#ifndef __LZCNT__ +#define __LZCNT__ +#endif +#ifndef __POPCNT__ +#define __POPCNT__ +#endif +#ifndef __RDSEED__ +#define __RDSEED__ +#endif +#ifndef __PRFCHW__ +#define __PRFCHW__ +#endif +#ifndef __SSE4A__ +#define __SSE4A__ +#endif +#ifndef __FMA4__ +#define __FMA4__ +#endif +#ifndef __XOP__ +#define __XOP__ +#endif +#ifndef __F16C__ +#define __F16C__ +#endif +#ifndef __MMX__ +#define __MMX__ +#endif +#ifndef __SSE__ +#define __SSE__ +#endif +#ifndef __SSE2__ +#define __SSE2__ +#endif +#ifndef __SSE3__ +#define __SSE3__ +#endif +#ifndef __SSSE3__ +#define __SSSE3__ +#endif +#ifndef __SSE4_1__ +#define __SSE4_1__ +#endif +#ifndef __SSE4_2__ +#define __SSE4_2__ +#endif +#ifndef __AES__ +#define __AES__ +#endif +#ifndef __AVX__ +#define __AVX__ +#endif +#ifndef __AVX2__ +#define __AVX2__ +#endif +#ifndef __BMI__ +#define __BMI__ +#endif +#ifndef __BMI2__ +#define __BMI2__ +#endif +#ifndef __LZCNT__ +#define __LZCNT__ +#endif +#ifndef __FMA__ +#define __FMA__ +#endif +#ifndef __RDRND__ +#define __RDRND__ +#endif + +// Now include the metaheader that includes all x86 intrinsic headers. +#include + +#endif -- GitLab From 90a4c23274a94fbdad21ca3bbc79c71e697a82b8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 9 May 2013 15:10:36 +0000 Subject: [PATCH 088/467] Avoid runtime type checks. In most cases the relocation type implies the object word size and endianness. llvm-svn: 181515 --- llvm/include/llvm/Object/RelocVisitor.h | 54 ++++++++++++++++++------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/Object/RelocVisitor.h b/llvm/include/llvm/Object/RelocVisitor.h index df21e8696ce7..69ce5cffc3cf 100644 --- a/llvm/include/llvm/Object/RelocVisitor.h +++ b/llvm/include/llvm/Object/RelocVisitor.h @@ -124,12 +124,37 @@ private: StringRef FileFormat; bool HasError; - int64_t getAddend(RelocationRef R) { + int64_t getAddend32LE(RelocationRef R) { + const ELF32LEObjectFile *Obj = cast(R.getObjectFile()); + DataRefImpl DRI = R.getRawDataRefImpl(); int64_t Addend; - getELFRelocationAddend(R, Addend); + Obj->getRelocationAddend(DRI, Addend); + return Addend; + } + + int64_t getAddend64LE(RelocationRef R) { + const ELF64LEObjectFile *Obj = cast(R.getObjectFile()); + DataRefImpl DRI = R.getRawDataRefImpl(); + int64_t Addend; + Obj->getRelocationAddend(DRI, Addend); + return Addend; + } + + int64_t getAddend32BE(RelocationRef R) { + const ELF32BEObjectFile *Obj = cast(R.getObjectFile()); + DataRefImpl DRI = R.getRawDataRefImpl(); + int64_t Addend; + Obj->getRelocationAddend(DRI, Addend); return Addend; } + int64_t getAddend64BE(RelocationRef R) { + const ELF64BEObjectFile *Obj = cast(R.getObjectFile()); + DataRefImpl DRI = R.getRawDataRefImpl(); + int64_t Addend; + Obj->getRelocationAddend(DRI, Addend); + return Addend; + } /// Operations /// 386-ELF @@ -140,13 +165,13 @@ private: // Ideally the Addend here will be the addend in the data for // the relocation. It's not actually the case for Rel relocations. RelocToApply visitELF_386_32(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend32LE(R); return RelocToApply(Value + Addend, 4); } RelocToApply visitELF_386_PC32(RelocationRef R, uint64_t Value, uint64_t SecAddr) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend32LE(R); uint64_t Address; R.getOffset(Address); return RelocToApply(Value + Addend - Address, 4); @@ -157,44 +182,45 @@ private: return RelocToApply(0, 0); } RelocToApply visitELF_X86_64_64(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64LE(R); return RelocToApply(Value + Addend, 8); } RelocToApply visitELF_X86_64_PC32(RelocationRef R, uint64_t Value, uint64_t SecAddr) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64LE(R); uint64_t Address; R.getOffset(Address); return RelocToApply(Value + Addend - Address, 4); } RelocToApply visitELF_X86_64_32(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64LE(R); uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } RelocToApply visitELF_X86_64_32S(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64LE(R); int32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } /// PPC64 ELF RelocToApply visitELF_PPC64_ADDR32(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64BE(R); uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } /// MIPS ELF RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend; + getELFRelocationAddend(R, Addend); uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } // AArch64 ELF RelocToApply visitELF_AARCH64_ABS32(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64LE(R); int64_t Res = Value + Addend; // Overflow check allows for both signed and unsigned interpretation. @@ -205,13 +231,13 @@ private: } RelocToApply visitELF_AARCH64_ABS64(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64LE(R); return RelocToApply(Value + Addend, 8); } // SystemZ ELF RelocToApply visitELF_390_32(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64BE(R); int64_t Res = Value + Addend; // Overflow check allows for both signed and unsigned interpretation. @@ -222,7 +248,7 @@ private: } RelocToApply visitELF_390_64(RelocationRef R, uint64_t Value) { - int64_t Addend = getAddend(R); + int64_t Addend = getAddend64BE(R); return RelocToApply(Value + Addend, 8); } }; -- GitLab From e46dd48e9fe535825bc81e44c8863b0ee5b44354 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 9 May 2013 16:22:31 +0000 Subject: [PATCH 089/467] [doc parsing]: don't attempt to fix single character commands (\t \n are common). \\ rdar://12381408 llvm-svn: 181517 --- clang/lib/AST/CommentCommandTraits.cpp | 4 ++++ clang/test/Sema/warn-documentation-fixits.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp index dc4744a53c59..2b5e624fb71a 100644 --- a/clang/lib/AST/CommentCommandTraits.cpp +++ b/clang/lib/AST/CommentCommandTraits.cpp @@ -49,6 +49,10 @@ HelperTypoCorrectCommandInfo(SmallVectorImpl &BestCommand, const unsigned MaxEditDistance = 1; unsigned BestEditDistance = MaxEditDistance + 1; StringRef Name = Command->Name; + // Don't attempt trying to typo fix single character commands. + // \t and \n are very common + if (Name.size() <= 1) + return; unsigned MinPossibleEditDistance = abs((int)Name.size() - (int)Typo.size()); if (MinPossibleEditDistance > 0 && diff --git a/clang/test/Sema/warn-documentation-fixits.cpp b/clang/test/Sema/warn-documentation-fixits.cpp index 707ecb362f86..a5a477f66d6d 100644 --- a/clang/test/Sema/warn-documentation-fixits.cpp +++ b/clang/test/Sema/warn-documentation-fixits.cpp @@ -67,6 +67,9 @@ int FooBar(); /// \fooba bbb IS_DOXYGEN_END int gorf(); +/// \t bbb IS_DOXYGEN_END +int Bar(); + // CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a" // CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa" // CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T" -- GitLab From 21b972ae9497b79af7320b9ff5a7ef28c5aab900 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 9 May 2013 16:32:32 +0000 Subject: [PATCH 090/467] InstCombine: Don't just copy known bits from the first operand of an srem. That's obviously wrong. Conservatively restrict it to the sign bit, which matches the original intention of this analysis. Fixes PR15940. llvm-svn: 181518 --- .../InstCombine/InstCombineSimplifyDemanded.cpp | 2 +- llvm/test/Transforms/InstCombine/icmp.ll | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 8add1ea618d3..a7bfe0965b03 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -754,7 +754,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, ComputeMaskedBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1); // If it's known zero, our sign bit is also zero. if (LHSKnownZero.isNegative()) - KnownZero |= LHSKnownZero; + KnownZero.setBit(KnownZero.getBitWidth() - 1); } break; case Instruction::URem: { diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index c912a576c3d2..ed1cd1e5a4cb 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -707,6 +707,18 @@ define i1 @test69(i32 %c) nounwind uwtable { ret i1 %3 } +; PR15940 +; CHECK: @test70 +; CHECK-NEXT: %A = srem i32 5, %X +; CHECK-NEXT: %C = icmp ne i32 %A, 2 +; CHECK-NEXT: ret i1 %C +define i1 @test70(i32 %X) { + %A = srem i32 5, %X + %B = add i32 %A, 2 + %C = icmp ne i32 %B, 4 + ret i1 %C +} + ; CHECK: @icmp_sext16trunc ; CHECK-NEXT: %1 = trunc i32 %x to i16 ; CHECK-NEXT: %cmp = icmp slt i16 %1, 36 -- GitLab From c50e730d6effdbd20ccbf02b4c1f54679093f297 Mon Sep 17 00:00:00 2001 From: Edwin Vane Date: Thu, 9 May 2013 16:42:37 +0000 Subject: [PATCH 091/467] Updating LibASTMatchersReference to include namespaceDecl() The namespaceDecl() ASTMatcher was added in r179027. llvm-svn: 181519 --- clang/docs/LibASTMatchersReference.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index e80e4426f4b6..e571c0780c33 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -212,6 +212,17 @@ Example matches X, S, the anonymous union type, i, and U;

+Matcher<Decl>namespaceDeclMatcher<NamespaceDecl>... +
Matches a declaration of a namespace.
+
+Given
+  namespace {}
+  namespace test {}
+namespaceDecl()
+  matches "namespace {}" and "namespace test {}"
+
+ + Matcher<Decl>recordDeclMatcher<CXXRecordDecl>...
Matches C++ class declarations.
 
-- 
GitLab


From 1333fa3d68deae7aa978849b3a642dedb09e82ca Mon Sep 17 00:00:00 2001
From: Richard Osborne 
Date: Thu, 9 May 2013 16:43:42 +0000
Subject: [PATCH 092/467] [XCore] Fix handling of functions where only the LR
 is spilled.

Previously we only checked if the LR required saving if the frame size was
non zero. However because the caller reserves 1 word for the callee to use
that doesn't count towards our frame size it is possible for the LR to need
saving and for the frame size to be 0.

We didn't hit when the LR needed saving because of a function calls because
the 1 word of stack we must allocate for our callee means the frame size
is always non zero in this case. However we can hit this case if the LR is
clobbered in inline asm.

llvm-svn: 181520
---
 llvm/lib/Target/XCore/XCoreFrameLowering.cpp | 57 ++++++++++----------
 llvm/test/CodeGen/XCore/epilogue_prologue.ll | 11 ++++
 2 files changed, 41 insertions(+), 27 deletions(-)
 create mode 100644 llvm/test/CodeGen/XCore/epilogue_prologue.ll

diff --git a/llvm/lib/Target/XCore/XCoreFrameLowering.cpp b/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
index beeb07f831c6..8cd10b4e7430 100644
--- a/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
@@ -116,9 +116,9 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
   }
   bool emitFrameMoves = XCoreRegisterInfo::needsFrameMoves(MF);
 
+  bool saveLR = XFI->getUsesLR();
   // Do we need to allocate space on the stack?
   if (FrameSize) {
-    bool saveLR = XFI->getUsesLR();
     bool LRSavedOnEntry = false;
     int Opcode;
     if (saveLR && (MFI->getObjectOffset(XFI->getLRSpillSlot()) == 0)) {
@@ -148,18 +148,18 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
         Moves.push_back(MachineMove(FrameLabel, CSDst, CSSrc));
       }
     }
-    if (saveLR) {
-      int LRSpillOffset = MFI->getObjectOffset(XFI->getLRSpillSlot());
-      storeToStack(MBB, MBBI, XCore::LR, LRSpillOffset + FrameSize*4, dl, TII);
-      MBB.addLiveIn(XCore::LR);
+  }
+  if (saveLR) {
+    int LRSpillOffset = MFI->getObjectOffset(XFI->getLRSpillSlot());
+    storeToStack(MBB, MBBI, XCore::LR, LRSpillOffset + FrameSize*4, dl, TII);
+    MBB.addLiveIn(XCore::LR);
 
-      if (emitFrameMoves) {
-        MCSymbol *SaveLRLabel = MMI->getContext().CreateTempSymbol();
-        BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(SaveLRLabel);
-        MachineLocation CSDst(MachineLocation::VirtualFP, LRSpillOffset);
-        MachineLocation CSSrc(XCore::LR);
-        MMI->getFrameMoves().push_back(MachineMove(SaveLRLabel, CSDst, CSSrc));
-      }
+    if (emitFrameMoves) {
+      MCSymbol *SaveLRLabel = MMI->getContext().CreateTempSymbol();
+      BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(SaveLRLabel);
+      MachineLocation CSDst(MachineLocation::VirtualFP, LRSpillOffset);
+      MachineLocation CSSrc(XCore::LR);
+      MMI->getFrameMoves().push_back(MachineMove(SaveLRLabel, CSDst, CSSrc));
     }
   }
 
@@ -213,6 +213,7 @@ void XCoreFrameLowering::emitEpilogue(MachineFunction &MF,
   MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
   const XCoreInstrInfo &TII =
     *static_cast(MF.getTarget().getInstrInfo());
+  XCoreFunctionInfo *XFI = MF.getInfo();
   DebugLoc dl = MBBI->getDebugLoc();
 
   bool FP = hasFP(MF);
@@ -237,24 +238,26 @@ void XCoreFrameLowering::emitEpilogue(MachineFunction &MF,
     report_fatal_error("emitEpilogue Frame size too big: " + Twine(FrameSize));
   }
 
-  if (FrameSize) {
-    XCoreFunctionInfo *XFI = MF.getInfo();
+  if (FP) {
+    // Restore R10
+    int FPSpillOffset = MFI->getObjectOffset(XFI->getFPSpillSlot());
+    FPSpillOffset += FrameSize*4;
+    loadFromStack(MBB, MBBI, XCore::R10, FPSpillOffset, dl, TII);
+  }
 
-    if (FP) {
-      // Restore R10
-      int FPSpillOffset = MFI->getObjectOffset(XFI->getFPSpillSlot());
-      FPSpillOffset += FrameSize*4;
-      loadFromStack(MBB, MBBI, XCore::R10, FPSpillOffset, dl, TII);
-    }
-    bool restoreLR = XFI->getUsesLR();
-    if (restoreLR && MFI->getObjectOffset(XFI->getLRSpillSlot()) != 0) {
-      int LRSpillOffset = MFI->getObjectOffset(XFI->getLRSpillSlot());
-      LRSpillOffset += FrameSize*4;
-      loadFromStack(MBB, MBBI, XCore::LR, LRSpillOffset, dl, TII);
-      restoreLR = false;
-    }
+  bool restoreLR = XFI->getUsesLR();
+  if (restoreLR &&
+      (FrameSize == 0 || MFI->getObjectOffset(XFI->getLRSpillSlot()) != 0)) {
+    int LRSpillOffset = MFI->getObjectOffset(XFI->getLRSpillSlot());
+    LRSpillOffset += FrameSize*4;
+    loadFromStack(MBB, MBBI, XCore::LR, LRSpillOffset, dl, TII);
+    restoreLR = false;
+  }
+
+  if (FrameSize) {
     if (restoreLR) {
       // Fold prologue into return instruction
+      assert(MFI->getObjectOffset(XFI->getLRSpillSlot()) == 0);
       assert(MBBI->getOpcode() == XCore::RETSP_u6
         || MBBI->getOpcode() == XCore::RETSP_lu6);
       int Opcode = (isU6) ? XCore::RETSP_u6 : XCore::RETSP_lu6;
diff --git a/llvm/test/CodeGen/XCore/epilogue_prologue.ll b/llvm/test/CodeGen/XCore/epilogue_prologue.ll
new file mode 100644
index 000000000000..49a4cc79ac21
--- /dev/null
+++ b/llvm/test/CodeGen/XCore/epilogue_prologue.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -march=xcore | FileCheck %s
+
+; CHECK: f1
+; CHECK: stw lr, sp[0]
+; CHECK: ldw lr, sp[0]
+; CHECK-NEXT: retsp 0
+define void @f1() nounwind {
+entry:
+  tail call void asm sideeffect "", "~{lr}"() nounwind
+  ret void
+}
-- 
GitLab


From 395a6d48780ff68ef0944630232df05925c17e31 Mon Sep 17 00:00:00 2001
From: Fariborz Jahanian 
Date: Thu, 9 May 2013 16:44:02 +0000
Subject: [PATCH 093/467] [doc parsing]: So, in this patch, single character
 'commands' will not go through typo fixit logic, preserving the old behavior
 (no typo, no diagnostics). // rdar://12381408

llvm-svn: 181521
---
 clang/lib/AST/CommentCommandTraits.cpp | 4 ----
 clang/lib/AST/CommentLexer.cpp         | 4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp
index 2b5e624fb71a..dc4744a53c59 100644
--- a/clang/lib/AST/CommentCommandTraits.cpp
+++ b/clang/lib/AST/CommentCommandTraits.cpp
@@ -49,10 +49,6 @@ HelperTypoCorrectCommandInfo(SmallVectorImpl &BestCommand,
   const unsigned MaxEditDistance = 1;
   unsigned BestEditDistance = MaxEditDistance + 1;
   StringRef Name = Command->Name;
-  // Don't attempt trying to typo fix single character commands.
-  // \t and \n are very common
-  if (Name.size() <= 1)
-    return;
   
   unsigned MinPossibleEditDistance = abs((int)Name.size() - (int)Typo.size());
   if (MinPossibleEditDistance > 0 &&
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index b195d52e8ef1..c589219f06ff 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -355,6 +355,10 @@ void Lexer::lexCommentText(Token &T) {
         if (!Info) {
           formTokenWithChars(T, TokenPtr, tok::unknown_command);
           T.setUnknownCommandName(CommandName);
+          // single character command impostures, such as \t or \n must not go
+          // through the fixit logic.
+          if (CommandName.size() <= 1)
+            return;
           if ((Info = Traits.getTypoCorrectCommandInfo(CommandName))) {
             StringRef CorrectedName = Info->Name;
             SourceRange CommandRange(T.getLocation().getLocWithOffset(1),
-- 
GitLab


From fc4f7dc0a6d3fe4e40eb0ac52f17ab1d9dc48ee6 Mon Sep 17 00:00:00 2001
From: Edwin Vane 
Date: Thu, 9 May 2013 17:00:17 +0000
Subject: [PATCH 094/467] Adding isConst() ASTMatcher for CXXMethodDecl nodes

Updated reference and unit tests.

llvm-svn: 181522
---
 clang/docs/LibASTMatchersReference.html         | 13 +++++++++++++
 clang/include/clang/ASTMatchers/ASTMatchers.h   | 15 +++++++++++++++
 clang/unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++++++
 3 files changed, 35 insertions(+)

diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index e571c0780c33..0ea55bfef54d 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1524,6 +1524,19 @@ Usable as: Matcher<CXXMethodDecl>isConst
+
Matches if the given method declaration is const.
+
+Given
+struct A {
+  void foo() const;
+  void bar();
+};
+
+methodDecl(isConst()) matches A::foo() but not A::bar()
+
+ + Matcher<CXXMethodDecl>isOverride
Matches if the given method declaration overrides another method.
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 70f539be7944..2b04f8c2e4b2 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2542,6 +2542,21 @@ AST_MATCHER(CXXMethodDecl, isVirtual) {
   return Node.isVirtual();
 }
 
+/// \brief Matches if the given method declaration is const.
+///
+/// Given
+/// \code
+/// struct A {
+///   void foo() const;
+///   void bar();
+/// };
+/// \endcode
+///
+/// methodDecl(isConst()) matches A::foo() but not A::bar()
+AST_MATCHER(CXXMethodDecl, isConst) {
+  return Node.isConst();
+}
+
 /// \brief Matches if the given method declaration overrides another method.
 ///
 /// Given
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index cfa53868ed29..50aa583f940a 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1507,6 +1507,13 @@ TEST(Matcher, MatchesVirtualMethod) {
       methodDecl(isVirtual())));
 }
 
+TEST(Matcher, MatchesConstMethod) {
+  EXPECT_TRUE(matches("struct A { void foo() const; };",
+                      methodDecl(isConst())));
+  EXPECT_TRUE(notMatches("struct A { void foo(); };",
+                         methodDecl(isConst())));
+}
+
 TEST(Matcher, MatchesOverridingMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); }; "
                       "class Y : public X { int f(); };",
-- 
GitLab


From 0321b8ffd6de8c6fda99cc3daeb08d33fe8ff03e Mon Sep 17 00:00:00 2001
From: Fariborz Jahanian 
Date: Thu, 9 May 2013 17:18:52 +0000
Subject: [PATCH 095/467] [doc parsing]: make single character command
 impostures warn in pedantic mode.

llvm-svn: 181523
---
 clang/lib/AST/CommentCommandTraits.cpp | 5 +++++
 clang/lib/AST/CommentLexer.cpp         | 4 ----
 clang/test/Sema/warn-documentation.m   | 4 ++++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp
index dc4744a53c59..6baf4a9dc6b1 100644
--- a/clang/lib/AST/CommentCommandTraits.cpp
+++ b/clang/lib/AST/CommentCommandTraits.cpp
@@ -68,6 +68,11 @@ HelperTypoCorrectCommandInfo(SmallVectorImpl &BestCommand,
 
 const CommandInfo *
 CommandTraits::getTypoCorrectCommandInfo(StringRef Typo) const {
+  // single character command impostures, such as \t or \n must not go
+  // through the fixit logic.
+  if (Typo.size() <= 1)
+    return NULL;
+  
   SmallVector BestCommand;
   
   int NumOfCommands = sizeof(Commands) / sizeof(CommandInfo);
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index c589219f06ff..b195d52e8ef1 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -355,10 +355,6 @@ void Lexer::lexCommentText(Token &T) {
         if (!Info) {
           formTokenWithChars(T, TokenPtr, tok::unknown_command);
           T.setUnknownCommandName(CommandName);
-          // single character command impostures, such as \t or \n must not go
-          // through the fixit logic.
-          if (CommandName.size() <= 1)
-            return;
           if ((Info = Traits.getTypoCorrectCommandInfo(CommandName))) {
             StringRef CorrectedName = Info->Name;
             SourceRange CommandRange(T.getLocation().getLocWithOffset(1),
diff --git a/clang/test/Sema/warn-documentation.m b/clang/test/Sema/warn-documentation.m
index 0737a8dedd03..14e0c347e3f9 100644
--- a/clang/test/Sema/warn-documentation.m
+++ b/clang/test/Sema/warn-documentation.m
@@ -172,3 +172,7 @@ struct S;
   @struct S1 THIS IS IT
 */
 @interface S1 @end
+
+// expected-warning@+1 {{unknown command tag name}}
+/// \t bbb IS_DOXYGEN_END
+int FooBar();
-- 
GitLab


From 007521673bc1a8c594f96673b4dfb48499432112 Mon Sep 17 00:00:00 2001
From: Rafael Espindola 
Date: Thu, 9 May 2013 17:22:59 +0000
Subject: [PATCH 096/467] Don't replace an alias in llvm.used with its target.

When we replace an internal alias with its target, be careful not to
replace the entry in llvm.used (and llvm.compiler_used).

llvm-svn: 181524
---
 llvm/lib/Transforms/IPO/GlobalOpt.cpp        | 104 ++++++++++++++++++-
 llvm/test/Transforms/GlobalOpt/alias-used.ll |  42 ++++++++
 2 files changed, 144 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/Transforms/GlobalOpt/alias-used.ll

diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index b035a821b4cf..0ef900e2b9a9 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -3041,6 +3041,105 @@ bool GlobalOpt::OptimizeGlobalCtorsList(GlobalVariable *&GCL) {
   return true;
 }
 
+static Value::use_iterator getFirst(Value *V, SmallPtrSet &Tried) {
+  for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) {
+    Use *U = &I.getUse();
+    if (Tried.count(U))
+      continue;
+
+    User *Usr = *I;
+    GlobalVariable *GV = dyn_cast(Usr);
+    if (!GV || !GV->hasName()) {
+      Tried.insert(U);
+      return I;
+    }
+
+    StringRef Name = GV->getName();
+    if (Name != "llvm.used" && Name != "llvm.compiler_used") {
+      Tried.insert(U);
+      return I;
+    }
+  }
+  return V->use_end();
+}
+
+static bool replaceAllNonLLVMUsedUsesWith(Constant *Old, Constant *New);
+
+static bool replaceUsesOfWithOnConstant(ConstantArray *CA, Value *From,
+                                        Value *ToV, Use *U) {
+  Constant *To = cast(ToV);
+
+  SmallVector NewOps;
+  for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i) {
+    Constant *Op = CA->getOperand(i);
+    NewOps.push_back(Op == From ? To : Op);
+  }
+
+  Constant *Replacement = ConstantArray::get(CA->getType(), NewOps);
+  assert(Replacement != CA && "CA didn't contain From!");
+
+  bool Ret = replaceAllNonLLVMUsedUsesWith(CA, Replacement);
+  if (Replacement->use_empty())
+    Replacement->destroyConstant();
+  if (CA->use_empty())
+    CA->destroyConstant();
+  return Ret;
+}
+
+static bool replaceUsesOfWithOnConstant(ConstantExpr *CE, Value *From,
+                                        Value *ToV, Use *U) {
+  Constant *To = cast(ToV);
+  SmallVector NewOps;
+  for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) {
+    Constant *Op = CE->getOperand(i);
+    NewOps.push_back(Op == From ? To : Op);
+  }
+
+  Constant *Replacement = CE->getWithOperands(NewOps);
+  assert(Replacement != CE && "CE didn't contain From!");
+
+  bool Ret = replaceAllNonLLVMUsedUsesWith(CE, Replacement);
+  if (Replacement->use_empty())
+    Replacement->destroyConstant();
+  if (CE->use_empty())
+    CE->destroyConstant();
+  return Ret;
+}
+
+static bool replaceUsesOfWithOnConstant(Constant *C, Value *From, Value *To,
+                                        Use *U) {
+  if (ConstantArray *CA = dyn_cast(C))
+    return replaceUsesOfWithOnConstant(CA, From, To, U);
+  if (ConstantExpr *CE = dyn_cast(C))
+    return replaceUsesOfWithOnConstant(CE, From, To, U);
+  C->replaceUsesOfWithOnConstant(From, To, U);
+  return true;
+}
+
+static bool replaceAllNonLLVMUsedUsesWith(Constant *Old, Constant *New) {
+  SmallPtrSet Tried;
+  bool Ret = false;
+  for (;;) {
+    Value::use_iterator I = getFirst(Old, Tried);
+    if (I == Old->use_end())
+      break;
+    Use &U = I.getUse();
+
+    // Must handle Constants specially, we cannot call replaceUsesOfWith on a
+    // constant because they are uniqued.
+    if (Constant *C = dyn_cast(U.getUser())) {
+      if (!isa(C)) {
+        Ret |= replaceUsesOfWithOnConstant(C, Old, New, &U);
+        continue;
+      }
+    }
+
+    U.set(New);
+    Ret = true;
+  }
+  return Ret;
+}
+
 bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
   bool Changed = false;
 
@@ -3060,11 +3159,12 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
     bool hasOneUse = Target->hasOneUse() && Aliasee->hasOneUse();
 
     // Make all users of the alias use the aliasee instead.
-    if (!J->use_empty()) {
-      J->replaceAllUsesWith(Aliasee);
+    if (replaceAllNonLLVMUsedUsesWith(J, Aliasee)) {
       ++NumAliasesResolved;
       Changed = true;
     }
+    if (!J->use_empty())
+      continue;
 
     // If the alias is externally visible, we may still be able to simplify it.
     if (!J->hasLocalLinkage()) {
diff --git a/llvm/test/Transforms/GlobalOpt/alias-used.ll b/llvm/test/Transforms/GlobalOpt/alias-used.ll
new file mode 100644
index 000000000000..f91579bf0507
--- /dev/null
+++ b/llvm/test/Transforms/GlobalOpt/alias-used.ll
@@ -0,0 +1,42 @@
+; RUN: opt < %s -globalopt -S | FileCheck %s
+
+@c = global i8 42
+
+@llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca], section "llvm.metadata"
+; CHECK: @llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca], section "llvm.metadata"
+
+@llvm.compiler_used = appending global [2 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @fa3 to i8*)], section "llvm.metadata"
+
+@sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca]
+; CHECK: @sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*), i8* @c]
+
+@other = global i32* bitcast (void ()* @fa to i32*)
+; CHECK: @other = global i32* bitcast (void ()* @f to i32*)
+
+@fa = alias internal void ()* @f
+; CHECK: @fa = alias internal void ()* @f
+
+@fa2 = alias internal void ()* @f
+; CHECK-NOT: @fa2
+
+@fa3 = alias internal void ()* @f
+; CHECK: @fa3
+
+@ca = alias internal i8* @c
+; CHECK: @ca = alias internal i8* @c
+
+define void @f() {
+  ret void
+}
+
+define i8* @g() {
+  ret i8* bitcast (void ()* @fa to i8*);
+}
+
+define i8* @g2() {
+  ret i8* bitcast (void ()* @fa2 to i8*);
+}
+
+define i8* @h() {
+  ret i8* @ca
+}
-- 
GitLab


From e4a5588bcb9e5f4e78e143a5841a946409953a4e Mon Sep 17 00:00:00 2001
From: David Blaikie 
Date: Thu, 9 May 2013 17:29:54 +0000
Subject: [PATCH 097/467] Remove trailing whitespace

llvm-svn: 181525
---
 clang/test/CodeGenCXX/debug-info-template.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp
index 9d52159bed84..438ec1efca68 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -32,15 +32,15 @@ static Test test;
 
 // PR9608
 template  struct TheTemplate {
-  struct Empty2 {}; 
-  typedef const Empty2 DependentType[i]; 
-  TheTemplate() {} 
-}; 
+  struct Empty2 {};
+  typedef const Empty2 DependentType[i];
+  TheTemplate() {}
+};
 
-class TheTemplateTest : public TheTemplate<42> { 
-  TheTemplateTest(); 
-  void method(const TheTemplate<42>::DependentType *) {} 
-}; 
+class TheTemplateTest : public TheTemplate<42> {
+  TheTemplateTest();
+  void method(const TheTemplate<42>::DependentType *) {}
+};
 
-TheTemplateTest::TheTemplateTest() : TheTemplate<42>() {} 
+TheTemplateTest::TheTemplateTest() : TheTemplate<42>() {}
 
-- 
GitLab


From e347243061ddab130ba27c22d5ac704520f53777 Mon Sep 17 00:00:00 2001
From: Daniel Malea 
Date: Thu, 9 May 2013 17:34:40 +0000
Subject: [PATCH 098/467] Revert r181482 as it causes occasional hangs in LLDB
 buildbots

llvm-svn: 181526
---
 lldb/include/lldb/Target/Thread.h             |  4 ----
 lldb/include/lldb/Target/ThreadList.h         |  3 ---
 lldb/source/Target/Process.cpp                | 13 -----------
 lldb/source/Target/Thread.cpp                 |  6 -----
 lldb/source/Target/ThreadList.cpp             | 22 -------------------
 .../thread/state/TestThreadStates.py          |  2 ++
 6 files changed, 2 insertions(+), 48 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h
index fc58a6903b6f..e2207a0036c6 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -277,10 +277,6 @@ public:
     virtual void
     DidResume ();
 
-    // This notifies the thread when a private stop occurs.
-    virtual void
-    DidStop ();
-
     virtual void
     RefreshStateAfterStop() = 0;
 
diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h
index ddf49b002ecf..959091c81bfe 100644
--- a/lldb/include/lldb/Target/ThreadList.h
+++ b/lldb/include/lldb/Target/ThreadList.h
@@ -119,9 +119,6 @@ public:
     void
     DidResume ();
 
-    void
-    DidStop ();
-
     void
     DiscardThreadPlans();
 
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f6fdca8a425a..93fd93a71de4 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1722,19 +1722,6 @@ Process::SetPrivateState (StateType new_state)
         m_private_state.SetValueNoLock (new_state);
         if (StateIsStoppedState(new_state, false))
         {
-            // Note, this currently assumes that all threads in the list
-            // stop when the process stops.  In the future we will want to
-            // support a debugging model where some threads continue to run
-            // while others are stopped.  When that happens we will either need
-            // a way for the thread list to identify which threads are stopping
-            // or create a special thread list containing only threads which
-            // actually stopped.
-            //
-            // The process plugin is responsible for managing the actual
-            // behavior of the threads and should have stopped any threads
-            // that are going to stop before we get here.
-            m_thread_list.DidStop();
-
             m_mod_id.BumpStopID();
             m_memory_cache.Clear();
             if (log)
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index c4aa25446823..646a63511e93 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -658,12 +658,6 @@ Thread::DidResume ()
     SetResumeSignal (LLDB_INVALID_SIGNAL_NUMBER);
 }
 
-void
-Thread::DidStop ()
-{
-    SetState (eStateStopped);
-}
-
 bool
 Thread::ShouldStop (Event* event_ptr)
 {
diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp
index 1f8b351100a6..d84a2340cbcc 100644
--- a/lldb/source/Target/ThreadList.cpp
+++ b/lldb/source/Target/ThreadList.cpp
@@ -11,7 +11,6 @@
 #include 
 
 #include "lldb/Core/Log.h"
-#include "lldb/Core/State.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Target/Thread.h"
@@ -644,27 +643,6 @@ ThreadList::DidResume ()
     }
 }
 
-void
-ThreadList::DidStop ()
-{
-    Mutex::Locker locker(GetMutex());
-    collection::iterator pos, end = m_threads.end();
-    for (pos = m_threads.begin(); pos != end; ++pos)
-    {
-        // Notify threads that the process just stopped.
-        // Note, this currently assumes that all threads in the list
-        // stop when the process stops.  In the future we will want to support
-        // a debugging model where some threads continue to run while others
-        // are stopped.  We either need to handle that somehow here or
-        // create a special thread list containing only threads which will
-        // stop in the code that calls this method (currently
-        // Process::SetPrivateState).
-        ThreadSP thread_sp(*pos);
-        if (StateIsRunningState(thread_sp->GetState()))
-            thread_sp->DidStop ();
-    }
-}
-
 ThreadSP
 ThreadList::GetSelectedThread ()
 {
diff --git a/lldb/test/functionalities/thread/state/TestThreadStates.py b/lldb/test/functionalities/thread/state/TestThreadStates.py
index 185eb50106ac..7e59b22aaee6 100644
--- a/lldb/test/functionalities/thread/state/TestThreadStates.py
+++ b/lldb/test/functionalities/thread/state/TestThreadStates.py
@@ -14,12 +14,14 @@ class StopThreadsTestCase(TestBase):
 
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
+    @unittest2.expectedFailure("PR-15824") # thread states not properly maintained
     def test_state_after_breakpoint_with_dsym(self):
         """Test thread state after breakpoint."""
         self.buildDsym()
         self.thread_state_after_breakpoint_test()
 
     @dwarf_test
+    @unittest2.expectedFailure("PR-15824") # thread states not properly maintained
     def test_state_after_breakpoint_with_dwarf(self):
         """Test thread state after breakpoint."""
         self.buildDwarf()
-- 
GitLab


From 0646c86dcb1a78c4bf218037939cbd7d0849254b Mon Sep 17 00:00:00 2001
From: Richard Smith 
Date: Thu, 9 May 2013 17:41:19 +0000
Subject: [PATCH 099/467] Fix the return type of the complex creal functions.
 Patch by YunZhong Gao, modified to use _Static_assert and to check
 __STDC_HOSTED__ by me.

llvm-svn: 181527
---
 clang/lib/Headers/tgmath.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Headers/tgmath.h b/clang/lib/Headers/tgmath.h
index 4fa1cf72f2af..a48e267e60d0 100644
--- a/clang/lib/Headers/tgmath.h
+++ b/clang/lib/Headers/tgmath.h
@@ -1340,15 +1340,15 @@ static long double _Complex
 
 // creal
 
-static float _Complex
+static float
     _TG_ATTRS
     __tg_creal(float __x) {return __x;}
 
-static double _Complex
+static double
     _TG_ATTRS
     __tg_creal(double __x) {return __x;}
 
-static long double _Complex
+static long double
     _TG_ATTRS
     __tg_creal(long double __x) {return __x;}
 
-- 
GitLab


From 3429028a811c1ce5e2ab1bb41f4af75c5ea7bf67 Mon Sep 17 00:00:00 2001
From: "Ariel J. Bernal" 
Date: Thu, 9 May 2013 17:46:20 +0000
Subject: [PATCH 100/467] Use 'auto const&' for iterators whose deref operator
 return a const var

This patch fixes PR15601.
- Added check for whether the loop variable and the initializer have the same
type.
- Added tests.

llvm-svn: 181528
---
 .../AddOverride/AddOverrideActions.cpp        |  4 +
 .../cpp11-migrate/LoopConvert/LoopActions.cpp | 74 ++++++++++++++++---
 .../cpp11-migrate/LoopConvert/LoopActions.h   |  4 +-
 .../LoopConvert/LoopMatchers.cpp              | 26 ++++++-
 .../cpp11-migrate/LoopConvert/LoopMatchers.h  |  2 +
 .../LoopConvert/Inputs/structures.h           |  3 +
 .../cpp11-migrate/LoopConvert/iterator.cpp    | 54 ++++++++++++--
 .../LoopConvert/naming-conflict.cpp           | 10 ++-
 .../cpp11-migrate/LoopConvert/nesting.cpp     | 12 +++
 .../LoopConvert/single-iterator.cpp           | 51 +++++++++++--
 10 files changed, 212 insertions(+), 28 deletions(-)

diff --git a/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp b/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp
index a40f673132cf..3d1f1ff8c139 100644
--- a/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp
+++ b/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp
@@ -32,6 +32,10 @@ void AddOverrideFixer::run(const MatchFinder::MatchResult &Result) {
   const CXXMethodDecl *M = Result.Nodes.getDeclAs(MethodId);
   assert(M && "Bad Callback. No node provided");
 
+  // Check that the method declaration in the main file
+  if (!SM.isFromMainFile(M->getLocStart()))
+    return;
+
   // First check that there isn't already an override attribute.
   if (!M->hasAttr()) {
     if (M->getLocStart().isFileID()) {
diff --git a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.cpp b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.cpp
index 4ba22b3f2845..88c219aefece 100644
--- a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.cpp
+++ b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.cpp
@@ -791,7 +791,8 @@ void LoopFixer::doConversion(ASTContext *Context,
                              bool AliasFromForInit,
                              const ForStmt *TheLoop,
                              bool ContainerNeedsDereference,
-                             bool DerefByValue) {
+                             bool DerefByValue,
+                             bool DerefByConstRef) {
   std::string VarName;
   bool VarNameFromAlias = Usages.size() == 1 && AliasDecl;
   bool AliasVarIsRef = false;
@@ -849,8 +850,11 @@ void LoopFixer::doConversion(ASTContext *Context,
     // to 'T&&'.
     if (DerefByValue)
       AutoRefType = Context->getRValueReferenceType(AutoRefType);
-    else
+    else {
+      if (DerefByConstRef)
+        AutoRefType = Context->getConstType(AutoRefType);
       AutoRefType = Context->getLValueReferenceType(AutoRefType);
+    }
   }
 
   std::string MaybeDereference = ContainerNeedsDereference ? "*" : "";
@@ -979,6 +983,7 @@ void LoopFixer::findAndVerifyUsages(ASTContext *Context,
                                     const Expr *BoundExpr,
                                     bool ContainerNeedsDereference,
                                     bool DerefByValue,
+                                    bool DerefByConstRef,
                                     const ForStmt *TheLoop,
                                     Confidence ConfidenceLevel) {
   ForLoopIndexUseVisitor Finder(Context, LoopVar, EndVar, ContainerExpr,
@@ -1013,7 +1018,7 @@ void LoopFixer::findAndVerifyUsages(ASTContext *Context,
   doConversion(Context, LoopVar, getReferencedVariable(ContainerExpr),
                ContainerString, Finder.getUsages(), Finder.getAliasDecl(),
                Finder.aliasUseRequired(), Finder.aliasFromForInit(), TheLoop,
-               ContainerNeedsDereference, DerefByValue);
+               ContainerNeedsDereference, DerefByValue, DerefByConstRef);
   ++*AcceptedChanges;
 }
 
@@ -1051,14 +1056,67 @@ void LoopFixer::run(const MatchFinder::MatchResult &Result) {
     ConfidenceLevel.lowerTo(RL_Reasonable);
 
   const Expr *ContainerExpr = NULL;
+  bool DerefByValue = false;
+  bool DerefByConstRef = false;
   bool ContainerNeedsDereference = false;
   // FIXME: Try to put most of this logic inside a matcher. Currently, matchers
   // don't allow the right-recursive checks in digThroughConstructors.
-  if (FixerKind == LFK_Iterator)
+  if (FixerKind == LFK_Iterator) {
     ContainerExpr = findContainer(Context, LoopVar->getInit(),
                                   EndVar ? EndVar->getInit() : EndCall,
                                   &ContainerNeedsDereference);
-  else if (FixerKind == LFK_PseudoArray) {
+
+    QualType InitVarType = InitVar->getType();
+    QualType CanonicalInitVarType = InitVarType.getCanonicalType();
+
+    const CXXMemberCallExpr *BeginCall =
+        Nodes.getNodeAs(BeginCallName);
+    assert(BeginCall != 0 && "Bad Callback. No begin call expression.");
+    QualType CanonicalBeginType =
+        BeginCall->getMethodDecl()->getResultType().getCanonicalType();
+
+    if (CanonicalBeginType->isPointerType() &&
+        CanonicalInitVarType->isPointerType()) {
+      QualType BeginPointeeType = CanonicalBeginType->getPointeeType();
+      QualType InitPointeeType = CanonicalInitVarType->getPointeeType();
+      // If the initializer and the variable are both pointers check if the
+      // un-qualified pointee types match otherwise we don't use auto.
+      if (!Context->hasSameUnqualifiedType(InitPointeeType, BeginPointeeType))
+        return;
+    } else {
+      // Check for qualified types to avoid conversions from non-const to const
+      // iterator types.
+      if (!Context->hasSameType(CanonicalInitVarType, CanonicalBeginType))
+        return;
+    }
+
+    DerefByValue = Nodes.getNodeAs(DerefByValueResultName) != 0;
+    if (!DerefByValue) {
+      if (const QualType *DerefType =
+              Nodes.getNodeAs(DerefByRefResultName)) {
+        // A node will only be bound with DerefByRefResultName if we're dealing
+        // with a user-defined iterator type. Test the const qualification of
+        // the reference type.
+        DerefByConstRef = (*DerefType)->getAs()->getPointeeType()
+            .isConstQualified();
+      } else {
+        // By nature of the matcher this case is triggered only for built-in
+        // iterator types (i.e. pointers).
+        assert(isa(CanonicalInitVarType) &&
+               "Non-class iterator type is not a pointer type");
+        QualType InitPointeeType = CanonicalInitVarType->getPointeeType();
+        QualType BeginPointeeType = CanonicalBeginType->getPointeeType();
+        // If the initializer and variable have both the same type just use auto
+        // otherwise we test for const qualification of the pointed-at type.
+        if (!Context->hasSameType(InitPointeeType, BeginPointeeType))
+          DerefByConstRef = InitPointeeType.isConstQualified();
+      }
+    } else {
+      // If the de-referece operator return by value then test for the canonical
+      // const qualification of the init variable type.
+      DerefByConstRef = CanonicalInitVarType.isConstQualified();
+    }
+  } else if (FixerKind == LFK_PseudoArray) {
     if (!EndCall)
       return;
     ContainerExpr = EndCall->getImplicitObjectArgument();
@@ -1071,9 +1129,7 @@ void LoopFixer::run(const MatchFinder::MatchResult &Result) {
   if (!ContainerExpr && !BoundExpr)
     return;
 
-  bool DerefByValue = Nodes.getNodeAs(DerefByValueResultName) != 0;
-
   findAndVerifyUsages(Context, LoopVar, EndVar, ContainerExpr, BoundExpr,
-                      ContainerNeedsDereference, DerefByValue, TheLoop,
-                      ConfidenceLevel);
+                      ContainerNeedsDereference, DerefByValue, DerefByConstRef,
+                      TheLoop, ConfidenceLevel);
 }
diff --git a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.h b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.h
index 6a488894ad3a..eebee338208f 100644
--- a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.h
+++ b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopActions.h
@@ -77,7 +77,8 @@ class LoopFixer : public clang::ast_matchers::MatchFinder::MatchCallback {
                     bool AliasFromForInit,
                     const clang::ForStmt *TheLoop,
                     bool ContainerNeedsDereference,
-                    bool DerefByValue);
+                    bool DerefByValue,
+                    bool DerefByConstRef);
 
   /// \brief Given a loop header that would be convertible, discover all usages
   /// of the index variable and convert the loop if possible.
@@ -88,6 +89,7 @@ class LoopFixer : public clang::ast_matchers::MatchFinder::MatchCallback {
                            const clang::Expr *BoundExpr,
                            bool ContainerNeedsDereference,
                            bool DerefByValue,
+                           bool DerefByConstRef,
                            const clang::ForStmt *TheLoop,
                            Confidence ConfidenceLevel);
 
diff --git a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp
index ffd9f794b0cf..a7ca15f3eb3d 100644
--- a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp
+++ b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp
@@ -22,10 +22,12 @@ const char ConditionBoundName[] = "conditionBound";
 const char ConditionVarName[] = "conditionVar";
 const char IncrementVarName[] = "incrementVar";
 const char InitVarName[] = "initVar";
+const char BeginCallName[] = "beginCall";
 const char EndCallName[] = "endCall";
 const char ConditionEndVarName[] = "conditionEndVar";
 const char EndVarName[] = "endVar";
 const char DerefByValueResultName[] = "derefByValueResult";
+const char DerefByRefResultName[] = "derefByRefResult";
 
 // shared matchers
 static const TypeMatcher AnyType = anything();
@@ -109,10 +111,23 @@ StatementMatcher makeArrayLoopMatcher() {
 ///   - If the end iterator variable 'g' is defined, it is the same as 'f'
 StatementMatcher makeIteratorLoopMatcher() {
   StatementMatcher BeginCallMatcher =
-      memberCallExpr(argumentCountIs(0), callee(methodDecl(hasName("begin"))));
+      memberCallExpr(
+        argumentCountIs(0),
+        callee(
+          methodDecl(hasName("begin"))
+        )
+      ).bind(BeginCallName);
 
   DeclarationMatcher InitDeclMatcher =
-      varDecl(hasInitializer(anything())).bind(InitVarName);
+      varDecl(
+        hasInitializer(
+          anyOf(
+            ignoringParenImpCasts(BeginCallMatcher),
+            materializeTemporaryExpr(ignoringParenImpCasts(BeginCallMatcher)),
+            hasDescendant(BeginCallMatcher)
+          )
+        )
+      ).bind(InitVarName);
 
   DeclarationMatcher EndDeclMatcher =
       varDecl(hasInitializer(anything())).bind(EndVarName);
@@ -157,7 +172,11 @@ StatementMatcher makeIteratorLoopMatcher() {
                 returns(
                   // Skip loops where the iterator's operator* returns an
                   // rvalue reference. This is just weird.
-                  qualType(unless(hasCanonicalType(rValueReferenceType())))
+                  qualType(
+                    unless(
+                      hasCanonicalType(rValueReferenceType())
+                    )
+                  ).bind(DerefByRefResultName)
                 )
               )
             )
@@ -165,6 +184,7 @@ StatementMatcher makeIteratorLoopMatcher() {
         )
       );
 
+
   return
     forStmt(
       hasLoopInit(anyOf(
diff --git a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.h b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.h
index 7824a82ad48c..6946f49504b5 100644
--- a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.h
+++ b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.h
@@ -27,10 +27,12 @@ extern const char ConditionVarName[];
 extern const char ConditionEndVarName[];
 extern const char IncrementVarName[];
 extern const char InitVarName[];
+extern const char BeginCallName[];
 extern const char EndExprName[];
 extern const char EndCallName[];
 extern const char EndVarName[];
 extern const char DerefByValueResultName[];
+extern const char DerefByRefResultName[];
 
 clang::ast_matchers::StatementMatcher makeArrayLoopMatcher();
 clang::ast_matchers::StatementMatcher makeIteratorLoopMatcher();
diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h b/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h
index e37f2b54794a..9dd04f42b5ab 100644
--- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h
+++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h
@@ -131,10 +131,13 @@ class transparent {
 template
 struct Nested {
   typedef IteratorType* iterator;
+  typedef const IteratorType* const_iterator;
   IteratorType *operator->();
   IteratorType operator*();
   iterator begin();
   iterator end();
+  const_iterator begin() const;
+  const_iterator end() const;
 };
 
 // Like llvm::SmallPtrSet, the iterator has a dereference operator that returns
diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp
index 53030b50f034..3d98c0bca24a 100644
--- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp
@@ -23,20 +23,20 @@ void f() {
   // CHECK-NEXT: printf("I found %d\n", elem);
 
   S s;
-  for (S::const_iterator it = s.begin(), e = s.end(); it != e; ++it) {
+  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
     printf("s has value %d\n", (*it).x);
   }
   // CHECK: for (auto & elem : s)
   // CHECK-NEXT: printf("s has value %d\n", (elem).x);
 
   S *ps;
-  for (S::const_iterator it = ps->begin(), e = ps->end(); it != e; ++it) {
+  for (S::iterator it = ps->begin(), e = ps->end(); it != e; ++it) {
     printf("s has value %d\n", (*it).x);
   }
   // CHECK: for (auto & p : *ps)
   // CHECK-NEXT: printf("s has value %d\n", (p).x);
 
-  for (S::const_iterator it = s.begin(), e = s.end(); it != e; ++it) {
+  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
     printf("s has value %d\n", it->x);
   }
   // CHECK: for (auto & elem : s)
@@ -80,18 +80,18 @@ void f() {
   // CHECK-NEXT: int k = A->x + elem.x;
 
   dependent v;
-  for (dependent::const_iterator it = v.begin(), e = v.end();
+  for (dependent::iterator it = v.begin(), e = v.end();
        it != e; ++it) {
     printf("Fibonacci number is %d\n", *it);
   }
-  // CHECK: for (auto & elem : v)
+  // CHECK: for (auto & elem : v) {
   // CHECK-NEXT: printf("Fibonacci number is %d\n", elem);
 
-  for (dependent::const_iterator it(v.begin()), e = v.end();
+  for (dependent::iterator it(v.begin()), e = v.end();
        it != e; ++it) {
     printf("Fibonacci number is %d\n", *it);
   }
-  // CHECK: for (auto & elem : v)
+  // CHECK: for (auto & elem : v) {
   // CHECK-NEXT: printf("Fibonacci number is %d\n", elem);
 
   doublyDependent intmap;
@@ -134,6 +134,46 @@ void f() {
   }
 }
 
+// Tests to verify the proper use of auto where the init variable type and the
+// initializer type differ or are mostly the same except for const qualifiers.
+void different_type() {
+  // s.begin() returns a type 'iterator' which is just a non-const pointer and
+  // differs from const_iterator only on the const qualification.
+  S s;
+  for (S::const_iterator it = s.begin(), e = s.end(); it != e; ++it) {
+    printf("s has value %d\n", (*it).x);
+  }
+  // CHECK: for (auto const & elem : s)
+  // CHECK-NEXT: printf("s has value %d\n", (elem).x);
+
+  S *ps;
+  for (S::const_iterator it = ps->begin(), e = ps->end(); it != e; ++it) {
+    printf("s has value %d\n", (*it).x);
+  }
+  // CHECK: for (auto const & p : *ps)
+  // CHECK-NEXT: printf("s has value %d\n", (p).x);
+
+  // v.begin() returns a user-defined type 'iterator' which, since it's
+  // different from const_iterator, disqualifies these loops from
+  // transformation.
+  dependent v;
+  for (dependent::const_iterator it = v.begin(), e = v.end();
+       it != e; ++it) {
+    printf("Fibonacci number is %d\n", *it);
+  }
+  // CHECK: for (dependent::const_iterator it = v.begin(), e = v.end();
+  // CHECK-NEXT: it != e; ++it) {
+  // CHECK-NEXT: printf("Fibonacci number is %d\n", *it);
+
+  for (dependent::const_iterator it(v.begin()), e = v.end();
+       it != e; ++it) {
+    printf("Fibonacci number is %d\n", *it);
+  }
+  // CHECK: for (dependent::const_iterator it(v.begin()), e = v.end();
+  // CHECK-NEXT: it != e; ++it) {
+  // CHECK-NEXT: printf("Fibonacci number is %d\n", *it);
+}
+
 // Tests to ensure that an implicit 'this' is picked up as the container.
 // If member calls are made to 'this' within the loop, the transform becomes
 // risky as these calls may affect state that affects the loop.
diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp
index 050f44ef9008..9597c63a6f28 100644
--- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp
@@ -32,7 +32,7 @@ void sameNames() {
 
 void macroConflict() {
   S MAXs;
-  for (S::const_iterator it = MAXs.begin(), e = MAXs.end(); it != e; ++it) {
+  for (S::iterator it = MAXs.begin(), e = MAXs.end(); it != e; ++it) {
     printf("s has value %d\n", (*it).x);
     printf("Max of 3 and 5: %d\n", MAX(3,5));
   }
@@ -40,6 +40,14 @@ void macroConflict() {
   // CHECK-NEXT: printf("s has value %d\n", (MAXs_it).x);
   // CHECK-NEXT: printf("Max of 3 and 5: %d\n", MAX(3,5));
 
+  for (S::const_iterator it = MAXs.begin(), e = MAXs.end(); it != e; ++it) {
+    printf("s has value %d\n", (*it).x);
+    printf("Max of 3 and 5: %d\n", MAX(3,5));
+  }
+  // CHECK: for (auto const & MAXs_it : MAXs)
+  // CHECK-NEXT: printf("s has value %d\n", (MAXs_it).x);
+  // CHECK-NEXT: printf("Max of 3 and 5: %d\n", MAX(3,5));
+
   T DEFs;
   for (T::iterator it = DEFs.begin(), e = DEFs.end(); it != e; ++it) {
     if (*it == DEF) {
diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp
index 729b5ff21a68..b26cf218d774 100644
--- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp
@@ -54,4 +54,16 @@ void f() {
   // CHECK: for (auto & elem : NestT) {
   // CHECK-NEXT: for (T::iterator TI = (elem).begin(), TE = (elem).end(); TI != TE; ++TI) {
   // CHECK-NEXT: printf("%d", *TI);
+
+  Nested NestS;
+  for (Nested::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
+    for (S::const_iterator SI = (*I).begin(), SE = (*I).end(); SI != SE; ++SI) {
+      printf("%d", *SI);
+    }
+  }
+  // The inner loop is also convertible, but doesn't need to be converted
+  // immediately. Update this test when that changes!
+  // CHECK: for (auto const & elem : NestS) {
+  // CHECK-NEXT: for (S::const_iterator SI = (elem).begin(), SE = (elem).end(); SI != SE; ++SI) {
+  // CHECK-NEXT: printf("%d", *SI);
 }
diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp
index 91b6ea5b2f71..c717ed6c5e2d 100644
--- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp
@@ -34,20 +34,20 @@ void f() {
   // CHECK-NEXT: printf("I found %d\n", elem);
 
   S s;
-  for (S::const_iterator it = s.begin(); it != s.end(); ++it) {
+  for (S::iterator it = s.begin(); it != s.end(); ++it) {
     printf("s has value %d\n", (*it).x);
   }
   // CHECK: for (auto & elem : s)
   // CHECK-NEXT: printf("s has value %d\n", (elem).x);
 
   S *ps;
-  for (S::const_iterator it = ps->begin(); it != ps->end(); ++it) {
+  for (S::iterator it = ps->begin(); it != ps->end(); ++it) {
     printf("s has value %d\n", (*it).x);
   }
   // CHECK: for (auto & p : *ps)
   // CHECK-NEXT: printf("s has value %d\n", (p).x);
 
-  for (S::const_iterator it = s.begin(); it != s.end(); ++it) {
+  for (S::iterator it = s.begin(); it != s.end(); ++it) {
     printf("s has value %d\n", it->x);
   }
   // CHECK: for (auto & elem : s)
@@ -91,18 +91,18 @@ void f() {
   // CHECK-NEXT: int k = A->x + elem.x;
 
   dependent v;
-  for (dependent::const_iterator it = v.begin();
+  for (dependent::iterator it = v.begin();
        it != v.end(); ++it) {
     printf("Fibonacci number is %d\n", *it);
   }
-  // CHECK: for (auto & elem : v)
+  // CHECK: for (auto & elem : v) {
   // CHECK-NEXT: printf("Fibonacci number is %d\n", elem);
 
-  for (dependent::const_iterator it(v.begin());
+  for (dependent::iterator it(v.begin());
        it != v.end(); ++it) {
     printf("Fibonacci number is %d\n", *it);
   }
-  // CHECK: for (auto & elem : v)
+  // CHECK: for (auto & elem : v) {
   // CHECK-NEXT: printf("Fibonacci number is %d\n", elem);
 
   doublyDependent intmap;
@@ -113,3 +113,40 @@ void f() {
   // CHECK: for (auto & elem : intmap)
   // CHECK-NEXT: printf("intmap[%d] = %d", elem.first, elem.second);
 }
+
+void different_type() {
+  // Tests to verify the proper use of auto where the init variable type and the
+  // initializer type differ or are mostly the same except for const qualifiers.
+
+  // s.begin() returns a type 'iterator' which is just a non-const pointer and
+  // differs from const_iterator only on the const qualification.
+  S s;
+  for (S::const_iterator it = s.begin(); it != s.end(); ++it) {
+    printf("s has value %d\n", (*it).x);
+  }
+  // CHECK: for (auto const & elem : s)
+  // CHECK-NEXT: printf("s has value %d\n", (elem).x);
+
+  S *ps;
+  for (S::const_iterator it = ps->begin(); it != ps->end(); ++it) {
+    printf("s has value %d\n", (*it).x);
+  }
+  // CHECK: for (auto const & p : *ps)
+  // CHECK-NEXT: printf("s has value %d\n", (p).x);
+
+  // v.begin() returns a user-defined type 'iterator' which, since it's
+  // different from const_iterator, disqualifies these loops from
+  // transformation.
+  dependent v;
+  for (dependent::const_iterator it = v.begin(); it != v.end(); ++it) {
+    printf("Fibonacci number is %d\n", *it);
+  }
+  // CHECK: for (dependent::const_iterator it = v.begin(); it != v.end(); ++it) {
+  // CHECK-NEXT: printf("Fibonacci number is %d\n", *it);
+
+  for (dependent::const_iterator it(v.begin()); it != v.end(); ++it) {
+    printf("Fibonacci number is %d\n", *it);
+  }
+  // CHECK: for (dependent::const_iterator it(v.begin()); it != v.end(); ++it) {
+  // CHECK-NEXT: printf("Fibonacci number is %d\n", *it);
+}
-- 
GitLab


From 98d5c52d2e1c23760b4233bbc8d040868bbe9469 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Thu, 9 May 2013 18:21:45 +0000
Subject: [PATCH 101/467] Simplify the code a bit.

The compact unwind registers were defined in two different
places. It's better just to place them in the function that uses them
and specify that this is a 64-bit or 32-bit machine.

No functionality change.

llvm-svn: 181529
---
 llvm/lib/Target/X86/X86FrameLowering.cpp | 29 ++++++++----------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 16e1e42c501d..ae51178f73b8 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -369,7 +369,14 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(MachineFunction &MF,
 /// getCompactUnwindRegNum - Get the compact unwind number for a given
 /// register. The number corresponds to the enum lists in
 /// compact_unwind_encoding.h.
-static int getCompactUnwindRegNum(const uint16_t *CURegs, unsigned Reg) {
+static int getCompactUnwindRegNum(unsigned Reg, bool is64Bit) {
+  static const uint16_t CU32BitRegs[] = {
+    X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
+  };
+  static const uint16_t CU64BitRegs[] = {
+    X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
+  };
+  const uint16_t *CURegs = is64Bit ? CU64BitRegs : CU32BitRegs;
   for (int Idx = 1; *CURegs; ++CURegs, ++Idx)
     if (*CURegs == Reg)
       return Idx;
@@ -398,16 +405,8 @@ encodeCompactUnwindRegistersWithoutFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
   //     4       3
   //     5       3
   //
-  static const uint16_t CU32BitRegs[] = {
-    X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
-  };
-  static const uint16_t CU64BitRegs[] = {
-    X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
-  };
-  const uint16_t *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
-
   for (unsigned i = 0; i != CU_NUM_SAVED_REGS; ++i) {
-    int CUReg = getCompactUnwindRegNum(CURegs, SavedRegs[i]);
+    int CUReg = getCompactUnwindRegNum(SavedRegs[i], Is64Bit);
     if (CUReg == -1) return ~0U;
     SavedRegs[i] = CUReg;
   }
@@ -466,14 +465,6 @@ encodeCompactUnwindRegistersWithoutFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
 static uint32_t
 encodeCompactUnwindRegistersWithFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
                                       bool Is64Bit) {
-  static const uint16_t CU32BitRegs[] = {
-    X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
-  };
-  static const uint16_t CU64BitRegs[] = {
-    X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
-  };
-  const uint16_t *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
-
   // Encode the registers in the order they were saved, 3-bits per register. The
   // registers are numbered from 1 to CU_NUM_SAVED_REGS.
   uint32_t RegEnc = 0;
@@ -481,7 +472,7 @@ encodeCompactUnwindRegistersWithFrame(unsigned SavedRegs[CU_NUM_SAVED_REGS],
     unsigned Reg = SavedRegs[I];
     if (Reg == 0) continue;
 
-    int CURegNum = getCompactUnwindRegNum(CURegs, Reg);
+    int CURegNum = getCompactUnwindRegNum(Reg, Is64Bit);
     if (CURegNum == -1) return ~0U;
 
     // Encode the 3-bit register number in order, skipping over 3-bits for each
-- 
GitLab


From 978e972ff9bd8c185feb5389cd03c0a02f4f91f6 Mon Sep 17 00:00:00 2001
From: Jyotsna Verma 
Date: Thu, 9 May 2013 18:25:44 +0000
Subject: [PATCH 102/467] Hexagon: Use relation map for
 getMatchingCondBranchOpcode() and getInvertedPredicatedOpcode() functions
 instead of switch cases.

llvm-svn: 181530
---
 llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 540 +------------------
 llvm/test/CodeGen/Hexagon/pred-instrs.ll     |  30 ++
 2 files changed, 35 insertions(+), 535 deletions(-)
 create mode 100644 llvm/test/CodeGen/Hexagon/pred-instrs.ll

diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
index f1141708b3c6..60976b12722e 100644
--- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
@@ -917,19 +917,6 @@ bool HexagonInstrInfo::isPredicable(MachineInstr *MI) const {
 //  cPt    ---> cNotPt
 //  cNotPt ---> cPt
 //
-// however, these inversiones are NOT included:
-//
-//  cdnPt      -X-> cdnNotPt
-//  cdnNotPt   -X-> cdnPt
-//  cPt_nv     -X-> cNotPt_nv (new value stores)
-//  cNotPt_nv  -X-> cPt_nv    (new value stores)
-//
-// because only the following transformations are allowed:
-//
-//  cNotPt  ---> cdnNotPt
-//  cPt     ---> cdnPt
-//  cNotPt  ---> cNotPt_nv
-//  cPt     ---> cPt_nv
 unsigned HexagonInstrInfo::getInvertedPredicatedOpcode(const int Opc) const {
   int InvPredOpcode;
   InvPredOpcode = isPredicatedTrue(Opc) ? Hexagon::getFalsePredOpcode(Opc)
@@ -939,332 +926,12 @@ unsigned HexagonInstrInfo::getInvertedPredicatedOpcode(const int Opc) const {
 
   switch(Opc) {
     default: llvm_unreachable("Unexpected predicated instruction");
-    case Hexagon::TFR_cPt:
-      return Hexagon::TFR_cNotPt;
-    case Hexagon::TFR_cNotPt:
-      return Hexagon::TFR_cPt;
-
-    case Hexagon::TFRI_cPt:
-      return Hexagon::TFRI_cNotPt;
-    case Hexagon::TFRI_cNotPt:
-      return Hexagon::TFRI_cPt;
-
-    case Hexagon::JMP_t:
-      return Hexagon::JMP_f;
-    case Hexagon::JMP_f:
-      return Hexagon::JMP_t;
-
-    case Hexagon::ADD_ri_cPt:
-      return Hexagon::ADD_ri_cNotPt;
-    case Hexagon::ADD_ri_cNotPt:
-      return Hexagon::ADD_ri_cPt;
-
-    case Hexagon::ADD_rr_cPt:
-      return Hexagon::ADD_rr_cNotPt;
-    case Hexagon::ADD_rr_cNotPt:
-      return Hexagon::ADD_rr_cPt;
-
-    case Hexagon::XOR_rr_cPt:
-      return Hexagon::XOR_rr_cNotPt;
-    case Hexagon::XOR_rr_cNotPt:
-      return Hexagon::XOR_rr_cPt;
-
-    case Hexagon::AND_rr_cPt:
-      return Hexagon::AND_rr_cNotPt;
-    case Hexagon::AND_rr_cNotPt:
-      return Hexagon::AND_rr_cPt;
-
-    case Hexagon::OR_rr_cPt:
-      return Hexagon::OR_rr_cNotPt;
-    case Hexagon::OR_rr_cNotPt:
-      return Hexagon::OR_rr_cPt;
-
-    case Hexagon::SUB_rr_cPt:
-      return Hexagon::SUB_rr_cNotPt;
-    case Hexagon::SUB_rr_cNotPt:
-      return Hexagon::SUB_rr_cPt;
-
     case Hexagon::COMBINE_rr_cPt:
       return Hexagon::COMBINE_rr_cNotPt;
     case Hexagon::COMBINE_rr_cNotPt:
       return Hexagon::COMBINE_rr_cPt;
 
-    case Hexagon::ASLH_cPt_V4:
-      return Hexagon::ASLH_cNotPt_V4;
-    case Hexagon::ASLH_cNotPt_V4:
-      return Hexagon::ASLH_cPt_V4;
-
-    case Hexagon::ASRH_cPt_V4:
-      return Hexagon::ASRH_cNotPt_V4;
-    case Hexagon::ASRH_cNotPt_V4:
-      return Hexagon::ASRH_cPt_V4;
-
-    case Hexagon::SXTB_cPt_V4:
-      return Hexagon::SXTB_cNotPt_V4;
-    case Hexagon::SXTB_cNotPt_V4:
-      return Hexagon::SXTB_cPt_V4;
-
-    case Hexagon::SXTH_cPt_V4:
-      return Hexagon::SXTH_cNotPt_V4;
-    case Hexagon::SXTH_cNotPt_V4:
-      return Hexagon::SXTH_cPt_V4;
-
-    case Hexagon::ZXTB_cPt_V4:
-      return Hexagon::ZXTB_cNotPt_V4;
-    case Hexagon::ZXTB_cNotPt_V4:
-      return Hexagon::ZXTB_cPt_V4;
-
-    case Hexagon::ZXTH_cPt_V4:
-      return Hexagon::ZXTH_cNotPt_V4;
-    case Hexagon::ZXTH_cNotPt_V4:
-      return Hexagon::ZXTH_cPt_V4;
-
-
-    case Hexagon::JMPR_t:
-      return Hexagon::JMPR_f;
-    case Hexagon::JMPR_f:
-      return Hexagon::JMPR_t;
-
-  // V4 indexed+scaled load.
-    case Hexagon::LDrid_indexed_shl_cPt_V4:
-      return Hexagon::LDrid_indexed_shl_cNotPt_V4;
-    case Hexagon::LDrid_indexed_shl_cNotPt_V4:
-      return Hexagon::LDrid_indexed_shl_cPt_V4;
-
-    case Hexagon::LDrib_indexed_shl_cPt_V4:
-      return Hexagon::LDrib_indexed_shl_cNotPt_V4;
-    case Hexagon::LDrib_indexed_shl_cNotPt_V4:
-      return Hexagon::LDrib_indexed_shl_cPt_V4;
-
-    case Hexagon::LDriub_indexed_shl_cPt_V4:
-      return Hexagon::LDriub_indexed_shl_cNotPt_V4;
-    case Hexagon::LDriub_indexed_shl_cNotPt_V4:
-      return Hexagon::LDriub_indexed_shl_cPt_V4;
-
-    case Hexagon::LDrih_indexed_shl_cPt_V4:
-      return Hexagon::LDrih_indexed_shl_cNotPt_V4;
-    case Hexagon::LDrih_indexed_shl_cNotPt_V4:
-      return Hexagon::LDrih_indexed_shl_cPt_V4;
-
-    case Hexagon::LDriuh_indexed_shl_cPt_V4:
-      return Hexagon::LDriuh_indexed_shl_cNotPt_V4;
-    case Hexagon::LDriuh_indexed_shl_cNotPt_V4:
-      return Hexagon::LDriuh_indexed_shl_cPt_V4;
-
-    case Hexagon::LDriw_indexed_shl_cPt_V4:
-      return Hexagon::LDriw_indexed_shl_cNotPt_V4;
-    case Hexagon::LDriw_indexed_shl_cNotPt_V4:
-      return Hexagon::LDriw_indexed_shl_cPt_V4;
-
-    // Byte.
-    case Hexagon::POST_STbri_cPt:
-      return Hexagon::POST_STbri_cNotPt;
-    case Hexagon::POST_STbri_cNotPt:
-      return Hexagon::POST_STbri_cPt;
-
-    case Hexagon::STrib_cPt:
-      return Hexagon::STrib_cNotPt;
-    case Hexagon::STrib_cNotPt:
-      return Hexagon::STrib_cPt;
-
-    case Hexagon::STrib_indexed_cPt:
-      return Hexagon::STrib_indexed_cNotPt;
-    case Hexagon::STrib_indexed_cNotPt:
-      return Hexagon::STrib_indexed_cPt;
-
-    case Hexagon::STrib_imm_cPt_V4:
-      return Hexagon::STrib_imm_cNotPt_V4;
-    case Hexagon::STrib_imm_cNotPt_V4:
-      return Hexagon::STrib_imm_cPt_V4;
-
-    case Hexagon::STrib_indexed_shl_cPt_V4:
-      return Hexagon::STrib_indexed_shl_cNotPt_V4;
-    case Hexagon::STrib_indexed_shl_cNotPt_V4:
-      return Hexagon::STrib_indexed_shl_cPt_V4;
-
-  // Halfword.
-    case Hexagon::POST_SThri_cPt:
-      return Hexagon::POST_SThri_cNotPt;
-    case Hexagon::POST_SThri_cNotPt:
-      return Hexagon::POST_SThri_cPt;
-
-    case Hexagon::STrih_cPt:
-      return Hexagon::STrih_cNotPt;
-    case Hexagon::STrih_cNotPt:
-      return Hexagon::STrih_cPt;
-
-    case Hexagon::STrih_indexed_cPt:
-      return Hexagon::STrih_indexed_cNotPt;
-    case Hexagon::STrih_indexed_cNotPt:
-      return Hexagon::STrih_indexed_cPt;
-
-    case Hexagon::STrih_imm_cPt_V4:
-      return Hexagon::STrih_imm_cNotPt_V4;
-    case Hexagon::STrih_imm_cNotPt_V4:
-      return Hexagon::STrih_imm_cPt_V4;
-
-    case Hexagon::STrih_indexed_shl_cPt_V4:
-      return Hexagon::STrih_indexed_shl_cNotPt_V4;
-    case Hexagon::STrih_indexed_shl_cNotPt_V4:
-      return Hexagon::STrih_indexed_shl_cPt_V4;
-
-  // Word.
-    case Hexagon::POST_STwri_cPt:
-      return Hexagon::POST_STwri_cNotPt;
-    case Hexagon::POST_STwri_cNotPt:
-      return Hexagon::POST_STwri_cPt;
-
-    case Hexagon::STriw_cPt:
-      return Hexagon::STriw_cNotPt;
-    case Hexagon::STriw_cNotPt:
-      return Hexagon::STriw_cPt;
-
-    case Hexagon::STriw_indexed_cPt:
-      return Hexagon::STriw_indexed_cNotPt;
-    case Hexagon::STriw_indexed_cNotPt:
-      return Hexagon::STriw_indexed_cPt;
-
-    case Hexagon::STriw_indexed_shl_cPt_V4:
-      return Hexagon::STriw_indexed_shl_cNotPt_V4;
-    case Hexagon::STriw_indexed_shl_cNotPt_V4:
-      return Hexagon::STriw_indexed_shl_cPt_V4;
-
-    case Hexagon::STriw_imm_cPt_V4:
-      return Hexagon::STriw_imm_cNotPt_V4;
-    case Hexagon::STriw_imm_cNotPt_V4:
-      return Hexagon::STriw_imm_cPt_V4;
-
-  // Double word.
-    case Hexagon::POST_STdri_cPt:
-      return Hexagon::POST_STdri_cNotPt;
-    case Hexagon::POST_STdri_cNotPt:
-      return Hexagon::POST_STdri_cPt;
-
-    case Hexagon::STrid_cPt:
-      return Hexagon::STrid_cNotPt;
-    case Hexagon::STrid_cNotPt:
-      return Hexagon::STrid_cPt;
-
-    case Hexagon::STrid_indexed_cPt:
-      return Hexagon::STrid_indexed_cNotPt;
-    case Hexagon::STrid_indexed_cNotPt:
-      return Hexagon::STrid_indexed_cPt;
-
-    case Hexagon::STrid_indexed_shl_cPt_V4:
-      return Hexagon::STrid_indexed_shl_cNotPt_V4;
-    case Hexagon::STrid_indexed_shl_cNotPt_V4:
-      return Hexagon::STrid_indexed_shl_cPt_V4;
-
-    // V4 Store to global address.
-    case Hexagon::STd_GP_cPt_V4:
-      return Hexagon::STd_GP_cNotPt_V4;
-    case Hexagon::STd_GP_cNotPt_V4:
-      return Hexagon::STd_GP_cPt_V4;
-
-    case Hexagon::STb_GP_cPt_V4:
-      return Hexagon::STb_GP_cNotPt_V4;
-    case Hexagon::STb_GP_cNotPt_V4:
-      return Hexagon::STb_GP_cPt_V4;
-
-    case Hexagon::STh_GP_cPt_V4:
-      return Hexagon::STh_GP_cNotPt_V4;
-    case Hexagon::STh_GP_cNotPt_V4:
-      return Hexagon::STh_GP_cPt_V4;
-
-    case Hexagon::STw_GP_cPt_V4:
-      return Hexagon::STw_GP_cNotPt_V4;
-    case Hexagon::STw_GP_cNotPt_V4:
-      return Hexagon::STw_GP_cPt_V4;
-
-  // Load.
-    case Hexagon::LDrid_cPt:
-      return Hexagon::LDrid_cNotPt;
-    case Hexagon::LDrid_cNotPt:
-      return Hexagon::LDrid_cPt;
-
-    case Hexagon::LDriw_cPt:
-      return Hexagon::LDriw_cNotPt;
-    case Hexagon::LDriw_cNotPt:
-      return Hexagon::LDriw_cPt;
-
-    case Hexagon::LDrih_cPt:
-      return Hexagon::LDrih_cNotPt;
-    case Hexagon::LDrih_cNotPt:
-      return Hexagon::LDrih_cPt;
-
-    case Hexagon::LDriuh_cPt:
-      return Hexagon::LDriuh_cNotPt;
-    case Hexagon::LDriuh_cNotPt:
-      return Hexagon::LDriuh_cPt;
-
-    case Hexagon::LDrib_cPt:
-      return Hexagon::LDrib_cNotPt;
-    case Hexagon::LDrib_cNotPt:
-      return Hexagon::LDrib_cPt;
-
-    case Hexagon::LDriub_cPt:
-      return Hexagon::LDriub_cNotPt;
-    case Hexagon::LDriub_cNotPt:
-      return Hexagon::LDriub_cPt;
-
- // Load Indexed.
-    case Hexagon::LDrid_indexed_cPt:
-      return Hexagon::LDrid_indexed_cNotPt;
-    case Hexagon::LDrid_indexed_cNotPt:
-      return Hexagon::LDrid_indexed_cPt;
-
-    case Hexagon::LDriw_indexed_cPt:
-      return Hexagon::LDriw_indexed_cNotPt;
-    case Hexagon::LDriw_indexed_cNotPt:
-      return Hexagon::LDriw_indexed_cPt;
-
-    case Hexagon::LDrih_indexed_cPt:
-      return Hexagon::LDrih_indexed_cNotPt;
-    case Hexagon::LDrih_indexed_cNotPt:
-      return Hexagon::LDrih_indexed_cPt;
-
-    case Hexagon::LDriuh_indexed_cPt:
-      return Hexagon::LDriuh_indexed_cNotPt;
-    case Hexagon::LDriuh_indexed_cNotPt:
-      return Hexagon::LDriuh_indexed_cPt;
-
-    case Hexagon::LDrib_indexed_cPt:
-      return Hexagon::LDrib_indexed_cNotPt;
-    case Hexagon::LDrib_indexed_cNotPt:
-      return Hexagon::LDrib_indexed_cPt;
-
-    case Hexagon::LDriub_indexed_cPt:
-      return Hexagon::LDriub_indexed_cNotPt;
-    case Hexagon::LDriub_indexed_cNotPt:
-      return Hexagon::LDriub_indexed_cPt;
-
-  // Post Inc Load.
-    case Hexagon::POST_LDrid_cPt:
-      return Hexagon::POST_LDrid_cNotPt;
-    case Hexagon::POST_LDriw_cNotPt:
-      return Hexagon::POST_LDriw_cPt;
-
-    case Hexagon::POST_LDrih_cPt:
-      return Hexagon::POST_LDrih_cNotPt;
-    case Hexagon::POST_LDrih_cNotPt:
-      return Hexagon::POST_LDrih_cPt;
-
-    case Hexagon::POST_LDriuh_cPt:
-      return Hexagon::POST_LDriuh_cNotPt;
-    case Hexagon::POST_LDriuh_cNotPt:
-      return Hexagon::POST_LDriuh_cPt;
-
-    case Hexagon::POST_LDrib_cPt:
-      return Hexagon::POST_LDrib_cNotPt;
-    case Hexagon::POST_LDrib_cNotPt:
-      return Hexagon::POST_LDrib_cPt;
-
-    case Hexagon::POST_LDriub_cPt:
-      return Hexagon::POST_LDriub_cNotPt;
-    case Hexagon::POST_LDriub_cNotPt:
-      return Hexagon::POST_LDriub_cPt;
-
-  // Dealloc_return.
+      // Dealloc_return.
     case Hexagon::DEALLOC_RET_cPt_V4:
       return Hexagon::DEALLOC_RET_cNotPt_V4;
     case Hexagon::DEALLOC_RET_cNotPt_V4:
@@ -1285,218 +952,21 @@ getMatchingCondBranchOpcode(int Opc, bool invertPredicate) const {
   // This switch case will be removed once all the instructions have been
   // modified to use relation maps.
   switch(Opc) {
-  case Hexagon::TFR:
-    return !invertPredicate ? Hexagon::TFR_cPt :
-                              Hexagon::TFR_cNotPt;
   case Hexagon::TFRI_f:
     return !invertPredicate ? Hexagon::TFRI_cPt_f :
                               Hexagon::TFRI_cNotPt_f;
-  case Hexagon::TFRI:
-    return !invertPredicate ? Hexagon::TFRI_cPt :
-                              Hexagon::TFRI_cNotPt;
-  case Hexagon::JMP:
-    return !invertPredicate ? Hexagon::JMP_t :
-                              Hexagon::JMP_f;
-
   case Hexagon::COMBINE_rr:
     return !invertPredicate ? Hexagon::COMBINE_rr_cPt :
                               Hexagon::COMBINE_rr_cNotPt;
-  case Hexagon::ASLH:
-    return !invertPredicate ? Hexagon::ASLH_cPt_V4 :
-                              Hexagon::ASLH_cNotPt_V4;
-  case Hexagon::ASRH:
-    return !invertPredicate ? Hexagon::ASRH_cPt_V4 :
-                              Hexagon::ASRH_cNotPt_V4;
-  case Hexagon::SXTB:
-    return !invertPredicate ? Hexagon::SXTB_cPt_V4 :
-                              Hexagon::SXTB_cNotPt_V4;
-  case Hexagon::SXTH:
-    return !invertPredicate ? Hexagon::SXTH_cPt_V4 :
-                              Hexagon::SXTH_cNotPt_V4;
-  case Hexagon::ZXTB:
-    return !invertPredicate ? Hexagon::ZXTB_cPt_V4 :
-                              Hexagon::ZXTB_cNotPt_V4;
-  case Hexagon::ZXTH:
-    return !invertPredicate ? Hexagon::ZXTH_cPt_V4 :
-                              Hexagon::ZXTH_cNotPt_V4;
-
-  case Hexagon::JMPR:
-    return !invertPredicate ? Hexagon::JMPR_t :
-                              Hexagon::JMPR_f;
-
-  // V4 indexed+scaled load.
-  case Hexagon::LDrid_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::LDrid_indexed_shl_cPt_V4 :
-                              Hexagon::LDrid_indexed_shl_cNotPt_V4;
-  case Hexagon::LDrib_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::LDrib_indexed_shl_cPt_V4 :
-                              Hexagon::LDrib_indexed_shl_cNotPt_V4;
-  case Hexagon::LDriub_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 :
-                              Hexagon::LDriub_indexed_shl_cNotPt_V4;
-  case Hexagon::LDrih_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::LDrih_indexed_shl_cPt_V4 :
-                              Hexagon::LDrih_indexed_shl_cNotPt_V4;
-  case Hexagon::LDriuh_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 :
-                              Hexagon::LDriuh_indexed_shl_cNotPt_V4;
-  case Hexagon::LDriw_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::LDriw_indexed_shl_cPt_V4 :
-                              Hexagon::LDriw_indexed_shl_cNotPt_V4;
-
-  // V4 Load from global address
-  case Hexagon::LDd_GP_V4:
-    return !invertPredicate ? Hexagon::LDd_GP_cPt_V4 :
-                              Hexagon::LDd_GP_cNotPt_V4;
-  case Hexagon::LDb_GP_V4:
-    return !invertPredicate ? Hexagon::LDb_GP_cPt_V4 :
-                              Hexagon::LDb_GP_cNotPt_V4;
-  case Hexagon::LDub_GP_V4:
-    return !invertPredicate ? Hexagon::LDub_GP_cPt_V4 :
-                              Hexagon::LDub_GP_cNotPt_V4;
-  case Hexagon::LDh_GP_V4:
-    return !invertPredicate ? Hexagon::LDh_GP_cPt_V4 :
-                              Hexagon::LDh_GP_cNotPt_V4;
-  case Hexagon::LDuh_GP_V4:
-    return !invertPredicate ? Hexagon::LDuh_GP_cPt_V4 :
-                              Hexagon::LDuh_GP_cNotPt_V4;
-  case Hexagon::LDw_GP_V4:
-    return !invertPredicate ? Hexagon::LDw_GP_cPt_V4 :
-                              Hexagon::LDw_GP_cNotPt_V4;
-
-    // Byte.
-  case Hexagon::POST_STbri:
-    return !invertPredicate ? Hexagon::POST_STbri_cPt :
-                              Hexagon::POST_STbri_cNotPt;
-  case Hexagon::STrib:
-    return !invertPredicate ? Hexagon::STrib_cPt :
-                              Hexagon::STrib_cNotPt;
-  case Hexagon::STrib_indexed:
-    return !invertPredicate ? Hexagon::STrib_indexed_cPt :
-                              Hexagon::STrib_indexed_cNotPt;
-  case Hexagon::STrib_imm_V4:
-    return !invertPredicate ? Hexagon::STrib_imm_cPt_V4 :
-                              Hexagon::STrib_imm_cNotPt_V4;
-  case Hexagon::STrib_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::STrib_indexed_shl_cPt_V4 :
-                              Hexagon::STrib_indexed_shl_cNotPt_V4;
-  // Halfword.
-  case Hexagon::POST_SThri:
-    return !invertPredicate ? Hexagon::POST_SThri_cPt :
-                              Hexagon::POST_SThri_cNotPt;
-  case Hexagon::STrih:
-    return !invertPredicate ? Hexagon::STrih_cPt :
-                              Hexagon::STrih_cNotPt;
-  case Hexagon::STrih_indexed:
-    return !invertPredicate ? Hexagon::STrih_indexed_cPt :
-                              Hexagon::STrih_indexed_cNotPt;
-  case Hexagon::STrih_imm_V4:
-    return !invertPredicate ? Hexagon::STrih_imm_cPt_V4 :
-                              Hexagon::STrih_imm_cNotPt_V4;
-  case Hexagon::STrih_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::STrih_indexed_shl_cPt_V4 :
-                              Hexagon::STrih_indexed_shl_cNotPt_V4;
+
   // Word.
-  case Hexagon::POST_STwri:
-    return !invertPredicate ? Hexagon::POST_STwri_cPt :
-                              Hexagon::POST_STwri_cNotPt;
-  case Hexagon::STriw:
+  case Hexagon::STriw_f:
     return !invertPredicate ? Hexagon::STriw_cPt :
                               Hexagon::STriw_cNotPt;
-  case Hexagon::STriw_indexed:
+  case Hexagon::STriw_indexed_f:
     return !invertPredicate ? Hexagon::STriw_indexed_cPt :
                               Hexagon::STriw_indexed_cNotPt;
-  case Hexagon::STriw_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::STriw_indexed_shl_cPt_V4 :
-                              Hexagon::STriw_indexed_shl_cNotPt_V4;
-  case Hexagon::STriw_imm_V4:
-    return !invertPredicate ? Hexagon::STriw_imm_cPt_V4 :
-                              Hexagon::STriw_imm_cNotPt_V4;
-  // Double word.
-  case Hexagon::POST_STdri:
-    return !invertPredicate ? Hexagon::POST_STdri_cPt :
-                              Hexagon::POST_STdri_cNotPt;
-  case Hexagon::STrid:
-    return !invertPredicate ? Hexagon::STrid_cPt :
-                              Hexagon::STrid_cNotPt;
-  case Hexagon::STrid_indexed:
-    return !invertPredicate ? Hexagon::STrid_indexed_cPt :
-                              Hexagon::STrid_indexed_cNotPt;
-  case Hexagon::STrid_indexed_shl_V4:
-    return !invertPredicate ? Hexagon::STrid_indexed_shl_cPt_V4 :
-                              Hexagon::STrid_indexed_shl_cNotPt_V4;
-
-  // V4 Store to global address
-  case Hexagon::STd_GP_V4:
-    return !invertPredicate ? Hexagon::STd_GP_cPt_V4 :
-                              Hexagon::STd_GP_cNotPt_V4;
-  case Hexagon::STb_GP_V4:
-    return !invertPredicate ? Hexagon::STb_GP_cPt_V4 :
-                              Hexagon::STb_GP_cNotPt_V4;
-  case Hexagon::STh_GP_V4:
-    return !invertPredicate ? Hexagon::STh_GP_cPt_V4 :
-                              Hexagon::STh_GP_cNotPt_V4;
-  case Hexagon::STw_GP_V4:
-    return !invertPredicate ? Hexagon::STw_GP_cPt_V4 :
-                              Hexagon::STw_GP_cNotPt_V4;
-
-  // Load.
-  case Hexagon::LDrid:
-    return !invertPredicate ? Hexagon::LDrid_cPt :
-                              Hexagon::LDrid_cNotPt;
-  case Hexagon::LDriw:
-    return !invertPredicate ? Hexagon::LDriw_cPt :
-                              Hexagon::LDriw_cNotPt;
-  case Hexagon::LDrih:
-    return !invertPredicate ? Hexagon::LDrih_cPt :
-                              Hexagon::LDrih_cNotPt;
-  case Hexagon::LDriuh:
-    return !invertPredicate ? Hexagon::LDriuh_cPt :
-                              Hexagon::LDriuh_cNotPt;
-  case Hexagon::LDrib:
-    return !invertPredicate ? Hexagon::LDrib_cPt :
-                              Hexagon::LDrib_cNotPt;
-  case Hexagon::LDriub:
-    return !invertPredicate ? Hexagon::LDriub_cPt :
-                              Hexagon::LDriub_cNotPt;
- // Load Indexed.
-  case Hexagon::LDrid_indexed:
-    return !invertPredicate ? Hexagon::LDrid_indexed_cPt :
-                              Hexagon::LDrid_indexed_cNotPt;
-  case Hexagon::LDriw_indexed:
-    return !invertPredicate ? Hexagon::LDriw_indexed_cPt :
-                              Hexagon::LDriw_indexed_cNotPt;
-  case Hexagon::LDrih_indexed:
-    return !invertPredicate ? Hexagon::LDrih_indexed_cPt :
-                              Hexagon::LDrih_indexed_cNotPt;
-  case Hexagon::LDriuh_indexed:
-    return !invertPredicate ? Hexagon::LDriuh_indexed_cPt :
-                              Hexagon::LDriuh_indexed_cNotPt;
-  case Hexagon::LDrib_indexed:
-    return !invertPredicate ? Hexagon::LDrib_indexed_cPt :
-                              Hexagon::LDrib_indexed_cNotPt;
-  case Hexagon::LDriub_indexed:
-    return !invertPredicate ? Hexagon::LDriub_indexed_cPt :
-                              Hexagon::LDriub_indexed_cNotPt;
-  // Post Increment Load.
-  case Hexagon::POST_LDrid:
-    return !invertPredicate ? Hexagon::POST_LDrid_cPt :
-                              Hexagon::POST_LDrid_cNotPt;
-  case Hexagon::POST_LDriw:
-    return !invertPredicate ? Hexagon::POST_LDriw_cPt :
-                              Hexagon::POST_LDriw_cNotPt;
-  case Hexagon::POST_LDrih:
-    return !invertPredicate ? Hexagon::POST_LDrih_cPt :
-                              Hexagon::POST_LDrih_cNotPt;
-  case Hexagon::POST_LDriuh:
-    return !invertPredicate ? Hexagon::POST_LDriuh_cPt :
-                              Hexagon::POST_LDriuh_cNotPt;
-  case Hexagon::POST_LDrib:
-    return !invertPredicate ? Hexagon::POST_LDrib_cPt :
-                              Hexagon::POST_LDrib_cNotPt;
-  case Hexagon::POST_LDriub:
-    return !invertPredicate ? Hexagon::POST_LDriub_cPt :
-                              Hexagon::POST_LDriub_cNotPt;
+
   // DEALLOC_RETURN.
   case Hexagon::DEALLOC_RET_V4:
     return !invertPredicate ? Hexagon::DEALLOC_RET_cPt_V4 :
diff --git a/llvm/test/CodeGen/Hexagon/pred-instrs.ll b/llvm/test/CodeGen/Hexagon/pred-instrs.ll
new file mode 100644
index 000000000000..800073e49b03
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/pred-instrs.ll
@@ -0,0 +1,30 @@
+; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s
+; Check that we are able to predicate instructions.
+
+; CHECK: if{{ *}}({{!*}}p{{[0-3]}}{{[.new]*}}){{ *}}r{{[0-9]+}}{{ *}}={{ *}}{{and|aslh}}
+; CHECK: if{{ *}}({{!*}}p{{[0-3]}}{{[.new]*}}){{ *}}r{{[0-9]+}}{{ *}}={{ *}}{{and|aslh}}
+@a = external global i32
+@d = external global i32
+
+; Function Attrs: nounwind
+define i32 @test1(i8 zeroext %la, i8 zeroext %lb) {
+entry:
+  %cmp = icmp eq i8 %la, %lb
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:                                          ; preds = %entry
+  %conv1 = zext i8 %la to i32
+  %shl = shl nuw nsw i32 %conv1, 16
+  br label %if.end
+
+if.else:                                          ; preds = %entry
+  %and8 = and i8 %lb, %la
+  %and = zext i8 %and8 to i32
+  br label %if.end
+
+if.end:                                           ; preds = %if.else, %if.then
+  %storemerge = phi i32 [ %and, %if.else ], [ %shl, %if.then ]
+  store i32 %storemerge, i32* @a, align 4
+  %0 = load i32* @d, align 4
+  ret i32 %0
+}
-- 
GitLab


From 8797d39fd9e60d06b72ea3e28e3d12fa2e709bce Mon Sep 17 00:00:00 2001
From: Richard Smith 
Date: Thu, 9 May 2013 18:33:50 +0000
Subject: [PATCH 103/467] Add testcase missed from r181527.

llvm-svn: 181531
---
 clang/test/Headers/tgmath.c | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 clang/test/Headers/tgmath.c

diff --git a/clang/test/Headers/tgmath.c b/clang/test/Headers/tgmath.c
new file mode 100644
index 000000000000..a95e33a53c44
--- /dev/null
+++ b/clang/test/Headers/tgmath.c
@@ -0,0 +1,41 @@
+// RUN: %clang -fsyntax-only %s
+
+#ifdef __STDC_HOSTED__
+
+#include 
+
+float f;
+double d;
+long double l;
+
+float complex fc;
+double complex dc;
+long double complex lc;
+
+// creal
+
+_Static_assert(sizeof(creal(f)) == sizeof(f), "");
+_Static_assert(sizeof(creal(d)) == sizeof(d), "");
+_Static_assert(sizeof(creal(l)) == sizeof(l), "");
+
+_Static_assert(sizeof(creal(fc)) == sizeof(f), "");
+_Static_assert(sizeof(creal(dc)) == sizeof(d), "");
+_Static_assert(sizeof(creal(lc)) == sizeof(l), "");
+
+// fabs
+
+_Static_assert(sizeof(fabs(f)) == sizeof(f), "");
+_Static_assert(sizeof(fabs(d)) == sizeof(d), "");
+_Static_assert(sizeof(fabs(l)) == sizeof(l), "");
+
+_Static_assert(sizeof(fabs(fc)) == sizeof(f), "");
+_Static_assert(sizeof(fabs(dc)) == sizeof(d), "");
+_Static_assert(sizeof(fabs(lc)) == sizeof(l), "");
+
+// logb
+
+_Static_assert(sizeof(logb(f)) == sizeof(f), "");
+_Static_assert(sizeof(logb(d)) == sizeof(d), "");
+_Static_assert(sizeof(logb(l)) == sizeof(l), "");
+
+#endif
-- 
GitLab


From 1d8d7e4d38da4105ae8ca44486f9971bb8e59eda Mon Sep 17 00:00:00 2001
From: Shuxin Yang 
Date: Thu, 9 May 2013 18:34:27 +0000
Subject: [PATCH 104/467] [GVN] Split critical-edge on the fly, instead of
 postpone edge-splitting to next   iteration.

  This on step toward non-iterative GVN. My local hack suggests that getting rid
of iteration will speedup GVN by 30%+ on a medium sized input (2k LOC, C++).
I cannot explain why not 2x or more at this moment.

llvm-svn: 181532
---
 llvm/lib/Transforms/Scalar/GVN.cpp | 52 ++++++++++++++++++++++--------
 1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index f350b9bbde55..996996dc55d9 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -45,6 +45,7 @@
 #include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/SSAUpdater.h"
+#include 
 using namespace llvm;
 using namespace PatternMatch;
 
@@ -692,6 +693,7 @@ namespace {
     void cleanupGlobalSets();
     void verifyRemoved(const Instruction *I) const;
     bool splitCriticalEdges();
+    BasicBlock *splitCriticalEdges(BasicBlock *Pred, BasicBlock *Succ);
     unsigned replaceAllDominatedUsesWith(Value *From, Value *To,
                                          const BasicBlockEdge &Root);
     bool propagateEquality(Value *LHS, Value *RHS, const BasicBlockEdge &Root);
@@ -1513,7 +1515,7 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
   for (unsigned i = 0, e = UnavailableBlocks.size(); i != e; ++i)
     FullyAvailableBlocks[UnavailableBlocks[i]] = false;
 
-  SmallVector, 4> NeedToSplit;
+  SmallVector CriticalEdgePred;
   for (pred_iterator PI = pred_begin(LoadBB), E = pred_end(LoadBB);
        PI != E; ++PI) {
     BasicBlock *Pred = *PI;
@@ -1536,20 +1538,14 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
         return false;
       }
 
-      unsigned SuccNum = GetSuccessorNumber(Pred, LoadBB);
-      NeedToSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum));
+      CriticalEdgePred.push_back(Pred);
     }
   }
 
-  if (!NeedToSplit.empty()) {
-    toSplit.append(NeedToSplit.begin(), NeedToSplit.end());
-    return false;
-  }
-
   // Decide whether PRE is profitable for this load.
   unsigned NumUnavailablePreds = PredLoads.size();
   assert(NumUnavailablePreds != 0 &&
-         "Fully available value should be eliminated above!");
+         "Fully available value should already be eliminated!");
 
   // If this load is unavailable in multiple predecessors, reject it.
   // FIXME: If we could restructure the CFG, we could make a common pred with
@@ -1558,6 +1554,17 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
   if (NumUnavailablePreds != 1)
       return false;
 
+  // Split critical edges, and update the unavailable predecessors accordingly.
+  for (SmallVector::iterator I = CriticalEdgePred.begin(), 
+         E = CriticalEdgePred.end(); I != E; I++) {
+    BasicBlock *OrigPred = *I;
+    BasicBlock *NewPred = splitCriticalEdges(OrigPred, LoadBB);
+    PredLoads.erase(OrigPred);
+    PredLoads[NewPred] = 0;
+    DEBUG(dbgs() << "Split critical edge " << OrigPred->getName() << "->"
+                 << LoadBB->getName() << '\n');
+  }
+
   // Check if the load can safely be moved to all the unavailable predecessors.
   bool CanDoPRE = true;
   SmallVector NewInsts;
@@ -1594,7 +1601,9 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
       if (MD) MD->removeInstruction(I);
       I->eraseFromParent();
     }
-    return false;
+    // HINT:Don't revert the edge-splitting as following transformation may 
+    // also need to split these critial edges.
+    return !CriticalEdgePred.empty();
   }
 
   // Okay, we can eliminate this load by inserting a reload in the predecessor
@@ -2297,8 +2306,6 @@ bool GVN::runOnFunction(Function& F) {
   while (ShouldContinue) {
     DEBUG(dbgs() << "GVN iteration: " << Iteration << "\n");
     ShouldContinue = iterateOnFunction(F);
-    if (splitCriticalEdges())
-      ShouldContinue = true;
     Changed |= ShouldContinue;
     ++Iteration;
   }
@@ -2310,6 +2317,7 @@ bool GVN::runOnFunction(Function& F) {
       Changed |= PREChanged;
     }
   }
+
   // FIXME: Should perform GVN again after PRE does something.  PRE can move
   // computations into blocks where they become fully redundant.  Note that
   // we can't do this until PRE's critical edge splitting updates memdep.
@@ -2543,6 +2551,15 @@ bool GVN::performPRE(Function &F) {
   return Changed;
 }
 
+/// Split the critical edge connecting the given two blocks, and return
+/// the block inserted to the critical edge.
+BasicBlock *GVN::splitCriticalEdges(BasicBlock *Pred, BasicBlock *Succ) {
+  BasicBlock *BB = SplitCriticalEdge(Pred, Succ, this);
+  if (MD)
+    MD->invalidateCachedPredecessors();
+  return BB;
+}
+
 /// splitCriticalEdges - Split critical edges found during the previous
 /// iteration that may enable further optimization.
 bool GVN::splitCriticalEdges() {
@@ -2569,9 +2586,18 @@ bool GVN::iterateOnFunction(Function &F) {
        RE = RPOT.end(); RI != RE; ++RI)
     Changed |= processBlock(*RI);
 #else
+  // Save the blocks this function have before transformation begins. GVN may
+  // split critical edge, and hence may invalidate the RPO/DT iterator.
+  //
+  std::vector BBVect;
+  BBVect.reserve(256);
   for (df_iterator DI = df_begin(DT->getRootNode()),
        DE = df_end(DT->getRootNode()); DI != DE; ++DI)
-    Changed |= processBlock(DI->getBlock());
+    BBVect.push_back(DI->getBlock());
+
+  for (std::vector::iterator I = BBVect.begin(), E = BBVect.end();
+       I != E; I++)
+    Changed |= processBlock(*I);
 #endif
 
   return Changed;
-- 
GitLab


From f2f6e114fd8a048e4a83d04ab7cd454b24f6a550 Mon Sep 17 00:00:00 2001
From: Richard Smith 
Date: Thu, 9 May 2013 18:53:17 +0000
Subject: [PATCH 105/467] Switch C++1y paper links back to the canonical
 location at open-std.org now that the post-Bristol mailing has shipped.

llvm-svn: 181533
---
 clang/www/cxx_status.html | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 13fa86068d3a..ee1827ecf174 100644
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -426,7 +426,7 @@ available.

decltype(auto) - N3638 + N3638 Clang 3.3 @@ -435,38 +435,38 @@ available.

Runtime-sized arrays with automatic storage duration - N3639 + N3639 Partial Initialized lambda captures - N3648 + N3648 No Generic lambdas - N3649 + N3649 No [WIP] Variable templates - N3651 + N3651 No Relaxing requirements on constexpr functions - N3652 + N3652 Partial Member initializers and aggregates - N3653 + N3653 Clang 3.3 Clarifying memory allocation - N3664 + N3664 Yes -- GitLab From 8a5a9dfb5dfda5b36902fe864089c17eadb838b8 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 9 May 2013 19:00:18 +0000 Subject: [PATCH 106/467] Initialize codecvt explicitly with the C locale, which might not be 0. llvm-svn: 181534 --- libcxx/src/locale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 8b6905fe9451..7d0e62980ce9 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -1376,7 +1376,7 @@ locale::id codecvt::id; codecvt::codecvt(size_t refs) : locale::facet(refs), - __l(0) + __l(_LIBCPP_GET_C_LOCALE) { } -- GitLab From 00681dc1f070496b2b0ddbd260e01b3e290ae9fd Mon Sep 17 00:00:00 2001 From: Jyotsna Verma Date: Thu, 9 May 2013 19:16:07 +0000 Subject: [PATCH 107/467] Hexagon: Remove switch cases from GetDotNewPredOp and isPostIncrement functions. No functionality change. llvm-svn: 181535 --- llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 119 ++-- llvm/lib/Target/Hexagon/HexagonInstrInfo.h | 3 + .../Target/Hexagon/HexagonVLIWPacketizer.cpp | 517 +----------------- 3 files changed, 46 insertions(+), 593 deletions(-) diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp index 60976b12722e..469e8021fae0 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -735,83 +735,6 @@ bool HexagonInstrInfo::isNewValueStore(const MachineInstr *MI) const { } } -bool HexagonInstrInfo::isPostIncrement (const MachineInstr* MI) const { - switch (MI->getOpcode()) - { - default: return false; - // Load Byte - case Hexagon::POST_LDrib: - case Hexagon::POST_LDrib_cPt: - case Hexagon::POST_LDrib_cNotPt: - case Hexagon::POST_LDrib_cdnPt_V4: - case Hexagon::POST_LDrib_cdnNotPt_V4: - - // Load unsigned byte - case Hexagon::POST_LDriub: - case Hexagon::POST_LDriub_cPt: - case Hexagon::POST_LDriub_cNotPt: - case Hexagon::POST_LDriub_cdnPt_V4: - case Hexagon::POST_LDriub_cdnNotPt_V4: - - // Load halfword - case Hexagon::POST_LDrih: - case Hexagon::POST_LDrih_cPt: - case Hexagon::POST_LDrih_cNotPt: - case Hexagon::POST_LDrih_cdnPt_V4: - case Hexagon::POST_LDrih_cdnNotPt_V4: - - // Load unsigned halfword - case Hexagon::POST_LDriuh: - case Hexagon::POST_LDriuh_cPt: - case Hexagon::POST_LDriuh_cNotPt: - case Hexagon::POST_LDriuh_cdnPt_V4: - case Hexagon::POST_LDriuh_cdnNotPt_V4: - - // Load word - case Hexagon::POST_LDriw: - case Hexagon::POST_LDriw_cPt: - case Hexagon::POST_LDriw_cNotPt: - case Hexagon::POST_LDriw_cdnPt_V4: - case Hexagon::POST_LDriw_cdnNotPt_V4: - - // Load double word - case Hexagon::POST_LDrid: - case Hexagon::POST_LDrid_cPt: - case Hexagon::POST_LDrid_cNotPt: - case Hexagon::POST_LDrid_cdnPt_V4: - case Hexagon::POST_LDrid_cdnNotPt_V4: - - // Store byte - case Hexagon::POST_STbri: - case Hexagon::POST_STbri_cPt: - case Hexagon::POST_STbri_cNotPt: - case Hexagon::POST_STbri_cdnPt_V4: - case Hexagon::POST_STbri_cdnNotPt_V4: - - // Store halfword - case Hexagon::POST_SThri: - case Hexagon::POST_SThri_cPt: - case Hexagon::POST_SThri_cNotPt: - case Hexagon::POST_SThri_cdnPt_V4: - case Hexagon::POST_SThri_cdnNotPt_V4: - - // Store word - case Hexagon::POST_STwri: - case Hexagon::POST_STwri_cPt: - case Hexagon::POST_STwri_cNotPt: - case Hexagon::POST_STwri_cdnPt_V4: - case Hexagon::POST_STwri_cdnNotPt_V4: - - // Store double word - case Hexagon::POST_STdri: - case Hexagon::POST_STdri_cPt: - case Hexagon::POST_STdri_cNotPt: - case Hexagon::POST_STdri_cdnPt_V4: - case Hexagon::POST_STdri_cdnNotPt_V4: - return true; - } -} - bool HexagonInstrInfo::isNewValueInst(const MachineInstr *MI) const { if (isNewValueJump(MI)) return true; @@ -1672,6 +1595,10 @@ bool HexagonInstrInfo::isNewValueJump(const MachineInstr *MI) const { return false; } +bool HexagonInstrInfo::isPostIncrement (const MachineInstr* MI) const { + return (getAddrMode(MI) == HexagonII::PostInc); +} + bool HexagonInstrInfo::isNewValue(const MachineInstr* MI) const { const uint64_t F = MI->getDesc().TSFlags; return ((F >> HexagonII::NewValuePos) & HexagonII::NewValueMask); @@ -1684,6 +1611,44 @@ bool HexagonInstrInfo::isDotNewInst (const MachineInstr* MI) const { (isPredicated(MI) && isPredicatedNew(MI))); } +// Return .new predicate version for an instruction. +int HexagonInstrInfo::GetDotNewPredOp(MachineInstr *MI, + const MachineBranchProbabilityInfo + *MBPI) const { + + int NewOpcode = Hexagon::getPredNewOpcode(MI->getOpcode()); + if (NewOpcode >= 0) // Valid predicate new instruction + return NewOpcode; + + switch (MI->getOpcode()) { + default: llvm_unreachable("Unknown .new type"); + // Condtional Jumps + case Hexagon::JMP_t: + case Hexagon::JMP_f: + return getDotNewPredJumpOp(MI, MBPI); + + case Hexagon::JMPR_t: + return Hexagon::JMPR_tnew_tV3; + + case Hexagon::JMPR_f: + return Hexagon::JMPR_fnew_tV3; + + case Hexagon::JMPret_t: + return Hexagon::JMPret_tnew_tV3; + + case Hexagon::JMPret_f: + return Hexagon::JMPret_fnew_tV3; + + + // Conditional combine + case Hexagon::COMBINE_rr_cPt : + return Hexagon::COMBINE_rr_cdnPt; + case Hexagon::COMBINE_rr_cNotPt : + return Hexagon::COMBINE_rr_cdnNotPt; + } +} + + unsigned HexagonInstrInfo::getAddrMode(const MachineInstr* MI) const { const uint64_t F = MI->getDesc().TSFlags; diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h index b721da4620c7..2becc025705a 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h @@ -185,6 +185,9 @@ public: bool isNewValueInst(const MachineInstr* MI) const; bool isNewValue(const MachineInstr* MI) const; bool isDotNewInst(const MachineInstr* MI) const; + int GetDotNewPredOp(MachineInstr *MI, + const MachineBranchProbabilityInfo + *MBPI) const; bool isDeallocRet(const MachineInstr *MI) const; unsigned getInvertedPredicatedOpcode(const int Opc) const; bool isExtendable(const MachineInstr* MI) const; diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index 39995e10b96d..fbe67e3882fe 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -742,521 +742,6 @@ static int GetDotNewOp(const int opc) { } } -// Return .new predicate version for an instruction -static int GetDotNewPredOp(MachineInstr *MI, - const MachineBranchProbabilityInfo *MBPI, - const HexagonInstrInfo *QII) { - switch (MI->getOpcode()) { - default: llvm_unreachable("Unknown .new type"); - // Conditional stores - // Store byte conditionally - case Hexagon::STrib_cPt : - return Hexagon::STrib_cdnPt_V4; - - case Hexagon::STrib_cNotPt : - return Hexagon::STrib_cdnNotPt_V4; - - case Hexagon::STrib_indexed_cPt : - return Hexagon::STrib_indexed_cdnPt_V4; - - case Hexagon::STrib_indexed_cNotPt : - return Hexagon::STrib_indexed_cdnNotPt_V4; - - case Hexagon::STrib_imm_cPt_V4 : - return Hexagon::STrib_imm_cdnPt_V4; - - case Hexagon::STrib_imm_cNotPt_V4 : - return Hexagon::STrib_imm_cdnNotPt_V4; - - case Hexagon::POST_STbri_cPt : - return Hexagon::POST_STbri_cdnPt_V4; - - case Hexagon::POST_STbri_cNotPt : - return Hexagon::POST_STbri_cdnNotPt_V4; - - case Hexagon::STrib_indexed_shl_cPt_V4 : - return Hexagon::STrib_indexed_shl_cdnPt_V4; - - case Hexagon::STrib_indexed_shl_cNotPt_V4 : - return Hexagon::STrib_indexed_shl_cdnNotPt_V4; - - case Hexagon::STb_GP_cPt_V4 : - return Hexagon::STb_GP_cdnPt_V4; - - case Hexagon::STb_GP_cNotPt_V4 : - return Hexagon::STb_GP_cdnNotPt_V4; - - // Store doubleword conditionally - case Hexagon::STrid_cPt : - return Hexagon::STrid_cdnPt_V4; - - case Hexagon::STrid_cNotPt : - return Hexagon::STrid_cdnNotPt_V4; - - case Hexagon::STrid_indexed_cPt : - return Hexagon::STrid_indexed_cdnPt_V4; - - case Hexagon::STrid_indexed_cNotPt : - return Hexagon::STrid_indexed_cdnNotPt_V4; - - case Hexagon::STrid_indexed_shl_cPt_V4 : - return Hexagon::STrid_indexed_shl_cdnPt_V4; - - case Hexagon::STrid_indexed_shl_cNotPt_V4 : - return Hexagon::STrid_indexed_shl_cdnNotPt_V4; - - case Hexagon::POST_STdri_cPt : - return Hexagon::POST_STdri_cdnPt_V4; - - case Hexagon::POST_STdri_cNotPt : - return Hexagon::POST_STdri_cdnNotPt_V4; - - case Hexagon::STd_GP_cPt_V4 : - return Hexagon::STd_GP_cdnPt_V4; - - case Hexagon::STd_GP_cNotPt_V4 : - return Hexagon::STd_GP_cdnNotPt_V4; - - // Store halfword conditionally - case Hexagon::STrih_cPt : - return Hexagon::STrih_cdnPt_V4; - - case Hexagon::STrih_cNotPt : - return Hexagon::STrih_cdnNotPt_V4; - - case Hexagon::STrih_indexed_cPt : - return Hexagon::STrih_indexed_cdnPt_V4; - - case Hexagon::STrih_indexed_cNotPt : - return Hexagon::STrih_indexed_cdnNotPt_V4; - - case Hexagon::STrih_imm_cPt_V4 : - return Hexagon::STrih_imm_cdnPt_V4; - - case Hexagon::STrih_imm_cNotPt_V4 : - return Hexagon::STrih_imm_cdnNotPt_V4; - - case Hexagon::STrih_indexed_shl_cPt_V4 : - return Hexagon::STrih_indexed_shl_cdnPt_V4; - - case Hexagon::STrih_indexed_shl_cNotPt_V4 : - return Hexagon::STrih_indexed_shl_cdnNotPt_V4; - - case Hexagon::POST_SThri_cPt : - return Hexagon::POST_SThri_cdnPt_V4; - - case Hexagon::POST_SThri_cNotPt : - return Hexagon::POST_SThri_cdnNotPt_V4; - - case Hexagon::STh_GP_cPt_V4 : - return Hexagon::STh_GP_cdnPt_V4; - - case Hexagon::STh_GP_cNotPt_V4 : - return Hexagon::STh_GP_cdnNotPt_V4; - - // Store word conditionally - case Hexagon::STriw_cPt : - return Hexagon::STriw_cdnPt_V4; - - case Hexagon::STriw_cNotPt : - return Hexagon::STriw_cdnNotPt_V4; - - case Hexagon::STriw_indexed_cPt : - return Hexagon::STriw_indexed_cdnPt_V4; - - case Hexagon::STriw_indexed_cNotPt : - return Hexagon::STriw_indexed_cdnNotPt_V4; - - case Hexagon::STriw_imm_cPt_V4 : - return Hexagon::STriw_imm_cdnPt_V4; - - case Hexagon::STriw_imm_cNotPt_V4 : - return Hexagon::STriw_imm_cdnNotPt_V4; - - case Hexagon::STriw_indexed_shl_cPt_V4 : - return Hexagon::STriw_indexed_shl_cdnPt_V4; - - case Hexagon::STriw_indexed_shl_cNotPt_V4 : - return Hexagon::STriw_indexed_shl_cdnNotPt_V4; - - case Hexagon::POST_STwri_cPt : - return Hexagon::POST_STwri_cdnPt_V4; - - case Hexagon::POST_STwri_cNotPt : - return Hexagon::POST_STwri_cdnNotPt_V4; - - case Hexagon::STw_GP_cPt_V4 : - return Hexagon::STw_GP_cdnPt_V4; - - case Hexagon::STw_GP_cNotPt_V4 : - return Hexagon::STw_GP_cdnNotPt_V4; - - // Condtional Jumps - case Hexagon::JMP_t: - case Hexagon::JMP_f: - return QII->getDotNewPredJumpOp(MI, MBPI); - - case Hexagon::JMPR_t: - return Hexagon::JMPR_tnew_tV3; - - case Hexagon::JMPR_f: - return Hexagon::JMPR_fnew_tV3; - - // Conditional Transfers - case Hexagon::TFR_cPt: - return Hexagon::TFR_cdnPt; - - case Hexagon::TFR_cNotPt: - return Hexagon::TFR_cdnNotPt; - - case Hexagon::TFRI_cPt: - return Hexagon::TFRI_cdnPt; - - case Hexagon::TFRI_cNotPt: - return Hexagon::TFRI_cdnNotPt; - - // Load double word - case Hexagon::LDrid_cPt : - return Hexagon::LDrid_cdnPt; - - case Hexagon::LDrid_cNotPt : - return Hexagon::LDrid_cdnNotPt; - - case Hexagon::LDrid_indexed_cPt : - return Hexagon::LDrid_indexed_cdnPt; - - case Hexagon::LDrid_indexed_cNotPt : - return Hexagon::LDrid_indexed_cdnNotPt; - - case Hexagon::POST_LDrid_cPt : - return Hexagon::POST_LDrid_cdnPt_V4; - - case Hexagon::POST_LDrid_cNotPt : - return Hexagon::POST_LDrid_cdnNotPt_V4; - - // Load word - case Hexagon::LDriw_cPt : - return Hexagon::LDriw_cdnPt; - - case Hexagon::LDriw_cNotPt : - return Hexagon::LDriw_cdnNotPt; - - case Hexagon::LDriw_indexed_cPt : - return Hexagon::LDriw_indexed_cdnPt; - - case Hexagon::LDriw_indexed_cNotPt : - return Hexagon::LDriw_indexed_cdnNotPt; - - case Hexagon::POST_LDriw_cPt : - return Hexagon::POST_LDriw_cdnPt_V4; - - case Hexagon::POST_LDriw_cNotPt : - return Hexagon::POST_LDriw_cdnNotPt_V4; - - // Load halfword - case Hexagon::LDrih_cPt : - return Hexagon::LDrih_cdnPt; - - case Hexagon::LDrih_cNotPt : - return Hexagon::LDrih_cdnNotPt; - - case Hexagon::LDrih_indexed_cPt : - return Hexagon::LDrih_indexed_cdnPt; - - case Hexagon::LDrih_indexed_cNotPt : - return Hexagon::LDrih_indexed_cdnNotPt; - - case Hexagon::POST_LDrih_cPt : - return Hexagon::POST_LDrih_cdnPt_V4; - - case Hexagon::POST_LDrih_cNotPt : - return Hexagon::POST_LDrih_cdnNotPt_V4; - - // Load byte - case Hexagon::LDrib_cPt : - return Hexagon::LDrib_cdnPt; - - case Hexagon::LDrib_cNotPt : - return Hexagon::LDrib_cdnNotPt; - - case Hexagon::LDrib_indexed_cPt : - return Hexagon::LDrib_indexed_cdnPt; - - case Hexagon::LDrib_indexed_cNotPt : - return Hexagon::LDrib_indexed_cdnNotPt; - - case Hexagon::POST_LDrib_cPt : - return Hexagon::POST_LDrib_cdnPt_V4; - - case Hexagon::POST_LDrib_cNotPt : - return Hexagon::POST_LDrib_cdnNotPt_V4; - - // Load unsigned halfword - case Hexagon::LDriuh_cPt : - return Hexagon::LDriuh_cdnPt; - - case Hexagon::LDriuh_cNotPt : - return Hexagon::LDriuh_cdnNotPt; - - case Hexagon::LDriuh_indexed_cPt : - return Hexagon::LDriuh_indexed_cdnPt; - - case Hexagon::LDriuh_indexed_cNotPt : - return Hexagon::LDriuh_indexed_cdnNotPt; - - case Hexagon::POST_LDriuh_cPt : - return Hexagon::POST_LDriuh_cdnPt_V4; - - case Hexagon::POST_LDriuh_cNotPt : - return Hexagon::POST_LDriuh_cdnNotPt_V4; - - // Load unsigned byte - case Hexagon::LDriub_cPt : - return Hexagon::LDriub_cdnPt; - - case Hexagon::LDriub_cNotPt : - return Hexagon::LDriub_cdnNotPt; - - case Hexagon::LDriub_indexed_cPt : - return Hexagon::LDriub_indexed_cdnPt; - - case Hexagon::LDriub_indexed_cNotPt : - return Hexagon::LDriub_indexed_cdnNotPt; - - case Hexagon::POST_LDriub_cPt : - return Hexagon::POST_LDriub_cdnPt_V4; - - case Hexagon::POST_LDriub_cNotPt : - return Hexagon::POST_LDriub_cdnNotPt_V4; - - // V4 indexed+scaled load - - case Hexagon::LDrid_indexed_shl_cPt_V4 : - return Hexagon::LDrid_indexed_shl_cdnPt_V4; - - case Hexagon::LDrid_indexed_shl_cNotPt_V4 : - return Hexagon::LDrid_indexed_shl_cdnNotPt_V4; - - case Hexagon::LDrib_indexed_shl_cPt_V4 : - return Hexagon::LDrib_indexed_shl_cdnPt_V4; - - case Hexagon::LDrib_indexed_shl_cNotPt_V4 : - return Hexagon::LDrib_indexed_shl_cdnNotPt_V4; - - case Hexagon::LDriub_indexed_shl_cPt_V4 : - return Hexagon::LDriub_indexed_shl_cdnPt_V4; - - case Hexagon::LDriub_indexed_shl_cNotPt_V4 : - return Hexagon::LDriub_indexed_shl_cdnNotPt_V4; - - case Hexagon::LDrih_indexed_shl_cPt_V4 : - return Hexagon::LDrih_indexed_shl_cdnPt_V4; - - case Hexagon::LDrih_indexed_shl_cNotPt_V4 : - return Hexagon::LDrih_indexed_shl_cdnNotPt_V4; - - case Hexagon::LDriuh_indexed_shl_cPt_V4 : - return Hexagon::LDriuh_indexed_shl_cdnPt_V4; - - case Hexagon::LDriuh_indexed_shl_cNotPt_V4 : - return Hexagon::LDriuh_indexed_shl_cdnNotPt_V4; - - case Hexagon::LDriw_indexed_shl_cPt_V4 : - return Hexagon::LDriw_indexed_shl_cdnPt_V4; - - case Hexagon::LDriw_indexed_shl_cNotPt_V4 : - return Hexagon::LDriw_indexed_shl_cdnNotPt_V4; - - // V4 global address load - - case Hexagon::LDd_GP_cPt_V4: - return Hexagon::LDd_GP_cdnPt_V4; - - case Hexagon::LDd_GP_cNotPt_V4: - return Hexagon::LDd_GP_cdnNotPt_V4; - - case Hexagon::LDb_GP_cPt_V4: - return Hexagon::LDb_GP_cdnPt_V4; - - case Hexagon::LDb_GP_cNotPt_V4: - return Hexagon::LDb_GP_cdnNotPt_V4; - - case Hexagon::LDub_GP_cPt_V4: - return Hexagon::LDub_GP_cdnPt_V4; - - case Hexagon::LDub_GP_cNotPt_V4: - return Hexagon::LDub_GP_cdnNotPt_V4; - - case Hexagon::LDh_GP_cPt_V4: - return Hexagon::LDh_GP_cdnPt_V4; - - case Hexagon::LDh_GP_cNotPt_V4: - return Hexagon::LDh_GP_cdnNotPt_V4; - - case Hexagon::LDuh_GP_cPt_V4: - return Hexagon::LDuh_GP_cdnPt_V4; - - case Hexagon::LDuh_GP_cNotPt_V4: - return Hexagon::LDuh_GP_cdnNotPt_V4; - - case Hexagon::LDw_GP_cPt_V4: - return Hexagon::LDw_GP_cdnPt_V4; - - case Hexagon::LDw_GP_cNotPt_V4: - return Hexagon::LDw_GP_cdnNotPt_V4; - - // Conditional store new-value byte - case Hexagon::STrib_cPt_nv_V4 : - return Hexagon::STrib_cdnPt_nv_V4; - case Hexagon::STrib_cNotPt_nv_V4 : - return Hexagon::STrib_cdnNotPt_nv_V4; - - case Hexagon::STrib_indexed_cPt_nv_V4 : - return Hexagon::STrib_indexed_cdnPt_nv_V4; - case Hexagon::STrib_indexed_cNotPt_nv_V4 : - return Hexagon::STrib_indexed_cdnNotPt_nv_V4; - - case Hexagon::STrib_indexed_shl_cPt_nv_V4 : - return Hexagon::STrib_indexed_shl_cdnPt_nv_V4; - case Hexagon::STrib_indexed_shl_cNotPt_nv_V4 : - return Hexagon::STrib_indexed_shl_cdnNotPt_nv_V4; - - case Hexagon::POST_STbri_cPt_nv_V4 : - return Hexagon::POST_STbri_cdnPt_nv_V4; - case Hexagon::POST_STbri_cNotPt_nv_V4 : - return Hexagon::POST_STbri_cdnNotPt_nv_V4; - - case Hexagon::STb_GP_cPt_nv_V4 : - return Hexagon::STb_GP_cdnPt_nv_V4; - - case Hexagon::STb_GP_cNotPt_nv_V4 : - return Hexagon::STb_GP_cdnNotPt_nv_V4; - - // Conditional store new-value halfword - case Hexagon::STrih_cPt_nv_V4 : - return Hexagon::STrih_cdnPt_nv_V4; - case Hexagon::STrih_cNotPt_nv_V4 : - return Hexagon::STrih_cdnNotPt_nv_V4; - - case Hexagon::STrih_indexed_cPt_nv_V4 : - return Hexagon::STrih_indexed_cdnPt_nv_V4; - case Hexagon::STrih_indexed_cNotPt_nv_V4 : - return Hexagon::STrih_indexed_cdnNotPt_nv_V4; - - case Hexagon::STrih_indexed_shl_cPt_nv_V4 : - return Hexagon::STrih_indexed_shl_cdnPt_nv_V4; - case Hexagon::STrih_indexed_shl_cNotPt_nv_V4 : - return Hexagon::STrih_indexed_shl_cdnNotPt_nv_V4; - - case Hexagon::POST_SThri_cPt_nv_V4 : - return Hexagon::POST_SThri_cdnPt_nv_V4; - case Hexagon::POST_SThri_cNotPt_nv_V4 : - return Hexagon::POST_SThri_cdnNotPt_nv_V4; - - case Hexagon::STh_GP_cPt_nv_V4 : - return Hexagon::STh_GP_cdnPt_nv_V4; - - case Hexagon::STh_GP_cNotPt_nv_V4 : - return Hexagon::STh_GP_cdnNotPt_nv_V4; - - // Conditional store new-value word - case Hexagon::STriw_cPt_nv_V4 : - return Hexagon::STriw_cdnPt_nv_V4; - case Hexagon::STriw_cNotPt_nv_V4 : - return Hexagon::STriw_cdnNotPt_nv_V4; - - case Hexagon::STriw_indexed_cPt_nv_V4 : - return Hexagon::STriw_indexed_cdnPt_nv_V4; - case Hexagon::STriw_indexed_cNotPt_nv_V4 : - return Hexagon::STriw_indexed_cdnNotPt_nv_V4; - - case Hexagon::STriw_indexed_shl_cPt_nv_V4 : - return Hexagon::STriw_indexed_shl_cdnPt_nv_V4; - case Hexagon::STriw_indexed_shl_cNotPt_nv_V4 : - return Hexagon::STriw_indexed_shl_cdnNotPt_nv_V4; - - case Hexagon::POST_STwri_cPt_nv_V4 : - return Hexagon::POST_STwri_cdnPt_nv_V4; - case Hexagon::POST_STwri_cNotPt_nv_V4: - return Hexagon::POST_STwri_cdnNotPt_nv_V4; - - case Hexagon::STw_GP_cPt_nv_V4 : - return Hexagon::STw_GP_cdnPt_nv_V4; - - case Hexagon::STw_GP_cNotPt_nv_V4 : - return Hexagon::STw_GP_cdnNotPt_nv_V4; - - // Conditional add - case Hexagon::ADD_ri_cPt : - return Hexagon::ADD_ri_cdnPt; - case Hexagon::ADD_ri_cNotPt : - return Hexagon::ADD_ri_cdnNotPt; - - case Hexagon::ADD_rr_cPt : - return Hexagon::ADD_rr_cdnPt; - case Hexagon::ADD_rr_cNotPt : - return Hexagon::ADD_rr_cdnNotPt; - - // Conditional logical Operations - case Hexagon::XOR_rr_cPt : - return Hexagon::XOR_rr_cdnPt; - case Hexagon::XOR_rr_cNotPt : - return Hexagon::XOR_rr_cdnNotPt; - - case Hexagon::AND_rr_cPt : - return Hexagon::AND_rr_cdnPt; - case Hexagon::AND_rr_cNotPt : - return Hexagon::AND_rr_cdnNotPt; - - case Hexagon::OR_rr_cPt : - return Hexagon::OR_rr_cdnPt; - case Hexagon::OR_rr_cNotPt : - return Hexagon::OR_rr_cdnNotPt; - - // Conditional Subtract - case Hexagon::SUB_rr_cPt : - return Hexagon::SUB_rr_cdnPt; - case Hexagon::SUB_rr_cNotPt : - return Hexagon::SUB_rr_cdnNotPt; - - // Conditional combine - case Hexagon::COMBINE_rr_cPt : - return Hexagon::COMBINE_rr_cdnPt; - case Hexagon::COMBINE_rr_cNotPt : - return Hexagon::COMBINE_rr_cdnNotPt; - - case Hexagon::ASLH_cPt_V4 : - return Hexagon::ASLH_cdnPt_V4; - case Hexagon::ASLH_cNotPt_V4 : - return Hexagon::ASLH_cdnNotPt_V4; - - case Hexagon::ASRH_cPt_V4 : - return Hexagon::ASRH_cdnPt_V4; - case Hexagon::ASRH_cNotPt_V4 : - return Hexagon::ASRH_cdnNotPt_V4; - - case Hexagon::SXTB_cPt_V4 : - return Hexagon::SXTB_cdnPt_V4; - case Hexagon::SXTB_cNotPt_V4 : - return Hexagon::SXTB_cdnNotPt_V4; - - case Hexagon::SXTH_cPt_V4 : - return Hexagon::SXTH_cdnPt_V4; - case Hexagon::SXTH_cNotPt_V4 : - return Hexagon::SXTH_cdnNotPt_V4; - - case Hexagon::ZXTB_cPt_V4 : - return Hexagon::ZXTB_cdnPt_V4; - case Hexagon::ZXTB_cNotPt_V4 : - return Hexagon::ZXTB_cdnNotPt_V4; - - case Hexagon::ZXTH_cPt_V4 : - return Hexagon::ZXTH_cdnPt_V4; - case Hexagon::ZXTH_cNotPt_V4 : - return Hexagon::ZXTH_cdnNotPt_V4; - } -} - // Returns true if an instruction can be promoted to .new predicate // or new-value store. bool HexagonPacketizerList::isNewifiable(MachineInstr* MI) { @@ -1294,7 +779,7 @@ bool HexagonPacketizerList::PromoteToDotNew(MachineInstr* MI, int NewOpcode; if (RC == &Hexagon::PredRegsRegClass) - NewOpcode = GetDotNewPredOp(MI, MBPI, QII); + NewOpcode = QII->GetDotNewPredOp(MI, MBPI); else NewOpcode = GetDotNewOp(MI->getOpcode()); MI->setDesc(QII->get(NewOpcode)); -- GitLab From 3b4c30b7e77edb76da538fb4989957a219c6438f Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Thu, 9 May 2013 19:17:11 +0000 Subject: [PATCH 108/467] CodeGen for CapturedStmts EmitCapturedStmt creates a captured struct containing all of the captured variables, and then emits a call to the outlined function. This is similar in principle to EmitBlockLiteral. GenerateCapturedFunction actually produces the outlined function. It is based on GenerateBlockFunction, but is much simpler. The function type is determined by the parameters that are in the CapturedDecl. Some changes have been added to this patch that were reviewed as part of the serialization patch and moving the parameters to the captured decl. Differential Revision: http://llvm-reviews.chandlerc.com/D640 llvm-svn: 181536 --- clang/include/clang/AST/GlobalDecl.h | 1 + .../clang/Basic/DiagnosticSemaKinds.td | 5 +- clang/lib/AST/ItaniumMangle.cpp | 4 + clang/lib/AST/MicrosoftMangle.cpp | 4 + clang/lib/CodeGen/CGExpr.cpp | 16 ++- clang/lib/CodeGen/CGStmt.cpp | 95 ++++++++++++- clang/lib/CodeGen/CodeGenFunction.cpp | 3 + clang/lib/CodeGen/CodeGenFunction.h | 65 ++++++++- clang/lib/Sema/SemaExpr.cpp | 10 +- .../test/CodeGen/captured-statements-nested.c | 126 ++++++++++++++++++ clang/test/CodeGen/captured-statements.c | 80 +++++++++++ clang/test/CodeGenCXX/captured-statements.cpp | 97 ++++++++++++++ clang/test/Sema/captured-statements.c | 12 +- 13 files changed, 497 insertions(+), 21 deletions(-) create mode 100644 clang/test/CodeGen/captured-statements-nested.c create mode 100644 clang/test/CodeGen/captured-statements.c create mode 100644 clang/test/CodeGenCXX/captured-statements.cpp diff --git a/clang/include/clang/AST/GlobalDecl.h b/clang/include/clang/AST/GlobalDecl.h index c43e44c26f31..54c9d88c9b2e 100644 --- a/clang/include/clang/AST/GlobalDecl.h +++ b/clang/include/clang/AST/GlobalDecl.h @@ -41,6 +41,7 @@ public: GlobalDecl(const VarDecl *D) { Init(D);} GlobalDecl(const FunctionDecl *D) { Init(D); } GlobalDecl(const BlockDecl *D) { Init(D); } + GlobalDecl(const CapturedDecl *D) { Init(D); } GlobalDecl(const ObjCMethodDecl *D) { Init(D); } GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 0c308469fc7e..11fd91ab5bdd 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4848,8 +4848,6 @@ let CategoryName = "Lambda Issue" in { "duration">; def err_this_capture : Error< "'this' cannot be %select{implicitly |}0captured in this context">; - def err_lambda_capture_block : Error< - "__block variable %0 cannot be captured in a lambda expression">; def err_lambda_capture_anonymous_var : Error< "unnamed variable cannot be implicitly captured in a lambda expression">; def err_lambda_capture_vm_type : Error< @@ -4893,6 +4891,9 @@ let CategoryName = "Lambda Issue" in { def err_return_in_captured_stmt : Error< "cannot return from %0">; +def err_capture_block_variable : Error< + "__block variable %0 cannot be captured in a " + "%select{lambda expression|captured statement}1">; def err_operator_arrow_circular : Error< "circular pointer delegation detected">; diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 5ad8021fac92..d28aced172ff 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -1419,6 +1419,10 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) { NameStream.flush(); Out << Name.size() << Name; return; + } else if (isa(DC)) { + // Skip CapturedDecl context. + manglePrefix(getEffectiveParentContext(DC), NoFunction); + return; } const NamedDecl *ND = cast(DC); diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 1785063d7b1a..7c797eef4d5f 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -541,6 +541,10 @@ void MicrosoftCXXNameMangler::manglePostfix(const DeclContext *DC, Context.mangleBlock(BD, Out); Out << '@'; return manglePostfix(DC->getParent(), NoFunction); + } else if (isa(DC)) { + // Skip CapturedDecl context. + manglePostfix(DC->getParent(), NoFunction); + return; } if (NoFunction && (isa(DC) || isa(DC))) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 64670c5e81e4..8ba5a1ce5223 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1793,6 +1793,13 @@ static LValue EmitFunctionDeclLValue(CodeGenFunction &CGF, return CGF.MakeAddrLValue(V, E->getType(), Alignment); } +static LValue EmitCapturedFieldLValue(CodeGenFunction &CGF, const FieldDecl *FD, + llvm::Value *ThisValue) { + QualType TagType = CGF.getContext().getTagDeclType(FD->getParent()); + LValue LV = CGF.MakeNaturalAlignAddrLValue(ThisValue, TagType); + return CGF.EmitLValueForField(LV, FD); +} + LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { const NamedDecl *ND = E->getDecl(); CharUnits Alignment = getContext().getDeclAlign(ND); @@ -1844,10 +1851,11 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { // Use special handling for lambdas. if (!V) { if (FieldDecl *FD = LambdaCaptureFields.lookup(VD)) { - QualType LambdaTagType = getContext().getTagDeclType(FD->getParent()); - LValue LambdaLV = MakeNaturalAlignAddrLValue(CXXABIThisValue, - LambdaTagType); - return EmitLValueForField(LambdaLV, FD); + return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue); + } else if (CapturedStmtInfo) { + if (const FieldDecl *FD = CapturedStmtInfo->lookup(VD)) + return EmitCapturedFieldLValue(*this, FD, + CapturedStmtInfo->getContextValue()); } assert(isa(CurCodeDecl) && E->refersToEnclosingLocal()); diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 208455c88c7d..353d6c3d3967 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/Intrinsics.h" +#include "llvm/Support/CallSite.h" using namespace clang; using namespace CodeGen; @@ -137,7 +138,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::GCCAsmStmtClass: // Intentional fall-through. case Stmt::MSAsmStmtClass: EmitAsmStmt(cast(*S)); break; case Stmt::CapturedStmtClass: - EmitCapturedStmt(cast(*S)); + EmitCapturedStmt(cast(*S), CR_Default); break; case Stmt::ObjCAtTryStmtClass: EmitObjCAtTryStmt(cast(*S)); @@ -1750,6 +1751,94 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { } } -void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) { - llvm_unreachable("not implemented yet"); +static LValue InitCapturedStruct(CodeGenFunction &CGF, const CapturedStmt &S) { + const RecordDecl *RD = S.getCapturedRecordDecl(); + QualType RecordTy = CGF.getContext().getRecordType(RD); + + // Initialize the captured struct. + LValue SlotLV = CGF.MakeNaturalAlignAddrLValue( + CGF.CreateMemTemp(RecordTy, "agg.captured"), RecordTy); + + RecordDecl::field_iterator CurField = RD->field_begin(); + for (CapturedStmt::capture_init_iterator I = S.capture_init_begin(), + E = S.capture_init_end(); + I != E; ++I, ++CurField) { + LValue LV = CGF.EmitLValueForFieldInitialization(SlotLV, *CurField); + CGF.EmitInitializerForField(*CurField, LV, *I, ArrayRef()); + } + + return SlotLV; +} + +/// Generate an outlined function for the body of a CapturedStmt, store any +/// captured variables into the captured struct, and call the outlined function. +llvm::Function * +CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K) { + const CapturedDecl *CD = S.getCapturedDecl(); + const RecordDecl *RD = S.getCapturedRecordDecl(); + assert(CD->hasBody() && "missing CapturedDecl body"); + + LValue CapStruct = InitCapturedStruct(*this, S); + + // Emit the CapturedDecl + CodeGenFunction CGF(CGM, true); + CGF.CapturedStmtInfo = new CGCapturedStmtInfo(S, K); + llvm::Function *F = CGF.GenerateCapturedStmtFunction(CD, RD); + delete CGF.CapturedStmtInfo; + + // Emit call to the helper function. + EmitCallOrInvoke(F, CapStruct.getAddress()); + + return F; +} + +/// Creates the outlined function for a CapturedStmt. +llvm::Function * +CodeGenFunction::GenerateCapturedStmtFunction(const CapturedDecl *CD, + const RecordDecl *RD) { + assert(CapturedStmtInfo && + "CapturedStmtInfo should be set when generating the captured function"); + + // Check if we should generate debug info for this function. + maybeInitializeDebugInfo(); + + // Build the argument list. + ASTContext &Ctx = CGM.getContext(); + FunctionArgList Args; + Args.append(CD->param_begin(), CD->param_end()); + + // Create the function declaration. + FunctionType::ExtInfo ExtInfo; + const CGFunctionInfo &FuncInfo = + CGM.getTypes().arrangeFunctionDeclaration(Ctx.VoidTy, Args, ExtInfo, + /*IsVariadic=*/false); + llvm::FunctionType *FuncLLVMTy = CGM.getTypes().GetFunctionType(FuncInfo); + + llvm::Function *F = + llvm::Function::Create(FuncLLVMTy, llvm::GlobalValue::InternalLinkage, + CapturedStmtInfo->getHelperName(), &CGM.getModule()); + CGM.SetInternalFunctionAttributes(CD, F, FuncInfo); + + // Generate the function. + StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, CD->getBody()->getLocStart()); + + // Set the context parameter in CapturedStmtInfo. + llvm::Value *DeclPtr = LocalDeclMap[CD->getContextParam()]; + assert(DeclPtr && "missing context parameter for CapturedStmt"); + CapturedStmtInfo->setContextValue(Builder.CreateLoad(DeclPtr)); + + // If 'this' is captured, load it into CXXThisValue. + if (CapturedStmtInfo->isCXXThisExprCaptured()) { + FieldDecl *FD = CapturedStmtInfo->getThisFieldDecl(); + LValue LV = MakeNaturalAlignAddrLValue(CapturedStmtInfo->getContextValue(), + Ctx.getTagDeclType(RD)); + LValue ThisLValue = EmitLValueForField(LV, FD); + + CXXThisValue = EmitLoadOfLValue(ThisLValue).getScalarVal(); + } + + CapturedStmtInfo->EmitBody(*this, CD->getBody()); + FinishFunction(CD->getBodyRBrace()); + + return F; } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 75c60edbba53..071c08e6bf2e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -33,6 +33,7 @@ using namespace CodeGen; CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext) : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()), Builder(cgm.getModule().getContext()), + CapturedStmtInfo(0), SanitizePerformTypeCheck(CGM.getSanOpts().Null | CGM.getSanOpts().Alignment | CGM.getSanOpts().ObjectSize | @@ -1447,3 +1448,5 @@ llvm::Value *CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D, return V; } + +CodeGenFunction::CGCapturedStmtInfo::~CGCapturedStmtInfo() { } diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index ff74c15c38c3..6caf1689a9da 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -23,6 +23,7 @@ #include "clang/AST/ExprObjC.h" #include "clang/AST/Type.h" #include "clang/Basic/ABI.h" +#include "clang/Basic/CapturedStmt.h" #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/ArrayRef.h" @@ -606,6 +607,65 @@ public: /// we prefer to insert allocas. llvm::AssertingVH AllocaInsertPt; + /// \brief API for captured statement code generation. + class CGCapturedStmtInfo { + public: + explicit CGCapturedStmtInfo(const CapturedStmt &S, + CapturedRegionKind K = CR_Default) + : Kind(K), ThisValue(0), CXXThisFieldDecl(0) { + + RecordDecl::field_iterator Field = + S.getCapturedRecordDecl()->field_begin(); + for (CapturedStmt::const_capture_iterator I = S.capture_begin(), + E = S.capture_end(); + I != E; ++I, ++Field) { + if (I->capturesThis()) + CXXThisFieldDecl = *Field; + else + CaptureFields[I->getCapturedVar()] = *Field; + } + } + + virtual ~CGCapturedStmtInfo(); + + CapturedRegionKind getKind() const { return Kind; } + + void setContextValue(llvm::Value *V) { ThisValue = V; } + // \brief Retrieve the value of the context parameter. + llvm::Value *getContextValue() const { return ThisValue; } + + /// \brief Lookup the captured field decl for a variable. + const FieldDecl *lookup(const VarDecl *VD) const { + return CaptureFields.lookup(VD); + } + + bool isCXXThisExprCaptured() const { return CXXThisFieldDecl != 0; } + FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; } + + /// \brief Emit the captured statement body. + virtual void EmitBody(CodeGenFunction &CGF, Stmt *S) { + CGF.EmitStmt(S); + } + + /// \brief Get the name of the capture helper. + virtual StringRef getHelperName() const { return "__captured_stmt"; } + + private: + /// \brief The kind of captured statement being generated. + CapturedRegionKind Kind; + + /// \brief Keep the map between VarDecl and FieldDecl. + llvm::SmallDenseMap CaptureFields; + + /// \brief The base address of the captured record, passed in as the first + /// argument of the parallel region function. + llvm::Value *ThisValue; + + /// \brief Captured 'this' type. + FieldDecl *CXXThisFieldDecl; + }; + CGCapturedStmtInfo *CapturedStmtInfo; + /// BoundsChecking - Emit run-time bounds checks. Higher values mean /// potentially higher performance penalties. unsigned char BoundsChecking; @@ -2188,7 +2248,6 @@ public: void EmitCaseStmt(const CaseStmt &S); void EmitCaseStmtRange(const CaseStmt &S); void EmitAsmStmt(const AsmStmt &S); - void EmitCapturedStmt(const CapturedStmt &S); void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S); void EmitObjCAtTryStmt(const ObjCAtTryStmt &S); @@ -2204,6 +2263,10 @@ public: void EmitCXXTryStmt(const CXXTryStmt &S); void EmitCXXForRangeStmt(const CXXForRangeStmt &S); + llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K); + llvm::Function *GenerateCapturedStmtFunction(const CapturedDecl *CD, + const RecordDecl *RD); + //===--------------------------------------------------------------------===// // LValue Expression Emission //===--------------------------------------------------------------------===// diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index dd05b822364d..19ed4bcc0fb7 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11212,12 +11212,12 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, return true; } } - // Lambdas are not allowed to capture __block variables; they don't - // support the expected semantics. - if (IsLambda && HasBlocksAttr) { + // Lambdas and captured statements are not allowed to capture __block + // variables; they don't support the expected semantics. + if (HasBlocksAttr && (IsLambda || isa(CSI))) { if (BuildAndDiagnose) { - Diag(Loc, diag::err_lambda_capture_block) - << Var->getDeclName(); + Diag(Loc, diag::err_capture_block_variable) + << Var->getDeclName() << !IsLambda; Diag(Var->getLocation(), diag::note_previous_decl) << Var->getDeclName(); } diff --git a/clang/test/CodeGen/captured-statements-nested.c b/clang/test/CodeGen/captured-statements-nested.c new file mode 100644 index 000000000000..d8ec74692adf --- /dev/null +++ b/clang/test/CodeGen/captured-statements-nested.c @@ -0,0 +1,126 @@ +// RUN: %clang_cc1 -fblocks -emit-llvm %s -o %t +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK1 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK2 + +struct A { + int a; + float b; + char c; +}; + +void test_nest_captured_stmt(int param) { + int w; + // CHECK1: %struct.anon{{.*}} = type { i32*, i32* } + // CHECK1: %struct.anon{{.*}} = type { i32*, i32*, i32**, i32* } + // CHECK1: [[T:%struct.anon.*]] = type { i32*, i32*, %struct.A*, i32**, i32* } + #pragma clang __debug captured + { + int x; + int *y = &w; + #pragma clang __debug captured + { + struct A z; + #pragma clang __debug captured + { + w = x = z.a = 1; + *y = param; + z.b = 0.1f; + z.c = 'c'; + + // CHECK1: define internal void @__captured_stmt{{.*}}([[T]] + // + // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 2 + // CHECK1-NEXT: load %struct.A** + // CHECK1-NEXT: getelementptr inbounds %struct.A* + // CHECK1-NEXT: store i32 1 + // + // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 1 + // CHECK1-NEXT: load i32** + // CHECK1-NEXT: store i32 1 + // + // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 0 + // CHECK1-NEXT: load i32** + // CHECK1-NEXT: store i32 1 + // + // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 4 + // CHECK1-NEXT: load i32** + // CHECK1-NEXT: load i32* + // CHECK1-NEXT: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 3 + // CHECK1-NEXT: load i32*** + // CHECK1-NEXT: load i32** + // CHECK1-NEXT: store i32 + // + // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 2 + // CHECK1-NEXT: load %struct.A** + // CHECK1-NEXT: getelementptr inbounds %struct.A* + // CHECK1-NEXT: store float + // + // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 2 + // CHECK1-NEXT: load %struct.A** + // CHECK1-NEXT: getelementptr inbounds %struct.A* + // CHECK1-NEXT: store i8 99 + } + } + } +} + +void test_nest_block() { + __block int x; + int y; + ^{ + int z; + x = z; + #pragma clang __debug captured + { + z = y; // OK + } + }(); + + // CHECK2: define internal void @{{.*}}test_nest_block_block_invoke + // + // CHECK2: [[Z:%[0-9a-z_]*]] = alloca i32 + // CHECK2: alloca %struct.anon{{.*}} + // + // CHECK2: store i32 + // CHECK2: store i32* [[Z]] + // + // CHECK2: getelementptr inbounds %struct.anon + // CHECK2-NEXT: getelementptr inbounds + // CHECK2-NEXT: store i32* + // + // CHECK2: call void @__captured_stmt + + int a; + #pragma clang __debug captured + { + __block int b; + int c; + __block int d; + ^{ + b = a; + b = c; + b = d; + }(); + } + + // CHECK2: alloca %struct.__block_byref_b + // CHECK2-NEXT: [[C:%[0-9a-z_]*]] = alloca i32 + // CHECK2-NEXT: alloca %struct.__block_byref_d + // + // CHECK2: bitcast %struct.__block_byref_b* + // CHECK2-NEXT: store i8* + // + // CHECK2: [[CapA:%[0-9a-z_.]*]] = getelementptr inbounds {{.*}}, i32 0, i32 7 + // + // CHECK2: getelementptr inbounds %struct.anon{{.*}}, i32 0, i32 0 + // CHECK2: load i32** + // CHECK2: load i32* + // CHECK2: store i32 {{.*}}, i32* [[CapA]] + // + // CHECK2: [[CapC:%[0-9a-z_.]*]] = getelementptr inbounds {{.*}}, i32 0, i32 8 + // CHECK2-NEXT: [[Val:%[0-9a-z_]*]] = load i32* [[C]] + // CHECK2-NEXT: store i32 [[Val]], i32* [[CapC]] + // + // CHECK2: bitcast %struct.__block_byref_d* + // CHECK2-NEXT: store i8* +} diff --git a/clang/test/CodeGen/captured-statements.c b/clang/test/CodeGen/captured-statements.c new file mode 100644 index 000000000000..c87c1873506b --- /dev/null +++ b/clang/test/CodeGen/captured-statements.c @@ -0,0 +1,80 @@ +// RUN: %clang_cc1 -emit-llvm %s -o %t +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 + +int foo(); +int global; + +// Single statement +void test1() { + int i = 0; + #pragma clang __debug captured + { + i++; + } + // CHECK-1: %struct.anon = type { i32* } + // + // CHECK-1: test1 + // CHECK-1: alloca %struct.anon + // CHECK-1: getelementptr inbounds %struct.anon* + // CHECK-1: store i32* %i + // CHECK-1: call void @[[HelperName:__captured_stmt[0-9]+]] +} + +// CHECK-1: define internal void @[[HelperName]](%struct.anon +// CHECK-1: getelementptr inbounds %struct.anon{{.*}}, i32 0, i32 0 +// CHECK-1: load i32** +// CHECK-1: load i32* +// CHECK-1: add nsw i32 +// CHECK-1: store i32 + +// Compound statement with local variable +void test2(int x) { + #pragma clang __debug captured + { + int i; + for (i = 0; i < x; i++) + foo(); + } + // CHECK-2: test2 + // CHECK-2-NOT: %i + // CHECK-2: call void @[[HelperName:__captured_stmt[0-9]+]] +} + +// CHECK-2: define internal void @[[HelperName]] +// CHECK-2-NOT: } +// CHECK-2: %i = alloca i32 + +// Capture array +void test3() { + int arr[] = {1, 2, 3, 4, 5}; + #pragma clang __debug captured + { + arr[2] = arr[1]; + } + // CHECK-3: test3 + // CHECK-3: alloca [5 x i32] + // CHECK-3: call void @__captured_stmt +} + +void dont_capture_global() { + static int s; + extern int e; + #pragma clang __debug captured + { + global++; + s++; + e++; + } + + // CHECK-GLOBALS: %[[Capture:struct\.anon[\.0-9]*]] = type {} + // CHECK-GLOBALS: call void @__captured_stmt[[HelperName:[0-9]+]](%[[Capture]] +} + +// CHECK-GLOBALS: define internal void @__captured_stmt[[HelperName]] +// CHECK-GLOBALS-NOT: ret +// CHECK-GLOBALS: load i32* @global +// CHECK-GLOBALS: load i32* @ +// CHECK-GLOBALS: load i32* @e diff --git a/clang/test/CodeGenCXX/captured-statements.cpp b/clang/test/CodeGenCXX/captured-statements.cpp new file mode 100644 index 000000000000..1d5ab205f655 --- /dev/null +++ b/clang/test/CodeGenCXX/captured-statements.cpp @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o %t +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-4 + +struct Foo { + int x; + float y; + ~Foo() {} +}; + +struct TestClass { + int x; + + TestClass() : x(0) {}; + void MemberFunc() { + Foo f; + #pragma clang __debug captured + { + f.y = x; + } + } +}; + +void test1() { + TestClass c; + c.MemberFunc(); + // CHECK-1: %[[Capture:struct\.anon[\.0-9]*]] = type { %struct.Foo*, %struct.TestClass* } + + // CHECK-1: define {{.*}} void @_ZN9TestClass10MemberFuncEv + // CHECK-1: alloca %struct.anon + // CHECK-1: getelementptr inbounds %[[Capture]]* %{{[^,]*}}, i32 0, i32 0 + // CHECK-1: store %struct.Foo* %f, %struct.Foo** + // CHECK-1: getelementptr inbounds %[[Capture]]* %{{[^,]*}}, i32 0, i32 1 + // CHECK-1: call void @[[HelperName:[A-Za-z0-9_]+]](%[[Capture]]* + // CHECK-1: call void @_ZN3FooD1Ev + // CHECK-1: ret +} + +// CHECK-1: define internal void @[[HelperName]] +// CHECK-1: getelementptr inbounds %[[Capture]]* {{[^,]*}}, i32 0, i32 1 +// CHECK-1: getelementptr inbounds %struct.TestClass* {{[^,]*}}, i32 0, i32 0 +// CHECK-1: getelementptr inbounds %[[Capture]]* {{[^,]*}}, i32 0, i32 0 + +void test2(int x) { + int y = [&]() { + #pragma clang __debug captured + { + x++; + } + return x; + }(); + + // CHECK-2: define void @_Z5test2i + // CHECK-2: call i32 @[[Lambda:["$\w]+]] + // + // CHECK-2: define internal i32 @[[Lambda]] + // CHECK-2: call void @[[HelperName:["$_A-Za-z0-9]+]](%[[Capture:.*]]* + // + // CHECK-2: define internal void @[[HelperName]] + // CHECK-2: getelementptr inbounds %[[Capture]]* + // CHECK-2: load i32** + // CHECK-2: load i32* +} + +void test3(int x) { + #pragma clang __debug captured + { + x = [=]() { return x + 1; } (); + } + + // CHECK-3: %[[Capture:struct\.anon[\.0-9]*]] = type { i32* } + + // CHECK-3: define void @_Z5test3i(i32 %x) + // CHECK-3: store i32* + // CHECK-3: call void @{{.*}}__captured_stmt + // CHECK-3: ret void +} + +void test4() { + #pragma clang __debug captured + { + Foo f; + f.x = 5; + } + // CHECK-4: %[[Capture:struct\.anon[\.0-9]*]] = type { i32* } + + // CHECK-4: define void @_Z5test3i(i32 %x) + // CHECK-4: store i32* + // CHECK-4: call void @[[HelperName:["$_A-Za-z0-9]+]](%[[Capture:.*]]* + // CHECK-4: ret void + // + // CHECK-4: define internal void @[[HelperName]] + // CHECK-4: store i32 5, i32* + // CHECK-4: call void @{{.*}}FooD1Ev(%struct.Foo* +} diff --git a/clang/test/Sema/captured-statements.c b/clang/test/Sema/captured-statements.c index 9285a7802d50..86e9273944bf 100644 --- a/clang/test/Sema/captured-statements.c +++ b/clang/test/Sema/captured-statements.c @@ -49,29 +49,29 @@ void test_nest() { } void test_nest_block() { - __block int x; + __block int x; // expected-note {{'x' declared here}} int y; ^{ int z; #pragma clang __debug captured { - x = y; // OK + x = y; // expected-error{{__block variable 'x' cannot be captured in a captured statement}} y = z; // expected-error{{variable is not assignable (missing __block type specifier)}} z = y; // OK } }(); - __block int a; + __block int a; // expected-note 2 {{'a' declared here}} int b; #pragma clang __debug captured { __block int c; int d; ^{ - a = b; // OK - a = c; // OK + a = b; // expected-error{{__block variable 'a' cannot be captured in a captured statement}} b = d; // OK - Consistent with block inside a lambda - c = a; // OK + c = a; // expected-error{{__block variable 'a' cannot be captured in a captured statement}} + c = d; // OK d = b; // expected-error{{variable is not assignable (missing __block type specifier)}} }(); } -- GitLab From 078551c7b1b9ea71e32b0c9f87fb547d9f3ed9c7 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 9 May 2013 19:33:49 +0000 Subject: [PATCH 109/467] Recursive commands invocations are not currently supported by our CommandInterpreter CommandScriptImport can actually be made to invoke itself recursively, so we need to work around that by clearing the m_exe_ctx This is a short-term workaround, a more interesting solution would be to actually make sure recursive command invocations work properly llvm-svn: 181537 --- lldb/source/Commands/CommandObjectCommands.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 75bcfc2cca78..278fdc0c8764 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1397,6 +1397,13 @@ protected: Error error; const bool init_session = true; + // FIXME: this is necessary because CommandObject::CheckRequirements() assumes that + // commands won't ever be recursively invoked, but it's actually possible to craft + // a Python script that does other "command script imports" in __lldb_init_module + // the real fix is to have recursive commands possible with a CommandInvocation object + // separate from the CommandObject itself, so that recursive command invocations + // won't stomp on each other (wrt to execution contents, options, and more) + m_exe_ctx.Clear(); if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str(), m_options.m_allow_reload, init_session, -- GitLab From acbb1a5db5791f8c4b6beb1a673d474589d9a9a5 Mon Sep 17 00:00:00 2001 From: Ashok Thirumurthi Date: Thu, 9 May 2013 19:59:47 +0000 Subject: [PATCH 110/467] Fixed "log enable linux registers" and added a test. - Eliminated the use of static for methods that read m_register_infos, so that these routines can be implemented in the base class. - Eliminated m_register_infos in the base class because this is not used when derived classes call UpdateRegisterInfo. - Also moved the namespace using declarations from headers to source files. Thanks to Daniel and Samuel for their review feedback. llvm-svn: 181538 --- .../Process/FreeBSD/ProcessMonitor.cpp | 4 +-- .../Plugins/Process/FreeBSD/ProcessMonitor.h | 4 +-- .../Plugins/Process/Linux/ProcessMonitor.cpp | 23 +++++++++-------- .../Plugins/Process/Linux/ProcessMonitor.h | 6 ++--- .../Plugins/Process/POSIX/POSIXThread.cpp | 18 ++++++------- .../Plugins/Process/POSIX/POSIXThread.h | 8 +++--- .../POSIX/RegisterContextFreeBSD_x86_64.cpp | 17 ++++++++----- .../POSIX/RegisterContextFreeBSD_x86_64.h | 11 ++++---- .../POSIX/RegisterContextLinux_x86_64.cpp | 17 ++++++++----- .../POSIX/RegisterContextLinux_x86_64.h | 11 ++++---- .../Process/POSIX/RegisterContextPOSIX.h | 4 +++ .../Process/POSIX/RegisterContext_i386.cpp | 8 +++--- .../Process/POSIX/RegisterContext_i386.h | 4 +-- .../Process/POSIX/RegisterContext_x86_64.cpp | 15 +++++------ .../Process/POSIX/RegisterContext_x86_64.h | 9 +++---- .../functionalities/register/TestRegisters.py | 25 ++++++++++++++++++- 16 files changed, 111 insertions(+), 73 deletions(-) diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index f2b1e9d5d560..18be9129b901 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -1437,7 +1437,7 @@ ProcessMonitor::WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, } bool -ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset, +ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char* reg_name, unsigned size, RegisterValue &value) { bool result; @@ -1448,7 +1448,7 @@ ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset, bool ProcessMonitor::WriteRegisterValue(lldb::tid_t tid, unsigned offset, - const RegisterValue &value) + const char* reg_name, const RegisterValue &value) { bool result; WriteRegOperation op(offset, value, result); diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h index 0762ef9ad863..7ddf083b0985 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -107,7 +107,7 @@ public: /// FIXME: The FreeBSD implementation of this function should use tid in order /// to enable support for debugging threaded programs. bool - ReadRegisterValue(lldb::tid_t tid, unsigned offset, + ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, unsigned size, lldb_private::RegisterValue &value); /// Writes the given value to the register identified by the given @@ -117,7 +117,7 @@ public: /// FIXME: The FreeBSD implementation of this function should use tid in order /// to enable support for debugging threaded programs. bool - WriteRegisterValue(lldb::tid_t tid, unsigned offset, + WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, const lldb_private::RegisterValue &value); /// Reads all general purpose registers into the specified buffer. diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index 4ebde16245e0..e9a45d79da67 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -449,9 +449,9 @@ WriteOperation::Execute(ProcessMonitor *monitor) class ReadRegOperation : public Operation { public: - ReadRegOperation(lldb::tid_t tid, unsigned offset, + ReadRegOperation(lldb::tid_t tid, unsigned offset, const char *reg_name, RegisterValue &value, bool &result) - : m_tid(tid), m_offset(offset), + : m_tid(tid), m_offset(offset), m_reg_name(reg_name), m_value(value), m_result(result) { } @@ -460,6 +460,7 @@ public: private: lldb::tid_t m_tid; uintptr_t m_offset; + const char *m_reg_name; RegisterValue &m_value; bool &m_result; }; @@ -481,7 +482,7 @@ ReadRegOperation::Execute(ProcessMonitor *monitor) } if (log) log->Printf ("ProcessMonitor::%s() reg %s: 0x%" PRIx64, __FUNCTION__, - POSIXThread::GetRegisterNameFromOffset(m_offset), data); + m_reg_name, data); } //------------------------------------------------------------------------------ @@ -490,9 +491,9 @@ ReadRegOperation::Execute(ProcessMonitor *monitor) class WriteRegOperation : public Operation { public: - WriteRegOperation(lldb::tid_t tid, unsigned offset, + WriteRegOperation(lldb::tid_t tid, unsigned offset, const char *reg_name, const RegisterValue &value, bool &result) - : m_tid(tid), m_offset(offset), + : m_tid(tid), m_offset(offset), m_reg_name(reg_name), m_value(value), m_result(result) { } @@ -501,6 +502,7 @@ public: private: lldb::tid_t m_tid; uintptr_t m_offset; + const char *m_reg_name; const RegisterValue &m_value; bool &m_result; }; @@ -518,8 +520,7 @@ WriteRegOperation::Execute(ProcessMonitor *monitor) #endif if (log) - log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__, - POSIXThread::GetRegisterNameFromOffset(m_offset), buf); + log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__, m_reg_name, buf); if (PTRACE(PTRACE_POKEUSER, m_tid, (void*)m_offset, buf, 0)) m_result = false; else @@ -1715,21 +1716,21 @@ ProcessMonitor::WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, } bool -ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset, +ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char* reg_name, unsigned size, RegisterValue &value) { bool result; - ReadRegOperation op(tid, offset, value, result); + ReadRegOperation op(tid, offset, reg_name, value, result); DoOperation(&op); return result; } bool ProcessMonitor::WriteRegisterValue(lldb::tid_t tid, unsigned offset, - const RegisterValue &value) + const char* reg_name, const RegisterValue &value) { bool result; - WriteRegOperation op(tid, offset, value, result); + WriteRegOperation op(tid, offset, reg_name, value, result); DoOperation(&op); return result; } diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.h b/lldb/source/Plugins/Process/Linux/ProcessMonitor.h index c446dcd2821a..5563991d26c2 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.h +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.h @@ -24,12 +24,10 @@ namespace lldb_private class Error; class Module; class Scalar; - } // End lldb_private namespace. class ProcessLinux; class Operation; -class ProcessPOSIX; /// @class ProcessMonitor /// @brief Manages communication with the inferior (debugee) process. @@ -107,7 +105,7 @@ public: /// /// This method is provided for use by RegisterContextLinux derivatives. bool - ReadRegisterValue(lldb::tid_t tid, unsigned offset, + ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, unsigned size, lldb_private::RegisterValue &value); /// Writes the given value to the register identified by the given @@ -115,7 +113,7 @@ public: /// /// This method is provided for use by RegisterContextLinux derivatives. bool - WriteRegisterValue(lldb::tid_t tid, unsigned offset, + WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, const lldb_private::RegisterValue &value); /// Reads all general purpose registers into the specified buffer. diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp index 45762ecd9e4f..e08414f8e578 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp @@ -441,11 +441,14 @@ POSIXThread::GetRegisterIndexFromOffset(unsigned offset) case ArchSpec::eCore_x86_32_i386: case ArchSpec::eCore_x86_32_i486: case ArchSpec::eCore_x86_32_i486sx: - reg = RegisterContext_i386::GetRegisterIndexFromOffset(offset); - break; - case ArchSpec::eCore_x86_64_x86_64: - reg = RegisterContext_x86_64::GetRegisterIndexFromOffset(offset); + { + RegisterContextSP base = GetRegisterContext(); + if (base) { + RegisterContextPOSIX &context = static_cast(*base); + reg = context.GetRegisterIndexFromOffset(offset); + } + } break; } return reg; @@ -454,7 +457,7 @@ POSIXThread::GetRegisterIndexFromOffset(unsigned offset) const char * POSIXThread::GetRegisterName(unsigned reg) { - const char * name; + const char * name = nullptr; ArchSpec arch = Host::GetArchitecture(); switch (arch.GetCore()) @@ -466,11 +469,8 @@ POSIXThread::GetRegisterName(unsigned reg) case ArchSpec::eCore_x86_32_i386: case ArchSpec::eCore_x86_32_i486: case ArchSpec::eCore_x86_32_i486sx: - name = RegisterContext_i386::GetRegisterName(reg); - break; - case ArchSpec::eCore_x86_64_x86_64: - name = RegisterContext_x86_64::GetRegisterName(reg); + name = GetRegisterContext()->GetRegisterName(reg); break; } return name; diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.h b/lldb/source/Plugins/Process/POSIX/POSIXThread.h index fc6c759f0f55..8d353aac588e 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.h +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.h @@ -49,17 +49,17 @@ public: CreateRegisterContextForFrame (lldb_private::StackFrame *frame); //-------------------------------------------------------------------------- - // These static functions provide a mapping from the register offset + // These functions provide a mapping from the register offset // back to the register index or name for use in debugging or log // output. - static unsigned + unsigned GetRegisterIndexFromOffset(unsigned offset); - static const char * + const char * GetRegisterName(unsigned reg); - static const char * + const char * GetRegisterNameFromOffset(unsigned offset); //-------------------------------------------------------------------------- diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp b/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp index 48a6c4bab70f..bd866784223d 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp @@ -9,11 +9,13 @@ #include "RegisterContextFreeBSD_x86_64.h" +using namespace lldb_private; + // Computes the offset of the given GPR in the user data area. #define GPR_OFFSET(regname) \ (offsetof(GPR, regname)) -// Updates the FreeBSD specific information (offset and size) +// Update the FreeBSD specific information (offset and size). #define UPDATE_GPR_INFO(reg) \ do { \ m_register_infos[gpr_##reg].byte_size = sizeof(GPR::reg); \ @@ -79,14 +81,17 @@ const RegisterInfo * RegisterContextFreeBSD_x86_64::GetRegisterInfo() { // Allocate RegisterInfo only once - if (m_register_infos == nullptr) + if (!m_register_infos) { m_register_infos = new RegisterInfo[k_num_registers]; // Copy the register information from base class - memcpy(m_register_infos, RegisterContext_x86_64::GetRegisterInfo(), - sizeof(RegisterInfo) * k_num_registers); - // Update the FreeBSD specfic register information(offset and size) - UpdateRegisterInfo(); + if (m_register_infos) + { + memcpy(m_register_infos, RegisterContext_x86_64::GetRegisterInfo(), + sizeof(RegisterInfo) * k_num_registers); + // Update the Linux specific register information (offset and size). + UpdateRegisterInfo(); + } } return m_register_infos; } diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.h index 355baafb7e4c..4ea87c5becc1 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.h @@ -12,24 +12,25 @@ #include "Plugins/Process/POSIX/RegisterContext_x86_64.h" -using namespace lldb_private; - class RegisterContextFreeBSD_x86_64: public RegisterContext_x86_64 { public: - RegisterContextFreeBSD_x86_64(Thread &thread, uint32_t concrete_frame_idx); + RegisterContextFreeBSD_x86_64(lldb_private::Thread &thread, uint32_t concrete_frame_idx); virtual ~RegisterContextFreeBSD_x86_64(); - size_t GetGPRSize(); + size_t + GetGPRSize(); protected: virtual const lldb_private::RegisterInfo * GetRegisterInfo(); + virtual void + UpdateRegisterInfo(); + private: static lldb_private::RegisterInfo *m_register_infos; - void UpdateRegisterInfo(); }; #endif diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.cpp index 477f748c14d0..2266d7ce3df6 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.cpp +++ b/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.cpp @@ -9,11 +9,13 @@ #include "RegisterContextLinux_x86_64.h" +using namespace lldb_private; + // Computes the offset of the given GPR in the user data area. #define GPR_OFFSET(regname) \ (offsetof(GPR, regname)) -// Updates the Linux specific information (offset and size) +// Update the Linux specific information (offset and size). #define UPDATE_GPR_INFO(reg) \ do { \ m_register_infos[gpr_##reg].byte_size = sizeof(GPR::reg); \ @@ -114,14 +116,17 @@ const RegisterInfo * RegisterContextLinux_x86_64::GetRegisterInfo() { // Allocate RegisterInfo only once - if (m_register_infos == nullptr) + if (!m_register_infos) { m_register_infos = new RegisterInfo[k_num_registers]; // Copy the register information from base class - memcpy(m_register_infos, RegisterContext_x86_64::GetRegisterInfo(), - sizeof(RegisterInfo) * k_num_registers); - // Update the Linux specific register information(offset and size) - UpdateRegisterInfo(); + if (m_register_infos) + { + memcpy(m_register_infos, RegisterContext_x86_64::GetRegisterInfo(), + sizeof(RegisterInfo) * k_num_registers); + // Update the Linux specific register information (offset and size). + UpdateRegisterInfo(); + } } return m_register_infos; } diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.h b/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.h index 1df607f63c8b..d9d400de3396 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.h +++ b/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_x86_64.h @@ -12,24 +12,25 @@ #include "Plugins/Process/POSIX/RegisterContext_x86_64.h" -using namespace lldb_private; - class RegisterContextLinux_x86_64: public RegisterContext_x86_64 { public: - RegisterContextLinux_x86_64(Thread &thread, uint32_t concrete_frame_idx); + RegisterContextLinux_x86_64(lldb_private::Thread &thread, uint32_t concrete_frame_idx); virtual ~RegisterContextLinux_x86_64(); - size_t GetGPRSize(); + size_t + GetGPRSize(); protected: virtual const lldb_private::RegisterInfo * GetRegisterInfo(); + virtual void + UpdateRegisterInfo(); + private: static lldb_private::RegisterInfo *m_register_infos; - void UpdateRegisterInfo(); }; #endif diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContextPOSIX.h b/lldb/source/Plugins/Process/POSIX/RegisterContextPOSIX.h index 46aa9ca154e5..bd26a315da77 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContextPOSIX.h +++ b/lldb/source/Plugins/Process/POSIX/RegisterContextPOSIX.h @@ -36,6 +36,10 @@ public: /// True if the operation succeeded and false otherwise. virtual bool UpdateAfterBreakpoint() { return true; } + /// Determines the index in lldb's register file given a kernel byte offset. + virtual unsigned + GetRegisterIndexFromOffset(unsigned offset) { return LLDB_INVALID_REGNUM; } + // Checks to see if a watchpoint specified by hw_index caused the inferior // to stop. virtual bool diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.cpp b/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.cpp index 08f9c6196093..ac74580e44a6 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.cpp +++ b/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.cpp @@ -341,7 +341,8 @@ RegisterContext_i386::ReadRegister(const RegisterInfo *reg_info, { const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadRegisterValue(m_thread.GetID(), GetRegOffset(reg), GetRegSize(reg), value); + return monitor.ReadRegisterValue(m_thread.GetID(), GetRegOffset(reg), + GetRegisterName(reg), GetRegSize(reg), value); } bool @@ -351,11 +352,12 @@ RegisterContext_i386::ReadAllRegisterValues(DataBufferSP &data_sp) } bool RegisterContext_i386::WriteRegister(const RegisterInfo *reg_info, - const RegisterValue &value) + const RegisterValue &value) { const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); - return monitor.WriteRegisterValue(m_thread.GetID(), GetRegOffset(reg), value); + return monitor.WriteRegisterValue(m_thread.GetID(), GetRegOffset(reg), + GetRegisterName(reg), value); } bool diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.h b/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.h index d81ca02701c4..96066c47b815 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.h +++ b/lldb/source/Plugins/Process/POSIX/RegisterContext_i386.h @@ -43,10 +43,10 @@ public: const lldb_private::RegisterSet * GetRegisterSet(size_t set); - static unsigned + unsigned GetRegisterIndexFromOffset(unsigned offset); - static const char * + const char * GetRegisterName(unsigned reg); bool diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp b/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp index e99c257d9d5c..b808140359be 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp +++ b/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp @@ -457,8 +457,6 @@ g_register_infos[k_num_registers] = DEFINE_DR(dr, 7) }; -RegisterInfo *RegisterContext_x86_64::m_register_infos = g_register_infos; - static bool IsGPR(unsigned reg) { return reg <= k_last_gpr; // GPR's come first. @@ -549,7 +547,7 @@ RegisterContext_x86_64::GetRegisterCount() const RegisterInfo * RegisterContext_x86_64::GetRegisterInfo() { - return m_register_infos; + return g_register_infos; } const RegisterInfo * @@ -587,7 +585,7 @@ RegisterContext_x86_64::GetRegisterIndexFromOffset(unsigned offset) unsigned reg; for (reg = 0; reg < k_num_registers; reg++) { - if (m_register_infos[reg].byte_offset == offset) + if (GetRegisterInfo()[reg].byte_offset == offset) break; } assert(reg < k_num_registers && "Invalid register offset."); @@ -598,7 +596,7 @@ const char * RegisterContext_x86_64::GetRegisterName(unsigned reg) { assert(reg < k_num_registers && "Invalid register offset."); - return m_register_infos[reg].name; + return GetRegisterInfo()[reg].name; } lldb::ByteOrder @@ -690,7 +688,8 @@ RegisterContext_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue } else { ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), GetRegisterSize(reg), value); + return monitor.ReadRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), + GetRegisterName(reg), GetRegisterSize(reg), value); } if (reg_info->encoding == eEncodingVector) { @@ -788,7 +787,7 @@ RegisterContext_x86_64::WriteRegister(const lldb_private::RegisterInfo *reg_info const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; if (IsGPR(reg)) { ProcessMonitor &monitor = GetMonitor(); - return monitor.WriteRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), value); + return monitor.WriteRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), GetRegisterName(reg), value); } if (IsFPR(reg, m_fpr_type)) { @@ -890,6 +889,7 @@ RegisterContext_x86_64::ReadRegister(const unsigned reg, ProcessMonitor &monitor = GetMonitor(); return monitor.ReadRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), + GetRegisterName(reg), GetRegisterSize(reg), value); } @@ -901,6 +901,7 @@ RegisterContext_x86_64::WriteRegister(const unsigned reg, ProcessMonitor &monitor = GetMonitor(); return monitor.WriteRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), + GetRegisterName(reg), value); } diff --git a/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.h b/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.h index 8b6fa9d93b9a..8834a5169ca1 100644 --- a/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.h +++ b/lldb/source/Plugins/Process/POSIX/RegisterContext_x86_64.h @@ -161,10 +161,10 @@ public: const lldb_private::RegisterSet * GetRegisterSet(size_t set); - static unsigned + unsigned GetRegisterIndexFromOffset(unsigned offset); - static const char * + const char * GetRegisterName(unsigned reg); virtual bool @@ -317,9 +317,6 @@ protected: virtual bool WriteRegister(const unsigned reg, const lldb_private::RegisterValue &value); -private: - static lldb_private::RegisterInfo *m_register_infos; - private: uint64_t m_gpr[k_num_gpr_registers]; // general purpose registers. FPRType m_fpr_type; // determines the type of data stored by union FPR, if any. @@ -332,7 +329,7 @@ private: bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order); bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); - static bool IsFPR(unsigned reg, FPRType fpr_type); + bool IsFPR(unsigned reg, FPRType fpr_type); bool ReadGPR(); bool ReadFPR(); diff --git a/lldb/test/functionalities/register/TestRegisters.py b/lldb/test/functionalities/register/TestRegisters.py index bb54fd825249..c2a538c7b87a 100644 --- a/lldb/test/functionalities/register/TestRegisters.py +++ b/lldb/test/functionalities/register/TestRegisters.py @@ -2,7 +2,7 @@ Test the 'register' command. """ -import os, time +import os, sys, time import re import unittest2 import lldb @@ -13,6 +13,10 @@ class RegisterCommandsTestCase(TestBase): mydir = os.path.join("functionalities", "register") + def setUp(self): + TestBase.setUp(self) + self.has_teardown = False + def test_register_commands(self): """Test commands related to registers, in particular vector registers.""" if not self.getArchitecture() in ['i386', 'x86_64']: @@ -51,6 +55,8 @@ class RegisterCommandsTestCase(TestBase): def common_setup(self): exe = os.path.join(os.getcwd(), "a.out") + self.log_file = exe + ".log" + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main(). @@ -62,10 +68,27 @@ class RegisterCommandsTestCase(TestBase): self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['stopped', 'stop reason = breakpoint']) + # platform specific logging of the specified category + def log_enable(self, category): + self.platform = "" + if sys.platform.startswith("darwin"): + self.platform = "" # TODO: add support for "log enable darwin registers" + if sys.platform.startswith("linux"): + self.platform = "linux" + + if self.platform != "": + self.runCmd("log enable " + self.platform + " " + str(category) + " registers -v -f " + self.log_file, RUN_SUCCEEDED) + if not self.has_teardown: + self.has_teardown = True + self.addTearDownHook(lambda: os.remove(self.log_file)) + def register_commands(self): """Test commands related to registers, in particular vector registers.""" self.common_setup() + # verify that logging does not assert + self.log_enable("registers") + self.expect("register read -a", MISSING_EXPECTED_REGISTERS, substrs = ['registers were unavailable'], matching = False) self.runCmd("register read xmm0") -- GitLab From b40bf83eab6049a06159ad69b6422de9d6f3e2ee Mon Sep 17 00:00:00 2001 From: Edwin Vane Date: Thu, 9 May 2013 20:03:52 +0000 Subject: [PATCH 111/467] Transform for loops over pseudo-arrays only if begin/end members exist For loops using pseudo-arrays, classes that can be used like arrays from the Loop Convert Transform's point of view, should only get transformed if the pseudo-array class has begin()/end() members for the range-based for-loop to call. Free versions of begin()/end() should also be allowed but this is an enhancement for another revision. llvm-svn: 181539 --- .../LoopConvert/LoopMatchers.cpp | 49 ++++++++++++++++++- .../LoopConvert/free_begin_end_fail.cpp | 32 ++++++++++++ .../cpp11-migrate/LoopConvert/pseudoarray.cpp | 41 +++++++++++++++- 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp diff --git a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp index a7ca15f3eb3d..d69f2a888119 100644 --- a/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp +++ b/clang-tools-extra/cpp11-migrate/LoopConvert/LoopMatchers.cpp @@ -258,10 +258,57 @@ StatementMatcher makeIteratorLoopMatcher() { /// - If the end iterator variable 'g' is defined, it is the same as 'j' /// - The container's iterators would not be invalidated during the loop StatementMatcher makePseudoArrayLoopMatcher() { + // Test that the incoming type has a record declaration that has methods + // called 'begin' and 'end'. If the incoming type is const, then make sure + // these methods are also marked const. + // + // FIXME: To be completely thorough this matcher should also ensure the + // return type of begin/end is an iterator that dereferences to the same as + // what operator[] or at() returns. Such a test isn't likely to fail except + // for pathological cases. + // + // FIXME: Also, a record doesn't necessarily need begin() and end(). Free + // functions called begin() and end() taking the container as an argument + // are also allowed. + TypeMatcher RecordWithBeginEnd = + qualType(anyOf( + qualType( + isConstQualified(), + hasDeclaration( + recordDecl( + hasMethod( + methodDecl( + hasName("begin"), + isConst() + ) + ), + hasMethod( + methodDecl( + hasName("end"), + isConst() + ) + ) + ) + ) // hasDeclaration + ), // qualType + qualType( + unless(isConstQualified()), + hasDeclaration( + recordDecl( + hasMethod(hasName("begin")), + hasMethod(hasName("end")) + ) + ) + ) // qualType + ) + ); + StatementMatcher SizeCallMatcher = memberCallExpr(argumentCountIs(0), callee(methodDecl(anyOf(hasName("size"), - hasName("length"))))); + hasName("length")))), + on(anyOf(hasType(pointsTo(RecordWithBeginEnd)), + hasType(RecordWithBeginEnd)))); StatementMatcher EndInitMatcher = expr(anyOf( diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp new file mode 100644 index 000000000000..27f7e8bf75ec --- /dev/null +++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp @@ -0,0 +1,32 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11 +// RUN: FileCheck -input-file=%t.cpp %s +// XFAIL: * + +struct MyArray { + unsigned size(); +}; + +template +struct MyContainer { +}; + +int *begin(const MyArray &Arr); +int *end(const MyArray &Arr); + +template +T *begin(const MyContainer &C); +template +T *end(const MyContainer &C); + +// The Loop Convert Transform doesn't detect free functions begin()/end() and +// so fails to transform these cases which it should. +void f() { + MyArray Arr; + for (unsigned i = 0, e = Arr.size(); i < e; ++i) {} + // CHECK: for (auto & elem : Arr) {} + + MyContainer C; + for (int *I = begin(C), *E = end(C); I != E; ++I) {} + // CHECK: for (auto & elem : C) {} +} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp index 37105f9e0b40..5aeaf79fc9ff 100644 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp +++ b/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp @@ -1,5 +1,5 @@ // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs +// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11 // RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" @@ -64,3 +64,42 @@ void noContainer() { for (auto i = 0; i < v.size(); ++i) ; // CHECK: for (auto & elem : v) ; } + +struct NoBeginEnd { + unsigned size() const; +}; + +struct NoConstBeginEnd { + NoConstBeginEnd(); + unsigned size() const; + unsigned begin(); + unsigned end(); +}; + +struct ConstBeginEnd { + ConstBeginEnd(); + unsigned size() const; + unsigned begin() const; + unsigned end() const; +}; + +// Shouldn't transform pseudo-array uses if the container doesn't provide +// begin() and end() of the right const-ness. +void NoBeginEndTest() { + NoBeginEnd NBE; + for (unsigned i = 0, e = NBE.size(); i < e; ++i) {} + // CHECK: for (unsigned i = 0, e = NBE.size(); i < e; ++i) {} + + const NoConstBeginEnd const_NCBE; + for (unsigned i = 0, e = const_NCBE.size(); i < e; ++i) {} + // CHECK: for (unsigned i = 0, e = const_NCBE.size(); i < e; ++i) {} + + ConstBeginEnd CBE; + for (unsigned i = 0, e = CBE.size(); i < e; ++i) {} + // CHECK: for (auto & elem : CBE) {} + + const ConstBeginEnd const_CBE; + for (unsigned i = 0, e = const_CBE.size(); i < e; ++i) {} + // CHECK: for (auto & elem : const_CBE) {} +} + -- GitLab From 07fe235e2b6efca368a1ec6f7bc9e0feff00b4ab Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 9 May 2013 20:10:38 +0000 Subject: [PATCH 112/467] Generate a compact unwind encoding in the face of a stack alignment push. We generate a `push' of a random register (%rax) if the stack needs to be aligned by the size of that register. However, this could mess up compact unwind generation. In particular, we want to still generate compact unwind in the presence of this monstrosity. Check if the push of of the %rax/%eax register. If it is and it's marked with the `FrameSetup' flag, then we can generate a compact unwind encoding for the function only if the push is the last FrameSetup instruction. llvm-svn: 181540 --- llvm/lib/Target/X86/X86FrameLowering.cpp | 6 +++++ llvm/test/CodeGen/X86/compact-unwind.ll | 30 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 llvm/test/CodeGen/X86/compact-unwind.ll diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index ae51178f73b8..42b4e735096d 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -525,6 +525,12 @@ uint32_t X86FrameLowering::getCompactUnwindEncoding(MachineFunction &MF) const { // If there are too many saved registers, we cannot use compact encoding. if (SavedRegIdx >= CU_NUM_SAVED_REGS) return CU::UNWIND_MODE_DWARF; + unsigned Reg = MI.getOperand(0).getReg(); + if (Reg == (Is64Bit ? X86::RAX : X86::EAX)) { + ExpectEnd = true; + continue; + } + SavedRegs[SavedRegIdx++] = MI.getOperand(0).getReg(); StackAdjust += OffsetSize; InstrOffset += PushInstrSize; diff --git a/llvm/test/CodeGen/X86/compact-unwind.ll b/llvm/test/CodeGen/X86/compact-unwind.ll new file mode 100644 index 000000000000..8c4fa27da560 --- /dev/null +++ b/llvm/test/CodeGen/X86/compact-unwind.ll @@ -0,0 +1,30 @@ +; RUN: llc < %s -disable-cfi -disable-fp-elim -mtriple x86_64-apple-darwin11 | FileCheck %s + +%ty = type { i8* } + +@gv = external global i32 + +; This is aligning the stack with a push of a random register. +; CHECK: pushq %rax + +; Even though we can't encode %rax into the compact unwind, We still want to be +; able to generate a compact unwind encoding in this particular case. +; +; CHECK: __LD,__compact_unwind +; CHECK: _foo ## Range Start +; CHECK: 16842753 ## Compact Unwind Encoding: 0x1010001 + +define i8* @foo(i64 %size) { + %addr = alloca i64, align 8 + %tmp20 = load i32* @gv, align 4 + %tmp21 = call i32 @bar() + %tmp25 = load i64* %addr, align 8 + %tmp26 = inttoptr i64 %tmp25 to %ty* + %tmp29 = getelementptr inbounds %ty* %tmp26, i64 0, i32 0 + %tmp34 = load i8** %tmp29, align 8 + %tmp35 = getelementptr inbounds i8* %tmp34, i64 %size + store i8* %tmp35, i8** %tmp29, align 8 + ret i8* null +} + +declare i32 @bar() -- GitLab From 0698787d1904676e631d8baf1275590048790970 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Thu, 9 May 2013 20:42:43 +0000 Subject: [PATCH 113/467] Fix captured statements codegen test on ARM The return type of the destructor may vary between platforms, so stop inadvertently testing it. llvm-svn: 181541 --- clang/test/CodeGenCXX/captured-statements.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/CodeGenCXX/captured-statements.cpp b/clang/test/CodeGenCXX/captured-statements.cpp index 1d5ab205f655..389d8d0e0e12 100644 --- a/clang/test/CodeGenCXX/captured-statements.cpp +++ b/clang/test/CodeGenCXX/captured-statements.cpp @@ -34,7 +34,7 @@ void test1() { // CHECK-1: store %struct.Foo* %f, %struct.Foo** // CHECK-1: getelementptr inbounds %[[Capture]]* %{{[^,]*}}, i32 0, i32 1 // CHECK-1: call void @[[HelperName:[A-Za-z0-9_]+]](%[[Capture]]* - // CHECK-1: call void @_ZN3FooD1Ev + // CHECK-1: call {{.*}}FooD1Ev // CHECK-1: ret } @@ -93,5 +93,5 @@ void test4() { // // CHECK-4: define internal void @[[HelperName]] // CHECK-4: store i32 5, i32* - // CHECK-4: call void @{{.*}}FooD1Ev(%struct.Foo* + // CHECK-4: call {{.*}}FooD1Ev } -- GitLab From f03b2e8385b476546c2f5f54fe3685cd36605e6e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 9 May 2013 20:48:12 +0000 Subject: [PATCH 114/467] Debug Info: Remove unnecessary check for dependent array types This was added, untested (though the relevant crash was tested), in r128725/PR9600. Removing it doesn't cause failures & nothing I can imagine could cause this check to ever return 'true' (we should never be dealing with dependent types here). The subsequent change to check "isIncompleteType" (r128855/PR9608) makes a lot more sense. llvm-svn: 181542 --- clang/lib/CodeGen/CGDebugInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index f6ee4b8446d2..6678aa7198b1 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1585,7 +1585,7 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, Align = 0; else Align = CGM.getContext().getTypeAlign(Ty->getElementType()); - } else if (Ty->isDependentSizedArrayType() || Ty->isIncompleteType()) { + } else if (Ty->isIncompleteType()) { Size = 0; Align = 0; } else { -- GitLab From 452abac4b344742c94703c1165dc0f51caeff8e3 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 9 May 2013 21:01:17 +0000 Subject: [PATCH 115/467] [ms-cxxabi] Implement member pointer conversions Summary: This only supports converting along non-virtual inheritance paths by changing the field offset or the non-virtual base adjustment. This implements three kinds of conversions: - codegen for Value conversions - Constant emission for APValue - Constant folding for CastExprs In almost all constant initialization settings EmitMemberPointer(APValue) is called, except when the expression contains a reinterpret cast. reinterpret casts end up being a big corner case because the null value changes between different kinds of member pointers. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D741 llvm-svn: 181543 --- clang/lib/CodeGen/CGCXXABI.cpp | 22 ++ clang/lib/CodeGen/CGCXXABI.h | 6 + clang/lib/CodeGen/ItaniumCXXABI.cpp | 17 +- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 304 ++++++++++++++++-- .../microsoft-abi-member-pointers.cpp | 177 +++++++++- 5 files changed, 485 insertions(+), 41 deletions(-) diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp index 68fecb2d0cb8..4a125e6d7fa7 100644 --- a/clang/lib/CodeGen/CGCXXABI.cpp +++ b/clang/lib/CodeGen/CGCXXABI.cpp @@ -251,6 +251,28 @@ llvm::Constant *CGCXXABI::getMemberPointerAdjustment(const CastExpr *E) { E->path_end()); } +CharUnits CGCXXABI::getMemberPointerPathAdjustment(const APValue &MP) { + // TODO: Store base specifiers in APValue member pointer paths so we can + // easily reuse CGM.GetNonVirtualBaseClassOffset(). + const ValueDecl *MPD = MP.getMemberPointerDecl(); + CharUnits ThisAdjustment = CharUnits::Zero(); + ArrayRef Path = MP.getMemberPointerPath(); + bool DerivedMember = MP.isMemberPointerToDerivedMember(); + const CXXRecordDecl *RD = cast(MPD->getDeclContext()); + for (unsigned I = 0, N = Path.size(); I != N; ++I) { + const CXXRecordDecl *Base = RD; + const CXXRecordDecl *Derived = Path[I]; + if (DerivedMember) + std::swap(Base, Derived); + ThisAdjustment += + getContext().getASTRecordLayout(Derived).getBaseClassOffset(Base); + RD = Path[I]; + } + if (DerivedMember) + ThisAdjustment = -ThisAdjustment; + return ThisAdjustment; +} + llvm::BasicBlock *CGCXXABI::EmitCtorCompleteObjectHandler( CodeGenFunction &CGF) { if (CGM.getTarget().getCXXABI().hasConstructorVariants()) diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h index 1e4da631d6f6..7f72e1db6e93 100644 --- a/clang/lib/CodeGen/CGCXXABI.h +++ b/clang/lib/CodeGen/CGCXXABI.h @@ -192,6 +192,12 @@ protected: /// is required. llvm::Constant *getMemberPointerAdjustment(const CastExpr *E); + /// \brief Computes the non-virtual adjustment needed for a member pointer + /// conversion along an inheritance path stored in an APValue. Unlike + /// getMemberPointerAdjustment(), the adjustment can be negative if the path + /// is from a derived type to a base type. + CharUnits getMemberPointerPathAdjustment(const APValue &MP); + public: /// Adjust the given non-null pointer to an object of polymorphic /// type to point to the complete object. diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index e117e2867bdd..f7869568a47c 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -573,22 +573,7 @@ llvm::Constant *ItaniumCXXABI::EmitMemberPointer(const APValue &MP, if (!MPD) return EmitNullMemberPointer(MPT); - // Compute the this-adjustment. - CharUnits ThisAdjustment = CharUnits::Zero(); - ArrayRef Path = MP.getMemberPointerPath(); - bool DerivedMember = MP.isMemberPointerToDerivedMember(); - const CXXRecordDecl *RD = cast(MPD->getDeclContext()); - for (unsigned I = 0, N = Path.size(); I != N; ++I) { - const CXXRecordDecl *Base = RD; - const CXXRecordDecl *Derived = Path[I]; - if (DerivedMember) - std::swap(Base, Derived); - ThisAdjustment += - getContext().getASTRecordLayout(Derived).getBaseClassOffset(Base); - RD = Path[I]; - } - if (DerivedMember) - ThisAdjustment = -ThisAdjustment; + CharUnits ThisAdjustment = getMemberPointerPathAdjustment(MP); if (const CXXMethodDecl *MD = dyn_cast(MPD)) return BuildMemberPointer(MD, ThisAdjustment); diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index f5242eaaa2fb..79af5af0363a 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -130,6 +130,14 @@ private: return llvm::Constant::getAllOnesValue(CGM.IntTy); } + llvm::Constant *getConstantOrZeroInt(llvm::Constant *C) { + return C ? C : getZeroInt(); + } + + llvm::Value *getValueOrZeroInt(llvm::Value *C) { + return C ? C : getZeroInt(); + } + void GetNullMemberPointerFields(const MemberPointerType *MPT, llvm::SmallVectorImpl &fields); @@ -143,7 +151,15 @@ private: /// function member pointers. llvm::Constant *EmitFullMemberPointer(llvm::Constant *FirstField, bool IsMemberFunction, - const CXXRecordDecl *RD); + const CXXRecordDecl *RD, + CharUnits NonVirtualBaseAdjustment); + + llvm::Constant *BuildMemberPointer(const CXXRecordDecl *RD, + const CXXMethodDecl *MD, + CharUnits NonVirtualBaseAdjustment); + + bool MemberPointerConstantIsNull(const MemberPointerType *MPT, + llvm::Constant *MP); public: virtual llvm::Type *ConvertMemberPointerType(const MemberPointerType *MPT); @@ -172,6 +188,13 @@ public: llvm::Value *MemPtr, const MemberPointerType *MPT); + virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF, + const CastExpr *E, + llvm::Value *Src); + + virtual llvm::Constant *EmitMemberPointerConversion(const CastExpr *E, + llvm::Constant *Src); + virtual llvm::Value * EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, llvm::Value *&This, @@ -429,8 +452,10 @@ static bool hasVBPtrOffsetField(MSInheritanceModel Inheritance) { return Inheritance == MSIM_Unspecified; } -static bool hasOnlyOneField(MSInheritanceModel Inheritance) { - return Inheritance <= MSIM_SinglePolymorphic; +static bool hasOnlyOneField(bool IsMemberFunction, + MSInheritanceModel Inheritance) { + return Inheritance <= MSIM_SinglePolymorphic || + (!IsMemberFunction && Inheritance <= MSIM_MultiplePolymorphic); } // Only member pointers to functions need a this adjustment, since it can be @@ -531,22 +556,25 @@ MicrosoftCXXABI::EmitNullMemberPointer(const MemberPointerType *MPT) { llvm::Constant * MicrosoftCXXABI::EmitFullMemberPointer(llvm::Constant *FirstField, bool IsMemberFunction, - const CXXRecordDecl *RD) + const CXXRecordDecl *RD, + CharUnits NonVirtualBaseAdjustment) { MSInheritanceModel Inheritance = RD->getMSInheritanceModel(); // Single inheritance class member pointer are represented as scalars instead // of aggregates. - if (hasOnlyOneField(Inheritance)) + if (hasOnlyOneField(IsMemberFunction, Inheritance)) return FirstField; llvm::SmallVector fields; fields.push_back(FirstField); if (hasNonVirtualBaseAdjustmentField(IsMemberFunction, Inheritance)) - fields.push_back(getZeroInt()); + fields.push_back(llvm::ConstantInt::get( + CGM.IntTy, NonVirtualBaseAdjustment.getQuantity())); if (hasVBPtrOffsetField(Inheritance)) { + // FIXME: We actually need to search non-virtual bases for vbptrs. int64_t VBPtrOffset = getContext().getASTRecordLayout(RD).getVBPtrOffset().getQuantity(); if (VBPtrOffset == -1) @@ -567,14 +595,40 @@ MicrosoftCXXABI::EmitMemberDataPointer(const MemberPointerType *MPT, const CXXRecordDecl *RD = MPT->getClass()->getAsCXXRecordDecl(); llvm::Constant *FirstField = llvm::ConstantInt::get(CGM.IntTy, offset.getQuantity()); - return EmitFullMemberPointer(FirstField, /*IsMemberFunction=*/false, RD); + return EmitFullMemberPointer(FirstField, /*IsMemberFunction=*/false, RD, + CharUnits::Zero()); +} + +llvm::Constant *MicrosoftCXXABI::EmitMemberPointer(const CXXMethodDecl *MD) { + return BuildMemberPointer(MD->getParent(), MD, CharUnits::Zero()); +} + +llvm::Constant *MicrosoftCXXABI::EmitMemberPointer(const APValue &MP, + QualType MPType) { + const MemberPointerType *MPT = MPType->castAs(); + const ValueDecl *MPD = MP.getMemberPointerDecl(); + if (!MPD) + return EmitNullMemberPointer(MPT); + + CharUnits ThisAdjustment = getMemberPointerPathAdjustment(MP); + + // FIXME PR15713: Support virtual inheritance paths. + + if (const CXXMethodDecl *MD = dyn_cast(MPD)) + return BuildMemberPointer(MPT->getClass()->getAsCXXRecordDecl(), + MD, ThisAdjustment); + + CharUnits FieldOffset = + getContext().toCharUnitsFromBits(getContext().getFieldOffset(MPD)); + return EmitMemberDataPointer(MPT, ThisAdjustment + FieldOffset); } llvm::Constant * -MicrosoftCXXABI::EmitMemberPointer(const CXXMethodDecl *MD) { +MicrosoftCXXABI::BuildMemberPointer(const CXXRecordDecl *RD, + const CXXMethodDecl *MD, + CharUnits NonVirtualBaseAdjustment) { assert(MD->isInstance() && "Member function must not be static!"); MD = MD->getCanonicalDecl(); - const CXXRecordDecl *RD = MD->getParent(); CodeGenTypes &Types = CGM.getTypes(); llvm::Constant *FirstField; @@ -599,15 +653,8 @@ MicrosoftCXXABI::EmitMemberPointer(const CXXMethodDecl *MD) { } // The rest of the fields are common with data member pointers. - return EmitFullMemberPointer(FirstField, /*IsMemberFunction=*/true, RD); -} - -llvm::Constant * -MicrosoftCXXABI::EmitMemberPointer(const APValue &MP, QualType MPT) { - // FIXME PR15875: Implement member pointer conversions for Constants. - const CXXRecordDecl *RD = MPT->castAs()->getClass()->getAsCXXRecordDecl(); - return EmitFullMemberPointer(llvm::Constant::getNullValue(CGM.VoidPtrTy), - /*IsMemberFunction=*/true, RD); + return EmitFullMemberPointer(FirstField, /*IsMemberFunction=*/true, RD, + NonVirtualBaseAdjustment); } /// Member pointers are the same if they're either bitwise identical *or* both @@ -638,7 +685,7 @@ MicrosoftCXXABI::EmitMemberPointerComparison(CodeGenFunction &CGF, // single icmp. const CXXRecordDecl *RD = MPT->getClass()->getAsCXXRecordDecl(); MSInheritanceModel Inheritance = RD->getMSInheritanceModel(); - if (hasOnlyOneField(Inheritance)) + if (hasOnlyOneField(MPT->isMemberFunctionPointer(), Inheritance)) return Builder.CreateICmp(Eq, L, R); // Compare the first field. @@ -703,6 +750,37 @@ MicrosoftCXXABI::EmitMemberPointerIsNotNull(CodeGenFunction &CGF, return Res; } +bool MicrosoftCXXABI::MemberPointerConstantIsNull(const MemberPointerType *MPT, + llvm::Constant *Val) { + // Function pointers are null if the pointer in the first field is null. + if (MPT->isMemberFunctionPointer()) { + llvm::Constant *FirstField = Val->getType()->isStructTy() ? + Val->getAggregateElement(0U) : Val; + return FirstField->isNullValue(); + } + + // If it's not a function pointer and it's zero initializable, we can easily + // check zero. + if (isZeroInitializable(MPT) && Val->isNullValue()) + return true; + + // Otherwise, break down all the fields for comparison. Hopefully these + // little Constants are reused, while a big null struct might not be. + llvm::SmallVector Fields; + GetNullMemberPointerFields(MPT, Fields); + if (Fields.size() == 1) { + assert(Val->getType()->isIntegerTy()); + return Val == Fields[0]; + } + + unsigned I, E; + for (I = 0, E = Fields.size(); I != E; ++I) { + if (Val->getAggregateElement(I) != Fields[I]) + break; + } + return I == E; +} + // Returns an adjusted base cast to i8*, since we do more address arithmetic on // it. llvm::Value * @@ -803,6 +881,194 @@ MicrosoftCXXABI::EmitMemberDataPointerAddress(CodeGenFunction &CGF, return Builder.CreateBitCast(Addr, PType); } +static MSInheritanceModel +getInheritanceFromMemptr(const MemberPointerType *MPT) { + return MPT->getClass()->getAsCXXRecordDecl()->getMSInheritanceModel(); +} + +llvm::Value * +MicrosoftCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF, + const CastExpr *E, + llvm::Value *Src) { + assert(E->getCastKind() == CK_DerivedToBaseMemberPointer || + E->getCastKind() == CK_BaseToDerivedMemberPointer || + E->getCastKind() == CK_ReinterpretMemberPointer); + + // Use constant emission if we can. + if (isa(Src)) + return EmitMemberPointerConversion(E, cast(Src)); + + // We may be adding or dropping fields from the member pointer, so we need + // both types and the inheritance models of both records. + const MemberPointerType *SrcTy = + E->getSubExpr()->getType()->castAs(); + const MemberPointerType *DstTy = E->getType()->castAs(); + MSInheritanceModel SrcInheritance = getInheritanceFromMemptr(SrcTy); + MSInheritanceModel DstInheritance = getInheritanceFromMemptr(DstTy); + bool IsFunc = SrcTy->isMemberFunctionPointer(); + + // If the classes use the same null representation, reinterpret_cast is a nop. + bool IsReinterpret = E->getCastKind() == CK_ReinterpretMemberPointer; + if (IsReinterpret && (IsFunc || + nullFieldOffsetIsZero(SrcInheritance) == + nullFieldOffsetIsZero(DstInheritance))) + return Src; + + CGBuilderTy &Builder = CGF.Builder; + + // Branch past the conversion if Src is null. + llvm::Value *IsNotNull = EmitMemberPointerIsNotNull(CGF, Src, SrcTy); + llvm::Constant *DstNull = EmitNullMemberPointer(DstTy); + + // C++ 5.2.10p9: The null member pointer value is converted to the null member + // pointer value of the destination type. + if (IsReinterpret) { + // For reinterpret casts, sema ensures that src and dst are both functions + // or data and have the same size, which means the LLVM types should match. + assert(Src->getType() == DstNull->getType()); + return Builder.CreateSelect(IsNotNull, Src, DstNull); + } + + llvm::BasicBlock *OriginalBB = Builder.GetInsertBlock(); + llvm::BasicBlock *ConvertBB = CGF.createBasicBlock("memptr.convert"); + llvm::BasicBlock *ContinueBB = CGF.createBasicBlock("memptr.converted"); + Builder.CreateCondBr(IsNotNull, ConvertBB, ContinueBB); + CGF.EmitBlock(ConvertBB); + + // Decompose src. + llvm::Value *FirstField = Src; + llvm::Value *NonVirtualBaseAdjustment = 0; + llvm::Value *VirtualBaseAdjustmentOffset = 0; + llvm::Value *VBPtrOffset = 0; + if (!hasOnlyOneField(IsFunc, SrcInheritance)) { + // We need to extract values. + unsigned I = 0; + FirstField = Builder.CreateExtractValue(Src, I++); + if (hasNonVirtualBaseAdjustmentField(IsFunc, SrcInheritance)) + NonVirtualBaseAdjustment = Builder.CreateExtractValue(Src, I++); + if (hasVBPtrOffsetField(SrcInheritance)) + VBPtrOffset = Builder.CreateExtractValue(Src, I++); + if (hasVirtualBaseAdjustmentField(SrcInheritance)) + VirtualBaseAdjustmentOffset = Builder.CreateExtractValue(Src, I++); + } + + // For data pointers, we adjust the field offset directly. For functions, we + // have a separate field. + llvm::Constant *Adj = getMemberPointerAdjustment(E); + if (Adj) { + Adj = llvm::ConstantExpr::getTruncOrBitCast(Adj, CGM.IntTy); + llvm::Value *&NVAdjustField = IsFunc ? NonVirtualBaseAdjustment : FirstField; + bool isDerivedToBase = (E->getCastKind() == CK_DerivedToBaseMemberPointer); + if (!NVAdjustField) // If this field didn't exist in src, it's zero. + NVAdjustField = getZeroInt(); + if (isDerivedToBase) + NVAdjustField = Builder.CreateNSWSub(NVAdjustField, Adj, "adj"); + else + NVAdjustField = Builder.CreateNSWAdd(NVAdjustField, Adj, "adj"); + } + + // FIXME PR15713: Support conversions through virtually derived classes. + + // Recompose dst from the null struct and the adjusted fields from src. + llvm::Value *Dst; + if (hasOnlyOneField(IsFunc, DstInheritance)) { + Dst = FirstField; + } else { + Dst = llvm::UndefValue::get(DstNull->getType()); + unsigned Idx = 0; + Dst = Builder.CreateInsertValue(Dst, FirstField, Idx++); + if (hasNonVirtualBaseAdjustmentField(IsFunc, DstInheritance)) + Dst = Builder.CreateInsertValue( + Dst, getValueOrZeroInt(NonVirtualBaseAdjustment), Idx++); + if (hasVBPtrOffsetField(DstInheritance)) + Dst = Builder.CreateInsertValue( + Dst, getValueOrZeroInt(VBPtrOffset), Idx++); + if (hasVirtualBaseAdjustmentField(DstInheritance)) + Dst = Builder.CreateInsertValue( + Dst, getValueOrZeroInt(VirtualBaseAdjustmentOffset), Idx++); + } + Builder.CreateBr(ContinueBB); + + // In the continuation, choose between DstNull and Dst. + CGF.EmitBlock(ContinueBB); + llvm::PHINode *Phi = Builder.CreatePHI(DstNull->getType(), 2, "memptr.converted"); + Phi->addIncoming(DstNull, OriginalBB); + Phi->addIncoming(Dst, ConvertBB); + return Phi; +} + +llvm::Constant * +MicrosoftCXXABI::EmitMemberPointerConversion(const CastExpr *E, + llvm::Constant *Src) { + const MemberPointerType *SrcTy = + E->getSubExpr()->getType()->castAs(); + const MemberPointerType *DstTy = E->getType()->castAs(); + + // If src is null, emit a new null for dst. We can't return src because dst + // might have a new representation. + if (MemberPointerConstantIsNull(SrcTy, Src)) + return EmitNullMemberPointer(DstTy); + + // We don't need to do anything for reinterpret_casts of non-null member + // pointers. We should only get here when the two type representations have + // the same size. + if (E->getCastKind() == CK_ReinterpretMemberPointer) + return Src; + + MSInheritanceModel SrcInheritance = getInheritanceFromMemptr(SrcTy); + MSInheritanceModel DstInheritance = getInheritanceFromMemptr(DstTy); + + // Decompose src. + llvm::Constant *FirstField = Src; + llvm::Constant *NonVirtualBaseAdjustment = 0; + llvm::Constant *VirtualBaseAdjustmentOffset = 0; + llvm::Constant *VBPtrOffset = 0; + bool IsFunc = SrcTy->isMemberFunctionPointer(); + if (!hasOnlyOneField(IsFunc, SrcInheritance)) { + // We need to extract values. + unsigned I = 0; + FirstField = Src->getAggregateElement(I++); + if (hasNonVirtualBaseAdjustmentField(IsFunc, SrcInheritance)) + NonVirtualBaseAdjustment = Src->getAggregateElement(I++); + if (hasVBPtrOffsetField(SrcInheritance)) + VBPtrOffset = Src->getAggregateElement(I++); + if (hasVirtualBaseAdjustmentField(SrcInheritance)) + VirtualBaseAdjustmentOffset = Src->getAggregateElement(I++); + } + + // For data pointers, we adjust the field offset directly. For functions, we + // have a separate field. + llvm::Constant *Adj = getMemberPointerAdjustment(E); + if (Adj) { + Adj = llvm::ConstantExpr::getTruncOrBitCast(Adj, CGM.IntTy); + llvm::Constant *&NVAdjustField = + IsFunc ? NonVirtualBaseAdjustment : FirstField; + bool IsDerivedToBase = (E->getCastKind() == CK_DerivedToBaseMemberPointer); + if (!NVAdjustField) // If this field didn't exist in src, it's zero. + NVAdjustField = getZeroInt(); + if (IsDerivedToBase) + NVAdjustField = llvm::ConstantExpr::getNSWSub(NVAdjustField, Adj); + else + NVAdjustField = llvm::ConstantExpr::getNSWAdd(NVAdjustField, Adj); + } + + // FIXME PR15713: Support conversions through virtually derived classes. + + // Recompose dst from the null struct and the adjusted fields from src. + if (hasOnlyOneField(IsFunc, DstInheritance)) + return FirstField; + + llvm::SmallVector Fields; + Fields.push_back(FirstField); + if (hasNonVirtualBaseAdjustmentField(IsFunc, DstInheritance)) + Fields.push_back(getConstantOrZeroInt(NonVirtualBaseAdjustment)); + if (hasVBPtrOffsetField(DstInheritance)) + Fields.push_back(getConstantOrZeroInt(VBPtrOffset)); + if (hasVirtualBaseAdjustmentField(DstInheritance)) + Fields.push_back(getConstantOrZeroInt(VirtualBaseAdjustmentOffset)); + return llvm::ConstantStruct::getAnon(Fields); +} + llvm::Value * MicrosoftCXXABI::EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, llvm::Value *&This, diff --git a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp index 3fffc9d72cb1..c4eba8248c35 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp @@ -1,16 +1,20 @@ // RUN: %clang_cc1 -fno-rtti -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s +// FIXME: Test x86_64 member pointers when codegen no longer asserts on records +// with virtual bases. struct B1 { void foo(); int b; }; struct B2 { + int b2; void foo(); }; struct Single : B1 { void foo(); }; struct Multiple : B1, B2 { + int m; void foo(); }; struct Virtual : virtual B1 { @@ -34,6 +38,7 @@ struct Polymorphic { // offset. struct NonZeroVBPtr : POD, Virtual { int n; + void foo(); }; struct Unspecified; @@ -68,6 +73,62 @@ struct Unspecified : Virtual { int u; }; +// Test memptr emission in a constant expression. +namespace Const { +void (Single ::*s_f_mp)() = &Single::foo; +void (Multiple ::*m_f_mp)() = &B2::foo; +void (Virtual ::*v_f_mp)() = &Virtual::foo; +void (Unspecified::*u_f_mp)() = &Unspecified::foo; +// CHECK: @"\01?s_f_mp@Const@@3P8Single@@AEXXZA" = +// CHECK: global i8* bitcast ({{.*}} @"\01?foo@Single@@QAEXXZ" to i8*), align 4 +// CHECK: @"\01?m_f_mp@Const@@3P8Multiple@@AEXXZA" = +// CHECK: global { i8*, i32 } { i8* bitcast ({{.*}} @"\01?foo@B2@@QAEXXZ" to i8*), i32 4 }, align 4 +// CHECK: @"\01?v_f_mp@Const@@3P8Virtual@@AEXXZA" = +// CHECK: global { i8*, i32, i32 } { i8* bitcast ({{.*}} @"\01?foo@Virtual@@QAEXXZ" to i8*), i32 0, i32 0 }, align 4 +// CHECK: @"\01?u_f_mp@Const@@3P8Unspecified@@AEXXZA" = +// CHECK: global { i8*, i32, i32, i32 } { i8* bitcast ({{.*}} @"\01?foo@Unspecified@@QAEXXZ" to i8*), i32 0, i32 0, i32 0 }, align 4 +} + +namespace CastParam { +// This exercises ConstExprEmitter instead of ValueDecl::evaluateValue. The +// extra reinterpret_cast for the parameter type requires more careful folding. +// FIXME: Or does it? If reinterpret_casts are no-ops, we should be able to +// strip them in evaluateValue() and just proceed as normal with an APValue. +struct A { + int a; + void foo(A *p); +}; +struct B { int b; }; +struct C : B, A { int c; }; + +void (A::*ptr1)(void *) = (void (A::*)(void *)) &A::foo; +// CHECK: @"\01?ptr1@CastParam@@3P8A@1@AEXPAX@ZA" = +// CHECK: global i8* bitcast (void ({{.*}})* @"\01?foo@A@CastParam@@QAEXPAU12@@Z" to i8*), align 4 + +// Try a reinterpret_cast followed by a memptr conversion. +void (C::*ptr2)(void *) = (void (C::*)(void *)) (void (A::*)(void *)) &A::foo; +// CHECK: @"\01?ptr2@CastParam@@3P8C@1@AEXPAX@ZA" = +// CHECK: global { i8*, i32 } { i8* bitcast (void ({{.*}})* @"\01?foo@A@CastParam@@QAEXPAU12@@Z" to i8*), i32 4 }, align 4 + +void (C::*ptr3)(void *) = (void (C::*)(void *)) (void (A::*)(void *)) (void (A::*)(A *)) 0; +// CHECK: @"\01?ptr3@CastParam@@3P8C@1@AEXPAX@ZA" = +// CHECK: global { i8*, i32 } zeroinitializer, align 4 + +struct D : C { + virtual void isPolymorphic(); + int d; +}; + +// Try a cast that changes the inheritance model. Null for D is 0, but null for +// C is -1. We need the cast to long in order to hit the non-APValue path. +int C::*ptr4 = (int C::*) (int D::*) (long D::*) 0; +// CHECK: @"\01?ptr4@CastParam@@3PQC@1@HA" = global i32 -1, align 4 + +// MSVC rejects this but we accept it. +int C::*ptr5 = (int C::*) (long D::*) 0; +// CHECK: @"\01?ptr5@CastParam@@3PQC@1@HA" = global i32 -1, align 4 +} + struct UnspecWithVBPtr; int UnspecWithVBPtr::*forceUnspecWithVBPtr; struct UnspecWithVBPtr : B1, virtual B2 { @@ -82,7 +143,7 @@ void EmitNonVirtualMemberPointers() { void (Virtual ::*v_f_memptr)() = &Virtual::foo; void (Unspecified::*u_f_memptr)() = &Unspecified::foo; void (UnspecWithVBPtr::*u2_f_memptr)() = &UnspecWithVBPtr::foo; -// CHECK: define void @"\01?EmitNonVirtualMemberPointers@@YAXXZ"() #0 { +// CHECK: define void @"\01?EmitNonVirtualMemberPointers@@YAXXZ"() {{.*}} { // CHECK: alloca i8*, align 4 // CHECK: alloca { i8*, i32 }, align 4 // CHECK: alloca { i8*, i32, i32 }, align 4 @@ -112,7 +173,7 @@ void podMemPtrs() { if (memptr) memptr = 0; // Check that member pointers use the right offsets and that null is -1. -// CHECK: define void @"\01?podMemPtrs@@YAXXZ"() #0 { +// CHECK: define void @"\01?podMemPtrs@@YAXXZ"() {{.*}} { // CHECK: %[[memptr:.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 0, i32* %[[memptr]], align 4 // CHECK-NEXT: store i32 4, i32* %[[memptr]], align 4 @@ -132,7 +193,7 @@ void polymorphicMemPtrs() { memptr = 0; // Member pointers for polymorphic classes include the vtable slot in their // offset and use 0 to represent null. -// CHECK: define void @"\01?polymorphicMemPtrs@@YAXXZ"() #0 { +// CHECK: define void @"\01?polymorphicMemPtrs@@YAXXZ"() {{.*}} { // CHECK: %[[memptr:.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 4, i32* %[[memptr]], align 4 // CHECK-NEXT: store i32 8, i32* %[[memptr]], align 4 @@ -233,7 +294,7 @@ int loadDataMemberPointerUnspecified(Unspecified *o, int Unspecified::*memptr) { void callMemberPointerSingle(Single *o, void (Single::*memptr)()) { (o->*memptr)(); // Just look for an indirect thiscall. -// CHECK: define void @"\01?callMemberPointerSingle@@{{.*}} #0 { +// CHECK: define void @"\01?callMemberPointerSingle@@{{.*}} {{.*}} { // CHECK: call x86_thiscallcc void %{{.*}}(%{{.*}} %{{.*}}) // CHECK: ret void // CHECK: } @@ -241,7 +302,7 @@ void callMemberPointerSingle(Single *o, void (Single::*memptr)()) { void callMemberPointerMultiple(Multiple *o, void (Multiple::*memptr)()) { (o->*memptr)(); -// CHECK: define void @"\01?callMemberPointerMultiple@@{{.*}} #0 { +// CHECK: define void @"\01?callMemberPointerMultiple@@{{.*}} { // CHECK: %[[memptr0:.*]] = extractvalue { i8*, i32 } %{{.*}}, 0 // CHECK: %[[memptr1:.*]] = extractvalue { i8*, i32 } %{{.*}}, 1 // CHECK: %[[this_adjusted:.*]] = getelementptr inbounds i8* %{{.*}}, i32 %[[memptr1]] @@ -255,7 +316,7 @@ void callMemberPointerMultiple(Multiple *o, void (Multiple::*memptr)()) { void callMemberPointerVirtualBase(Virtual *o, void (Virtual::*memptr)()) { (o->*memptr)(); // This shares a lot with virtual data member pointers. -// CHECK: define void @"\01?callMemberPointerVirtualBase@@{{.*}} #0 { +// CHECK: define void @"\01?callMemberPointerVirtualBase@@{{.*}} { // CHECK: %[[memptr0:.*]] = extractvalue { i8*, i32, i32 } %{{.*}}, 0 // CHECK: %[[memptr1:.*]] = extractvalue { i8*, i32, i32 } %{{.*}}, 1 // CHECK: %[[memptr2:.*]] = extractvalue { i8*, i32, i32 } %{{.*}}, 2 @@ -361,3 +422,107 @@ bool unspecDataMemptrEq(int Unspecified::*l, int Unspecified::*r) { // CHECK: ret i1 // CHECK: } } + +void (Multiple::*convertB2FuncToMultiple(void (B2::*mp)()))() { + return mp; +// CHECK: define i64 @"\01?convertB2FuncToMultiple@@YAP8Multiple@@AEXXZP8B2@@AEXXZ@Z"{{.*}} { +// CHECK: store +// CHECK: %[[mp:.*]] = load i8** %{{.*}}, align 4 +// CHECK: icmp ne i8* %[[mp]], null +// CHECK: br i1 %{{.*}} label %{{.*}}, label %{{.*}} +// +// memptr.convert: ; preds = %entry +// CHECK: insertvalue { i8*, i32 } undef, i8* %[[mp]], 0 +// CHECK: insertvalue { i8*, i32 } %{{.*}}, i32 4, 1 +// CHECK: br label +// +// memptr.converted: ; preds = %memptr.convert, %entry +// CHECK: phi { i8*, i32 } [ zeroinitializer, %{{.*}} ], [ {{.*}} ] +// CHECK: } +} + +void (B2::*convertMultipleFuncToB2(void (Multiple::*mp)()))() { +// FIXME: cl emits warning C4407 on this code because of the representation +// change. We might want to do the same. + return static_cast(mp); +// FIXME: We should return i8* instead of i32 here. The ptrtoint cast prevents +// LLVM from optimizing away the branch. This is likely a bug in +// lib/CodeGen/TargetInfo.cpp with how we classify memptr types for returns. +// +// CHECK: define i32 @"\01?convertMultipleFuncToB2@@YAP8B2@@AEXXZP8Multiple@@AEXXZ@Z"{{.*}} { +// CHECK: store +// CHECK: %[[src:.*]] = load { i8*, i32 }* %{{.*}}, align 4 +// CHECK: extractvalue { i8*, i32 } %[[src]], 0 +// CHECK: icmp ne i8* %{{.*}}, null +// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} +// +// memptr.convert: ; preds = %entry +// CHECK: %[[fp:.*]] = extractvalue { i8*, i32 } %[[src]], 0 +// CHECK: br label +// +// memptr.converted: ; preds = %memptr.convert, %entry +// CHECK: phi i8* [ null, %{{.*}} ], [ %[[fp]], %{{.*}} ] +// CHECK: } +} + +namespace Test1 { + +struct A { int a; }; +struct B { int b; }; +struct C : virtual A { int c; }; +struct D : B, C { int d; }; + +void (D::*convertCToD(void (C::*mp)()))() { + return mp; +// CHECK: define void @"\01?convertCToD@Test1@@YAP8D@1@AEXXZP8C@1@AEXXZ@Z"{{.*}} { +// CHECK: store +// CHECK: load { i8*, i32, i32 }* %{{.*}}, align 4 +// CHECK: extractvalue { i8*, i32, i32 } %{{.*}}, 0 +// CHECK: icmp ne i8* %{{.*}}, null +// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} +// +// memptr.convert: ; preds = %entry +// CHECK: extractvalue { i8*, i32, i32 } %{{.*}}, 0 +// CHECK: extractvalue { i8*, i32, i32 } %{{.*}}, 1 +// CHECK: extractvalue { i8*, i32, i32 } %{{.*}}, 2 +// CHECK: %[[adj:.*]] = add nsw i32 %{{.*}}, 4 +// CHECK: insertvalue { i8*, i32, i32 } undef, i8* {{.*}}, 0 +// CHECK: insertvalue { i8*, i32, i32 } {{.*}}, i32 %[[adj]], 1 +// CHECK: insertvalue { i8*, i32, i32 } {{.*}}, i32 {{.*}}, 2 +// CHECK: br label +// +// memptr.converted: ; preds = %memptr.convert, %entry +// CHECK: phi { i8*, i32, i32 } [ { i8* null, i32 0, i32 -1 }, {{.*}} ], [ {{.*}} ] +// CHECK: } +} + +} + +namespace Test2 { +// Test that we dynamically convert between different null reps. + +struct A { int a; }; +struct B : A { int b; }; +struct C : A { + int c; + virtual void hasVfPtr(); +}; + +int A::*reinterpret(int B::*mp) { + return reinterpret_cast(mp); +// CHECK: define i32 @"\01?reinterpret@Test2@@YAPQA@1@HPQB@1@H@Z"{{.*}} { +// CHECK-NOT: select +// CHECK: ret i32 +// CHECK: } +} + +int A::*reinterpret(int C::*mp) { + return reinterpret_cast(mp); +// CHECK: define i32 @"\01?reinterpret@Test2@@YAPQA@1@HPQC@1@H@Z"{{.*}} { +// CHECK: %[[mp:.*]] = load i32* +// CHECK: %[[cmp:.*]] = icmp ne i32 %[[mp]], 0 +// CHECK: select i1 %[[cmp]], i32 %[[mp]], i32 -1 +// CHECK: } +} + +} -- GitLab From 9c785c217b3f967cc55c54236b9089c3c2d47c6b Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 21:02:07 +0000 Subject: [PATCH 116/467] ArrayRef'ize some SemaOverload methods Patch by Robert Wilhelm. llvm-svn: 181544 --- clang/include/clang/Sema/Sema.h | 18 +++--- clang/lib/Sema/SemaDeclCXX.cpp | 8 ++- clang/lib/Sema/SemaExpr.cpp | 88 ++++++++++++++-------------- clang/lib/Sema/SemaExprCXX.cpp | 5 +- clang/lib/Sema/SemaExprObjC.cpp | 2 +- clang/lib/Sema/SemaOverload.cpp | 100 ++++++++++++++------------------ 6 files changed, 104 insertions(+), 117 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index f75ac93a908f..0fdd8e44518f 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2160,14 +2160,13 @@ public: ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true); bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, - Expr **Args, unsigned NumArgs, - SourceLocation RParenLoc, + MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result); @@ -2187,8 +2186,9 @@ public: ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, - SourceLocation LParenLoc, Expr **Args, - unsigned NumArgs, SourceLocation RParenLoc); + SourceLocation LParenLoc, + MultiExprArg Args, + SourceLocation RParenLoc); ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, Expr **Args, unsigned NumArgs, @@ -2945,7 +2945,7 @@ public: ObjCMethodDecl *Getter, SourceLocation Loc); void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, - Expr **Args, unsigned NumArgs); + ArrayRef Args); void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = 0, @@ -3256,7 +3256,7 @@ public: bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SourceLocation RParenLoc, bool ExecConfig = false); void CheckStaticArrayArgument(SourceLocation CallLoc, @@ -3271,7 +3271,7 @@ public: Expr *ExecConfig = 0, bool IsExecConfig = false); ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + ArrayRef Arg, SourceLocation RParenLoc, Expr *Config = 0, bool IsExecConfig = false); @@ -6778,7 +6778,7 @@ public: FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstProtoArg, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SmallVector &AllArgs, VariadicCallType CallType = VariadicDoesNotApply, bool AllowExplicit = false, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index a4e65ee76560..bece972a576f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -8557,7 +8557,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, ExprResult Call = S.BuildCallToMemberFunction(/*Scope=*/0, OpEqualRef.takeAs(), - Loc, &From, 1, Loc); + Loc, From, Loc); if (Call.isInvalid()) return StmtError(); @@ -10081,12 +10081,14 @@ Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply; SmallVector AllArgs; bool Invalid = GatherArgumentsForCall(Loc, Constructor, - Proto, 0, Args, NumArgs, AllArgs, + Proto, 0, + llvm::makeArrayRef(Args, NumArgs), + AllArgs, CallType, AllowExplicit, IsListInitialization); ConvertedArgs.append(AllArgs.begin(), AllArgs.end()); - DiagnoseSentinelCalls(Constructor, Loc, AllArgs.data(), AllArgs.size()); + DiagnoseSentinelCalls(Constructor, Loc, AllArgs); CheckConstructorCall(Constructor, llvm::makeArrayRef(AllArgs.data(), diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 19ed4bcc0fb7..8d76f60d395a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -316,7 +316,7 @@ std::string Sema::getDeletedOrUnavailableSuffix(const FunctionDecl *FD) { /// if so, it checks that the requirements of the sentinel are /// satisfied. void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, - Expr **args, unsigned numArgs) { + ArrayRef Args) { const SentinelAttr *attr = D->getAttr(); if (!attr) return; @@ -370,14 +370,14 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, // If there aren't enough arguments for all the formal parameters, // the sentinel, and the args after the sentinel, complain. - if (numArgs < numFormalParams + numArgsAfterSentinel + 1) { + if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) { Diag(Loc, diag::warn_not_enough_argument) << D->getDeclName(); Diag(D->getLocation(), diag::note_sentinel_here) << calleeType; return; } // Otherwise, find the sentinel expression. - Expr *sentinelExpr = args[numArgs - numArgsAfterSentinel - 1]; + Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1]; if (!sentinelExpr) return; if (sentinelExpr->isValueDependent()) return; if (Context.isSentinelNullExpr(sentinelExpr)) return; @@ -3811,7 +3811,7 @@ bool Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SourceLocation RParenLoc, bool IsExecConfig) { // Bail out early if calling a builtin with custom typechecking. @@ -3833,8 +3833,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // If too few arguments are available (and we don't have default // arguments for the remaining parameters), don't make the call. - if (NumArgs < NumArgsInProto) { - if (NumArgs < MinArgs) { + if (Args.size() < NumArgsInProto) { + if (Args.size() < MinArgs) { if (MinArgs == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName()) Diag(RParenLoc, MinArgs == NumArgsInProto && !Proto->isVariadic() ? diag::err_typecheck_call_too_few_args_one @@ -3846,7 +3846,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, ? diag::err_typecheck_call_too_few_args : diag::err_typecheck_call_too_few_args_at_least) << FnKind - << MinArgs << NumArgs << Fn->getSourceRange(); + << MinArgs << static_cast(Args.size()) + << Fn->getSourceRange(); // Emit the location of the prototype. if (FDecl && !FDecl->getBuiltinID() && !IsExecConfig) @@ -3860,7 +3861,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // If too many are passed and not variadic, error on the extras and drop // them. - if (NumArgs > NumArgsInProto) { + if (Args.size() > NumArgsInProto) { if (!Proto->isVariadic()) { if (NumArgsInProto == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName()) Diag(Args[NumArgsInProto]->getLocStart(), @@ -3868,18 +3869,20 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, ? diag::err_typecheck_call_too_many_args_one : diag::err_typecheck_call_too_many_args_at_most_one) << FnKind - << FDecl->getParamDecl(0) << NumArgs << Fn->getSourceRange() + << FDecl->getParamDecl(0) << static_cast(Args.size()) + << Fn->getSourceRange() << SourceRange(Args[NumArgsInProto]->getLocStart(), - Args[NumArgs-1]->getLocEnd()); + Args.back()->getLocEnd()); else Diag(Args[NumArgsInProto]->getLocStart(), MinArgs == NumArgsInProto ? diag::err_typecheck_call_too_many_args : diag::err_typecheck_call_too_many_args_at_most) << FnKind - << NumArgsInProto << NumArgs << Fn->getSourceRange() + << NumArgsInProto << static_cast(Args.size()) + << Fn->getSourceRange() << SourceRange(Args[NumArgsInProto]->getLocStart(), - Args[NumArgs-1]->getLocEnd()); + Args.back()->getLocEnd()); // Emit the location of the prototype. if (FDecl && !FDecl->getBuiltinID() && !IsExecConfig) @@ -3895,7 +3898,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, VariadicCallType CallType = getVariadicCallType(FDecl, Proto, Fn); Invalid = GatherArgumentsForCall(Call->getLocStart(), FDecl, - Proto, 0, Args, NumArgs, AllArgs, CallType); + Proto, 0, Args, AllArgs, CallType); if (Invalid) return true; unsigned TotalNumArgs = AllArgs.size(); @@ -3909,15 +3912,15 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstProtoArg, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SmallVector &AllArgs, VariadicCallType CallType, bool AllowExplicit, bool IsListInitialization) { unsigned NumArgsInProto = Proto->getNumArgs(); - unsigned NumArgsToCheck = NumArgs; + unsigned NumArgsToCheck = Args.size(); bool Invalid = false; - if (NumArgs != NumArgsInProto) + if (Args.size() != NumArgsInProto) // Use default arguments for missing arguments NumArgsToCheck = NumArgsInProto; unsigned ArgIx = 0; @@ -3927,7 +3930,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, Expr *Arg; ParmVarDecl *Param; - if (ArgIx < NumArgs) { + if (ArgIx < Args.size()) { Arg = Args[ArgIx++]; if (RequireCompleteType(Arg->getLocStart(), @@ -3988,7 +3991,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, // return __unknown_anytype aren't *really* variadic. if (Proto->getResultType() == Context.UnknownAnyTy && FDecl && FDecl->isExternC()) { - for (unsigned i = ArgIx; i != NumArgs; ++i) { + for (unsigned i = ArgIx, e = Args.size(); i != e; ++i) { QualType paramType; // ignored ExprResult arg = checkUnknownAnyArg(CallLoc, Args[i], paramType); Invalid |= arg.isInvalid(); @@ -3997,7 +4000,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, // Otherwise do argument promotion, (C99 6.5.2.2p7). } else { - for (unsigned i = ArgIx; i != NumArgs; ++i) { + for (unsigned i = ArgIx, e = Args.size(); i != e; ++i) { ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], CallType, FDecl); Invalid |= Arg.isInvalid(); @@ -4006,7 +4009,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, } // Check for array bounds violations. - for (unsigned i = ArgIx; i != NumArgs; ++i) + for (unsigned i = ArgIx, e = Args.size(); i != e; ++i) CheckArrayAccess(Args[i]); } return Invalid; @@ -4198,8 +4201,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, } if (Fn->getType() == Context.BoundMemberTy) { - return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs.data(), - ArgExprs.size(), RParenLoc); + return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, RParenLoc); } } @@ -4212,11 +4214,11 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, OverloadExpr *ovl = find.Expression; if (isa(ovl)) { UnresolvedLookupExpr *ULE = cast(ovl); - return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs.data(), - ArgExprs.size(), RParenLoc, ExecConfig); + return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs, + RParenLoc, ExecConfig); } else { - return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs.data(), - ArgExprs.size(), RParenLoc); + return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, + RParenLoc); } } } @@ -4240,9 +4242,8 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, else if (isa(NakedFn)) NDecl = cast(NakedFn)->getMemberDecl(); - return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs.data(), - ArgExprs.size(), RParenLoc, ExecConfig, - IsExecConfig); + return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc, + ExecConfig, IsExecConfig); } ExprResult @@ -4292,7 +4293,7 @@ ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SourceLocation RParenLoc, Expr *Config, bool IsExecConfig) { FunctionDecl *FDecl = dyn_cast_or_null(NDecl); @@ -4318,17 +4319,12 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, CallExpr *TheCall; if (Config) TheCall = new (Context) CUDAKernelCallExpr(Context, Fn, - cast(Config), - llvm::makeArrayRef(Args,NumArgs), - Context.BoolTy, - VK_RValue, + cast(Config), Args, + Context.BoolTy, VK_RValue, RParenLoc); else - TheCall = new (Context) CallExpr(Context, Fn, - llvm::makeArrayRef(Args, NumArgs), - Context.BoolTy, - VK_RValue, - RParenLoc); + TheCall = new (Context) CallExpr(Context, Fn, Args, Context.BoolTy, + VK_RValue, RParenLoc); // Bail out early if calling a builtin with custom typechecking. if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) @@ -4391,8 +4387,8 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, const FunctionProtoType *Proto = dyn_cast(FuncT); if (Proto) { - if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, NumArgs, - RParenLoc, IsExecConfig)) + if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc, + IsExecConfig)) return ExprError(); } else { assert(isa(FuncT) && "Unknown FunctionType!"); @@ -4401,11 +4397,11 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, // Check if we have too few/too many template arguments, based // on our knowledge of the function definition. const FunctionDecl *Def = 0; - if (FDecl->hasBody(Def) && NumArgs != Def->param_size()) { + if (FDecl->hasBody(Def) && Args.size() != Def->param_size()) { Proto = Def->getType()->getAs(); - if (!Proto || !(Proto->isVariadic() && NumArgs >= Def->param_size())) + if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->param_size())) Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments) - << (NumArgs > Def->param_size()) << FDecl << Fn->getSourceRange(); + << (Args.size() > Def->param_size()) << FDecl << Fn->getSourceRange(); } // If the function we're calling isn't a function prototype, but we have @@ -4415,7 +4411,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, } // Promote the arguments (C99 6.5.2.2p6). - for (unsigned i = 0; i != NumArgs; i++) { + for (unsigned i = 0, e = Args.size(); i != e; i++) { Expr *Arg = Args[i]; if (Proto && i < Proto->getNumArgs()) { @@ -4456,7 +4452,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, // Check for sentinels if (NDecl) - DiagnoseSentinelCalls(NDecl, LParenLoc, Args, NumArgs); + DiagnoseSentinelCalls(NDecl, LParenLoc, Args); // Do special checking on direct calls to functions. if (FDecl) { diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 27032a911147..ffe864963743 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1334,7 +1334,8 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply; if (GatherArgumentsForCall(PlacementLParen, OperatorNew, - Proto, 1, PlaceArgs, NumPlaceArgs, + Proto, 1, + llvm::makeArrayRef(PlaceArgs, NumPlaceArgs), AllPlaceArgs, CallType)) return ExprError(); @@ -1343,7 +1344,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, PlaceArgs = &AllPlaceArgs[0]; DiagnoseSentinelCalls(OperatorNew, PlacementLParen, - PlaceArgs, NumPlaceArgs); + llvm::makeArrayRef(PlaceArgs, NumPlaceArgs)); // FIXME: Missing call to CheckFunctionCall or equivalent } diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index cf77896cb8c3..cbe12e468960 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -1323,7 +1323,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, } } - DiagnoseSentinelCalls(Method, SelLoc, Args, NumArgs); + DiagnoseSentinelCalls(Method, SelLoc, llvm::makeArrayRef(Args, NumArgs)); // Do additional checkings on method. IsError |= CheckObjCMethodCall(Method, SelLoc, diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 529ba127cbab..cfc750c529e6 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -854,11 +854,11 @@ static bool checkPlaceholderForOverload(Sema &S, Expr *&E, /// checkArgPlaceholdersForOverload - Check a set of call operands for /// placeholders. -static bool checkArgPlaceholdersForOverload(Sema &S, Expr **args, - unsigned numArgs, +static bool checkArgPlaceholdersForOverload(Sema &S, + MultiExprArg Args, UnbridgedCastsSet &unbridged) { - for (unsigned i = 0; i != numArgs; ++i) - if (checkPlaceholderForOverload(S, args[i], &unbridged)) + for (unsigned i = 0, e = Args.size(); i != e; ++i) + if (checkPlaceholderForOverload(S, Args[i], &unbridged)) return true; return false; @@ -9890,7 +9890,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, /// \returns true when an the ExprResult output parameter has been set. bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, - Expr **Args, unsigned NumArgs, + MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result) { @@ -9913,15 +9913,14 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, #endif UnbridgedCastsSet UnbridgedCasts; - if (checkArgPlaceholdersForOverload(*this, Args, NumArgs, UnbridgedCasts)) { + if (checkArgPlaceholdersForOverload(*this, Args, UnbridgedCasts)) { *Result = ExprError(); return true; } // Add the functions denoted by the callee to the set of candidate // functions, including those from argument-dependent lookup. - AddOverloadedCallCandidates(ULE, llvm::makeArrayRef(Args, NumArgs), - *CandidateSet); + AddOverloadedCallCandidates(ULE, Args, *CandidateSet); // If we found nothing, try to recover. // BuildRecoveryCallExpr diagnoses the error itself, so we just bail @@ -9933,8 +9932,7 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, // classes. if (getLangOpts().MicrosoftMode && CurContext->isDependentContext() && (isa(CurContext) || isa(CurContext))) { - CallExpr *CE = new (Context) CallExpr(Context, Fn, - llvm::makeArrayRef(Args, NumArgs), + CallExpr *CE = new (Context) CallExpr(Context, Fn, Args, Context.DependentTy, VK_RValue, RParenLoc); CE->setTypeDependent(true); @@ -9954,7 +9952,7 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, @@ -9962,8 +9960,7 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, OverloadingResult OverloadResult, bool AllowTypoCorrection) { if (CandidateSet->empty()) - return BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc, - llvm::MutableArrayRef(Args, NumArgs), + return BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc, Args, RParenLoc, /*EmptyLookup=*/true, AllowTypoCorrection); @@ -9974,16 +9971,15 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, if (SemaRef.DiagnoseUseOfDecl(FDecl, ULE->getNameLoc())) return ExprError(); Fn = SemaRef.FixOverloadedFunctionReference(Fn, (*Best)->FoundDecl, FDecl); - return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, NumArgs, - RParenLoc, ExecConfig); + return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, RParenLoc, + ExecConfig); } case OR_No_Viable_Function: { // Try to recover by looking for viable functions which the user might // have meant to call. ExprResult Recovery = BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc, - llvm::MutableArrayRef(Args, NumArgs), - RParenLoc, + Args, RParenLoc, /*EmptyLookup=*/false, AllowTypoCorrection); if (!Recovery.isInvalid()) @@ -9992,16 +9988,14 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, SemaRef.Diag(Fn->getLocStart(), diag::err_ovl_no_viable_function_in_call) << ULE->getName() << Fn->getSourceRange(); - CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates, Args); break; } case OR_Ambiguous: SemaRef.Diag(Fn->getLocStart(), diag::err_ovl_ambiguous_call) << ULE->getName() << Fn->getSourceRange(); - CandidateSet->NoteCandidates(SemaRef, OCD_ViableCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet->NoteCandidates(SemaRef, OCD_ViableCandidates, Args); break; case OR_Deleted: { @@ -10010,15 +10004,14 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, << ULE->getName() << SemaRef.getDeletedOrUnavailableSuffix((*Best)->Function) << Fn->getSourceRange(); - CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates, Args); // We emitted an error for the unvailable/deleted function call but keep // the call in the AST. FunctionDecl *FDecl = (*Best)->Function; Fn = SemaRef.FixOverloadedFunctionReference(Fn, (*Best)->FoundDecl, FDecl); - return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, NumArgs, - RParenLoc, ExecConfig); + return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, RParenLoc, + ExecConfig); } } @@ -10035,22 +10028,22 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection) { OverloadCandidateSet CandidateSet(Fn->getExprLoc()); ExprResult result; - if (buildOverloadedCallSet(S, Fn, ULE, Args, NumArgs, LParenLoc, - &CandidateSet, &result)) + if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet, + &result)) return result; OverloadCandidateSet::iterator Best; OverloadingResult OverloadResult = CandidateSet.BestViableFunction(*this, Fn->getLocStart(), Best); - return FinishOverloadedCallExpr(*this, S, Fn, ULE, LParenLoc, Args, NumArgs, + return FinishOverloadedCallExpr(*this, S, Fn, ULE, LParenLoc, Args, RParenLoc, ExecConfig, &CandidateSet, &Best, OverloadResult, AllowTypoCorrection); @@ -10716,8 +10709,9 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, /// member function. ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, - SourceLocation LParenLoc, Expr **Args, - unsigned NumArgs, SourceLocation RParenLoc) { + SourceLocation LParenLoc, + MultiExprArg Args, + SourceLocation RParenLoc) { assert(MemExprE->getType() == Context.BoundMemberTy || MemExprE->getType() == Context.OverloadTy); @@ -10758,8 +10752,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, } CXXMemberCallExpr *call - = new (Context) CXXMemberCallExpr(Context, MemExprE, - llvm::makeArrayRef(Args, NumArgs), + = new (Context) CXXMemberCallExpr(Context, MemExprE, Args, resultType, valueKind, RParenLoc); if (CheckCallReturnType(proto->getResultType(), @@ -10767,14 +10760,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, call, 0)) return ExprError(); - if (ConvertArgumentsForCall(call, op, 0, proto, Args, NumArgs, RParenLoc)) + if (ConvertArgumentsForCall(call, op, 0, proto, Args, RParenLoc)) return ExprError(); return MaybeBindToTemporary(call); } UnbridgedCastsSet UnbridgedCasts; - if (checkArgPlaceholdersForOverload(*this, Args, NumArgs, UnbridgedCasts)) + if (checkArgPlaceholdersForOverload(*this, Args, UnbridgedCasts)) return ExprError(); MemberExpr *MemExpr; @@ -10818,7 +10811,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, // Microsoft supports direct constructor calls. if (getLangOpts().MicrosoftExt && isa(Func)) { AddOverloadCandidate(cast(Func), I.getPair(), - llvm::makeArrayRef(Args, NumArgs), CandidateSet); + Args, CandidateSet); } else if ((Method = dyn_cast(Func))) { // If explicit template arguments were provided, we can't call a // non-template member function. @@ -10826,15 +10819,13 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, continue; AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType, - ObjectClassification, - llvm::makeArrayRef(Args, NumArgs), CandidateSet, + ObjectClassification, Args, CandidateSet, /*SuppressUserConversions=*/false); } else { AddMethodTemplateCandidate(cast(Func), I.getPair(), ActingDC, TemplateArgs, ObjectType, ObjectClassification, - llvm::makeArrayRef(Args, NumArgs), - CandidateSet, + Args, CandidateSet, /*SuppressUsedConversions=*/false); } } @@ -10858,16 +10849,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, Diag(UnresExpr->getMemberLoc(), diag::err_ovl_no_viable_member_function_in_call) << DeclName << MemExprE->getSourceRange(); - CandidateSet.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args); // FIXME: Leaking incoming expressions! return ExprError(); case OR_Ambiguous: Diag(UnresExpr->getMemberLoc(), diag::err_ovl_ambiguous_member_call) << DeclName << MemExprE->getSourceRange(); - CandidateSet.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args); // FIXME: Leaking incoming expressions! return ExprError(); @@ -10877,8 +10866,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, << DeclName << getDeletedOrUnavailableSuffix(Best->Function) << MemExprE->getSourceRange(); - CandidateSet.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args); // FIXME: Leaking incoming expressions! return ExprError(); } @@ -10888,8 +10876,8 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, // If overload resolution picked a static member, build a // non-member call based on that function. if (Method->isStatic()) { - return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, - Args, NumArgs, RParenLoc); + return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args, + RParenLoc); } MemExpr = cast(MemExprE->IgnoreParens()); @@ -10901,8 +10889,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, assert(Method && "Member call to something that isn't a method?"); CXXMemberCallExpr *TheCall = - new (Context) CXXMemberCallExpr(Context, MemExprE, - llvm::makeArrayRef(Args, NumArgs), + new (Context) CXXMemberCallExpr(Context, MemExprE, Args, ResultType, VK, RParenLoc); // Check for a valid return type. @@ -10925,11 +10912,11 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, // Convert the rest of the arguments const FunctionProtoType *Proto = Method->getType()->getAs(); - if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args, NumArgs, + if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args, RParenLoc)) return ExprError(); - DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs); + DiagnoseSentinelCalls(Method, LParenLoc, Args); if (CheckFunctionCall(Method, TheCall, Proto)) return ExprError(); @@ -10965,7 +10952,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, ExprResult Object = Owned(Obj); UnbridgedCastsSet UnbridgedCasts; - if (checkArgPlaceholdersForOverload(*this, Args, NumArgs, UnbridgedCasts)) + if (checkArgPlaceholdersForOverload(*this, MultiExprArg(Args, NumArgs), + UnbridgedCasts)) return ExprError(); assert(Object.get()->getType()->isRecordType() && "Requires object type argument"); @@ -11243,7 +11231,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, if (IsError) return true; - DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs); + DiagnoseSentinelCalls(Method, LParenLoc, llvm::makeArrayRef(Args, NumArgs)); if (CheckFunctionCall(Method, TheCall, Proto)) return true; @@ -11473,7 +11461,7 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc, /*NeedsADL=*/true, /*Overloaded=*/false, FoundNames.begin(), FoundNames.end()); - bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, &Range, 1, Loc, + bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc, CandidateSet, CallExpr); if (CandidateSet->empty() || CandidateSetError) { *CallExpr = ExprError(); @@ -11487,7 +11475,7 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc, *CallExpr = ExprError(); return FRS_NoViableFunction; } - *CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, &Range, 1, + *CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range, Loc, 0, CandidateSet, &Best, OverloadResult, /*AllowTypoCorrection=*/false); -- GitLab From 06c5d201c46452119b7c799b9600e32a5a936bcf Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 9 May 2013 21:07:43 +0000 Subject: [PATCH 117/467] Rewrite assert to avoid warning when the record element type is byte-sized. BitstreamWriter asserts that when blob data is written from the record element vector, each element fits in a byte. However, if the record elements are specified as a SmallVector of 'char', this causes a warning from -Wtautological-constant-out-of-range-compare. Fix this by using llvm::isUInt<8> instead of a plain comparison against 256. llvm-svn: 181545 --- llvm/include/llvm/Bitcode/BitstreamWriter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Bitcode/BitstreamWriter.h b/llvm/include/llvm/Bitcode/BitstreamWriter.h index a837211875f5..f40a0d1d259f 100644 --- a/llvm/include/llvm/Bitcode/BitstreamWriter.h +++ b/llvm/include/llvm/Bitcode/BitstreamWriter.h @@ -381,7 +381,8 @@ private: BlobData = 0; } else { for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) { - assert(Vals[RecordIdx] < 256 && "Value too large to emit as blob"); + assert(isUInt<8>(Vals[RecordIdx]) && + "Value too large to emit as blob"); WriteByte((unsigned char)Vals[RecordIdx]); } } -- GitLab From b0f459e8aef298e0de35c209c8de492699f8b868 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 9 May 2013 21:10:06 +0000 Subject: [PATCH 118/467] Add pragma-comment.c test case for r181426 that I forgot to add llvm-svn: 181546 --- clang/test/CodeGen/pragma-comment.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 clang/test/CodeGen/pragma-comment.c diff --git a/clang/test/CodeGen/pragma-comment.c b/clang/test/CodeGen/pragma-comment.c new file mode 100644 index 000000000000..fd6b91e4679e --- /dev/null +++ b/clang/test/CodeGen/pragma-comment.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple i686-pc-linux -fms-extensions -emit-llvm -o - | FileCheck -check-prefix LINUX %s + +#pragma comment(lib, "msvcrt.lib") + +#define BAR "2" +#pragma comment(linker," /bar=" BAR) + +// CHECK: !llvm.module.flags = !{!0} +// CHECK: !0 = metadata !{i32 6, metadata !"Linker Options", metadata ![[link_opts:[0-9]+]]} +// CHECK: ![[link_opts]] = metadata !{metadata ![[msvcrt:[0-9]+]], metadata ![[bar:[0-9]+]]} +// CHECK: ![[msvcrt]] = metadata !{metadata !"/DEFAULTLIB:msvcrt.lib"} +// CHECK: ![[bar]] = metadata !{metadata !" /bar=2"} + +// LINUX: metadata !{metadata !"-lmsvcrt.lib"} +// LINUX: metadata !{metadata !" /bar=2"} -- GitLab From 4689326d4c956af27cacbc20db37893809012b52 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 9 May 2013 21:14:02 +0000 Subject: [PATCH 119/467] [lld] Fix wrong comment. llvm-svn: 181547 --- lld/lib/Driver/UniversalDriver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lld/lib/Driver/UniversalDriver.cpp b/lld/lib/Driver/UniversalDriver.cpp index 0a49501264c2..85ae4906a01a 100644 --- a/lld/lib/Driver/UniversalDriver.cpp +++ b/lld/lib/Driver/UniversalDriver.cpp @@ -9,7 +9,8 @@ /// /// \file /// -/// Concrete instance of the Driver for darwin's ld. +/// Driver for "universal" lld tool which can mimic any linker command line +/// parsing once it figures out which command line flavor to use. /// //===----------------------------------------------------------------------===// -- GitLab From 0b0bbd2f220c18c26dc8ea758819635c06baa7b7 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 9 May 2013 21:14:23 +0000 Subject: [PATCH 120/467] Implement n3607: 'equal', 'mismatch', and 'is_permutation' llvm-svn: 181548 --- libcxx/include/algorithm | 207 ++++++++++ .../alg.nonmodifying/alg.equal/equal.pass.cpp | 33 ++ .../alg.equal/equal_pred.pass.cpp | 50 +++ .../is_permutation.pass.cpp | 280 ++++++++++++++ .../is_permutation_pred.pass.cpp | 365 ++++++++++++++++++ .../mismatch/mismatch.pass.cpp | 24 ++ .../mismatch/mismatch_pred.pass.cpp | 23 ++ 7 files changed, 982 insertions(+) diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 39191db97768..f7e26cfeaa34 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -87,30 +87,63 @@ template pair mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); +template + pair + mismatch(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2); // **C++14** + template pair mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); +template + pair + mismatch(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + BinaryPredicate pred); // **C++14** + template bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); +template + bool + equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2); // **C++14** + template bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); +template + bool + equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + BinaryPredicate pred); // **C++14** + template bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); +template + bool + is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2); // **C++14** + template bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred); +template + bool + is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred); // **C++14** + template ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, @@ -1087,6 +1120,32 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>()); } +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY +pair<_InputIterator1, _InputIterator2> +mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __pred) +{ + for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + if (!__pred(*__first1, *__first2)) + break; + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +pair<_InputIterator1, _InputIterator2> +mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) +{ + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); +} +#endif + // equal template @@ -1110,6 +1169,60 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>()); } +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY +bool +__equal(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred, + input_iterator_tag, input_iterator_tag ) +{ + for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + if (!__pred(*__first1, *__first2)) + return false; + return __first1 == __last1 && __first2 == __last2; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, + _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, + random_access_iterator_tag, random_access_iterator_tag ) +{ + if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) + return false; + return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2, + typename add_lvalue_reference<_BinaryPredicate>::type> + (__first1, __last1, __first2, __pred ); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +equal(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred ) +{ + return _VSTD::__equal::type> + (__first1, __last1, __first2, __last2, __pred, + typename iterator_traits<_InputIterator1>::iterator_category(), + typename iterator_traits<_InputIterator2>::iterator_category()); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +equal(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) +{ + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(), + typename iterator_traits<_InputIterator1>::iterator_category(), + typename iterator_traits<_InputIterator2>::iterator_category()); +} +#endif + // is_permutation template @@ -1169,6 +1282,100 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>()); } +#if _LIBCPP_STD_VER > 11 +template +bool +__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred, + forward_iterator_tag, forward_iterator_tag ) +{ + // shorten sequences as much as possible by lopping of any equal parts + for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + if (!__pred(*__first1, *__first2)) + goto __not_done; + return __first1 == __last1 && __first2 == __last2; +__not_done: + // __first1 != __last1 && __first2 != __last2 && *__first1 != *__first2 + typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; + _D1 __l1 = _VSTD::distance(__first1, __last1); + + typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2; + _D1 __l2 = _VSTD::distance(__first2, __last2); + if (__l1 != __l2) + return false; + + // For each element in [f1, l1) see if there are the same number of + // equal elements in [f2, l2) + for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) + { + // Have we already counted the number of *__i in [f1, l1)? + for (_ForwardIterator1 __j = __first1; __j != __i; ++__j) + if (__pred(*__j, *__i)) + goto __next_iter; + { + // Count number of *__i in [f2, l2) + _D1 __c2 = 0; + for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) + if (__pred(*__i, *__j)) + ++__c2; + if (__c2 == 0) + return false; + // Count number of *__i in [__i, l1) (we can start with 1) + _D1 __c1 = 1; + for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) + if (__pred(*__i, *__j)) + ++__c1; + if (__c1 != __c2) + return false; + } +__next_iter:; + } + return true; +} + +template +bool +__is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1, + _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2, + _BinaryPredicate __pred, + random_access_iterator_tag, random_access_iterator_tag ) +{ + if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) + return false; + return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2, + typename add_lvalue_reference<_BinaryPredicate>::type> + (__first1, __last1, __first2, __pred ); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred ) +{ + return _VSTD::__is_permutation::type> + (__first1, __last1, __first2, __last2, __pred, + typename iterator_traits<_ForwardIterator1>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) +{ + typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; + typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; + return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, + __equal_to<__v1, __v2>(), + typename iterator_traits<_ForwardIterator1>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()); +} +#endif + // search template diff --git a/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp index 1b1a2ad420fb..6ecd4919f074 100644 --- a/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp +++ b/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp @@ -19,6 +19,10 @@ #include "test_iterators.h" +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; @@ -27,7 +31,36 @@ int main() assert(std::equal(input_iterator(ia), input_iterator(ia+s), input_iterator(ia))); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s))); + assert(std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s))); +#endif assert(!std::equal(input_iterator(ia), input_iterator(ia+s), input_iterator(ib))); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ib), + input_iterator(ib+s))); + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ib), + random_access_iterator(ib+s))); + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s-1))); + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s-1))); + +#endif } diff --git a/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp index b21d38b6ae59..b898220565f8 100644 --- a/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp +++ b/libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp @@ -21,6 +21,17 @@ #include "test_iterators.h" +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + +int comparison_count = 0; +template +bool counting_equals ( const T &a, const T &b ) { + ++comparison_count; + return a == b; + } + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; @@ -30,8 +41,47 @@ int main() input_iterator(ia+s), input_iterator(ia), std::equal_to())); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s), + std::equal_to())); + assert(std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s), + std::equal_to())); + + comparison_count = 0; + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s-1), + counting_equals)); + assert(comparison_count > 0); + comparison_count = 0; + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s-1), + counting_equals)); + assert(comparison_count == 0); +#endif + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ib), + std::equal_to())); +#ifdef HAS_FOUR_ITERATOR_VERSION assert(!std::equal(input_iterator(ia), input_iterator(ia+s), input_iterator(ib), + input_iterator(ib+s), + std::equal_to())); + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ib), + random_access_iterator(ib+s), std::equal_to())); +#endif } diff --git a/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp index f68ccedbbd62..8b5ba60826e4 100644 --- a/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp +++ b/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp @@ -19,6 +19,10 @@ #include "test_iterators.h" +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + int main() { { @@ -28,9 +32,25 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + 0), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + 0), + forward_iterator(ib), + forward_iterator(ib + 0)) == true); +#endif assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0}; @@ -39,6 +59,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { @@ -48,6 +74,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 0}; @@ -56,6 +92,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0}; @@ -64,6 +106,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0}; @@ -72,6 +120,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 1}; @@ -80,6 +134,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 1}; @@ -88,6 +148,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 1}; @@ -96,6 +166,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); +#endif } { const int ia[] = {0, 1}; @@ -104,6 +180,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {1, 0}; @@ -112,6 +194,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {1, 0}; @@ -120,6 +208,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); +#endif } { const int ia[] = {1, 0}; @@ -128,6 +222,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); +#endif } { const int ia[] = {1, 0}; @@ -136,6 +236,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {1, 1}; @@ -144,6 +250,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {1, 1}; @@ -152,6 +264,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {1, 1}; @@ -160,6 +278,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {1, 1}; @@ -168,6 +292,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); +#endif } { @@ -177,6 +307,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -185,6 +321,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -193,6 +335,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -201,6 +349,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -209,6 +363,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -217,6 +377,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -225,6 +391,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -233,6 +405,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -241,6 +419,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -249,6 +433,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -257,6 +451,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -265,6 +465,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -273,6 +483,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -281,6 +501,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -289,6 +519,16 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -297,6 +537,12 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -305,6 +551,20 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1), + forward_iterator(ib + sa)) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4}; @@ -313,6 +573,20 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1 ), + forward_iterator(ib + sa)) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1)) == false); +#endif } { const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4}; @@ -321,5 +595,11 @@ int main() assert(std::is_permutation(forward_iterator(ia), forward_iterator(ia + sa), forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == false); +#endif } } diff --git a/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp index 2a3174f511cb..ceb897da5148 100644 --- a/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp +++ b/libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp @@ -20,6 +20,18 @@ #include "test_iterators.h" +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + +int comparison_count = 0; +template +bool counting_equals ( const T &a, const T &b ) { + ++comparison_count; + return a == b; + } + + int main() { { @@ -34,6 +46,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0}; @@ -43,6 +67,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { @@ -53,6 +84,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0}; @@ -62,6 +105,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0}; @@ -71,6 +121,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0}; @@ -80,6 +137,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1}; @@ -89,6 +153,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1}; @@ -98,6 +169,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1}; @@ -107,6 +190,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1}; @@ -116,6 +211,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 0}; @@ -125,6 +227,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 0}; @@ -134,6 +243,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 0}; @@ -143,6 +264,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 0}; @@ -152,6 +285,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 1}; @@ -161,6 +301,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 1}; @@ -170,6 +317,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 1}; @@ -179,6 +333,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {1, 1}; @@ -188,6 +349,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { @@ -198,6 +371,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -207,6 +387,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -216,6 +403,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -225,6 +419,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -234,6 +435,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -243,6 +451,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -252,6 +467,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -261,6 +483,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 0}; @@ -270,6 +499,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -279,6 +515,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -288,6 +536,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -297,6 +552,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -306,6 +573,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -315,6 +594,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1, 2}; @@ -324,6 +615,18 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -333,6 +636,13 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 0, 1}; @@ -342,6 +652,23 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1), + forward_iterator(ib + sa), + std::equal_to()) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif } { const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4}; @@ -351,6 +678,37 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1), + forward_iterator(ib + sa), + std::equal_to()) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); + comparison_count = 0; + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + counting_equals) == false); + assert ( comparison_count > 0 ); + comparison_count = 0; + assert(std::is_permutation(random_access_iterator(ia), + random_access_iterator(ia + sa), + random_access_iterator(ib), + random_access_iterator(ib + sa - 1), + counting_equals) == false); + assert ( comparison_count == 0 ); +#endif } { const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4}; @@ -360,5 +718,12 @@ int main() forward_iterator(ia + sa), forward_iterator(ib), std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == false); +#endif } } diff --git a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp index 9dfebacf57cd..fe6785413826 100644 --- a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp +++ b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp @@ -19,6 +19,10 @@ #include "test_iterators.h" +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; @@ -31,4 +35,24 @@ int main() input_iterator >( input_iterator(ia+3), input_iterator(ib+3)))); + +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::mismatch(input_iterator(ia), + input_iterator(ia + sa), + input_iterator(ib), + input_iterator(ib + sa)) == + (std::pair, + input_iterator >( + input_iterator(ia+3), + input_iterator(ib+3)))); + + assert(std::mismatch(input_iterator(ia), + input_iterator(ia + sa), + input_iterator(ib), + input_iterator(ib + 2)) == + (std::pair, + input_iterator >( + input_iterator(ia+2), + input_iterator(ib+2)))); +#endif } diff --git a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp index 0258479b08f2..202a1b7bcb67 100644 --- a/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp +++ b/libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp @@ -21,6 +21,11 @@ #include "test_iterators.h" +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + + int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; @@ -34,6 +39,24 @@ int main() input_iterator >( input_iterator(ia+3), input_iterator(ib+3)))); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::mismatch(input_iterator(ia), + input_iterator(ia + sa), + input_iterator(ib), + input_iterator(ib + sa), + std::equal_to()) == + (std::pair, + input_iterator >( + input_iterator(ia+3), + input_iterator(ib+3)))); +#endif + assert(std::mismatch(ia, ia + sa, ib, std::equal_to()) == (std::pair(ia+3,ib+3))); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::mismatch(ia, ia + sa, ib, ib + sa, std::equal_to()) == + (std::pair(ia+3,ib+3))); + assert(std::mismatch(ia, ia + sa, ib, ib + 2, std::equal_to()) == + (std::pair(ia+2,ib+2))); +#endif } -- GitLab From ccd57d4186b9af65a53527186e5ad0301f24a340 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 21:15:03 +0000 Subject: [PATCH 121/467] Documentation warning: \param, not \parm llvm-svn: 181549 --- llvm/include/llvm/Option/Option.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Option/Option.h b/llvm/include/llvm/Option/Option.h index 541aa8d99185..4861b5972600 100644 --- a/llvm/include/llvm/Option/Option.h +++ b/llvm/include/llvm/Option/Option.h @@ -179,9 +179,9 @@ public: /// Index to the position where argument parsing should resume /// (even if the argument is missing values). /// - /// \parm ArgSize The number of bytes taken up by the matched Option prefix - /// and name. This is used to determine where joined values - /// start. + /// \param ArgSize The number of bytes taken up by the matched Option prefix + /// and name. This is used to determine where joined values + /// start. Arg *accept(const ArgList &Args, unsigned &Index, unsigned ArgSize) const; void dump() const; -- GitLab From f4d5bee616477d990a8ab102ac0e3c890c570e87 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 21:15:22 +0000 Subject: [PATCH 122/467] Documentation warning: \param, not \parm llvm-svn: 181550 --- clang/include/clang/Driver/Option.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Driver/Option.h b/clang/include/clang/Driver/Option.h index 764934fdf810..0536caa23b46 100644 --- a/clang/include/clang/Driver/Option.h +++ b/clang/include/clang/Driver/Option.h @@ -190,9 +190,9 @@ namespace options { /// Index to the position where argument parsing should resume /// (even if the argument is missing values). /// - /// \parm ArgSize The number of bytes taken up by the matched Option prefix - /// and name. This is used to determine where joined values - /// start. + /// \param ArgSize The number of bytes taken up by the matched Option prefix + /// and name. This is used to determine where joined values + /// start. Arg *accept(const ArgList &Args, unsigned &Index, unsigned ArgSize) const; void dump() const; -- GitLab From 9bf66a5fd06f1880647c601fc5c5b3787ebd1202 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 21:16:18 +0000 Subject: [PATCH 123/467] Fix a documentation warning: \bried -> \brief llvm-svn: 181551 --- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 4e75904ded4f..1c2b1e57d486 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -228,7 +228,7 @@ class MemorySanitizer : public FunctionPass { MDNode *ColdCallWeights; /// \brief Branch weights for origin store. MDNode *OriginStoreWeights; - /// \bried Path to blacklist file. + /// \brief Path to blacklist file. SmallString<64> BlacklistFile; /// \brief The blacklist. OwningPtr BL; -- GitLab From 8039fdf48c83aa67f4c7de7f93177ccede42e9ad Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 9 May 2013 21:32:04 +0000 Subject: [PATCH 124/467] DebugInfo: Simply & constrain test(s) for PR9600/PR9608 Both these tests were ultimately fixed by the check for "isIncompleteType" & neither test case was really reduced to a minimal form. On doing so it becomes apparent that the problem wasn't specific to templates at all, so I've moved the test case to a more appropriate test file and added FileCheck verification to it (to show the forward declaration of the array element type as well as the array alignment and size being 0 since it cannot be computed). That's about as far down this rabbithole as I'm willing to go today, so the rest of the un-FileChecked tests in test/CodeGenCXX/debug-info.cpp will have to go another day without actually testing anything other than the fact that they don't crash. & improve the actually interesting test case in test/CodeGenCXX/debug-info-templates.cpp which was my original goal (in preparation for expanding it/fixing some related bugs in non-type template parameters) llvm-svn: 181552 --- clang/test/CodeGenCXX/debug-info-template.cpp | 55 +++++-------------- clang/test/CodeGenCXX/debug-info.cpp | 11 +++- 2 files changed, 24 insertions(+), 42 deletions(-) diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp index 438ec1efca68..f68810b268de 100644 --- a/clang/test/CodeGenCXX/debug-info-template.cpp +++ b/clang/test/CodeGenCXX/debug-info-template.cpp @@ -1,46 +1,19 @@ // RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s -//CHECK: TC -//CHECK: DW_TAG_template_type_parameter - -template +// CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] +// CHECK: metadata [[TCI:![0-9]*]], i32 0, i32 1, %class.TC* @tci, null} ; [ DW_TAG_variable ] [tci] +// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] +// CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]]} +// +// We seem to be missing file/line/col info on template value parameters - +// metadata supports it but it's not populated. +// +// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT:![0-9]*]], i64 2, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[UINT]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] + +template class TC { -public: - TC(const TC &) {} - TC() {} -}; - -TC tci; - -//CHECK: TU<2> -//CHECK: DW_TAG_template_value_parameter -template -class TU { - int b; -}; - -TU<2> u2; - -// PR9600 -template class vector {}; -class Foo; -typedef vector FooVector[3]; -struct Test { - virtual void foo(FooVector *); -}; -static Test test; - -// PR9608 -template struct TheTemplate { - struct Empty2 {}; - typedef const Empty2 DependentType[i]; - TheTemplate() {} }; -class TheTemplateTest : public TheTemplate<42> { - TheTemplateTest(); - void method(const TheTemplate<42>::DependentType *) {} -}; - -TheTemplateTest::TheTemplateTest() : TheTemplate<42>() {} - +TC tci; diff --git a/clang/test/CodeGenCXX/debug-info.cpp b/clang/test/CodeGenCXX/debug-info.cpp index 33b52789caf2..d691f97e598c 100644 --- a/clang/test/CodeGenCXX/debug-info.cpp +++ b/clang/test/CodeGenCXX/debug-info.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -g %s +// RUN: %clang_cc1 -emit-llvm-only -g %s -o - | FileCheck %s template struct Identity { typedef T Type; }; @@ -67,3 +67,12 @@ class Cls { Cls obj; } + +namespace pr9608 { // also pr9600 +struct incomplete; +incomplete (*x)[3]; +// CHECK: metadata [[INCARRAYPTR:![0-9]*]], i32 0, i32 1, [3 x i8]** @_ZN6pr96081xE, null} ; [ DW_TAG_variable ] [x] +// CHECK: [[INCARRAYPTR]] = {{.*}}metadata [[INCARRAY:![0-9]*]]} ; [ DW_TAG_pointer_type ] +// CHECK: [[INCARRAY]] = {{.*}}metadata [[INCTYPE:![0-9]*]], metadata {{![0-9]*}}, i32 0, i32 0} ; [ DW_TAG_array_type ] [line 0, size 0, align 0, offset 0] [from incomplete] +// CHECK: [[INCTYPE]] = {{.*}} ; [ DW_TAG_structure_type ] [incomplete]{{.*}} [fwd] +} -- GitLab From 21b3ab43e1d85a962780916b9f221c813d9d6dcf Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 9 May 2013 21:36:41 +0000 Subject: [PATCH 125/467] C++1y n3648: parse and reject init-captures for now. llvm-svn: 181553 --- .../clang/Basic/DiagnosticSemaKinds.td | 2 + clang/include/clang/Sema/DeclSpec.h | 18 +++++---- clang/lib/Parse/ParseExprCXX.cpp | 38 ++++++++++++++++++- clang/lib/Sema/SemaLambda.cpp | 8 ++++ .../test/Parser/cxx0x-lambda-expressions.cpp | 18 +++++++++ .../Parser/objcxx0x-lambda-expressions.mm | 10 +++++ 6 files changed, 84 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 11fd91ab5bdd..18d5796ea14c 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4887,6 +4887,8 @@ let CategoryName = "Lambda Issue" in { def note_lambda_to_block_conv : Note< "implicit capture of lambda object due to conversion to block pointer " "here">; + def err_lambda_init_capture_unsupported : Error< + "sorry, initialized lambda-captures are not supported yet">; } def err_return_in_captured_stmt : Error< diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 059919a35bb0..7ee2c6cc1e55 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -2088,13 +2088,15 @@ private: struct LambdaCapture { LambdaCaptureKind Kind; SourceLocation Loc; - IdentifierInfo* Id; + IdentifierInfo *Id; SourceLocation EllipsisLoc; - + ExprResult Init; + LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo* Id = 0, - SourceLocation EllipsisLoc = SourceLocation()) - : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc) + SourceLocation EllipsisLoc = SourceLocation(), + ExprResult Init = ExprResult()) + : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc), Init(Init) {} }; @@ -2111,11 +2113,11 @@ struct LambdaIntroducer { /// \brief Append a capture in a lambda introducer. void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, - IdentifierInfo* Id = 0, - SourceLocation EllipsisLoc = SourceLocation()) { - Captures.push_back(LambdaCapture(Kind, Loc, Id, EllipsisLoc)); + IdentifierInfo* Id = 0, + SourceLocation EllipsisLoc = SourceLocation(), + ExprResult Init = ExprResult()) { + Captures.push_back(LambdaCapture(Kind, Loc, Id, EllipsisLoc, Init)); } - }; } // end namespace clang diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index f259d5f59b48..86e2e187d3e7 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -583,7 +583,7 @@ ExprResult Parser::ParseCXXIdExpression(bool isAddressOfOperand) { Tok.is(tok::l_paren), isAddressOfOperand); } -/// ParseLambdaExpression - Parse a C++0x lambda expression. +/// ParseLambdaExpression - Parse a C++11 lambda expression. /// /// lambda-expression: /// lambda-introducer lambda-declarator[opt] compound-statement @@ -605,10 +605,18 @@ ExprResult Parser::ParseCXXIdExpression(bool isAddressOfOperand) { /// capture-list ',' capture /// /// capture: +/// simple-capture +/// init-capture [C++1y] +/// +/// simple-capture: /// identifier /// '&' identifier /// 'this' /// +/// init-capture: [C++1y] +/// identifier initializer +/// '&' identifier initializer +/// /// lambda-declarator: /// '(' parameter-declaration-clause ')' attribute-specifier[opt] /// 'mutable'[opt] exception-specification[opt] @@ -737,6 +745,7 @@ Optional Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro) { SourceLocation Loc; IdentifierInfo* Id = 0; SourceLocation EllipsisLoc; + ExprResult Init; if (Tok.is(tok::kw_this)) { Kind = LCK_This; @@ -768,9 +777,31 @@ Optional Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro) { } else { return DiagResult(diag::err_expected_capture); } + + if (Tok.is(tok::l_paren)) { + BalancedDelimiterTracker Parens(*this, tok::l_paren); + Parens.consumeOpen(); + + ExprVector Exprs; + CommaLocsTy Commas; + if (ParseExpressionList(Exprs, Commas)) { + Parens.skipToEnd(); + Init = ExprError(); + } else { + Parens.consumeClose(); + Init = Actions.ActOnParenListExpr(Parens.getOpenLocation(), + Parens.getCloseLocation(), + Exprs); + } + } else if (Tok.is(tok::l_brace) || Tok.is(tok::equal)) { + if (Tok.is(tok::equal)) + ConsumeToken(); + + Init = ParseInitializer(); + } } - Intro.addCapture(Kind, Loc, Id, EllipsisLoc); + Intro.addCapture(Kind, Loc, Id, EllipsisLoc, Init); } T.consumeClose(); @@ -806,6 +837,9 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), LambdaBeginLoc, "lambda expression parsing"); + // FIXME: Call into Actions to add any init-capture declarations to the + // scope while parsing the lambda-declarator and compound-statement. + // Parse lambda-declarator[opt]. DeclSpec DS(AttrFactory); Declarator D(DS, Declarator::LambdaExprContext); diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 24388dd0f52b..4e11bb4c0557 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -559,6 +559,14 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, continue; } + // FIXME: C++1y [expr.prim.lambda]p11 + if (C->Init.isInvalid()) + continue; + if (C->Init.isUsable()) { + Diag(C->Loc, diag::err_lambda_init_capture_unsupported); + continue; + } + assert(C->Id && "missing identifier for capture"); // C++11 [expr.prim.lambda]p8: diff --git a/clang/test/Parser/cxx0x-lambda-expressions.cpp b/clang/test/Parser/cxx0x-lambda-expressions.cpp index 642c69a532ee..d7dc7d3a4730 100644 --- a/clang/test/Parser/cxx0x-lambda-expressions.cpp +++ b/clang/test/Parser/cxx0x-lambda-expressions.cpp @@ -48,4 +48,22 @@ class C { delete [] { return new int; } (); // expected-error{{expected expression}} delete [&] { return new int; } (); // ok, lambda } + + // We support init-captures in C++11 as an extension. + int z; + void init_capture() { + // FIXME: These diagnostics should all disappear once semantic analysis + // for init-captures is complete. + [n(0)] () -> int { return ++n; }; // expected-error {{not supported}} expected-error {{undeclared}} + [n{0}] { return; }; // expected-error {{not supported}} + [n = 0] { return ++n; }; // expected-error {{not supported}} expected-error {{undeclared}} + [n = {0}] { return; }; // expected-error {{not supported}} + [a([&b = z]{})](){}; // expected-error 2{{not supported}} + + int x = 4; // expected-note {{here}} + auto y = [&r = x, x = x + 1]() -> int { // expected-error 2{{not supported}} expected-note {{here}} + r += 2; // expected-error {{undeclared}} + return x + 2; // expected-error {{implicitly captured}} + } (); + } }; diff --git a/clang/test/Parser/objcxx0x-lambda-expressions.mm b/clang/test/Parser/objcxx0x-lambda-expressions.mm index fb90b16a971f..94e47ccd3e0a 100644 --- a/clang/test/Parser/objcxx0x-lambda-expressions.mm +++ b/clang/test/Parser/objcxx0x-lambda-expressions.mm @@ -17,6 +17,16 @@ class C { [foo,bar] () { return 3; }; [=,&foo] () {}; [this] () {}; + + [foo(bar)] () {}; // expected-error {{not supported}} + [foo = bar] () {}; // expected-error {{not supported}} + [foo{bar}] () {}; // expected-error {{not supported}} + [foo = {bar}] () {}; // expected-error {{not supported}} + + [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}} + + // FIXME: These are some appalling diagnostics. + [foo = bar baz]; // expected-error {{missing '['}} expected-warning 2{{receiver type 'int'}} expected-warning 2{{instance method '-baz'}} } }; -- GitLab From 37f25ae3cf7e1bd2fc131b303b2342e67384003b Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 9 May 2013 22:11:34 +0000 Subject: [PATCH 126/467] Fix some test cases I broke in r181552 llvm-svn: 181554 --- clang/test/CodeGenCXX/debug-info-template.cpp | 6 +++--- clang/test/CodeGenCXX/debug-info.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp index f68810b268de..38a99cf4c6ad 100644 --- a/clang/test/CodeGenCXX/debug-info-template.cpp +++ b/clang/test/CodeGenCXX/debug-info-template.cpp @@ -1,6 +1,5 @@ -// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s -// CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] // CHECK: metadata [[TCI:![0-9]*]], i32 0, i32 1, %class.TC* @tci, null} ; [ DW_TAG_variable ] [tci] // CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] // CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]]} @@ -8,7 +7,8 @@ // We seem to be missing file/line/col info on template value parameters - // metadata supports it but it's not populated. // -// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[INT:![0-9]*]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[INT]] = {{.*}} ; [ DW_TAG_base_type ] [int] // CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT:![0-9]*]], i64 2, {{.*}} ; [ DW_TAG_template_value_parameter ] // CHECK: [[UINT]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] diff --git a/clang/test/CodeGenCXX/debug-info.cpp b/clang/test/CodeGenCXX/debug-info.cpp index d691f97e598c..b16c564e7384 100644 --- a/clang/test/CodeGenCXX/debug-info.cpp +++ b/clang/test/CodeGenCXX/debug-info.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s template struct Identity { typedef T Type; }; -- GitLab From 32baf99b1d46570b6e34b2c1092e43abd845ef7a Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Thu, 9 May 2013 22:27:13 +0000 Subject: [PATCH 127/467] Teach SelectionDAG to constant fold all-constant FMA nodes the same way that it constant folds FADD, FMUL, etc. llvm-svn: 181555 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 15 +++++++++++++++ llvm/test/CodeGen/X86/fma.ll | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 15235c8ac307..f2c512dec7a5 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3261,6 +3261,21 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT, // Perform various simplifications. ConstantSDNode *N1C = dyn_cast(N1.getNode()); switch (Opcode) { + case ISD::FMA: { + ConstantFPSDNode *N1CFP = dyn_cast(N1); + ConstantFPSDNode *N2CFP = dyn_cast(N2); + ConstantFPSDNode *N3CFP = dyn_cast(N3); + if (N1CFP && N2CFP && N3CFP) { + APFloat V1 = N1CFP->getValueAPF(); + const APFloat &V2 = N2CFP->getValueAPF(); + const APFloat &V3 = N3CFP->getValueAPF(); + APFloat::opStatus s = + V1.fusedMultiplyAdd(V2, V3, APFloat::rmNearestTiesToEven); + if (s != APFloat::opInvalidOp) + return getConstantFP(V1, VT); + } + break; + } case ISD::CONCAT_VECTORS: // A CONCAT_VECTOR with all operands BUILD_VECTOR can be simplified to // one big BUILD_VECTOR. diff --git a/llvm/test/CodeGen/X86/fma.ll b/llvm/test/CodeGen/X86/fma.ll index bd3514cc3f73..917eac0ca32d 100644 --- a/llvm/test/CodeGen/X86/fma.ll +++ b/llvm/test/CodeGen/X86/fma.ll @@ -34,6 +34,14 @@ entry: ret x86_fp80 %call } +; CHECK: test_f32_cst +; CHECK-NOT: fma +define float @test_f32_cst() nounwind readnone ssp { +entry: + %call = tail call float @llvm.fma.f32(float 3.0, float 3.0, float 3.0) nounwind readnone + ret float %call +} + declare float @llvm.fma.f32(float, float, float) nounwind readnone declare double @llvm.fma.f64(double, double, double) nounwind readnone declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone -- GitLab From b8f6a8ab0795ac565b2d939b20ae71c1dbd6ab2d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 9 May 2013 22:43:45 +0000 Subject: [PATCH 128/467] Debug Info: include address-of ('&') operator and qualified names in template argument lists This fixes several (7 out of 16) cases of PR14492 in the GDB 7.5 test suite. It seems GDB was bailing out whenever it had even the slightest problem with the template argument list (& I assume it didn't like seeing template value parameters that were just simple names - perhaps assuming that lone names must be types, not values) llvm-svn: 181556 --- clang/lib/AST/TemplateBase.cpp | 3 ++- clang/test/CodeGenCXX/debug-info-template.cpp | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp index d68b95edb730..c3e2c4a7bba8 100644 --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -353,9 +353,10 @@ void TemplateArgument::print(const PrintingPolicy &Policy, case Declaration: { NamedDecl *ND = cast(getAsDecl()); + Out << '&'; if (ND->getDeclName()) { // FIXME: distinguish between pointer and reference args? - Out << *ND; + ND->printQualifiedName(Out); } else { Out << ""; } diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp index 38a99cf4c6ad..9bb75ffa3ba2 100644 --- a/clang/test/CodeGenCXX/debug-info-template.cpp +++ b/clang/test/CodeGenCXX/debug-info-template.cpp @@ -1,19 +1,26 @@ -// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -g %s -o - -std=c++11 | FileCheck %s +// CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] // CHECK: metadata [[TCI:![0-9]*]], i32 0, i32 1, %class.TC* @tci, null} ; [ DW_TAG_variable ] [tci] -// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] +// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] // CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]]} // // We seem to be missing file/line/col info on template value parameters - // metadata supports it but it's not populated. // -// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[INT:![0-9]*]], {{.*}} ; [ DW_TAG_template_type_parameter ] -// CHECK: [[INT]] = {{.*}} ; [ DW_TAG_base_type ] [int] +// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] // CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT:![0-9]*]], i64 2, {{.*}} ; [ DW_TAG_template_value_parameter ] // CHECK: [[UINT]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] -template +struct foo { + int e; + void f(); +}; + +template class TC { }; -TC tci; +int glb; + +TC tci; -- GitLab From 2edd9709c658e65c7bc8d3ab50e1c63857db8069 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 9 May 2013 22:45:27 +0000 Subject: [PATCH 129/467] Remove dependence on system headers from this test, to try to make the Windows bots happier. llvm-svn: 181558 --- clang/test/Headers/Inputs/include/complex.h | 3 +++ clang/test/Headers/Inputs/include/math.h | 1 + clang/test/Headers/tgmath.c | 7 ++----- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 clang/test/Headers/Inputs/include/complex.h create mode 100644 clang/test/Headers/Inputs/include/math.h diff --git a/clang/test/Headers/Inputs/include/complex.h b/clang/test/Headers/Inputs/include/complex.h new file mode 100644 index 000000000000..1ed5f53092a5 --- /dev/null +++ b/clang/test/Headers/Inputs/include/complex.h @@ -0,0 +1,3 @@ +#pragma once + +#define complex _Complex diff --git a/clang/test/Headers/Inputs/include/math.h b/clang/test/Headers/Inputs/include/math.h new file mode 100644 index 000000000000..6f70f09beec2 --- /dev/null +++ b/clang/test/Headers/Inputs/include/math.h @@ -0,0 +1 @@ +#pragma once diff --git a/clang/test/Headers/tgmath.c b/clang/test/Headers/tgmath.c index a95e33a53c44..b6694369834e 100644 --- a/clang/test/Headers/tgmath.c +++ b/clang/test/Headers/tgmath.c @@ -1,6 +1,5 @@ -// RUN: %clang -fsyntax-only %s - -#ifdef __STDC_HOSTED__ +// RUN: %clang -fsyntax-only -isystem %S/Inputs/include -Xclang -verify %s +// expected-no-diagnostics #include @@ -37,5 +36,3 @@ _Static_assert(sizeof(fabs(lc)) == sizeof(l), ""); _Static_assert(sizeof(logb(f)) == sizeof(f), ""); _Static_assert(sizeof(logb(d)) == sizeof(d), ""); _Static_assert(sizeof(logb(l)) == sizeof(l), ""); - -#endif -- GitLab From dd6a025986ac1f67f6635ff085dcd7fea9fb7789 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 9 May 2013 23:06:35 +0000 Subject: [PATCH 130/467] Don't try to free the C locale. llvm-svn: 181559 --- libcxx/src/locale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 7d0e62980ce9..97c2102c1b50 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -1393,7 +1393,7 @@ codecvt::codecvt(const char* nm, size_t refs) codecvt::~codecvt() { - if (__l != 0) + if (__l != _LIBCPP_GET_C_LOCALE) freelocale(__l); } -- GitLab From de9ce87f0368a2b0c753ecdeb7bd3738379c9c5c Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Thu, 9 May 2013 23:13:13 +0000 Subject: [PATCH 131/467] Don't completely drop methods we don't want to put into a CXXRecordDecl on the ground; rather, put them into the translation unit as functions. llvm-svn: 181560 --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index cbed4f224075..dd34a364c730 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -6302,6 +6302,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, is_variadic, type_quals); + bool ignore_containing_context = false; + if (type_name_cstr) { bool type_handled = false; @@ -6520,7 +6522,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } else { - return TypeSP(); + ignore_containing_context = true; } } } @@ -6562,7 +6564,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (!type_handled) { // We just have a function that isn't part of a class - clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (containing_decl_ctx, + clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (ignore_containing_context ? GetClangASTContext().GetTranslationUnitDecl() : containing_decl_ctx, type_name_cstr, clang_type, storage, -- GitLab From ffcf4ba947266a50a790a2ebbe3ceff0827b4d05 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 9 May 2013 23:16:27 +0000 Subject: [PATCH 132/467] Debug Info: Fix a problem that resulted in missing DW_AT_specifications for C++ constructors. If the DIType for a class was generated by CGDebugInfo::createContextChain(), the cache contains only a limited DIType wihtout any declarations. Since EmitFunctionStart() needs to find the canonical declaration for each method, we construct the complete type before emitting any method. rdar://problem/13116508 llvm-svn: 181561 --- clang/lib/CodeGen/CodeGenModule.cpp | 18 ++++++ clang/lib/CodeGen/CodeGenModule.h | 1 + .../CodeGenCXX/debug-info-decl-nested.cpp | 61 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 clang/test/CodeGenCXX/debug-info-decl-nested.cpp diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1da4e87c0a52..717ed17dd4ec 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1232,6 +1232,23 @@ CodeGenModule::shouldEmitFunction(const FunctionDecl *F) { return !isTriviallyRecursive(F); } +/// If the type for the method's class was generated by +/// CGDebugInfo::createContextChain(), the cache contains only a +/// limited DIType without any declarations. Since EmitFunctionStart() +/// needs to find the canonical declaration for each method, we need +/// to construct the complete type prior to emitting the method. +void CodeGenModule::CompleteDIClassType(const CXXMethodDecl* D) { + if (!D->isInstance()) + return; + + if (CGDebugInfo *DI = getModuleDebugInfo()) + if (getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) { + const PointerType *ThisPtr = + cast(D->getThisType(getContext())); + DI->getOrCreateRecordType(ThisPtr->getPointeeType(), D->getLocation()); + } +} + void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { const ValueDecl *D = cast(GD.getDecl()); @@ -1246,6 +1263,7 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { return; if (const CXXMethodDecl *Method = dyn_cast(D)) { + CompleteDIClassType(Method); // Make sure to emit the definition(s) before we emit the thunks. // This is necessary for the generation of certain thunks. if (const CXXConstructorDecl *CD = dyn_cast(Method)) diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 1d6c7e98e5c6..e4e29a8d6b68 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -1025,6 +1025,7 @@ private: void EmitNamespace(const NamespaceDecl *D); void EmitLinkageSpec(const LinkageSpecDecl *D); + void CompleteDIClassType(const CXXMethodDecl* D); /// EmitCXXConstructors - Emit constructors (base, complete) from a /// C++ constructor Decl. diff --git a/clang/test/CodeGenCXX/debug-info-decl-nested.cpp b/clang/test/CodeGenCXX/debug-info-decl-nested.cpp new file mode 100644 index 000000000000..7c8bd1facf2d --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-decl-nested.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -std=c++11 -g -O0 -emit-llvm -g -triple x86_64-apple-darwin %s -o %t +// RUN: cat %t | FileCheck %s -check-prefix=CHECK0 +// RUN: cat %t | FileCheck %s -check-prefix=CHECK1 +// RUN: cat %t | FileCheck %s -check-prefix=CHECK2 +// +// This test ensures that we associate a declaration with the +// definition of the constructor for OuterClass. The declaration is +// necessary so the backend can emit the DW_AT_specification attribute +// for the definition. +// +// rdar://problem/13116508 + +class Foo; +class OuterClass +{ + static class InnerClass { + public: + InnerClass(); // Here createContextChain() generates a limited type for OuterClass. + } theInnerClass; +// CHECK0: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [private] [OuterClass] + OuterClass(const Foo *); // line 10 +}; +OuterClass::InnerClass OuterClass::theInnerClass; // This toplevel decl causes InnerClass to be generated. +// CHECK0: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+1]]} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [OuterClass] +OuterClass::OuterClass(const Foo *meta) { } // line 13 + + + + + +class Foo1; +class OuterClass1 +{ + static class InnerClass1 { + public: + InnerClass1(); + } theInnerClass1; +// CHECK1: metadata {{.*}}, metadata ![[DECL:[0-9]+]], metadata {{.*}}, i32 [[@LINE+5]]} ; [ DW_TAG_subprogram ] [line [[@LINE+5]]] [def] [Bar] + void Bar(const Foo1 *); +}; +OuterClass1::InnerClass1 OuterClass1::theInnerClass1; +// CHECK1: [[DECL]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE-3]]] [private] [Bar] +void OuterClass1::Bar(const Foo1 *meta) { } + + + + + +class Foo2; +class OuterClass2 +{ + static class InnerClass2 { + public: + InnerClass2(); + } theInnerClass2; +// CHECK2: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [private] [~OuterClass2] + ~OuterClass2(); // line 10 +}; +OuterClass2::InnerClass2 OuterClass2::theInnerClass2; +// CHECK2: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+1]]} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [~OuterClass2] +OuterClass2::~OuterClass2() { } -- GitLab From d3b75560aa07b18e801bd8ef01dad09a5bab5a07 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 23:32:58 +0000 Subject: [PATCH 133/467] ArrayRef'ize Sema::BuildCallToObjectOfClassType llvm-svn: 181562 --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Sema/SemaExpr.cpp | 3 +-- clang/lib/Sema/SemaOverload.cpp | 44 ++++++++++++++------------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 0fdd8e44518f..c4dd54e934ae 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2191,7 +2191,7 @@ public: SourceLocation RParenLoc); ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + MultiExprArg Args, SourceLocation RParenLoc); ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8d76f60d395a..031a631f6c0a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4191,8 +4191,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, // Determine whether this is a call to an object (C++ [over.call.object]). if (Fn->getType()->isRecordType()) return Owned(BuildCallToObjectOfClassType(S, Fn, LParenLoc, - ArgExprs.data(), - ArgExprs.size(), RParenLoc)); + ArgExprs, RParenLoc)); if (Fn->getType() == Context.UnknownAnyTy) { ExprResult result = rebuildUnknownAnyFunction(*this, Fn); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index cfc750c529e6..3461f91ff316 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -10945,15 +10945,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, ExprResult Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + MultiExprArg Args, SourceLocation RParenLoc) { if (checkPlaceholderForOverload(*this, Obj)) return ExprError(); ExprResult Object = Owned(Obj); UnbridgedCastsSet UnbridgedCasts; - if (checkArgPlaceholdersForOverload(*this, MultiExprArg(Args, NumArgs), - UnbridgedCasts)) + if (checkArgPlaceholdersForOverload(*this, Args, UnbridgedCasts)) return ExprError(); assert(Object.get()->getType()->isRecordType() && "Requires object type argument"); @@ -10980,8 +10979,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end(); Oper != OperEnd; ++Oper) { AddMethodCandidate(Oper.getPair(), Object.get()->getType(), - Object.get()->Classify(Context), - llvm::makeArrayRef(Args, NumArgs), CandidateSet, + Object.get()->Classify(Context), + Args, CandidateSet, /*SuppressUserConversions=*/ false); } @@ -11028,8 +11027,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, if (const FunctionProtoType *Proto = ConvType->getAs()) { AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto, - Object.get(), llvm::makeArrayRef(Args, NumArgs), - CandidateSet); + Object.get(), Args, CandidateSet); } } } @@ -11054,16 +11052,14 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, Diag(Object.get()->getLocStart(), diag::err_ovl_no_viable_object_call) << Object.get()->getType() << Object.get()->getSourceRange(); - CandidateSet.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args); break; case OR_Ambiguous: Diag(Object.get()->getLocStart(), diag::err_ovl_ambiguous_object_call) << Object.get()->getType() << Object.get()->getSourceRange(); - CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args); break; case OR_Deleted: @@ -11073,8 +11069,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, << Object.get()->getType() << getDeletedOrUnavailableSuffix(Best->Function) << Object.get()->getSourceRange(); - CandidateSet.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args); break; } @@ -11109,8 +11104,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, CK_UserDefinedConversion, Call.get(), 0, VK_RValue)); - return ActOnCallExpr(S, Call.get(), LParenLoc, MultiExprArg(Args, NumArgs), - RParenLoc); + return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc); } CheckMemberOperatorAccess(LParenLoc, Object.get(), 0, Best->FoundDecl); @@ -11128,20 +11122,20 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, Method->getType()->getAs(); unsigned NumArgsInProto = Proto->getNumArgs(); - unsigned NumArgsToCheck = NumArgs; + unsigned NumArgsToCheck = Args.size(); // Build the full argument list for the method call (the // implicit object parameter is placed at the beginning of the // list). Expr **MethodArgs; - if (NumArgs < NumArgsInProto) { + if (Args.size() < NumArgsInProto) { NumArgsToCheck = NumArgsInProto; MethodArgs = new Expr*[NumArgsInProto + 1]; } else { - MethodArgs = new Expr*[NumArgs + 1]; + MethodArgs = new Expr*[Args.size() + 1]; } MethodArgs[0] = Object.get(); - for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx) + for (unsigned ArgIdx = 0, e = Args.size(); ArgIdx != e; ++ArgIdx) MethodArgs[ArgIdx + 1] = Args[ArgIdx]; DeclarationNameInfo OpLocInfo( @@ -11162,7 +11156,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, CXXOperatorCallExpr *TheCall = new (Context) CXXOperatorCallExpr(Context, OO_Call, NewFn.take(), - llvm::makeArrayRef(MethodArgs, NumArgs+1), + llvm::makeArrayRef(MethodArgs, Args.size()+1), ResultTy, VK, RParenLoc, false); delete [] MethodArgs; @@ -11172,9 +11166,9 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, // We may have default arguments. If so, we need to allocate more // slots in the call for them. - if (NumArgs < NumArgsInProto) + if (Args.size() < NumArgsInProto) TheCall->setNumArgs(Context, NumArgsInProto + 1); - else if (NumArgs > NumArgsInProto) + else if (Args.size() > NumArgsInProto) NumArgsToCheck = NumArgsInProto; bool IsError = false; @@ -11192,7 +11186,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, // Check the argument types. for (unsigned i = 0; i != NumArgsToCheck; i++) { Expr *Arg; - if (i < NumArgs) { + if (i < Args.size()) { Arg = Args[i]; // Pass the argument. @@ -11222,7 +11216,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, // If this is a variadic call, handle args passed through "...". if (Proto->isVariadic()) { // Promote the arguments (C99 6.5.2.2p7). - for (unsigned i = NumArgsInProto; i < NumArgs; i++) { + for (unsigned i = NumArgsInProto, e = Args.size(); i < e; i++) { ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod, 0); IsError |= Arg.isInvalid(); TheCall->setArg(i + 1, Arg.take()); @@ -11231,7 +11225,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, if (IsError) return true; - DiagnoseSentinelCalls(Method, LParenLoc, llvm::makeArrayRef(Args, NumArgs)); + DiagnoseSentinelCalls(Method, LParenLoc, Args); if (CheckFunctionCall(Method, TheCall, Proto)) return true; -- GitLab From 85378316bfb597efbe592a3b36b5b053229cea0f Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 23:45:53 +0000 Subject: [PATCH 134/467] ArrayRef'ize Sema::FindAllocationOverload llvm-svn: 181563 --- clang/include/clang/Sema/Sema.h | 4 ++-- clang/lib/Sema/SemaExprCXX.cpp | 39 ++++++++++++++------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index c4dd54e934ae..d68d948f2c4f 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3984,8 +3984,8 @@ public: FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete); bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, Expr** Args, - unsigned NumArgs, DeclContext *Ctx, + DeclarationName Name, MultiExprArg Args, + DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose = true); void DeclareGlobalNewDelete(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index ffe864963743..7aaa4a249f15 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1561,18 +1561,16 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, if (AllocElemType->isRecordType() && !UseGlobal) { CXXRecordDecl *Record = cast(AllocElemType->getAs()->getDecl()); - if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], - AllocArgs.size(), Record, /*AllowMissing=*/true, - OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, Record, + /*AllowMissing=*/true, OperatorNew)) return true; } if (!OperatorNew) { // Didn't find a member overload. Look for a global one. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], - AllocArgs.size(), TUDecl, /*AllowMissing=*/false, - OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, TUDecl, + /*AllowMissing=*/false, OperatorNew)) return true; } @@ -1714,8 +1712,8 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, /// FindAllocationOverload - Find an fitting overload for the allocation /// function in the specified scope. bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, Expr** Args, - unsigned NumArgs, DeclContext *Ctx, + DeclarationName Name, MultiExprArg Args, + DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose) { LookupResult R(*this, Name, StartLoc, LookupOrdinaryName); @@ -1742,15 +1740,13 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (FunctionTemplateDecl *FnTemplate = dyn_cast(D)) { AddTemplateOverloadCandidate(FnTemplate, Alloc.getPair(), /*ExplicitTemplateArgs=*/0, - llvm::makeArrayRef(Args, NumArgs), - Candidates, + Args, Candidates, /*SuppressUserConversions=*/false); continue; } FunctionDecl *Fn = cast(D); - AddOverloadCandidate(Fn, Alloc.getPair(), - llvm::makeArrayRef(Args, NumArgs), Candidates, + AddOverloadCandidate(Fn, Alloc.getPair(), Args, Candidates, /*SuppressUserConversions=*/false); } @@ -1766,7 +1762,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, // asserted on, though, since invalid decls are left in there.) // Watch out for variadic allocator function. unsigned NumArgsInFnDecl = FnDecl->getNumParams(); - for (unsigned i = 0; (i < NumArgs && i < NumArgsInFnDecl); ++i) { + for (unsigned i = 0; (i < Args.size() && i < NumArgsInFnDecl); ++i) { InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(i)); @@ -1794,8 +1790,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_no_viable_function_in_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); } return true; @@ -1803,8 +1798,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_ambiguous_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_ViableCandidates, - llvm::makeArrayRef(Args, NumArgs)); + Candidates.NoteCandidates(*this, OCD_ViableCandidates, Args); } return true; @@ -1815,8 +1809,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, << Name << getDeletedOrUnavailableSuffix(Best->Function) << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); } return true; } @@ -2051,10 +2044,9 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclContext *TUDecl = Context.getTranslationUnitDecl(); CXXNullPtrLiteralExpr Null(Context.VoidPtrTy, SourceLocation()); - Expr* DeallocArgs[1]; - DeallocArgs[0] = &Null; + Expr *DeallocArgs[1] = { &Null }; if (FindAllocationOverload(StartLoc, SourceRange(), Name, - DeallocArgs, 1, TUDecl, !Diagnose, + DeallocArgs, TUDecl, !Diagnose, Operator, Diagnose)) return true; @@ -2244,11 +2236,12 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); Expr *Arg = Ex.get(); + Expr *DeallocArgs[1] = { Arg }; if (!Context.hasSameType(Arg->getType(), Context.VoidPtrTy)) Arg = ImplicitCastExpr::Create(Context, Context.VoidPtrTy, CK_BitCast, Arg, 0, VK_RValue); if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, - &Arg, 1, TUDecl, /*AllowMissing=*/false, + DeallocArgs, TUDecl, /*AllowMissing=*/false, OperatorDelete)) return ExprError(); } -- GitLab From edb1dc8498c3e8917bdf955bd07212a1d05a2c21 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 9 May 2013 23:48:53 +0000 Subject: [PATCH 135/467] [x86AsmParser] It's valid to stop parsing an operand at an immediate. rdar://13854369 and PR15944 llvm-svn: 181564 --- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 4 +++- llvm/test/MC/X86/intel-syntax.s | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 68908abb5764..520c4c0048e2 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -219,7 +219,9 @@ private: const MCExpr *getSym() { return Sym; } StringRef getSymName() { return SymName; } int64_t getImm() { return Imm + IC.execute(); } - bool isValidEndState() { return State == IES_RBRAC; } + bool isValidEndState() { + return State == IES_RBRAC || State == IES_INTEGER; + } bool getStopOnLBrac() { return StopOnLBrac; } bool getAddImmPrefix() { return AddImmPrefix; } bool hadError() { return State == IES_ERROR; } diff --git a/llvm/test/MC/X86/intel-syntax.s b/llvm/test/MC/X86/intel-syntax.s index b2f337dac9d7..fa1ba5ba5432 100644 --- a/llvm/test/MC/X86/intel-syntax.s +++ b/llvm/test/MC/X86/intel-syntax.s @@ -322,4 +322,6 @@ _main: setnle al // CHECK: jne _foo jnz _foo +// CHECK: outb %al, $4 + out 4, al ret -- GitLab From 139474d49866a49fa1567025869e914322ff6032 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 9 May 2013 23:51:52 +0000 Subject: [PATCH 136/467] ArrayRef'ize Sema::ActOnMemInitializer llvm-svn: 181565 --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Parse/ParseDeclCXX.cpp | 5 ++--- clang/lib/Sema/SemaDeclCXX.cpp | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d68d948f2c4f..8e466385b4d2 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4467,7 +4467,7 @@ public: const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc); diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index f1fbbb15fed5..ae1ff37e6bc8 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -2809,9 +2809,8 @@ Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) { return Actions.ActOnMemInitializer(ConstructorDecl, getCurScope(), SS, II, TemplateTypeTy, DS, IdLoc, - T.getOpenLocation(), ArgExprs.data(), - ArgExprs.size(), T.getCloseLocation(), - EllipsisLoc); + T.getOpenLocation(), ArgExprs, + T.getCloseLocation(), EllipsisLoc); } Diag(Tok, getLangOpts().CPlusPlus11 ? diag::err_expected_lparen_or_lbrace diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index bece972a576f..b86a2b92779d 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2254,12 +2254,11 @@ Sema::ActOnMemInitializer(Decl *ConstructorD, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, - Expr **Args, unsigned NumArgs, + ArrayRef Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc) { Expr *List = new (Context) ParenListExpr(Context, LParenLoc, - llvm::makeArrayRef(Args, NumArgs), - RParenLoc); + Args, RParenLoc); return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy, DS, IdLoc, List, EllipsisLoc); } -- GitLab From ca2ffa7e65621f247fd1ad9d7a012b270bbd007c Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 9 May 2013 23:52:21 +0000 Subject: [PATCH 137/467] Add an explicit check for a darwin kernel KDP_VERSIONSTRING when starting a kdp communication session, instead of assuming darwin kernel for any "non-EFI" kdp session. llvm-svn: 181566 --- .../Process/MacOSX-Kernel/CommunicationKDP.cpp | 11 +++++++++++ .../Plugins/Process/MacOSX-Kernel/CommunicationKDP.h | 3 +++ .../Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index bbde8ed0709d..8340990db02a 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -544,6 +544,17 @@ CommunicationKDP::RemoteIsEFI () return false; } +bool +CommunicationKDP::RemoteIsDarwinKernel () +{ + if (GetKernelVersion() == NULL) + return false; + if (m_kernel_version.find("Darwin Kernel") != std::string::npos) + return true; + else + return false; +} + lldb::addr_t CommunicationKDP::GetLoadAddress () { diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h index 6b61f4422dde..f53b190522f3 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h @@ -233,6 +233,9 @@ public: bool RemoteIsEFI (); + bool + RemoteIsDarwinKernel (); + lldb::addr_t GetLoadAddress (); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index c78aa42da206..18007369e831 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -242,13 +242,13 @@ ProcessKDP::DoConnectRemote (Stream *strm, const char *remote_url) { m_dyld_plugin_name = DynamicLoaderStatic::GetPluginNameStatic(); } - else + else if (m_comm.RemoteIsDarwinKernel ()) { + m_dyld_plugin_name = DynamicLoaderDarwinKernel::GetPluginNameStatic(); if (kernel_load_addr != LLDB_INVALID_ADDRESS) { m_kernel_load_addr = kernel_load_addr; } - m_dyld_plugin_name = DynamicLoaderDarwinKernel::GetPluginNameStatic(); } // Set the thread ID -- GitLab From d95656e0b5f87c44aecc1504a9eb1aea384e0909 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 00:11:18 +0000 Subject: [PATCH 138/467] Revert my r181563, breaks tests on buildbots llvm-svn: 181568 --- clang/include/clang/Sema/Sema.h | 4 ++-- clang/lib/Sema/SemaExprCXX.cpp | 39 +++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 8e466385b4d2..fbc8283121c5 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3984,8 +3984,8 @@ public: FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete); bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, MultiExprArg Args, - DeclContext *Ctx, + DeclarationName Name, Expr** Args, + unsigned NumArgs, DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose = true); void DeclareGlobalNewDelete(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 7aaa4a249f15..ffe864963743 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1561,16 +1561,18 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, if (AllocElemType->isRecordType() && !UseGlobal) { CXXRecordDecl *Record = cast(AllocElemType->getAs()->getDecl()); - if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, Record, - /*AllowMissing=*/true, OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], + AllocArgs.size(), Record, /*AllowMissing=*/true, + OperatorNew)) return true; } if (!OperatorNew) { // Didn't find a member overload. Look for a global one. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, TUDecl, - /*AllowMissing=*/false, OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], + AllocArgs.size(), TUDecl, /*AllowMissing=*/false, + OperatorNew)) return true; } @@ -1712,8 +1714,8 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, /// FindAllocationOverload - Find an fitting overload for the allocation /// function in the specified scope. bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, MultiExprArg Args, - DeclContext *Ctx, + DeclarationName Name, Expr** Args, + unsigned NumArgs, DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose) { LookupResult R(*this, Name, StartLoc, LookupOrdinaryName); @@ -1740,13 +1742,15 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (FunctionTemplateDecl *FnTemplate = dyn_cast(D)) { AddTemplateOverloadCandidate(FnTemplate, Alloc.getPair(), /*ExplicitTemplateArgs=*/0, - Args, Candidates, + llvm::makeArrayRef(Args, NumArgs), + Candidates, /*SuppressUserConversions=*/false); continue; } FunctionDecl *Fn = cast(D); - AddOverloadCandidate(Fn, Alloc.getPair(), Args, Candidates, + AddOverloadCandidate(Fn, Alloc.getPair(), + llvm::makeArrayRef(Args, NumArgs), Candidates, /*SuppressUserConversions=*/false); } @@ -1762,7 +1766,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, // asserted on, though, since invalid decls are left in there.) // Watch out for variadic allocator function. unsigned NumArgsInFnDecl = FnDecl->getNumParams(); - for (unsigned i = 0; (i < Args.size() && i < NumArgsInFnDecl); ++i) { + for (unsigned i = 0; (i < NumArgs && i < NumArgsInFnDecl); ++i) { InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(i)); @@ -1790,7 +1794,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_no_viable_function_in_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); + Candidates.NoteCandidates(*this, OCD_AllCandidates, + llvm::makeArrayRef(Args, NumArgs)); } return true; @@ -1798,7 +1803,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_ambiguous_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_ViableCandidates, Args); + Candidates.NoteCandidates(*this, OCD_ViableCandidates, + llvm::makeArrayRef(Args, NumArgs)); } return true; @@ -1809,7 +1815,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, << Name << getDeletedOrUnavailableSuffix(Best->Function) << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); + Candidates.NoteCandidates(*this, OCD_AllCandidates, + llvm::makeArrayRef(Args, NumArgs)); } return true; } @@ -2044,9 +2051,10 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclContext *TUDecl = Context.getTranslationUnitDecl(); CXXNullPtrLiteralExpr Null(Context.VoidPtrTy, SourceLocation()); - Expr *DeallocArgs[1] = { &Null }; + Expr* DeallocArgs[1]; + DeallocArgs[0] = &Null; if (FindAllocationOverload(StartLoc, SourceRange(), Name, - DeallocArgs, TUDecl, !Diagnose, + DeallocArgs, 1, TUDecl, !Diagnose, Operator, Diagnose)) return true; @@ -2236,12 +2244,11 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); Expr *Arg = Ex.get(); - Expr *DeallocArgs[1] = { Arg }; if (!Context.hasSameType(Arg->getType(), Context.VoidPtrTy)) Arg = ImplicitCastExpr::Create(Context, Context.VoidPtrTy, CK_BitCast, Arg, 0, VK_RValue); if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, - DeallocArgs, TUDecl, /*AllowMissing=*/false, + &Arg, 1, TUDecl, /*AllowMissing=*/false, OperatorDelete)) return ExprError(); } -- GitLab From fce85ba455fc87df85e048588506b38fa436eb63 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Fri, 10 May 2013 00:16:10 +0000 Subject: [PATCH 139/467] Fix incorrect type usage; nice catch by Sebastian llvm-svn: 181569 --- libcxx/include/algorithm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index f7e26cfeaa34..703a9b3dce1a 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -1301,7 +1301,7 @@ __not_done: _D1 __l1 = _VSTD::distance(__first1, __last1); typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2; - _D1 __l2 = _VSTD::distance(__first2, __last2); + _D2 __l2 = _VSTD::distance(__first2, __last2); if (__l1 != __l2) return false; -- GitLab From 08c8668dbdc32bc4e09b9982099ac516b634ccbf Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 00:20:06 +0000 Subject: [PATCH 140/467] ArrayRef'ize Sema::FindAllocationOverload Now tests should pass. The previous error was caused by a misplaced backing array for MutableArrayRef that I introduced. llvm-svn: 181570 --- clang/include/clang/Sema/Sema.h | 4 ++-- clang/lib/Sema/SemaExprCXX.cpp | 39 ++++++++++++++------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index fbc8283121c5..8e466385b4d2 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3984,8 +3984,8 @@ public: FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete); bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, Expr** Args, - unsigned NumArgs, DeclContext *Ctx, + DeclarationName Name, MultiExprArg Args, + DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose = true); void DeclareGlobalNewDelete(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index ffe864963743..be5c00b8b947 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1561,18 +1561,16 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, if (AllocElemType->isRecordType() && !UseGlobal) { CXXRecordDecl *Record = cast(AllocElemType->getAs()->getDecl()); - if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], - AllocArgs.size(), Record, /*AllowMissing=*/true, - OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, Record, + /*AllowMissing=*/true, OperatorNew)) return true; } if (!OperatorNew) { // Didn't find a member overload. Look for a global one. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], - AllocArgs.size(), TUDecl, /*AllowMissing=*/false, - OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, TUDecl, + /*AllowMissing=*/false, OperatorNew)) return true; } @@ -1714,8 +1712,8 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, /// FindAllocationOverload - Find an fitting overload for the allocation /// function in the specified scope. bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, Expr** Args, - unsigned NumArgs, DeclContext *Ctx, + DeclarationName Name, MultiExprArg Args, + DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose) { LookupResult R(*this, Name, StartLoc, LookupOrdinaryName); @@ -1742,15 +1740,13 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (FunctionTemplateDecl *FnTemplate = dyn_cast(D)) { AddTemplateOverloadCandidate(FnTemplate, Alloc.getPair(), /*ExplicitTemplateArgs=*/0, - llvm::makeArrayRef(Args, NumArgs), - Candidates, + Args, Candidates, /*SuppressUserConversions=*/false); continue; } FunctionDecl *Fn = cast(D); - AddOverloadCandidate(Fn, Alloc.getPair(), - llvm::makeArrayRef(Args, NumArgs), Candidates, + AddOverloadCandidate(Fn, Alloc.getPair(), Args, Candidates, /*SuppressUserConversions=*/false); } @@ -1766,7 +1762,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, // asserted on, though, since invalid decls are left in there.) // Watch out for variadic allocator function. unsigned NumArgsInFnDecl = FnDecl->getNumParams(); - for (unsigned i = 0; (i < NumArgs && i < NumArgsInFnDecl); ++i) { + for (unsigned i = 0; (i < Args.size() && i < NumArgsInFnDecl); ++i) { InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(i)); @@ -1794,8 +1790,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_no_viable_function_in_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); } return true; @@ -1803,8 +1798,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_ambiguous_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_ViableCandidates, - llvm::makeArrayRef(Args, NumArgs)); + Candidates.NoteCandidates(*this, OCD_ViableCandidates, Args); } return true; @@ -1815,8 +1809,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, << Name << getDeletedOrUnavailableSuffix(Best->Function) << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, - llvm::makeArrayRef(Args, NumArgs)); + Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); } return true; } @@ -2051,10 +2044,9 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclContext *TUDecl = Context.getTranslationUnitDecl(); CXXNullPtrLiteralExpr Null(Context.VoidPtrTy, SourceLocation()); - Expr* DeallocArgs[1]; - DeallocArgs[0] = &Null; + Expr *DeallocArgs[1] = { &Null }; if (FindAllocationOverload(StartLoc, SourceRange(), Name, - DeallocArgs, 1, TUDecl, !Diagnose, + DeallocArgs, TUDecl, !Diagnose, Operator, Diagnose)) return true; @@ -2247,8 +2239,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, if (!Context.hasSameType(Arg->getType(), Context.VoidPtrTy)) Arg = ImplicitCastExpr::Create(Context, Context.VoidPtrTy, CK_BitCast, Arg, 0, VK_RValue); + Expr *DeallocArgs[1] = { Arg }; if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, - &Arg, 1, TUDecl, /*AllowMissing=*/false, + DeallocArgs, TUDecl, /*AllowMissing=*/false, OperatorDelete)) return ExprError(); } -- GitLab From 2a40f0848e5d27a8e3f58fdd94853bff2d61d259 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 00:27:15 +0000 Subject: [PATCH 141/467] ArrayRef'ize Sema::CheckMessageArgumentTypes llvm-svn: 181571 --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Sema/SemaExprObjC.cpp | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 8e466385b4d2..618574207dec 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -7111,7 +7111,7 @@ public: /// \param [out] ReturnType - The return type of the send. /// \return true iff there were any incompatible types. bool CheckMessageArgumentTypes(QualType ReceiverType, - Expr **Args, unsigned NumArgs, Selector Sel, + MultiExprArg Args, Selector Sel, ArrayRef SelectorLocs, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage, diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index cbe12e468960..0e3dc003ab12 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -1184,8 +1184,8 @@ void Sema::EmitRelatedResultTypeNote(const Expr *E) { } bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, - Expr **Args, unsigned NumArgs, - Selector Sel, + MultiExprArg Args, + Selector Sel, ArrayRef SelectorLocs, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage, @@ -1199,7 +1199,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, if (!Method) { // Apply default argument promotion as for (C99 6.5.2.2p6). - for (unsigned i = 0; i != NumArgs; i++) { + for (unsigned i = 0, e = Args.size(); i != e; i++) { if (Args[i]->isTypeDependent()) continue; @@ -1247,9 +1247,9 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, if (Method->param_size() > Sel.getNumArgs()) NumNamedArgs = Method->param_size(); // FIXME. This need be cleaned up. - if (NumArgs < NumNamedArgs) { + if (Args.size() < NumNamedArgs) { Diag(SelLoc, diag::err_typecheck_call_too_few_args) - << 2 << NumNamedArgs << NumArgs; + << 2 << NumNamedArgs << static_cast(Args.size()); return false; } @@ -1302,7 +1302,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, // Promote additional arguments to variadic methods. if (Method->isVariadic()) { - for (unsigned i = NumNamedArgs; i < NumArgs; ++i) { + for (unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) { if (Args[i]->isTypeDependent()) continue; @@ -1313,21 +1313,22 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, } } else { // Check for extra arguments to non-variadic methods. - if (NumArgs != NumNamedArgs) { + if (Args.size() != NumNamedArgs) { Diag(Args[NumNamedArgs]->getLocStart(), diag::err_typecheck_call_too_many_args) - << 2 /*method*/ << NumNamedArgs << NumArgs + << 2 /*method*/ << NumNamedArgs << static_cast(Args.size()) << Method->getSourceRange() << SourceRange(Args[NumNamedArgs]->getLocStart(), - Args[NumArgs-1]->getLocEnd()); + Args.back()->getLocEnd()); } } - DiagnoseSentinelCalls(Method, SelLoc, llvm::makeArrayRef(Args, NumArgs)); + DiagnoseSentinelCalls(Method, SelLoc, Args); // Do additional checkings on method. - IsError |= CheckObjCMethodCall(Method, SelLoc, - llvm::makeArrayRef(Args, NumArgs)); + IsError |= CheckObjCMethodCall( + Method, SelLoc, + llvm::makeArrayRef(Args.data(), Args.size())); return IsError; } @@ -2065,7 +2066,8 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, unsigned NumArgs = ArgsIn.size(); Expr **Args = ArgsIn.data(); - if (CheckMessageArgumentTypes(ReceiverType, Args, NumArgs, Sel, SelectorLocs, + if (CheckMessageArgumentTypes(ReceiverType, MultiExprArg(Args, NumArgs), + Sel, SelectorLocs, Method, true, SuperLoc.isValid(), LBracLoc, RBracLoc, ReturnType, VK)) @@ -2410,8 +2412,8 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, ExprValueKind VK = VK_RValue; bool ClassMessage = (ReceiverType->isObjCClassType() || ReceiverType->isObjCQualifiedClassType()); - if (CheckMessageArgumentTypes(ReceiverType, Args, NumArgs, Sel, - SelectorLocs, Method, + if (CheckMessageArgumentTypes(ReceiverType, MultiExprArg(Args, NumArgs), + Sel, SelectorLocs, Method, ClassMessage, SuperLoc.isValid(), LBracLoc, RBracLoc, ReturnType, VK)) return ExprError(); -- GitLab From 674eaa2c88daee6ce45b904234b53f191dd75a68 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 00:43:44 +0000 Subject: [PATCH 142/467] ArrayRef'ize ShuffleVectorExpr::setExprs But ShuffleVectorExpr should be tail-allocating the storage for expressions. llvm-svn: 181572 --- clang/include/clang/AST/Expr.h | 2 +- clang/lib/AST/Expr.cpp | 7 +++---- clang/lib/Serialization/ASTReaderStmt.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 4ff1257b7dc8..9509456839c4 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -3450,7 +3450,7 @@ public: return cast(SubExprs[Index]); } - void setExprs(ASTContext &C, Expr ** Exprs, unsigned NumExprs); + void setExprs(ASTContext &C, ArrayRef Exprs); unsigned getShuffleMaskIdx(ASTContext &Ctx, unsigned N) const { assert((N < NumExprs - 2) && "Shuffle idx out of range!"); diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 9538ddf9416c..545d5fe28c8a 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3565,13 +3565,12 @@ ShuffleVectorExpr::ShuffleVectorExpr(ASTContext &C, ArrayRef args, } } -void ShuffleVectorExpr::setExprs(ASTContext &C, Expr ** Exprs, - unsigned NumExprs) { +void ShuffleVectorExpr::setExprs(ASTContext &C, ArrayRef Exprs) { if (SubExprs) C.Deallocate(SubExprs); SubExprs = new (C) Stmt* [NumExprs]; - this->NumExprs = NumExprs; - memcpy(SubExprs, Exprs, sizeof(Expr *) * NumExprs); + this->NumExprs = Exprs.size(); + memcpy(SubExprs, Exprs.data(), sizeof(Expr *) * Exprs.size()); } GenericSelectionExpr::GenericSelectionExpr(ASTContext &Context, diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index e1357ba5e696..04fc2bde2ec1 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -847,7 +847,7 @@ void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { unsigned NumExprs = Record[Idx++]; while (NumExprs--) Exprs.push_back(Reader.ReadSubExpr()); - E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size()); + E->setExprs(Reader.getContext(), Exprs); E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); E->setRParenLoc(ReadSourceLocation(Record, Idx)); } -- GitLab From eb6b6e48578578f0bf07f7fffb0c4c0baab8b429 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 10 May 2013 00:50:33 +0000 Subject: [PATCH 143/467] [lld] Fix broken test. -layout-pass option does not exist. Also shuffle the atoms so that it can verify the layout pass actually changed the layout. llvm-svn: 181573 --- lld/test/layoutafter-test.objtxt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lld/test/layoutafter-test.objtxt b/lld/test/layoutafter-test.objtxt index 7d5ca3ac5d63..58c7d0a9674e 100644 --- a/lld/test/layoutafter-test.objtxt +++ b/lld/test/layoutafter-test.objtxt @@ -1,27 +1,27 @@ -# RUN: lld -core -layout-pass=true %s | FileCheck %s -check-prefix=CHKORDER +# RUN: lld -core --add-pass layout %s | FileCheck %s -check-prefix=CHKORDER --- defined-atoms: - - name: fn + - name: fn3 + scope: global + - name: fn2 scope: global references: - kind: layout-after offset: 0 - target: fn1 - - name: fn1 + target: fn3 + - name: fn scope: global references: - kind: layout-after offset: 0 - target: fn2 - - name: fn2 + target: fn1 + - name: fn1 scope: global references: - kind: layout-after offset: 0 - target: fn3 - - name: fn3 - scope: global + target: fn2 ... # CHKORDER: - name: fn -- GitLab From ea2d5f818b0573255740a80b42605999b28eefea Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 01:14:26 +0000 Subject: [PATCH 144/467] Remove redundant variable llvm-svn: 181574 --- clang/lib/Sema/SemaStmtAsm.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index fce95bebd1a9..1b8747621947 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -77,13 +77,12 @@ static bool isOperandMentioned(unsigned OpNo, StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, - MultiExprArg constraints, MultiExprArg exprs, + MultiExprArg constraints, MultiExprArg Exprs, Expr *asmString, MultiExprArg clobbers, SourceLocation RParenLoc) { unsigned NumClobbers = clobbers.size(); StringLiteral **Constraints = reinterpret_cast(constraints.data()); - Expr **Exprs = exprs.data(); StringLiteral *AsmString = cast(asmString); StringLiteral **Clobbers = reinterpret_cast(clobbers.data()); @@ -204,8 +203,8 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, GCCAsmStmt *NS = new (Context) GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, - NumInputs, Names, Constraints, Exprs, AsmString, - NumClobbers, Clobbers, RParenLoc); + NumInputs, Names, Constraints, Exprs.data(), + AsmString, NumClobbers, Clobbers, RParenLoc); // Validate the asm string, ensuring it makes sense given the operands we // have. SmallVector Pieces; -- GitLab From 1c7455f42ff8f51e09477fbfa763f56fd3a85a65 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 10 May 2013 01:28:51 +0000 Subject: [PATCH 145/467] [libclang] When parsing with CXTranslationUnit_ForSerialization, make sure to install the ASTWriter that we create as an ASTMutationListener. Fixes rdar://13833268 llvm-svn: 181575 --- clang/include/clang/Frontend/ASTUnit.h | 1 + clang/lib/Frontend/ASTUnit.cpp | 10 ++++++++++ clang/test/Index/pch-with-module.m | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 clang/test/Index/pch-with-module.m diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index 02c57d7472a5..9bd0ef31e09b 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -471,6 +471,7 @@ public: return OriginalSourceFile; } + ASTMutationListener *getASTMutationListener(); ASTDeserializationListener *getDeserializationListener(); /// \brief Add a temporary file that the ASTUnit depends on. diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index f05d7225465c..7850dc697be4 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -638,6 +638,12 @@ void StoredDiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level Level, StoredDiags.push_back(StoredDiagnostic(Level, Info)); } +ASTMutationListener *ASTUnit::getASTMutationListener() { + if (WriterData) + return &WriterData->Writer; + return 0; +} + ASTDeserializationListener *ASTUnit::getDeserializationListener() { if (WriterData) return &WriterData->Writer; @@ -929,6 +935,10 @@ public: handleTopLevelDecl(*it); } + virtual ASTMutationListener *GetASTMutationListener() { + return Unit.getASTMutationListener(); + } + virtual ASTDeserializationListener *GetASTDeserializationListener() { return Unit.getDeserializationListener(); } diff --git a/clang/test/Index/pch-with-module.m b/clang/test/Index/pch-with-module.m new file mode 100644 index 000000000000..e839c811dab6 --- /dev/null +++ b/clang/test/Index/pch-with-module.m @@ -0,0 +1,23 @@ +// RUN: rm -rf %t.cache +// RUN: c-index-test -write-pch %t.h.pch %s -target x86_64-apple-macosx10.7 -fobjc-arc -fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs -Xclang -fdisable-module-hash +// RUN: %clang -fsyntax-only %s -target x86_64-apple-macosx10.7 -include %t.h -fobjc-arc -fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs \ +// RUN: -Xclang -fdisable-module-hash -Xclang -detailed-preprocessing-record -Xclang -verify + +// expected-no-diagnostics + +#ifndef PCH_HEADER +#define PCH_HEADER + +#include + +@interface Module(PCHCat) +-(id)PCH_meth; +@end + +#else + +void foo(Module *m) { + [m PCH_meth]; +} + +#endif -- GitLab From a99c6ae47a72aa7ec836fd7569c17e189ebcda02 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 10 May 2013 02:09:24 +0000 Subject: [PATCH 146/467] R600: Expand vselect for v4i32 and v2i32 v2: Add vselect v4i32 test Patch by: Aaron Watry Reviewed-by: Tom Stellard Signed-off-by: Aaron Watry NOTE: This is a candidate for the 3.3 branch. llvm-svn: 181576 --- llvm/lib/Target/R600/R600ISelLowering.cpp | 3 +++ llvm/test/CodeGen/R600/vselect.ll | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 llvm/test/CodeGen/R600/vselect.ll diff --git a/llvm/lib/Target/R600/R600ISelLowering.cpp b/llvm/lib/Target/R600/R600ISelLowering.cpp index c6e2136ff48c..6dec4d1dbe36 100644 --- a/llvm/lib/Target/R600/R600ISelLowering.cpp +++ b/llvm/lib/Target/R600/R600ISelLowering.cpp @@ -78,6 +78,9 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) : setOperationAction(ISD::SELECT, MVT::i32, Custom); setOperationAction(ISD::SELECT, MVT::f32, Custom); + setOperationAction(ISD::VSELECT, MVT::v4i32, Expand); + setOperationAction(ISD::VSELECT, MVT::v2i32, Expand); + // Legalize loads and stores to the private address space. setOperationAction(ISD::LOAD, MVT::i32, Custom); setOperationAction(ISD::LOAD, MVT::v2i32, Custom); diff --git a/llvm/test/CodeGen/R600/vselect.ll b/llvm/test/CodeGen/R600/vselect.ll new file mode 100644 index 000000000000..6e459df847e7 --- /dev/null +++ b/llvm/test/CodeGen/R600/vselect.ll @@ -0,0 +1,17 @@ +;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s + +; CHECK: @test_select_v4i32 +; CHECK: CNDE_INT T{{[0-9]+\.[XYZW], PV\.[xyzw], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +; CHECK: CNDE_INT * T{{[0-9]+\.[XYZW], PV\.[xyzw], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +; CHECK: CNDE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +; CHECK: CNDE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} + +define void @test_select_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in0, <4 x i32> addrspace(1)* %in1) { +entry: + %0 = load <4 x i32> addrspace(1)* %in0 + %1 = load <4 x i32> addrspace(1)* %in1 + %cmp = icmp ne <4 x i32> %0, %1 + %result = select <4 x i1> %cmp, <4 x i32> %0, <4 x i32> %1 + store <4 x i32> %result, <4 x i32> addrspace(1)* %out + ret void +} -- GitLab From 7fb3963498363f78b30d65e07014e9690a7b1059 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 10 May 2013 02:09:29 +0000 Subject: [PATCH 147/467] R600: Expand SRA for v4i32/v2i32 v2: Add v4i32 test Patch by: Aaron Watry Reviewed-by: Tom Stellard Signed-off-by: Aaron Watry NOTE: This is a candidate for the 3.3 branch. llvm-svn: 181577 --- llvm/lib/Target/R600/R600ISelLowering.cpp | 2 ++ llvm/test/CodeGen/R600/sra.ll | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 llvm/test/CodeGen/R600/sra.ll diff --git a/llvm/lib/Target/R600/R600ISelLowering.cpp b/llvm/lib/Target/R600/R600ISelLowering.cpp index 6dec4d1dbe36..ac56ed86438f 100644 --- a/llvm/lib/Target/R600/R600ISelLowering.cpp +++ b/llvm/lib/Target/R600/R600ISelLowering.cpp @@ -50,6 +50,8 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) : setOperationAction(ISD::SHL, MVT::v2i32, Expand); setOperationAction(ISD::SRL, MVT::v4i32, Expand); setOperationAction(ISD::SRL, MVT::v2i32, Expand); + setOperationAction(ISD::SRA, MVT::v4i32, Expand); + setOperationAction(ISD::SRA, MVT::v2i32, Expand); setOperationAction(ISD::UINT_TO_FP, MVT::v4i32, Expand); setOperationAction(ISD::UDIV, MVT::v4i32, Expand); setOperationAction(ISD::UREM, MVT::v4i32, Expand); diff --git a/llvm/test/CodeGen/R600/sra.ll b/llvm/test/CodeGen/R600/sra.ll new file mode 100644 index 000000000000..972542d346f4 --- /dev/null +++ b/llvm/test/CodeGen/R600/sra.ll @@ -0,0 +1,13 @@ +; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s + +; CHECK: @ashr_v4i32 +; CHECK: ASHR * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +; CHECK: ASHR * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +; CHECK: ASHR * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +; CHECK: ASHR * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} + +define void @ashr_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> %a, <4 x i32> %b) { + %result = ashr <4 x i32> %a, %b + store <4 x i32> %result, <4 x i32> addrspace(1)* %out + ret void +} -- GitLab From 3deddc507982fe279a9d8769ebf544484b5c9b55 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 10 May 2013 02:09:34 +0000 Subject: [PATCH 148/467] R600: Expand MUL for v4i32/v2i32 Fixes piglit test for OpenCL builtin mul24, and allows mad24 to run. Patch by: Aaron Watry Reviewed-by: Tom Stellard Signed-off-by: Aaron Watry NOTE: This is a candidate for the 3.3 branch. llvm-svn: 181578 --- llvm/lib/Target/R600/R600ISelLowering.cpp | 2 ++ llvm/test/CodeGen/R600/mul.ll | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 llvm/test/CodeGen/R600/mul.ll diff --git a/llvm/lib/Target/R600/R600ISelLowering.cpp b/llvm/lib/Target/R600/R600ISelLowering.cpp index ac56ed86438f..b9822799e76d 100644 --- a/llvm/lib/Target/R600/R600ISelLowering.cpp +++ b/llvm/lib/Target/R600/R600ISelLowering.cpp @@ -43,6 +43,8 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) : setOperationAction(ISD::AND, MVT::v4i32, Expand); setOperationAction(ISD::FP_TO_SINT, MVT::v4i32, Expand); setOperationAction(ISD::FP_TO_UINT, MVT::v4i32, Expand); + setOperationAction(ISD::MUL, MVT::v2i32, Expand); + setOperationAction(ISD::MUL, MVT::v4i32, Expand); setOperationAction(ISD::OR, MVT::v4i32, Expand); setOperationAction(ISD::OR, MVT::v2i32, Expand); setOperationAction(ISD::SINT_TO_FP, MVT::v4i32, Expand); diff --git a/llvm/test/CodeGen/R600/mul.ll b/llvm/test/CodeGen/R600/mul.ll new file mode 100644 index 000000000000..7278e9039840 --- /dev/null +++ b/llvm/test/CodeGen/R600/mul.ll @@ -0,0 +1,16 @@ +;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s + +; mul24 and mad24 are affected +;CHECK: MULLO_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +;CHECK: MULLO_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +;CHECK: MULLO_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +;CHECK: MULLO_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} + +define void @test(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) { + %b_ptr = getelementptr <4 x i32> addrspace(1)* %in, i32 1 + %a = load <4 x i32> addrspace(1) * %in + %b = load <4 x i32> addrspace(1) * %b_ptr + %result = mul <4 x i32> %a, %b + store <4 x i32> %result, <4 x i32> addrspace(1)* %out + ret void +} -- GitLab From 3a7c34c7784d452e3baec9c5c3deb81ac1f69a66 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 10 May 2013 02:09:39 +0000 Subject: [PATCH 149/467] R600: Expand SUB for v2i32/v4i32 Patch by: Aaron Watry Reviewed-by: Tom Stellard Signed-off-by: Aaron Watry NOTE: This is a candidate for the 3.3 branch. llvm-svn: 181579 --- llvm/lib/Target/R600/R600ISelLowering.cpp | 2 ++ llvm/test/CodeGen/R600/sub.ll | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 llvm/test/CodeGen/R600/sub.ll diff --git a/llvm/lib/Target/R600/R600ISelLowering.cpp b/llvm/lib/Target/R600/R600ISelLowering.cpp index b9822799e76d..7252235d5ba0 100644 --- a/llvm/lib/Target/R600/R600ISelLowering.cpp +++ b/llvm/lib/Target/R600/R600ISelLowering.cpp @@ -54,6 +54,8 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) : setOperationAction(ISD::SRL, MVT::v2i32, Expand); setOperationAction(ISD::SRA, MVT::v4i32, Expand); setOperationAction(ISD::SRA, MVT::v2i32, Expand); + setOperationAction(ISD::SUB, MVT::v4i32, Expand); + setOperationAction(ISD::SUB, MVT::v2i32, Expand); setOperationAction(ISD::UINT_TO_FP, MVT::v4i32, Expand); setOperationAction(ISD::UDIV, MVT::v4i32, Expand); setOperationAction(ISD::UREM, MVT::v4i32, Expand); diff --git a/llvm/test/CodeGen/R600/sub.ll b/llvm/test/CodeGen/R600/sub.ll new file mode 100644 index 000000000000..12bfba39753e --- /dev/null +++ b/llvm/test/CodeGen/R600/sub.ll @@ -0,0 +1,15 @@ +;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s + +;CHECK: SUB_INT T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +;CHECK: SUB_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +;CHECK: SUB_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} +;CHECK: SUB_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} + +define void @test(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) { + %b_ptr = getelementptr <4 x i32> addrspace(1)* %in, i32 1 + %a = load <4 x i32> addrspace(1) * %in + %b = load <4 x i32> addrspace(1) * %b_ptr + %result = sub <4 x i32> %a, %b + store <4 x i32> %result, <4 x i32> addrspace(1)* %out + ret void +} -- GitLab From 2b971eb0d08f4355eca46dc094e7e03937532806 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 10 May 2013 02:09:45 +0000 Subject: [PATCH 150/467] R600: Remove AMDILPeeopholeOptimizer and replace optimizations with tablegen patterns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The BFE optimization was the only one we were actually using, and it was emitting an intrinsic that we don't support. https://bugs.freedesktop.org/show_bug.cgi?id=64201 Reviewed-by: Christian König NOTE: This is a candidate for the 3.3 branch. llvm-svn: 181580 --- llvm/lib/Target/R600/AMDGPUInstructions.td | 11 + llvm/lib/Target/R600/AMDGPUTargetMachine.cpp | 1 - .../Target/R600/AMDILPeepholeOptimizer.cpp | 1215 ----------------- llvm/lib/Target/R600/CMakeLists.txt | 1 - llvm/lib/Target/R600/R600Instructions.td | 1 + llvm/test/CodeGen/R600/bfe_uint.ll | 26 + 6 files changed, 38 insertions(+), 1217 deletions(-) delete mode 100644 llvm/lib/Target/R600/AMDILPeepholeOptimizer.cpp create mode 100644 llvm/test/CodeGen/R600/bfe_uint.ll diff --git a/llvm/lib/Target/R600/AMDGPUInstructions.td b/llvm/lib/Target/R600/AMDGPUInstructions.td index b44d2482d5e3..d2620b2877a5 100644 --- a/llvm/lib/Target/R600/AMDGPUInstructions.td +++ b/llvm/lib/Target/R600/AMDGPUInstructions.td @@ -284,6 +284,17 @@ class SHA256MaPattern : Pat < (BFI_INT (XOR i32:$x, i32:$y), i32:$z, i32:$y) >; +// Bitfield extract patterns + +def legalshift32 : ImmLeaf =0 && Imm < 32;}]>; +def bfemask : PatLeaf <(imm), [{return isMask_32(N->getZExtValue());}], + SDNodeXFormgetTargetConstant(CountTrailingOnes_32(N->getZExtValue()), MVT::i32);}]>>; + +class BFEPattern : Pat < + (and (srl i32:$x, legalshift32:$y), bfemask:$z), + (BFE $x, $y, $z) +>; + include "R600Instructions.td" include "SIInstrInfo.td" diff --git a/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp b/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp index 0ec67ce13b3a..31fbf32d0c9a 100644 --- a/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp @@ -115,7 +115,6 @@ AMDGPUPassConfig::addPreISel() { } bool AMDGPUPassConfig::addInstSelector() { - addPass(createAMDGPUPeepholeOpt(*TM)); addPass(createAMDGPUISelDag(getAMDGPUTargetMachine())); const AMDGPUSubtarget &ST = TM->getSubtarget(); diff --git a/llvm/lib/Target/R600/AMDILPeepholeOptimizer.cpp b/llvm/lib/Target/R600/AMDILPeepholeOptimizer.cpp deleted file mode 100644 index 3a28038666f7..000000000000 --- a/llvm/lib/Target/R600/AMDILPeepholeOptimizer.cpp +++ /dev/null @@ -1,1215 +0,0 @@ -//===-- AMDILPeepholeOptimizer.cpp - AMDGPU Peephole optimizations ---------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -/// \file -//==-----------------------------------------------------------------------===// - -#define DEBUG_TYPE "PeepholeOpt" -#ifdef DEBUG -#define DEBUGME (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) -#else -#define DEBUGME 0 -#endif - -#include "AMDILDevices.h" -#include "AMDGPUInstrInfo.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/Twine.h" -#include "llvm/IR/Constants.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineFunctionAnalysis.h" -#include "llvm/IR/Function.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/Module.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/MathExtras.h" - -#include - -#if 0 -STATISTIC(PointerAssignments, "Number of dynamic pointer " - "assigments discovered"); -STATISTIC(PointerSubtract, "Number of pointer subtractions discovered"); -#endif - -using namespace llvm; -// The Peephole optimization pass is used to do simple last minute optimizations -// that are required for correct code or to remove redundant functions -namespace { - -class OpaqueType; - -class LLVM_LIBRARY_VISIBILITY AMDGPUPeepholeOpt : public FunctionPass { -public: - TargetMachine &TM; - static char ID; - AMDGPUPeepholeOpt(TargetMachine &tm); - ~AMDGPUPeepholeOpt(); - const char *getPassName() const; - bool runOnFunction(Function &F); - bool doInitialization(Module &M); - bool doFinalization(Module &M); - void getAnalysisUsage(AnalysisUsage &AU) const; -protected: -private: - // Function to initiate all of the instruction level optimizations. - bool instLevelOptimizations(BasicBlock::iterator *inst); - // Quick check to see if we need to dump all of the pointers into the - // arena. If this is correct, then we set all pointers to exist in arena. This - // is a workaround for aliasing of pointers in a struct/union. - bool dumpAllIntoArena(Function &F); - // Because I don't want to invalidate any pointers while in the - // safeNestedForEachFunction. I push atomic conversions to a vector and handle - // it later. This function does the conversions if required. - void doAtomicConversionIfNeeded(Function &F); - // Because __amdil_is_constant cannot be properly evaluated if - // optimizations are disabled, the call's are placed in a vector - // and evaluated after the __amdil_image* functions are evaluated - // which should allow the __amdil_is_constant function to be - // evaluated correctly. - void doIsConstCallConversionIfNeeded(); - bool mChanged; - bool mDebug; - bool mConvertAtomics; - CodeGenOpt::Level optLevel; - // Run a series of tests to see if we can optimize a CALL instruction. - bool optimizeCallInst(BasicBlock::iterator *bbb); - // A peephole optimization to optimize bit extract sequences. - bool optimizeBitExtract(Instruction *inst); - // A peephole optimization to optimize bit insert sequences. - bool optimizeBitInsert(Instruction *inst); - bool setupBitInsert(Instruction *base, - Instruction *&src, - Constant *&mask, - Constant *&shift); - // Expand the bit field insert instruction on versions of OpenCL that - // don't support it. - bool expandBFI(CallInst *CI); - // Expand the bit field mask instruction on version of OpenCL that - // don't support it. - bool expandBFM(CallInst *CI); - // On 7XX and 8XX operations, we do not have 24 bit signed operations. So in - // this case we need to expand them. These functions check for 24bit functions - // and then expand. - bool isSigned24BitOps(CallInst *CI); - void expandSigned24BitOps(CallInst *CI); - // One optimization that can occur is that if the required workgroup size is - // specified then the result of get_local_size is known at compile time and - // can be returned accordingly. - bool isRWGLocalOpt(CallInst *CI); - // On northern island cards, the division is slightly less accurate than on - // previous generations, so we need to utilize a more accurate division. So we - // can translate the accurate divide to a normal divide on all other cards. - bool convertAccurateDivide(CallInst *CI); - void expandAccurateDivide(CallInst *CI); - // If the alignment is set incorrectly, it can produce really inefficient - // code. This checks for this scenario and fixes it if possible. - bool correctMisalignedMemOp(Instruction *inst); - - // If we are in no opt mode, then we need to make sure that - // local samplers are properly propagated as constant propagation - // doesn't occur and we need to know the value of kernel defined - // samplers at compile time. - bool propagateSamplerInst(CallInst *CI); - - // Helper functions - - // Group of functions that recursively calculate the size of a structure based - // on it's sub-types. - size_t getTypeSize(Type * const T, bool dereferencePtr = false); - size_t getTypeSize(StructType * const ST, bool dereferencePtr = false); - size_t getTypeSize(IntegerType * const IT, bool dereferencePtr = false); - size_t getTypeSize(FunctionType * const FT,bool dereferencePtr = false); - size_t getTypeSize(ArrayType * const AT, bool dereferencePtr = false); - size_t getTypeSize(VectorType * const VT, bool dereferencePtr = false); - size_t getTypeSize(PointerType * const PT, bool dereferencePtr = false); - size_t getTypeSize(OpaqueType * const OT, bool dereferencePtr = false); - - LLVMContext *mCTX; - Function *mF; - const AMDGPUSubtarget *mSTM; - SmallVector< std::pair, 16> atomicFuncs; - SmallVector isConstVec; -}; // class AMDGPUPeepholeOpt - char AMDGPUPeepholeOpt::ID = 0; - -// A template function that has two levels of looping before calling the -// function with a pointer to the current iterator. -template -Function safeNestedForEach(InputIterator First, InputIterator Last, - SecondIterator S, Function F) { - for ( ; First != Last; ++First) { - SecondIterator sf, sl; - for (sf = First->begin(), sl = First->end(); - sf != sl; ) { - if (!F(&sf)) { - ++sf; - } - } - } - return F; -} - -} // anonymous namespace - -namespace llvm { - FunctionPass * - createAMDGPUPeepholeOpt(TargetMachine &tm) { - return new AMDGPUPeepholeOpt(tm); - } -} // llvm namespace - -AMDGPUPeepholeOpt::AMDGPUPeepholeOpt(TargetMachine &tm) - : FunctionPass(ID), TM(tm) { - mDebug = DEBUGME; - optLevel = TM.getOptLevel(); - -} - -AMDGPUPeepholeOpt::~AMDGPUPeepholeOpt() { -} - -const char * -AMDGPUPeepholeOpt::getPassName() const { - return "AMDGPU PeepHole Optimization Pass"; -} - -bool -containsPointerType(Type *Ty) { - if (!Ty) { - return false; - } - switch(Ty->getTypeID()) { - default: - return false; - case Type::StructTyID: { - const StructType *ST = dyn_cast(Ty); - for (StructType::element_iterator stb = ST->element_begin(), - ste = ST->element_end(); stb != ste; ++stb) { - if (!containsPointerType(*stb)) { - continue; - } - return true; - } - break; - } - case Type::VectorTyID: - case Type::ArrayTyID: - return containsPointerType(dyn_cast(Ty)->getElementType()); - case Type::PointerTyID: - return true; - }; - return false; -} - -bool -AMDGPUPeepholeOpt::dumpAllIntoArena(Function &F) { - bool dumpAll = false; - for (Function::const_arg_iterator cab = F.arg_begin(), - cae = F.arg_end(); cab != cae; ++cab) { - const Argument *arg = cab; - const PointerType *PT = dyn_cast(arg->getType()); - if (!PT) { - continue; - } - Type *DereferencedType = PT->getElementType(); - if (!dyn_cast(DereferencedType) - ) { - continue; - } - if (!containsPointerType(DereferencedType)) { - continue; - } - // FIXME: Because a pointer inside of a struct/union may be aliased to - // another pointer we need to take the conservative approach and place all - // pointers into the arena until more advanced detection is implemented. - dumpAll = true; - } - return dumpAll; -} -void -AMDGPUPeepholeOpt::doIsConstCallConversionIfNeeded() { - if (isConstVec.empty()) { - return; - } - for (unsigned x = 0, y = isConstVec.size(); x < y; ++x) { - CallInst *CI = isConstVec[x]; - Constant *CV = dyn_cast(CI->getOperand(0)); - Type *aType = Type::getInt32Ty(*mCTX); - Value *Val = (CV != NULL) ? ConstantInt::get(aType, 1) - : ConstantInt::get(aType, 0); - CI->replaceAllUsesWith(Val); - CI->eraseFromParent(); - } - isConstVec.clear(); -} -void -AMDGPUPeepholeOpt::doAtomicConversionIfNeeded(Function &F) { - // Don't do anything if we don't have any atomic operations. - if (atomicFuncs.empty()) { - return; - } - // Change the function name for the atomic if it is required - uint32_t size = atomicFuncs.size(); - for (uint32_t x = 0; x < size; ++x) { - atomicFuncs[x].first->setOperand( - atomicFuncs[x].first->getNumOperands()-1, - atomicFuncs[x].second); - - } - mChanged = true; - if (mConvertAtomics) { - return; - } -} - -bool -AMDGPUPeepholeOpt::runOnFunction(Function &MF) { - mChanged = false; - mF = &MF; - mSTM = &TM.getSubtarget(); - if (mDebug) { - MF.dump(); - } - mCTX = &MF.getType()->getContext(); - mConvertAtomics = true; - safeNestedForEach(MF.begin(), MF.end(), MF.begin()->begin(), - std::bind1st(std::mem_fun(&AMDGPUPeepholeOpt::instLevelOptimizations), - this)); - - doAtomicConversionIfNeeded(MF); - doIsConstCallConversionIfNeeded(); - - if (mDebug) { - MF.dump(); - } - return mChanged; -} - -bool -AMDGPUPeepholeOpt::optimizeCallInst(BasicBlock::iterator *bbb) { - Instruction *inst = (*bbb); - CallInst *CI = dyn_cast(inst); - if (!CI) { - return false; - } - if (isSigned24BitOps(CI)) { - expandSigned24BitOps(CI); - ++(*bbb); - CI->eraseFromParent(); - return true; - } - if (propagateSamplerInst(CI)) { - return false; - } - if (expandBFI(CI) || expandBFM(CI)) { - ++(*bbb); - CI->eraseFromParent(); - return true; - } - if (convertAccurateDivide(CI)) { - expandAccurateDivide(CI); - ++(*bbb); - CI->eraseFromParent(); - return true; - } - - StringRef calleeName = CI->getOperand(CI->getNumOperands()-1)->getName(); - if (calleeName.startswith("__amdil_is_constant")) { - // If we do not have optimizations, then this - // cannot be properly evaluated, so we add the - // call instruction to a vector and process - // them at the end of processing after the - // samplers have been correctly handled. - if (optLevel == CodeGenOpt::None) { - isConstVec.push_back(CI); - return false; - } else { - Constant *CV = dyn_cast(CI->getOperand(0)); - Type *aType = Type::getInt32Ty(*mCTX); - Value *Val = (CV != NULL) ? ConstantInt::get(aType, 1) - : ConstantInt::get(aType, 0); - CI->replaceAllUsesWith(Val); - ++(*bbb); - CI->eraseFromParent(); - return true; - } - } - - if (calleeName.equals("__amdil_is_asic_id_i32")) { - ConstantInt *CV = dyn_cast(CI->getOperand(0)); - Type *aType = Type::getInt32Ty(*mCTX); - Value *Val = CV; - if (Val) { - Val = ConstantInt::get(aType, - mSTM->device()->getDeviceFlag() & CV->getZExtValue()); - } else { - Val = ConstantInt::get(aType, 0); - } - CI->replaceAllUsesWith(Val); - ++(*bbb); - CI->eraseFromParent(); - return true; - } - Function *F = dyn_cast(CI->getOperand(CI->getNumOperands()-1)); - if (!F) { - return false; - } - if (F->getName().startswith("__atom") && !CI->getNumUses() - && F->getName().find("_xchg") == StringRef::npos) { - std::string buffer(F->getName().str() + "_noret"); - F = dyn_cast( - F->getParent()->getOrInsertFunction(buffer, F->getFunctionType())); - atomicFuncs.push_back(std::make_pair(CI, F)); - } - - if (!mSTM->device()->isSupported(AMDGPUDeviceInfo::ArenaSegment) - && !mSTM->device()->isSupported(AMDGPUDeviceInfo::MultiUAV)) { - return false; - } - if (!mConvertAtomics) { - return false; - } - StringRef name = F->getName(); - if (name.startswith("__atom") && name.find("_g") != StringRef::npos) { - mConvertAtomics = false; - } - return false; -} - -bool -AMDGPUPeepholeOpt::setupBitInsert(Instruction *base, - Instruction *&src, - Constant *&mask, - Constant *&shift) { - if (!base) { - if (mDebug) { - dbgs() << "Null pointer passed into function.\n"; - } - return false; - } - bool andOp = false; - if (base->getOpcode() == Instruction::Shl) { - shift = dyn_cast(base->getOperand(1)); - } else if (base->getOpcode() == Instruction::And) { - mask = dyn_cast(base->getOperand(1)); - andOp = true; - } else { - if (mDebug) { - dbgs() << "Failed setup with no Shl or And instruction on base opcode!\n"; - } - // If the base is neither a Shl or a And, we don't fit any of the patterns above. - return false; - } - src = dyn_cast(base->getOperand(0)); - if (!src) { - if (mDebug) { - dbgs() << "Failed setup since the base operand is not an instruction!\n"; - } - return false; - } - // If we find an 'and' operation, then we don't need to - // find the next operation as we already know the - // bits that are valid at this point. - if (andOp) { - return true; - } - if (src->getOpcode() == Instruction::Shl && !shift) { - shift = dyn_cast(src->getOperand(1)); - src = dyn_cast(src->getOperand(0)); - } else if (src->getOpcode() == Instruction::And && !mask) { - mask = dyn_cast(src->getOperand(1)); - } - if (!mask && !shift) { - if (mDebug) { - dbgs() << "Failed setup since both mask and shift are NULL!\n"; - } - // Did not find a constant mask or a shift. - return false; - } - return true; -} -bool -AMDGPUPeepholeOpt::optimizeBitInsert(Instruction *inst) { - if (!inst) { - return false; - } - if (!inst->isBinaryOp()) { - return false; - } - if (inst->getOpcode() != Instruction::Or) { - return false; - } - if (optLevel == CodeGenOpt::None) { - return false; - } - // We want to do an optimization on a sequence of ops that in the end equals a - // single ISA instruction. - // The base pattern for this optimization is - ((A & B) << C) | ((D & E) << F) - // Some simplified versions of this pattern are as follows: - // (A & B) | (D & E) when B & E == 0 && C == 0 && F == 0 - // ((A & B) << C) | (D & E) when B ^ E == 0 && (1 << C) >= E - // (A & B) | ((D & E) << F) when B ^ E == 0 && (1 << F) >= B - // (A & B) | (D << F) when (1 << F) >= B - // (A << C) | (D & E) when (1 << C) >= E - if (mSTM->device()->getGeneration() == AMDGPUDeviceInfo::HD4XXX) { - // The HD4XXX hardware doesn't support the ubit_insert instruction. - return false; - } - Type *aType = inst->getType(); - bool isVector = aType->isVectorTy(); - int numEle = 1; - // This optimization only works on 32bit integers. - if (aType->getScalarType() - != Type::getInt32Ty(inst->getContext())) { - return false; - } - if (isVector) { - const VectorType *VT = dyn_cast(aType); - numEle = VT->getNumElements(); - // We currently cannot support more than 4 elements in a intrinsic and we - // cannot support Vec3 types. - if (numEle > 4 || numEle == 3) { - return false; - } - } - // TODO: Handle vectors. - if (isVector) { - if (mDebug) { - dbgs() << "!!! Vectors are not supported yet!\n"; - } - return false; - } - Instruction *LHSSrc = NULL, *RHSSrc = NULL; - Constant *LHSMask = NULL, *RHSMask = NULL; - Constant *LHSShift = NULL, *RHSShift = NULL; - Instruction *LHS = dyn_cast(inst->getOperand(0)); - Instruction *RHS = dyn_cast(inst->getOperand(1)); - if (!setupBitInsert(LHS, LHSSrc, LHSMask, LHSShift)) { - if (mDebug) { - dbgs() << "Found an OR Operation that failed setup!\n"; - inst->dump(); - if (LHS) { LHS->dump(); } - if (LHSSrc) { LHSSrc->dump(); } - if (LHSMask) { LHSMask->dump(); } - if (LHSShift) { LHSShift->dump(); } - } - // There was an issue with the setup for BitInsert. - return false; - } - if (!setupBitInsert(RHS, RHSSrc, RHSMask, RHSShift)) { - if (mDebug) { - dbgs() << "Found an OR Operation that failed setup!\n"; - inst->dump(); - if (RHS) { RHS->dump(); } - if (RHSSrc) { RHSSrc->dump(); } - if (RHSMask) { RHSMask->dump(); } - if (RHSShift) { RHSShift->dump(); } - } - // There was an issue with the setup for BitInsert. - return false; - } - if (mDebug) { - dbgs() << "Found an OR operation that can possible be optimized to ubit insert!\n"; - dbgs() << "Op: "; inst->dump(); - dbgs() << "LHS: "; if (LHS) { LHS->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "LHS Src: "; if (LHSSrc) { LHSSrc->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "LHS Mask: "; if (LHSMask) { LHSMask->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "LHS Shift: "; if (LHSShift) { LHSShift->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "RHS: "; if (RHS) { RHS->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "RHS Src: "; if (RHSSrc) { RHSSrc->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "RHS Mask: "; if (RHSMask) { RHSMask->dump(); } else { dbgs() << "(None)\n"; } - dbgs() << "RHS Shift: "; if (RHSShift) { RHSShift->dump(); } else { dbgs() << "(None)\n"; } - } - Constant *offset = NULL; - Constant *width = NULL; - uint32_t lhsMaskVal = 0, rhsMaskVal = 0; - uint32_t lhsShiftVal = 0, rhsShiftVal = 0; - uint32_t lhsMaskWidth = 0, rhsMaskWidth = 0; - uint32_t lhsMaskOffset = 0, rhsMaskOffset = 0; - lhsMaskVal = (LHSMask - ? dyn_cast(LHSMask)->getZExtValue() : 0); - rhsMaskVal = (RHSMask - ? dyn_cast(RHSMask)->getZExtValue() : 0); - lhsShiftVal = (LHSShift - ? dyn_cast(LHSShift)->getZExtValue() : 0); - rhsShiftVal = (RHSShift - ? dyn_cast(RHSShift)->getZExtValue() : 0); - lhsMaskWidth = lhsMaskVal ? CountPopulation_32(lhsMaskVal) : 32 - lhsShiftVal; - rhsMaskWidth = rhsMaskVal ? CountPopulation_32(rhsMaskVal) : 32 - rhsShiftVal; - lhsMaskOffset = lhsMaskVal ? CountTrailingZeros_32(lhsMaskVal) : lhsShiftVal; - rhsMaskOffset = rhsMaskVal ? CountTrailingZeros_32(rhsMaskVal) : rhsShiftVal; - // TODO: Handle the case of A & B | D & ~B(i.e. inverted masks). - if ((lhsMaskVal || rhsMaskVal) && !(lhsMaskVal ^ rhsMaskVal)) { - return false; - } - if (lhsMaskOffset >= (rhsMaskWidth + rhsMaskOffset)) { - offset = ConstantInt::get(aType, lhsMaskOffset, false); - width = ConstantInt::get(aType, lhsMaskWidth, false); - RHSSrc = RHS; - if (!isMask_32(lhsMaskVal) && !isShiftedMask_32(lhsMaskVal)) { - return false; - } - if (!LHSShift) { - LHSSrc = BinaryOperator::Create(Instruction::LShr, LHSSrc, offset, - "MaskShr", LHS); - } else if (lhsShiftVal != lhsMaskOffset) { - LHSSrc = BinaryOperator::Create(Instruction::LShr, LHSSrc, offset, - "MaskShr", LHS); - } - if (mDebug) { - dbgs() << "Optimizing LHS!\n"; - } - } else if (rhsMaskOffset >= (lhsMaskWidth + lhsMaskOffset)) { - offset = ConstantInt::get(aType, rhsMaskOffset, false); - width = ConstantInt::get(aType, rhsMaskWidth, false); - LHSSrc = RHSSrc; - RHSSrc = LHS; - if (!isMask_32(rhsMaskVal) && !isShiftedMask_32(rhsMaskVal)) { - return false; - } - if (!RHSShift) { - LHSSrc = BinaryOperator::Create(Instruction::LShr, LHSSrc, offset, - "MaskShr", RHS); - } else if (rhsShiftVal != rhsMaskOffset) { - LHSSrc = BinaryOperator::Create(Instruction::LShr, LHSSrc, offset, - "MaskShr", RHS); - } - if (mDebug) { - dbgs() << "Optimizing RHS!\n"; - } - } else { - if (mDebug) { - dbgs() << "Failed constraint 3!\n"; - } - return false; - } - if (mDebug) { - dbgs() << "Width: "; if (width) { width->dump(); } else { dbgs() << "(0)\n"; } - dbgs() << "Offset: "; if (offset) { offset->dump(); } else { dbgs() << "(0)\n"; } - dbgs() << "LHSSrc: "; if (LHSSrc) { LHSSrc->dump(); } else { dbgs() << "(0)\n"; } - dbgs() << "RHSSrc: "; if (RHSSrc) { RHSSrc->dump(); } else { dbgs() << "(0)\n"; } - } - if (!offset || !width) { - if (mDebug) { - dbgs() << "Either width or offset are NULL, failed detection!\n"; - } - return false; - } - // Lets create the function signature. - std::vector callTypes; - callTypes.push_back(aType); - callTypes.push_back(aType); - callTypes.push_back(aType); - callTypes.push_back(aType); - FunctionType *funcType = FunctionType::get(aType, callTypes, false); - std::string name = "__amdil_ubit_insert"; - if (isVector) { name += "_v" + itostr(numEle) + "u32"; } else { name += "_u32"; } - Function *Func = - dyn_cast(inst->getParent()->getParent()->getParent()-> - getOrInsertFunction(StringRef(name), funcType)); - Value *Operands[4] = { - width, - offset, - LHSSrc, - RHSSrc - }; - CallInst *CI = CallInst::Create(Func, Operands, "BitInsertOpt"); - if (mDebug) { - dbgs() << "Old Inst: "; - inst->dump(); - dbgs() << "New Inst: "; - CI->dump(); - dbgs() << "\n\n"; - } - CI->insertBefore(inst); - inst->replaceAllUsesWith(CI); - return true; -} - -bool -AMDGPUPeepholeOpt::optimizeBitExtract(Instruction *inst) { - if (!inst) { - return false; - } - if (!inst->isBinaryOp()) { - return false; - } - if (inst->getOpcode() != Instruction::And) { - return false; - } - if (optLevel == CodeGenOpt::None) { - return false; - } - // We want to do some simple optimizations on Shift right/And patterns. The - // basic optimization is to turn (A >> B) & C where A is a 32bit type, B is a - // value smaller than 32 and C is a mask. If C is a constant value, then the - // following transformation can occur. For signed integers, it turns into the - // function call dst = __amdil_ibit_extract(log2(C), B, A) For unsigned - // integers, it turns into the function call dst = - // __amdil_ubit_extract(log2(C), B, A) The function __amdil_[u|i]bit_extract - // can be found in Section 7.9 of the ATI IL spec of the stream SDK for - // Evergreen hardware. - if (mSTM->device()->getGeneration() == AMDGPUDeviceInfo::HD4XXX) { - // This does not work on HD4XXX hardware. - return false; - } - Type *aType = inst->getType(); - bool isVector = aType->isVectorTy(); - - // XXX Support vector types - if (isVector) { - return false; - } - int numEle = 1; - // This only works on 32bit integers - if (aType->getScalarType() - != Type::getInt32Ty(inst->getContext())) { - return false; - } - if (isVector) { - const VectorType *VT = dyn_cast(aType); - numEle = VT->getNumElements(); - // We currently cannot support more than 4 elements in a intrinsic and we - // cannot support Vec3 types. - if (numEle > 4 || numEle == 3) { - return false; - } - } - BinaryOperator *ShiftInst = dyn_cast(inst->getOperand(0)); - // If the first operand is not a shift instruction, then we can return as it - // doesn't match this pattern. - if (!ShiftInst || !ShiftInst->isShift()) { - return false; - } - // If we are a shift left, then we need don't match this pattern. - if (ShiftInst->getOpcode() == Instruction::Shl) { - return false; - } - bool isSigned = ShiftInst->isArithmeticShift(); - Constant *AndMask = dyn_cast(inst->getOperand(1)); - Constant *ShrVal = dyn_cast(ShiftInst->getOperand(1)); - // Lets make sure that the shift value and the and mask are constant integers. - if (!AndMask || !ShrVal) { - return false; - } - Constant *newMaskConst; - Constant *shiftValConst; - if (isVector) { - // Handle the vector case - std::vector maskVals; - std::vector shiftVals; - ConstantVector *AndMaskVec = dyn_cast(AndMask); - ConstantVector *ShrValVec = dyn_cast(ShrVal); - Type *scalarType = AndMaskVec->getType()->getScalarType(); - assert(AndMaskVec->getNumOperands() == - ShrValVec->getNumOperands() && "cannot have a " - "combination where the number of elements to a " - "shift and an and are different!"); - for (size_t x = 0, y = AndMaskVec->getNumOperands(); x < y; ++x) { - ConstantInt *AndCI = dyn_cast(AndMaskVec->getOperand(x)); - ConstantInt *ShiftIC = dyn_cast(ShrValVec->getOperand(x)); - if (!AndCI || !ShiftIC) { - return false; - } - uint32_t maskVal = (uint32_t)AndCI->getZExtValue(); - if (!isMask_32(maskVal)) { - return false; - } - maskVal = (uint32_t)CountTrailingOnes_32(maskVal); - uint32_t shiftVal = (uint32_t)ShiftIC->getZExtValue(); - // If the mask or shiftval is greater than the bitcount, then break out. - if (maskVal >= 32 || shiftVal >= 32) { - return false; - } - // If the mask val is greater than the the number of original bits left - // then this optimization is invalid. - if (maskVal > (32 - shiftVal)) { - return false; - } - maskVals.push_back(ConstantInt::get(scalarType, maskVal, isSigned)); - shiftVals.push_back(ConstantInt::get(scalarType, shiftVal, isSigned)); - } - newMaskConst = ConstantVector::get(maskVals); - shiftValConst = ConstantVector::get(shiftVals); - } else { - // Handle the scalar case - uint32_t maskVal = (uint32_t)dyn_cast(AndMask)->getZExtValue(); - // This must be a mask value where all lower bits are set to 1 and then any - // bit higher is set to 0. - if (!isMask_32(maskVal)) { - return false; - } - maskVal = (uint32_t)CountTrailingOnes_32(maskVal); - // Count the number of bits set in the mask, this is the width of the - // resulting bit set that is extracted from the source value. - uint32_t shiftVal = (uint32_t)dyn_cast(ShrVal)->getZExtValue(); - // If the mask or shift val is greater than the bitcount, then break out. - if (maskVal >= 32 || shiftVal >= 32) { - return false; - } - // If the mask val is greater than the the number of original bits left then - // this optimization is invalid. - if (maskVal > (32 - shiftVal)) { - return false; - } - newMaskConst = ConstantInt::get(aType, maskVal, isSigned); - shiftValConst = ConstantInt::get(aType, shiftVal, isSigned); - } - // Lets create the function signature. - std::vector callTypes; - callTypes.push_back(aType); - callTypes.push_back(aType); - callTypes.push_back(aType); - FunctionType *funcType = FunctionType::get(aType, callTypes, false); - std::string name = "llvm.AMDGPU.bit.extract.u32"; - if (isVector) { - name += ".v" + itostr(numEle) + "i32"; - } else { - name += "."; - } - // Lets create the function. - Function *Func = - dyn_cast(inst->getParent()->getParent()->getParent()-> - getOrInsertFunction(StringRef(name), funcType)); - Value *Operands[3] = { - ShiftInst->getOperand(0), - shiftValConst, - newMaskConst - }; - // Lets create the Call with the operands - CallInst *CI = CallInst::Create(Func, Operands, "ByteExtractOpt"); - CI->setDoesNotAccessMemory(); - CI->insertBefore(inst); - inst->replaceAllUsesWith(CI); - return true; -} - -bool -AMDGPUPeepholeOpt::expandBFI(CallInst *CI) { - if (!CI) { - return false; - } - Value *LHS = CI->getOperand(CI->getNumOperands() - 1); - if (!LHS->getName().startswith("__amdil_bfi")) { - return false; - } - Type* type = CI->getOperand(0)->getType(); - Constant *negOneConst = NULL; - if (type->isVectorTy()) { - std::vector negOneVals; - negOneConst = ConstantInt::get(CI->getContext(), - APInt(32, StringRef("-1"), 10)); - for (size_t x = 0, - y = dyn_cast(type)->getNumElements(); x < y; ++x) { - negOneVals.push_back(negOneConst); - } - negOneConst = ConstantVector::get(negOneVals); - } else { - negOneConst = ConstantInt::get(CI->getContext(), - APInt(32, StringRef("-1"), 10)); - } - // __amdil_bfi => (A & B) | (~A & C) - BinaryOperator *lhs = - BinaryOperator::Create(Instruction::And, CI->getOperand(0), - CI->getOperand(1), "bfi_and", CI); - BinaryOperator *rhs = - BinaryOperator::Create(Instruction::Xor, CI->getOperand(0), negOneConst, - "bfi_not", CI); - rhs = BinaryOperator::Create(Instruction::And, rhs, CI->getOperand(2), - "bfi_and", CI); - lhs = BinaryOperator::Create(Instruction::Or, lhs, rhs, "bfi_or", CI); - CI->replaceAllUsesWith(lhs); - return true; -} - -bool -AMDGPUPeepholeOpt::expandBFM(CallInst *CI) { - if (!CI) { - return false; - } - Value *LHS = CI->getOperand(CI->getNumOperands() - 1); - if (!LHS->getName().startswith("__amdil_bfm")) { - return false; - } - // __amdil_bfm => ((1 << (src0 & 0x1F)) - 1) << (src1 & 0x1f) - Constant *newMaskConst = NULL; - Constant *newShiftConst = NULL; - Type* type = CI->getOperand(0)->getType(); - if (type->isVectorTy()) { - std::vector newMaskVals, newShiftVals; - newMaskConst = ConstantInt::get(Type::getInt32Ty(*mCTX), 0x1F); - newShiftConst = ConstantInt::get(Type::getInt32Ty(*mCTX), 1); - for (size_t x = 0, - y = dyn_cast(type)->getNumElements(); x < y; ++x) { - newMaskVals.push_back(newMaskConst); - newShiftVals.push_back(newShiftConst); - } - newMaskConst = ConstantVector::get(newMaskVals); - newShiftConst = ConstantVector::get(newShiftVals); - } else { - newMaskConst = ConstantInt::get(Type::getInt32Ty(*mCTX), 0x1F); - newShiftConst = ConstantInt::get(Type::getInt32Ty(*mCTX), 1); - } - BinaryOperator *lhs = - BinaryOperator::Create(Instruction::And, CI->getOperand(0), - newMaskConst, "bfm_mask", CI); - lhs = BinaryOperator::Create(Instruction::Shl, newShiftConst, - lhs, "bfm_shl", CI); - lhs = BinaryOperator::Create(Instruction::Sub, lhs, - newShiftConst, "bfm_sub", CI); - BinaryOperator *rhs = - BinaryOperator::Create(Instruction::And, CI->getOperand(1), - newMaskConst, "bfm_mask", CI); - lhs = BinaryOperator::Create(Instruction::Shl, lhs, rhs, "bfm_shl", CI); - CI->replaceAllUsesWith(lhs); - return true; -} - -bool -AMDGPUPeepholeOpt::instLevelOptimizations(BasicBlock::iterator *bbb) { - Instruction *inst = (*bbb); - if (optimizeCallInst(bbb)) { - return true; - } - if (optimizeBitExtract(inst)) { - return false; - } - if (optimizeBitInsert(inst)) { - return false; - } - if (correctMisalignedMemOp(inst)) { - return false; - } - return false; -} -bool -AMDGPUPeepholeOpt::correctMisalignedMemOp(Instruction *inst) { - LoadInst *linst = dyn_cast(inst); - StoreInst *sinst = dyn_cast(inst); - unsigned alignment; - Type* Ty = inst->getType(); - if (linst) { - alignment = linst->getAlignment(); - Ty = inst->getType(); - } else if (sinst) { - alignment = sinst->getAlignment(); - Ty = sinst->getValueOperand()->getType(); - } else { - return false; - } - unsigned size = getTypeSize(Ty); - if (size == alignment || size < alignment) { - return false; - } - if (!Ty->isStructTy()) { - return false; - } - if (alignment < 4) { - if (linst) { - linst->setAlignment(0); - return true; - } else if (sinst) { - sinst->setAlignment(0); - return true; - } - } - return false; -} -bool -AMDGPUPeepholeOpt::isSigned24BitOps(CallInst *CI) { - if (!CI) { - return false; - } - Value *LHS = CI->getOperand(CI->getNumOperands() - 1); - std::string namePrefix = LHS->getName().substr(0, 14); - if (namePrefix != "__amdil_imad24" && namePrefix != "__amdil_imul24" - && namePrefix != "__amdil__imul24_high") { - return false; - } - if (mSTM->device()->usesHardware(AMDGPUDeviceInfo::Signed24BitOps)) { - return false; - } - return true; -} - -void -AMDGPUPeepholeOpt::expandSigned24BitOps(CallInst *CI) { - assert(isSigned24BitOps(CI) && "Must be a " - "signed 24 bit operation to call this function!"); - Value *LHS = CI->getOperand(CI->getNumOperands()-1); - // On 7XX and 8XX we do not have signed 24bit, so we need to - // expand it to the following: - // imul24 turns into 32bit imul - // imad24 turns into 32bit imad - // imul24_high turns into 32bit imulhigh - if (LHS->getName().substr(0, 14) == "__amdil_imad24") { - Type *aType = CI->getOperand(0)->getType(); - bool isVector = aType->isVectorTy(); - int numEle = isVector ? dyn_cast(aType)->getNumElements() : 1; - std::vector callTypes; - callTypes.push_back(CI->getOperand(0)->getType()); - callTypes.push_back(CI->getOperand(1)->getType()); - callTypes.push_back(CI->getOperand(2)->getType()); - FunctionType *funcType = - FunctionType::get(CI->getOperand(0)->getType(), callTypes, false); - std::string name = "__amdil_imad"; - if (isVector) { - name += "_v" + itostr(numEle) + "i32"; - } else { - name += "_i32"; - } - Function *Func = dyn_cast( - CI->getParent()->getParent()->getParent()-> - getOrInsertFunction(StringRef(name), funcType)); - Value *Operands[3] = { - CI->getOperand(0), - CI->getOperand(1), - CI->getOperand(2) - }; - CallInst *nCI = CallInst::Create(Func, Operands, "imad24"); - nCI->insertBefore(CI); - CI->replaceAllUsesWith(nCI); - } else if (LHS->getName().substr(0, 14) == "__amdil_imul24") { - BinaryOperator *mulOp = - BinaryOperator::Create(Instruction::Mul, CI->getOperand(0), - CI->getOperand(1), "imul24", CI); - CI->replaceAllUsesWith(mulOp); - } else if (LHS->getName().substr(0, 19) == "__amdil_imul24_high") { - Type *aType = CI->getOperand(0)->getType(); - - bool isVector = aType->isVectorTy(); - int numEle = isVector ? dyn_cast(aType)->getNumElements() : 1; - std::vector callTypes; - callTypes.push_back(CI->getOperand(0)->getType()); - callTypes.push_back(CI->getOperand(1)->getType()); - FunctionType *funcType = - FunctionType::get(CI->getOperand(0)->getType(), callTypes, false); - std::string name = "__amdil_imul_high"; - if (isVector) { - name += "_v" + itostr(numEle) + "i32"; - } else { - name += "_i32"; - } - Function *Func = dyn_cast( - CI->getParent()->getParent()->getParent()-> - getOrInsertFunction(StringRef(name), funcType)); - Value *Operands[2] = { - CI->getOperand(0), - CI->getOperand(1) - }; - CallInst *nCI = CallInst::Create(Func, Operands, "imul24_high"); - nCI->insertBefore(CI); - CI->replaceAllUsesWith(nCI); - } -} - -bool -AMDGPUPeepholeOpt::isRWGLocalOpt(CallInst *CI) { - return (CI != NULL - && CI->getOperand(CI->getNumOperands() - 1)->getName() - == "__amdil_get_local_size_int"); -} - -bool -AMDGPUPeepholeOpt::convertAccurateDivide(CallInst *CI) { - if (!CI) { - return false; - } - if (mSTM->device()->getGeneration() == AMDGPUDeviceInfo::HD6XXX - && (mSTM->getDeviceName() == "cayman")) { - return false; - } - return CI->getOperand(CI->getNumOperands() - 1)->getName().substr(0, 20) - == "__amdil_improved_div"; -} - -void -AMDGPUPeepholeOpt::expandAccurateDivide(CallInst *CI) { - assert(convertAccurateDivide(CI) - && "expanding accurate divide can only happen if it is expandable!"); - BinaryOperator *divOp = - BinaryOperator::Create(Instruction::FDiv, CI->getOperand(0), - CI->getOperand(1), "fdiv32", CI); - CI->replaceAllUsesWith(divOp); -} - -bool -AMDGPUPeepholeOpt::propagateSamplerInst(CallInst *CI) { - if (optLevel != CodeGenOpt::None) { - return false; - } - - if (!CI) { - return false; - } - - unsigned funcNameIdx = 0; - funcNameIdx = CI->getNumOperands() - 1; - StringRef calleeName = CI->getOperand(funcNameIdx)->getName(); - if (calleeName != "__amdil_image2d_read_norm" - && calleeName != "__amdil_image2d_read_unnorm" - && calleeName != "__amdil_image3d_read_norm" - && calleeName != "__amdil_image3d_read_unnorm") { - return false; - } - - unsigned samplerIdx = 2; - samplerIdx = 1; - Value *sampler = CI->getOperand(samplerIdx); - LoadInst *lInst = dyn_cast(sampler); - if (!lInst) { - return false; - } - - if (lInst->getPointerAddressSpace() != AMDGPUAS::PRIVATE_ADDRESS) { - return false; - } - - GlobalVariable *gv = dyn_cast(lInst->getPointerOperand()); - // If we are loading from what is not a global value, then we - // fail and return. - if (!gv) { - return false; - } - - // If we don't have an initializer or we have an initializer and - // the initializer is not a 32bit integer, we fail. - if (!gv->hasInitializer() - || !gv->getInitializer()->getType()->isIntegerTy(32)) { - return false; - } - - // Now that we have the global variable initializer, lets replace - // all uses of the load instruction with the samplerVal and - // reparse the __amdil_is_constant() function. - Constant *samplerVal = gv->getInitializer(); - lInst->replaceAllUsesWith(samplerVal); - return true; -} - -bool -AMDGPUPeepholeOpt::doInitialization(Module &M) { - return false; -} - -bool -AMDGPUPeepholeOpt::doFinalization(Module &M) { - return false; -} - -void -AMDGPUPeepholeOpt::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - FunctionPass::getAnalysisUsage(AU); - AU.setPreservesAll(); -} - -size_t AMDGPUPeepholeOpt::getTypeSize(Type * const T, bool dereferencePtr) { - size_t size = 0; - if (!T) { - return size; - } - switch (T->getTypeID()) { - case Type::X86_FP80TyID: - case Type::FP128TyID: - case Type::PPC_FP128TyID: - case Type::LabelTyID: - assert(0 && "These types are not supported by this backend"); - default: - case Type::FloatTyID: - case Type::DoubleTyID: - size = T->getPrimitiveSizeInBits() >> 3; - break; - case Type::PointerTyID: - size = getTypeSize(dyn_cast(T), dereferencePtr); - break; - case Type::IntegerTyID: - size = getTypeSize(dyn_cast(T), dereferencePtr); - break; - case Type::StructTyID: - size = getTypeSize(dyn_cast(T), dereferencePtr); - break; - case Type::ArrayTyID: - size = getTypeSize(dyn_cast(T), dereferencePtr); - break; - case Type::FunctionTyID: - size = getTypeSize(dyn_cast(T), dereferencePtr); - break; - case Type::VectorTyID: - size = getTypeSize(dyn_cast(T), dereferencePtr); - break; - }; - return size; -} - -size_t AMDGPUPeepholeOpt::getTypeSize(StructType * const ST, - bool dereferencePtr) { - size_t size = 0; - if (!ST) { - return size; - } - Type *curType; - StructType::element_iterator eib; - StructType::element_iterator eie; - for (eib = ST->element_begin(), eie = ST->element_end(); eib != eie; ++eib) { - curType = *eib; - size += getTypeSize(curType, dereferencePtr); - } - return size; -} - -size_t AMDGPUPeepholeOpt::getTypeSize(IntegerType * const IT, - bool dereferencePtr) { - return IT ? (IT->getBitWidth() >> 3) : 0; -} - -size_t AMDGPUPeepholeOpt::getTypeSize(FunctionType * const FT, - bool dereferencePtr) { - assert(0 && "Should not be able to calculate the size of an function type"); - return 0; -} - -size_t AMDGPUPeepholeOpt::getTypeSize(ArrayType * const AT, - bool dereferencePtr) { - return (size_t)(AT ? (getTypeSize(AT->getElementType(), - dereferencePtr) * AT->getNumElements()) - : 0); -} - -size_t AMDGPUPeepholeOpt::getTypeSize(VectorType * const VT, - bool dereferencePtr) { - return VT ? (VT->getBitWidth() >> 3) : 0; -} - -size_t AMDGPUPeepholeOpt::getTypeSize(PointerType * const PT, - bool dereferencePtr) { - if (!PT) { - return 0; - } - Type *CT = PT->getElementType(); - if (CT->getTypeID() == Type::StructTyID && - PT->getAddressSpace() == AMDGPUAS::PRIVATE_ADDRESS) { - return getTypeSize(dyn_cast(CT)); - } else if (dereferencePtr) { - size_t size = 0; - for (size_t x = 0, y = PT->getNumContainedTypes(); x < y; ++x) { - size += getTypeSize(PT->getContainedType(x), dereferencePtr); - } - return size; - } else { - return 4; - } -} - -size_t AMDGPUPeepholeOpt::getTypeSize(OpaqueType * const OT, - bool dereferencePtr) { - //assert(0 && "Should not be able to calculate the size of an opaque type"); - return 4; -} diff --git a/llvm/lib/Target/R600/CMakeLists.txt b/llvm/lib/Target/R600/CMakeLists.txt index 2ad2047278ca..97f0a40c2981 100644 --- a/llvm/lib/Target/R600/CMakeLists.txt +++ b/llvm/lib/Target/R600/CMakeLists.txt @@ -21,7 +21,6 @@ add_llvm_target(R600CodeGen AMDILISelDAGToDAG.cpp AMDILISelLowering.cpp AMDILNIDevice.cpp - AMDILPeepholeOptimizer.cpp AMDILSIDevice.cpp AMDGPUAsmPrinter.cpp AMDGPUFrameLowering.cpp diff --git a/llvm/lib/Target/R600/R600Instructions.td b/llvm/lib/Target/R600/R600Instructions.td index 8a60add450d7..8f47523524e5 100644 --- a/llvm/lib/Target/R600/R600Instructions.td +++ b/llvm/lib/Target/R600/R600Instructions.td @@ -1615,6 +1615,7 @@ let Predicates = [isEGorCayman] in { i32:$src2))], VecALU >; + def : BFEPattern ; def BFI_INT_eg : R600_3OP <0x06, "BFI_INT", [], VecALU>; defm : BFIPatterns ; diff --git a/llvm/test/CodeGen/R600/bfe_uint.ll b/llvm/test/CodeGen/R600/bfe_uint.ll new file mode 100644 index 000000000000..92570c315299 --- /dev/null +++ b/llvm/test/CodeGen/R600/bfe_uint.ll @@ -0,0 +1,26 @@ +; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s + +; CHECK: @bfe_def +; CHECK: BFE_UINT +define void @bfe_def(i32 addrspace(1)* %out, i32 %x) { +entry: + %0 = lshr i32 %x, 5 + %1 = and i32 %0, 15 ; 0xf + store i32 %1, i32 addrspace(1)* %out + ret void +} + +; This program could be implemented using a BFE_UINT instruction, however +; since the lshr constant + number of bits in the mask is >= 32, it can also be +; implmented with a LSHR instruction, which is better, because LSHR has less +; operands and requires less constants. + +; CHECK: @bfe_shift +; CHECK-NOT: BFE_UINT +define void @bfe_shift(i32 addrspace(1)* %out, i32 %x) { +entry: + %0 = lshr i32 %x, 16 + %1 = and i32 %0, 65535 ; 0xffff + store i32 %1, i32 addrspace(1)* %out + ret void +} -- GitLab From 041e36756390441e5745b06d1e047ac2951b7f50 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Fri, 10 May 2013 02:15:22 +0000 Subject: [PATCH 151/467] Temporarily roll back r181375 - it is causing an unexpected regression, I'll revisit this and apply once I figure out how to address that. llvm-svn: 181581 --- .../Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index 56c04ba17b6b..4b271b403175 100644 --- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -107,16 +107,6 @@ ReplaceDSYMSectionsWithExecutableSections (ObjectFile *exec_objfile, ObjectFile // and in the dSYM with those from the executable. If we fail to // replace the one in the dSYM, then add the executable section to // the dSYM. - SectionSP dsym_sect_sp(dsym_section_list->FindSectionByID(exec_sect_sp->GetID())); - if (dsym_sect_sp.get() && dsym_sect_sp->GetName() != exec_sect_sp->GetName()) - { - // The sections in a dSYM are normally a superset of the sections in an executable. - // If we find a section # in the exectuable & dSYM that don't have the same name, - // something has changed since the dSYM was written. The mach_kernel DSTROOT binary - // has a CTF segment added, for instance, and it's easiest to simply not add that to - // the dSYM - none of the nlist entries are going to have references to that section. - continue; - } if (dsym_section_list->ReplaceSection(exec_sect_sp->GetID(), exec_sect_sp, 0) == false) dsym_section_list->AddSection(exec_sect_sp); } -- GitLab From 58a6208976a818aba7379b529ff3202387cec1e7 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Fri, 10 May 2013 02:18:50 +0000 Subject: [PATCH 152/467] Scratch that, the problem was elsewhere. llvm-svn: 181582 --- .../Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index 4b271b403175..56c04ba17b6b 100644 --- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -107,6 +107,16 @@ ReplaceDSYMSectionsWithExecutableSections (ObjectFile *exec_objfile, ObjectFile // and in the dSYM with those from the executable. If we fail to // replace the one in the dSYM, then add the executable section to // the dSYM. + SectionSP dsym_sect_sp(dsym_section_list->FindSectionByID(exec_sect_sp->GetID())); + if (dsym_sect_sp.get() && dsym_sect_sp->GetName() != exec_sect_sp->GetName()) + { + // The sections in a dSYM are normally a superset of the sections in an executable. + // If we find a section # in the exectuable & dSYM that don't have the same name, + // something has changed since the dSYM was written. The mach_kernel DSTROOT binary + // has a CTF segment added, for instance, and it's easiest to simply not add that to + // the dSYM - none of the nlist entries are going to have references to that section. + continue; + } if (dsym_section_list->ReplaceSection(exec_sect_sp->GetID(), exec_sect_sp, 0) == false) dsym_section_list->AddSection(exec_sect_sp); } -- GitLab From 0f7f6f1abc511338738404d858c35093b5fb712a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 10 May 2013 02:36:35 +0000 Subject: [PATCH 153/467] Typo and misc comment fix. llvm-svn: 181583 --- clang/lib/Lex/Lexer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 9958287ba474..66498b1a2c9d 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1870,7 +1870,9 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr) { // Whitespace - Skip it, then return the token after the whitespace. bool SawNewline = isVerticalWhitespace(CurPtr[-1]); - unsigned char Char = *CurPtr; // Skip consequtive spaces efficiently. + unsigned char Char = *CurPtr; + + // Skip consecutive spaces efficiently. while (1) { // Skip horizontal whitespace very aggressively. while (isHorizontalWhitespace(Char)) @@ -1886,7 +1888,7 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr) { return false; } - // ok, but handle newline. + // OK, but handle newline. SawNewline = true; Char = *++CurPtr; } -- GitLab From 7500ab24640153a1943ed6ad7f52467553930a1e Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 10 May 2013 04:31:10 +0000 Subject: [PATCH 154/467] C++1y auto return type: when a function contains no 'return' statements at all, substitute 'void' into the return type rather than replacing it with 'void', so that we maintain the 'auto' type sugar. llvm-svn: 181584 --- clang/lib/Sema/SemaDecl.cpp | 31 +++++++++++-------- clang/lib/Sema/SemaStmt.cpp | 4 +-- .../SemaCXX/cxx1y-deduced-return-type.cpp | 5 +++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a50b5e7c7ff4..d14b10559d9a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8849,7 +8849,9 @@ bool Sema::canSkipFunctionBody(Decl *D) { // We cannot skip the body of a function (or function template) which is // constexpr, since we may need to evaluate its body in order to parse the // rest of the file. - return !FD->isConstexpr(); + // We cannot skip the body of a function with an undeduced return type, + // because any callers of that function need to know the type. + return !FD->isConstexpr() && !FD->getResultType()->isUndeducedType(); } Decl *Sema::ActOnSkippedFunctionBody(Decl *Decl) { @@ -8879,18 +8881,21 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (FD) { FD->setBody(Body); - if (getLangOpts().CPlusPlus1y && !FD->isInvalidDecl() && - !FD->isDependentContext()) { - if (FD->getResultType()->isUndeducedType()) { - // If the function has a deduced result type but contains no 'return' - // statements, the result type as written must be exactly 'auto', and - // the deduced result type is 'void'. - if (!FD->getResultType()->getAs()) { - Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto) - << FD->getResultType(); - FD->setInvalidDecl(); - } - Context.adjustDeducedFunctionResultType(FD, Context.VoidTy); + if (getLangOpts().CPlusPlus1y && !FD->isInvalidDecl() && Body && + !FD->isDependentContext() && FD->getResultType()->isUndeducedType()) { + // If the function has a deduced result type but contains no 'return' + // statements, the result type as written must be exactly 'auto', and + // the deduced result type is 'void'. + if (!FD->getResultType()->getAs()) { + Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto) + << FD->getResultType(); + FD->setInvalidDecl(); + } else { + // Substitute 'void' for the 'auto' in the type. + TypeLoc ResultType = FD->getTypeSourceInfo()->getTypeLoc(). + IgnoreParens().castAs().getResultLoc(); + Context.adjustDeducedFunctionResultType( + FD, SubstAutoType(ResultType.getType(), Context.VoidTy)); } } diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 248665ac86cb..b5ff7a30a9e2 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -2553,9 +2553,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { if (RetValExp && DiagnoseUnexpandedParameterPack(RetValExp)) return StmtError(); - // FIXME: Unify this and C++1y auto function handling. In particular, we - // should allow 'return { 1, 2, 3 };' in a lambda to deduce - // 'std::initializer_list'. + // FIXME: Unify this and C++1y auto function handling. if (isa(getCurFunction())) return ActOnCapScopeReturnStmt(ReturnLoc, RetValExp); diff --git a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp index f0146f88d686..eb6f6aaf9bcf 100644 --- a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp +++ b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp @@ -295,7 +295,12 @@ namespace NoReturn { auto f() {} void (*p)() = &f; + auto f(); // ok + auto *g() {} // expected-error {{cannot deduce return type 'auto *' for function with no return statements}} + + auto h() = delete; // expected-note {{explicitly deleted}} + auto x = h(); // expected-error {{call to deleted}} } namespace UseBeforeComplete { -- GitLab From 8f9624b3bc279f5788ef62f5518b19ab7634a6ac Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 10 May 2013 07:59:58 +0000 Subject: [PATCH 155/467] Fix bug when formatting overloaded operators. Before, the actual operator of an overloaded operator declaration was handled as a binary operator an thus, clang-format could not find valid formattings for many examples, e.g.: template AAAAAAA operator/(const AAAAAAA &a, BBBBBBB &b); llvm-svn: 181585 --- clang/lib/Format/TokenAnnotator.cpp | 5 ++++- clang/lib/Format/TokenAnnotator.h | 1 + clang/unittests/Format/FormatTest.cpp | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 75b173ef4f46..12031166e234 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -390,8 +390,11 @@ private: CurrentToken->Type = TT_PointerOrReference; consumeToken(); } - if (CurrentToken) + if (CurrentToken) { CurrentToken->Type = TT_OverloadedOperatorLParen; + if (CurrentToken->Parent->Type == TT_BinaryOperator) + CurrentToken->Parent->Type = TT_OverloadedOperator; + } break; case tok::question: parseConditional(); diff --git a/clang/lib/Format/TokenAnnotator.h b/clang/lib/Format/TokenAnnotator.h index a2080b5b6f30..5ea30159a2a0 100644 --- a/clang/lib/Format/TokenAnnotator.h +++ b/clang/lib/Format/TokenAnnotator.h @@ -45,6 +45,7 @@ enum TokenType { TT_ObjCMethodSpecifier, TT_ObjCProperty, TT_ObjCSelectorName, + TT_OverloadedOperator, TT_OverloadedOperatorLParen, TT_PointerOrReference, TT_PureVirtualSpecifier, diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 9e6a60961bce..30fea1c06791 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2490,6 +2490,8 @@ TEST_F(FormatTest, UndestandsOverloadedOperators) { verifyFormat("void *operator new[](std::size_t size);"); verifyFormat("void operator delete(void *ptr);"); verifyFormat("void operator delete[](void *ptr);"); + verifyFormat("template \n" + "AAAAAAA operator/(const AAAAAAA &a, BBBBBBB &b);"); verifyFormat( "ostream &operator<<(ostream &OutputStream,\n" -- GitLab From a6645e8b8f9c4805c3808e55fa17575c0360baaf Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 May 2013 09:16:52 +0000 Subject: [PATCH 156/467] InstCombine: Verify the type before transforming uitofp into select. PR15952. llvm-svn: 181586 --- .../InstCombine/InstCombineMulDivRem.cpp | 45 ++++++++++--------- llvm/test/Transforms/InstCombine/add4.ll | 18 ++++++++ 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 0ac0ca27acf6..ecc9fc3e4560 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -525,31 +525,32 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { } // B * (uitofp i1 C) -> select C, B, 0 - if(I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) { - Value *LHS=Op0, *RHS=Op1; - Value *B, *C; - if (!match(RHS, m_UIToFp(m_Value(C)))) - std::swap(LHS, RHS); - - if (match(RHS, m_UIToFp(m_Value(C)))) { - B=LHS; - Value *Zero = ConstantFP::getNegativeZero(B->getType()); - return SelectInst::Create(C, B, Zero); - } + if (I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) { + Value *LHS = Op0, *RHS = Op1; + Value *B, *C; + if (!match(RHS, m_UIToFp(m_Value(C)))) + std::swap(LHS, RHS); + + if (match(RHS, m_UIToFp(m_Value(C))) && C->getType()->isIntegerTy(1)) { + B = LHS; + Value *Zero = ConstantFP::getNegativeZero(B->getType()); + return SelectInst::Create(C, B, Zero); + } } // A * (1 - uitofp i1 C) -> select C, 0, A - if(I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) { - Value *LHS=Op0, *RHS=Op1; - Value *A, *C; - if (!match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C))))) - std::swap(LHS, RHS); - - if (match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C))))) { - A=LHS; - Value *Zero = ConstantFP::getNegativeZero(A->getType()); - return SelectInst::Create(C, Zero, A); - } + if (I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) { + Value *LHS = Op0, *RHS = Op1; + Value *A, *C; + if (!match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C))))) + std::swap(LHS, RHS); + + if (match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C)))) && + C->getType()->isIntegerTy(1)) { + A = LHS; + Value *Zero = ConstantFP::getNegativeZero(A->getType()); + return SelectInst::Create(C, Zero, A); + } } if (!isa(Op1)) diff --git a/llvm/test/Transforms/InstCombine/add4.ll b/llvm/test/Transforms/InstCombine/add4.ll index 3b19e9ef103d..0fc0a6c1ac26 100644 --- a/llvm/test/Transforms/InstCombine/add4.ll +++ b/llvm/test/Transforms/InstCombine/add4.ll @@ -38,3 +38,21 @@ EntryBlock: ; CHECK: select i1 %C, float %B, float %A } +; PR15952 +define float @test4(float %A, float %B, i32 %C) { + %cf = uitofp i32 %C to float + %mc = fsub float 1.000000e+00, %cf + %p1 = fmul fast float %A, %mc + ret float %p1 +; CHECK: @test4 +; CHECK: uitofp +} + +define float @test5(float %A, float %B, i32 %C) { + %cf = uitofp i32 %C to float + %p2 = fmul fast float %B, %cf + ret float %p2 +; CHECK: @test5 +; CHECK: uitofp +} + -- GitLab From 0d81e019169b544459992638047110cc630c36e4 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 10 May 2013 10:08:40 +0000 Subject: [PATCH 157/467] Add support for __wchar_t in -fms-extensions mode. MSVC provides __wchar_t. This is the same as the built-in wchar_t type from C++, but it is also available with -fno-wchar and in C. The commit changes ASTContext to have two different types for this: - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t. - WideCharTy is the type of a wide character literal. In C++ this is the same as WCharTy, and in C it is an integer type compatible with the type in . This fixes PR15815. llvm-svn: 181587 --- clang/include/clang/AST/ASTContext.h | 13 +++++++++---- clang/include/clang/AST/PrettyPrinter.h | 7 ++++++- clang/include/clang/Basic/TokenKinds.def | 1 + clang/lib/AST/ASTContext.cpp | 18 +++++++++++------- clang/lib/AST/Type.cpp | 2 +- clang/lib/Analysis/FormatString.cpp | 4 ++-- clang/lib/Analysis/PrintfFormatString.cpp | 2 +- clang/lib/Analysis/ScanfFormatString.cpp | 4 ++-- clang/lib/Sema/SemaDeclCXX.cpp | 4 ++-- clang/lib/Sema/SemaExpr.cpp | 6 +++--- clang/lib/Sema/SemaExprObjC.cpp | 4 ++-- clang/lib/Sema/SemaInit.cpp | 2 +- clang/lib/Sema/SemaTemplateInstantiate.cpp | 2 +- clang/test/Sema/ms-wchar.c | 15 +++++++++++++++ clang/test/SemaCXX/ms-wchar.cpp | 9 +++++++++ 15 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 clang/test/Sema/ms-wchar.c create mode 100644 clang/test/SemaCXX/ms-wchar.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index c5d3337fd22d..2d08c49e1d0f 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -740,7 +740,8 @@ public: CanQualType VoidTy; CanQualType BoolTy; CanQualType CharTy; - CanQualType WCharTy; // [C++ 3.9.1p5], integer type in C99. + CanQualType WCharTy; // [C++ 3.9.1p5]. + CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99. CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions. CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99. CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99. @@ -1130,11 +1131,15 @@ public: /// . CanQualType getUIntMaxType() const; - /// \brief In C++, this returns the unique wchar_t type. In C99, this - /// returns a type compatible with the type defined in as defined - /// by the target. + /// \brief Return the unique wchar_t type available in C++ (and available as + /// __wchar_t as a Microsoft extension). QualType getWCharType() const { return WCharTy; } + /// \brief Return the type of wide characters. In C++, this returns the + /// unique wchar_t type. In C99, this returns a type compatible with the type + /// defined in as defined by the target. + QualType getWideCharType() const { return WideCharTy; } + /// \brief Return the type of "signed wchar_t". /// /// Used when in C++, as a GCC extension. diff --git a/clang/include/clang/AST/PrettyPrinter.h b/clang/include/clang/AST/PrettyPrinter.h index e3c09e7b418f..adfd1ac936b9 100644 --- a/clang/include/clang/AST/PrettyPrinter.h +++ b/clang/include/clang/AST/PrettyPrinter.h @@ -40,7 +40,8 @@ struct PrintingPolicy { SuppressUnwrittenScope(false), SuppressInitializers(false), ConstantArraySizeAsWritten(false), AnonymousTagLocations(true), SuppressStrongLifetime(false), Bool(LO.Bool), - TerseOutput(false), PolishForDeclaration(false) { } + TerseOutput(false), PolishForDeclaration(false), + MSWChar(LO.MicrosoftExt && !LO.WChar) { } /// \brief What language we're printing. LangOptions LangOpts; @@ -146,6 +147,10 @@ struct PrintingPolicy { /// declaration tag; such as, do not print attributes attached to the declaration. /// unsigned PolishForDeclaration : 1; + + /// \brief When true, print the built-in wchar_t type as __wchar_t. For use in + /// Microsoft mode when wchar_t is not available. + unsigned MSWChar : 1; }; } // end namespace clang diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index bcf0f31dcbf6..0dbff81d3423 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -524,6 +524,7 @@ KEYWORD(__interface , KEYMS) ALIAS("__int8" , char , KEYMS) ALIAS("__int16" , short , KEYMS) ALIAS("__int32" , int , KEYMS) +ALIAS("__wchar_t" , wchar_t , KEYMS) ALIAS("_asm" , asm , KEYMS) ALIAS("_alignof" , __alignof , KEYMS) ALIAS("__builtin_alignof", __alignof , KEYMS) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index ffcf6b5d7a92..960f261816b1 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -897,13 +897,17 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) { InitBuiltinType(Int128Ty, BuiltinType::Int128); InitBuiltinType(UnsignedInt128Ty, BuiltinType::UInt128); - if (LangOpts.CPlusPlus && LangOpts.WChar) { // C++ 3.9.1p5 - if (TargetInfo::isTypeSigned(Target.getWCharType())) - InitBuiltinType(WCharTy, BuiltinType::WChar_S); - else // -fshort-wchar makes wchar_t be unsigned. - InitBuiltinType(WCharTy, BuiltinType::WChar_U); - } else // C99 (or C++ using -fno-wchar) - WCharTy = getFromTargetType(Target.getWCharType()); + // C++ 3.9.1p5 + if (TargetInfo::isTypeSigned(Target.getWCharType())) + InitBuiltinType(WCharTy, BuiltinType::WChar_S); + else // -fshort-wchar makes wchar_t be unsigned. + InitBuiltinType(WCharTy, BuiltinType::WChar_U); + if (LangOpts.CPlusPlus && LangOpts.WChar) + WideCharTy = WCharTy; + else { + // C99 (or C++ using -fno-wchar). + WideCharTy = getFromTargetType(Target.getWCharType()); + } WIntTy = getFromTargetType(Target.getWIntType()); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index fa16facb634f..a1f0b08494b0 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1521,7 +1521,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const { case Double: return "double"; case LongDouble: return "long double"; case WChar_S: - case WChar_U: return "wchar_t"; + case WChar_U: return Policy.MSWChar ? "__wchar_t" : "wchar_t"; case Char16: return "char16_t"; case Char32: return "char32_t"; case NullPtr: return "nullptr_t"; diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/Analysis/FormatString.cpp index ad0dce4444b6..382be24dca78 100644 --- a/clang/lib/Analysis/FormatString.cpp +++ b/clang/lib/Analysis/FormatString.cpp @@ -334,7 +334,7 @@ bool ArgType::matchesType(ASTContext &C, QualType argTy) const { return false; QualType pointeeTy = C.getCanonicalType(PT->getPointeeType()).getUnqualifiedType(); - return pointeeTy == C.getWCharType(); + return pointeeTy == C.getWideCharType(); } case WIntTy: { @@ -398,7 +398,7 @@ QualType ArgType::getRepresentativeType(ASTContext &C) const { Res = C.getPointerType(C.CharTy); break; case WCStrTy: - Res = C.getPointerType(C.getWCharType()); + Res = C.getPointerType(C.getWideCharType()); break; case ObjCPointerTy: Res = C.ObjCBuiltinIdTy; diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp index 8f151b9358e6..60f9517e7f91 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/lib/Analysis/PrintfFormatString.cpp @@ -372,7 +372,7 @@ ArgType PrintfSpecifier::getArgType(ASTContext &Ctx, case ConversionSpecifier::CArg: if (IsObjCLiteral) return ArgType(Ctx.UnsignedShortTy, "unichar"); - return ArgType(Ctx.WCharTy, "wchar_t"); + return ArgType(Ctx.WideCharTy, "wchar_t"); case ConversionSpecifier::pArg: return ArgType::CPointerTy; case ConversionSpecifier::ObjCObjArg: diff --git a/clang/lib/Analysis/ScanfFormatString.cpp b/clang/lib/Analysis/ScanfFormatString.cpp index 2dbc9e494881..676b68f391c5 100644 --- a/clang/lib/Analysis/ScanfFormatString.cpp +++ b/clang/lib/Analysis/ScanfFormatString.cpp @@ -311,7 +311,7 @@ ArgType ScanfSpecifier::getArgType(ASTContext &Ctx) const { case LengthModifier::None: return ArgType::PtrTo(ArgType::AnyCharTy); case LengthModifier::AsLong: - return ArgType::PtrTo(ArgType(Ctx.getWCharType(), "wchar_t")); + return ArgType::PtrTo(ArgType(Ctx.getWideCharType(), "wchar_t")); case LengthModifier::AsAllocate: case LengthModifier::AsMAllocate: return ArgType::PtrTo(ArgType::CStrTy); @@ -323,7 +323,7 @@ ArgType ScanfSpecifier::getArgType(ASTContext &Ctx) const { // FIXME: Mac OS X specific? switch (LM.getKind()) { case LengthModifier::None: - return ArgType::PtrTo(ArgType(Ctx.getWCharType(), "wchar_t")); + return ArgType::PtrTo(ArgType(Ctx.getWideCharType(), "wchar_t")); case LengthModifier::AsAllocate: case LengthModifier::AsMAllocate: return ArgType::PtrTo(ArgType(ArgType::WCStrTy, "wchar_t *")); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index b86a2b92779d..e5d0316f738e 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -10408,7 +10408,7 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { if (Context.hasSameType(T, Context.UnsignedLongLongTy) || Context.hasSameType(T, Context.LongDoubleTy) || Context.hasSameType(T, Context.CharTy) || - Context.hasSameType(T, Context.WCharTy) || + Context.hasSameType(T, Context.WideCharTy) || Context.hasSameType(T, Context.Char16Ty) || Context.hasSameType(T, Context.Char32Ty)) { if (++Param == FnDecl->param_end()) @@ -10438,7 +10438,7 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { // const char *, const wchar_t*, const char16_t*, and const char32_t* // are allowed as the first parameter to a two-parameter function if (!(Context.hasSameType(T, Context.CharTy) || - Context.hasSameType(T, Context.WCharTy) || + Context.hasSameType(T, Context.WideCharTy) || Context.hasSameType(T, Context.Char16Ty) || Context.hasSameType(T, Context.Char32Ty))) goto FinishedParams; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 031a631f6c0a..ef7e0f2e33d1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1448,7 +1448,7 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks, QualType StrTy = Context.CharTy; if (Literal.isWide()) - StrTy = Context.getWCharType(); + StrTy = Context.getWideCharType(); else if (Literal.isUTF16()) StrTy = Context.Char16Ty; else if (Literal.isUTF32()) @@ -2720,7 +2720,7 @@ ExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind) { llvm::APInt LengthI(32, Length + 1); if (IT == PredefinedExpr::LFunction) - ResTy = Context.WCharTy.withConst(); + ResTy = Context.WideCharTy.withConst(); else ResTy = Context.CharTy.withConst(); ResTy = Context.getConstantArrayType(ResTy, LengthI, ArrayType::Normal, 0); @@ -2742,7 +2742,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) { QualType Ty; if (Literal.isWide()) - Ty = Context.WCharTy; // L'x' -> wchar_t in C and C++. + Ty = Context.WideCharTy; // L'x' -> wchar_t in C and C++. else if (Literal.isUTF16()) Ty = Context.Char16Ty; // u'x' -> char16_t in C11 and C++11. else if (Literal.isUTF32()) diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 0e3dc003ab12..d37f61ab8abd 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -266,7 +266,7 @@ ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) { break; case CharacterLiteral::Wide: - NumberType = Context.getWCharType(); + NumberType = Context.getWideCharType(); break; case CharacterLiteral::UTF16: @@ -521,7 +521,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { break; case CharacterLiteral::Wide: - ValueType = Context.getWCharType(); + ValueType = Context.getWideCharType(); break; case CharacterLiteral::UTF16: diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 9e8936e17b8a..7016e565daba 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -65,7 +65,7 @@ static Expr *IsStringInit(Expr *Init, const ArrayType *AT, // correction from DR343): "An array with element type compatible with a // qualified or unqualified version of wchar_t may be initialized by a wide // string literal, optionally enclosed in braces." - if (Context.typesAreCompatible(Context.getWCharType(), + if (Context.typesAreCompatible(Context.getWideCharType(), ElemTy.getUnqualifiedType())) return Init; diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 7ef04e964dc6..862334a82a60 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1105,7 +1105,7 @@ TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) { llvm::APInt LengthI(32, Length + 1); QualType ResTy; if (IT == PredefinedExpr::LFunction) - ResTy = getSema().Context.WCharTy.withConst(); + ResTy = getSema().Context.WideCharTy.withConst(); else ResTy = getSema().Context.CharTy.withConst(); ResTy = getSema().Context.getConstantArrayType(ResTy, LengthI, diff --git a/clang/test/Sema/ms-wchar.c b/clang/test/Sema/ms-wchar.c new file mode 100644 index 000000000000..52a736c6402e --- /dev/null +++ b/clang/test/Sema/ms-wchar.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s + +// C++ mode with -fno-wchar works the same as C mode for wchar_t. +// RUN: %clang_cc1 -x c++ -fno-wchar -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s + +wchar_t f(); // expected-error{{unknown type name 'wchar_t'}} + +// __wchar_t is available as an MS extension. +__wchar_t g = L'a'; // expected-note {{previous}} + +// __wchar_t is a distinct type, separate from the target's integer type for wide chars. +unsigned short g; // expected-error {{redefinition of 'g' with a different type: 'unsigned short' vs '__wchar_t'}} + +// The type of a wide string literal is actually not __wchar_t. +__wchar_t s[] = L"Hello world!"; // expected-error {{array initializer must be an initializer list}} diff --git a/clang/test/SemaCXX/ms-wchar.cpp b/clang/test/SemaCXX/ms-wchar.cpp new file mode 100644 index 000000000000..2cbf745d3393 --- /dev/null +++ b/clang/test/SemaCXX/ms-wchar.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s + +wchar_t f(); +__wchar_t f(); // No error, wchar_t and __wchar_t are the same type. + +__wchar_t g = L'a'; +__wchar_t s[] = L"Hello world!"; + +unsigned short t[] = L"Hello world!"; // expected-error{{array initializer must be an initializer list}} -- GitLab From 3154a10bcb440bfbf5b1b918bc2b649cb9eb5ce0 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 10 May 2013 11:52:02 +0000 Subject: [PATCH 158/467] Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers. Differential Revision: http://llvm-reviews.chandlerc.com/D744 llvm-svn: 181588 --- clang/include/clang/ASTMatchers/ASTMatchers.h | 68 +++++++++++++++++++ .../unittests/ASTMatchers/ASTMatchersTest.cpp | 25 +++++++ 2 files changed, 93 insertions(+) diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 2b04f8c2e4b2..61f11060d828 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -894,6 +894,26 @@ const internal::VariadicDynCastAllOfMatcher switchStmt; /// matches 'case 42: break;' and 'default: break;'. const internal::VariadicDynCastAllOfMatcher switchCase; +/// \brief Matches case statements inside switch statements. +/// +/// Given +/// \code +/// switch(a) { case 42: break; default: break; } +/// \endcode +/// caseStmt() +/// matches 'case 42: break;'. +const internal::VariadicDynCastAllOfMatcher caseStmt; + +/// \brief Matches default statements inside switch statements. +/// +/// Given +/// \code +/// switch(a) { case 42: break; default: break; } +/// \endcode +/// defaultStmt() +/// matches 'default: break;'. +const internal::VariadicDynCastAllOfMatcher defaultStmt; + /// \brief Matches compound statements. /// /// Example matches '{}' and '{{}}'in 'for (;;) {{}}' @@ -3348,6 +3368,54 @@ AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, Stmt*, Other, 1) { /// @} +/// \brief Matches each case or default statement belonging to the given switch +/// statement. This matcher may produce multiple matches. +/// +/// Given +/// \code +/// switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } +/// \endcode +/// switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") +/// matches four times, with "c" binding each of "case 1:", "case 2:", +/// "case 3:" and "case 4:", and "s" respectively binding "switch (1)", +/// "switch (1)", "switch (2)" and "switch (2)". +AST_MATCHER_P(SwitchStmt, forEachSwitchCase, internal::Matcher, + InnerMatcher) { + // FIXME: getSwitchCaseList() does not necessarily guarantee a stable + // iteration order. We should use the more general iterating matchers once + // they are capable of expressing this matcher (for example, it should ignore + // case statements belonging to nested switch statements). + bool Matched = false; + for (const SwitchCase *SC = Node.getSwitchCaseList(); SC; + SC = SC->getNextSwitchCase()) { + BoundNodesTreeBuilder CaseBuilder; + bool CaseMatched = InnerMatcher.matches(*SC, Finder, &CaseBuilder); + if (CaseMatched) { + Matched = true; + Builder->addMatch(CaseBuilder.build()); + } + } + + return Matched; +} + +/// \brief If the given case statement does not use the GNU case range +/// extension, matches the constant given in the statement. +/// +/// Given +/// \code +/// switch (1) { case 1: case 1+1: case 3 ... 4: ; } +/// \endcode +/// caseStmt(hasCaseConstant(integerLiteral())) +/// matches "case 1:" +AST_MATCHER_P(CaseStmt, hasCaseConstant, internal::Matcher, + InnerMatcher) { + if (Node.getRHS()) + return false; + + return InnerMatcher.matches(*Node.getLHS(), Finder, Builder); +} + } // end namespace ast_matchers } // end namespace clang diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 50aa583f940a..8dd3b70d210f 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2924,6 +2924,31 @@ TEST(SwitchCase, MatchesSwitch) { EXPECT_TRUE(notMatches("void x() {}", switchStmt())); } +TEST(SwitchCase, MatchesEachCase) { + EXPECT_TRUE(notMatches("void x() { switch(42); }", + switchStmt(forEachSwitchCase(caseStmt())))); + EXPECT_TRUE(matches("void x() { switch(42) case 42:; }", + switchStmt(forEachSwitchCase(caseStmt())))); + EXPECT_TRUE(matches("void x() { switch(42) { case 42:; } }", + switchStmt(forEachSwitchCase(caseStmt())))); + EXPECT_TRUE(notMatches( + "void x() { if (1) switch(42) { case 42: switch (42) { default:; } } }", + ifStmt(has(switchStmt(forEachSwitchCase(defaultStmt())))))); + EXPECT_TRUE(matches("void x() { switch(42) { case 1+1: case 4:; } }", + switchStmt(forEachSwitchCase( + caseStmt(hasCaseConstant(integerLiteral())))))); + EXPECT_TRUE(notMatches("void x() { switch(42) { case 1+1: case 2+2:; } }", + switchStmt(forEachSwitchCase( + caseStmt(hasCaseConstant(integerLiteral())))))); + EXPECT_TRUE(notMatches("void x() { switch(42) { case 1 ... 2:; } }", + switchStmt(forEachSwitchCase( + caseStmt(hasCaseConstant(integerLiteral())))))); + EXPECT_TRUE(matchAndVerifyResultTrue( + "void x() { switch (42) { case 1: case 2: case 3: default:; } }", + switchStmt(forEachSwitchCase(caseStmt().bind("x"))), + new VerifyIdIsBoundTo("x", 3))); +} + TEST(ExceptionHandling, SimpleCases) { EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", catchStmt())); EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", tryStmt())); -- GitLab From 49149677d96672a598a05e56ea105035ff777a76 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 10 May 2013 11:56:10 +0000 Subject: [PATCH 159/467] Config file support for clang-format, part 2. Summary: Adds actual config file reading to the clang-format utility. Configuration file name is .clang-format. It is looked up for each input file in its parent directories starting from immediate one. First found .clang-format file is used. When using standard input, .clang-format is searched starting from the current directory. Added -dump-config option to easily create configuration files. Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, jordan_rose, kimgr Differential Revision: http://llvm-reviews.chandlerc.com/D758 llvm-svn: 181589 --- clang/include/clang/Format/Format.h | 23 +++++++++ clang/lib/Format/Format.cpp | 25 ++++++--- clang/tools/clang-format/ClangFormat.cpp | 64 ++++++++++++++++++------ clang/unittests/Format/FormatTest.cpp | 22 -------- 4 files changed, 90 insertions(+), 44 deletions(-) diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 0c9b4cadb55a..9d17c77db7fc 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -93,6 +93,29 @@ struct FormatStyle { /// \brief If \c true, aligns escaped newlines as far left as possible. /// Otherwise puts them into the right-most column. bool AlignEscapedNewlinesLeft; + + bool operator==(const FormatStyle &R) const { + return AccessModifierOffset == R.AccessModifierOffset && + AlignEscapedNewlinesLeft == R.AlignEscapedNewlinesLeft && + AllowAllParametersOfDeclarationOnNextLine == + R.AllowAllParametersOfDeclarationOnNextLine && + AllowShortIfStatementsOnASingleLine == + R.AllowShortIfStatementsOnASingleLine && + BinPackParameters == R.BinPackParameters && + ColumnLimit == R.ColumnLimit && + ConstructorInitializerAllOnOneLineOrOnePerLine == + R.ConstructorInitializerAllOnOneLineOrOnePerLine && + DerivePointerBinding == R.DerivePointerBinding && + IndentCaseLabels == R.IndentCaseLabels && + MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && + ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList && + PenaltyExcessCharacter == R.PenaltyExcessCharacter && + PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine && + PointerBindsToType == R.PointerBindsToType && + SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments && + Standard == R.Standard; + } + }; /// \brief Returns a format style complying with the LLVM coding standards: diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 2413e43b138e..fe8567de64b8 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -46,10 +46,19 @@ struct ScalarEnumerationTraits { template <> struct MappingTraits { static void mapping(llvm::yaml::IO &IO, clang::format::FormatStyle &Style) { - if (!IO.outputting()) { + if (IO.outputting()) { + StringRef StylesArray[] = { "LLVM", "Google", "Chromium", "Mozilla" }; + ArrayRef Styles(StylesArray); + for (size_t i = 0, e = Styles.size(); i < e; ++i) { + StringRef StyleName(Styles[i]); + if (Style == clang::format::getPredefinedStyle(StyleName)) { + IO.mapOptional("# BasedOnStyle", StyleName); + break; + } + } + } else { StringRef BasedOnStyle; IO.mapOptional("BasedOnStyle", BasedOnStyle); - if (!BasedOnStyle.empty()) Style = clang::format::getPredefinedStyle(BasedOnStyle); } @@ -245,9 +254,9 @@ public: private: void DebugTokenState(const AnnotatedToken &AnnotatedTok) { const Token &Tok = AnnotatedTok.FormatTok.Tok; - llvm::errs() << StringRef(SourceMgr.getCharacterData(Tok.getLocation()), + llvm::dbgs() << StringRef(SourceMgr.getCharacterData(Tok.getLocation()), Tok.getLength()); - llvm::errs(); + llvm::dbgs(); } struct ParenState { @@ -825,7 +834,7 @@ private: unsigned Penalty = Queue.top().first.first; StateNode *Node = Queue.top().second; if (Node->State.NextToken == NULL) { - DEBUG(llvm::errs() << "\n---\nPenalty for line: " << Penalty << "\n"); + DEBUG(llvm::dbgs() << "\n---\nPenalty for line: " << Penalty << "\n"); break; } Queue.pop(); @@ -845,8 +854,8 @@ private: // Reconstruct the solution. reconstructPath(InitialState, Queue.top().second); - DEBUG(llvm::errs() << "Total number of analyzed states: " << Count << "\n"); - DEBUG(llvm::errs() << "---\n"); + DEBUG(llvm::dbgs() << "Total number of analyzed states: " << Count << "\n"); + DEBUG(llvm::dbgs() << "---\n"); // Return the column after the last token of the solution. return Queue.top().second->State.Column; @@ -862,7 +871,7 @@ private: reconstructPath(State, Current->Previous); DEBUG({ if (Current->NewLine) { - llvm::errs() + llvm::dbgs() << "Penalty for splitting before " << Current->Previous->State.NextToken->FormatTok.Tok.getName() << ": " << Current->Previous->State.NextToken->SplitPenalty << "\n"; diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 57833edf0f31..5ae95781fb11 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -20,6 +20,7 @@ #include "clang/Format/Format.h" #include "clang/Lex/Lexer.h" #include "clang/Rewrite/Core/Rewriter.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Signals.h" @@ -36,13 +37,20 @@ Lengths("length", cl::desc("Format a range of this length. " "Can only be used with one input file.")); static cl::opt Style( "style", - cl::desc("Coding style, currently supports: LLVM, Google, Chromium, Mozilla."), + cl::desc( + "Coding style, currently supports: LLVM, Google, Chromium, Mozilla. " + "Use '-style file' to load style configuration from .clang-format file " + "located in one of the parent directories of the source file (or " + "current directory for stdin)."), cl::init("LLVM")); static cl::opt Inplace("i", cl::desc("Inplace edit s, if specified.")); static cl::opt OutputXML( "output-replacements-xml", cl::desc("Output replacements as XML.")); +static cl::opt + DumpConfig("dump-config", + cl::desc("Dump configuration options to stdout and exit. Can be used with -style option.")); static cl::list FileNames(cl::Positional, cl::desc("[ ...]")); @@ -59,18 +67,38 @@ static FileID createInMemoryFile(StringRef FileName, const MemoryBuffer *Source, return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User); } -static FormatStyle getStyle() { - FormatStyle TheStyle = getGoogleStyle(); - if (Style == "LLVM") - TheStyle = getLLVMStyle(); - else if (Style == "Chromium") - TheStyle = getChromiumStyle(); - else if (Style == "Mozilla") - TheStyle = getMozillaStyle(); - else if (Style != "Google") - llvm::errs() << "Unknown style " << Style << ", using Google style.\n"; - - return TheStyle; +FormatStyle getStyle(StringRef StyleName, StringRef FileName) { + if (!StyleName.equals_lower("file")) + return getPredefinedStyle(StyleName); + + SmallString<128> Path(FileName); + llvm::sys::fs::make_absolute(Path); + for (StringRef Directory = llvm::sys::path::parent_path(Path); + !Directory.empty(); + Directory = llvm::sys::path::parent_path(Directory)) { + SmallString<128> ConfigFile(Directory); + llvm::sys::path::append(ConfigFile, ".clang-format"); + DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n"); + bool IsFile = false; + llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile); + if (IsFile) { + OwningPtr Text; + if (error_code ec = MemoryBuffer::getFile(ConfigFile, Text)) { + llvm::errs() << ec.message() << "\n"; + continue; + } + FormatStyle Style; + if (error_code ec = parseConfiguration(Text->getBuffer(), &Style)) { + llvm::errs() << "Error reading " << ConfigFile << ": " << ec.message() + << "\n"; + continue; + } + DEBUG(llvm::dbgs() << "Using configuration file " << ConfigFile << "\n"); + return Style; + } + } + llvm::errs() << "Can't find usable .clang-format, using LLVM style\n"; + return getLLVMStyle(); } // Returns true on error. @@ -118,7 +146,8 @@ static bool format(std::string FileName) { } Ranges.push_back(CharSourceRange::getCharRange(Start, End)); } - tooling::Replacements Replaces = reformat(getStyle(), Lex, Sources, Ranges); + tooling::Replacements Replaces = + reformat(getStyle(Style, FileName), Lex, Sources, Ranges); if (OutputXML) { llvm::outs() << "\n\n"; @@ -171,6 +200,13 @@ int main(int argc, const char **argv) { if (Help) cl::PrintHelpMessage(); + if (DumpConfig) { + std::string Config = clang::format::configurationAsText( + clang::format::getStyle(Style, FileNames.empty() ? "-" : FileNames[0])); + llvm::outs() << Config << "\n"; + return 0; + } + bool Error = false; switch (FileNames.size()) { case 0: diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 30fea1c06791..fab34e8684e9 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3933,28 +3933,6 @@ TEST_F(FormatTest, DoNotCreateUnreasonableUnwrappedLines) { "}"); } -bool operator==(const FormatStyle &L, const FormatStyle &R) { - return L.AccessModifierOffset == R.AccessModifierOffset && - L.AlignEscapedNewlinesLeft == R.AlignEscapedNewlinesLeft && - L.AllowAllParametersOfDeclarationOnNextLine == - R.AllowAllParametersOfDeclarationOnNextLine && - L.AllowShortIfStatementsOnASingleLine == - R.AllowShortIfStatementsOnASingleLine && - L.BinPackParameters == R.BinPackParameters && - L.ColumnLimit == R.ColumnLimit && - L.ConstructorInitializerAllOnOneLineOrOnePerLine == - R.ConstructorInitializerAllOnOneLineOrOnePerLine && - L.DerivePointerBinding == R.DerivePointerBinding && - L.IndentCaseLabels == R.IndentCaseLabels && - L.MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && - L.ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList && - L.PenaltyExcessCharacter == R.PenaltyExcessCharacter && - L.PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine && - L.PointerBindsToType == R.PointerBindsToType && - L.SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments && - L.Standard == R.Standard; -} - bool allStylesEqual(ArrayRef Styles) { for (size_t i = 1; i < Styles.size(); ++i) if (!(Styles[0] == Styles[i])) -- GitLab From 1cb530f1e0a69df266ea09945ce281f1b10fb821 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 10 May 2013 13:00:49 +0000 Subject: [PATCH 160/467] Always format entire macro definitions. Thereby, the macro is consistently formatted (including the trailing escaped newlines) even if clang-format is invoked only on single lines of the macro. llvm-svn: 181590 --- clang/lib/Format/Format.cpp | 22 +++++++++++++++++++++- clang/unittests/Format/FormatTest.cpp | 26 +++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index fe8567de64b8..98cb81ef4161 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1118,12 +1118,21 @@ public: std::vector IndentForLevel; bool PreviousLineWasTouched = false; const AnnotatedToken *PreviousLineLastToken = 0; + bool FormatPPDirective = false; for (std::vector::iterator I = AnnotatedLines.begin(), E = AnnotatedLines.end(); I != E; ++I) { const AnnotatedLine &TheLine = *I; const FormatToken &FirstTok = TheLine.First.FormatTok; int Offset = getIndentOffset(TheLine.First); + + // Check whether this line is part of a formatted preprocessor directive. + if (FirstTok.HasUnescapedNewline) + FormatPPDirective = false; + if (!FormatPPDirective && TheLine.InPPDirective && + (touchesLine(TheLine) || touchesPPDirective(I + 1, E))) + FormatPPDirective = true; + while (IndentForLevel.size() <= TheLine.Level) IndentForLevel.push_back(-1); IndentForLevel.resize(TheLine.Level + 1); @@ -1135,7 +1144,7 @@ public: /*WhitespaceStartColumn*/ 0); } } else if (TheLine.Type != LT_Invalid && - (WasMoved || touchesLine(TheLine))) { + (WasMoved || FormatPPDirective || touchesLine(TheLine))) { unsigned LevelIndent = getIndent(IndentForLevel, TheLine.Level); unsigned Indent = LevelIndent; if (static_cast(Indent) + Offset >= 0) @@ -1412,6 +1421,17 @@ private: return touchesRanges(LineRange); } + bool touchesPPDirective(std::vector::iterator I, + std::vector::iterator E) { + for (; I != E; ++I) { + if (I->First.FormatTok.HasUnescapedNewline) + return false; + if (touchesLine(*I)) + return true; + } + return false; + } + bool touchesEmptyLineBefore(const AnnotatedLine &TheLine) { const FormatToken *First = &TheLine.First.FormatTok; CharSourceRange LineRange = CharSourceRange::getCharRange( diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index fab34e8684e9..f8ccf8607042 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1289,9 +1289,29 @@ TEST_F(FormatTest, LayoutCodeInMacroDefinitions) { TEST_F(FormatTest, LayoutRemainingTokens) { EXPECT_EQ("{}", format("{}")); } -TEST_F(FormatTest, LayoutSingleUnwrappedLineInMacro) { - EXPECT_EQ("# define A\\\n b;", - format("# define A b;", 11, 2, getLLVMStyleWithColumns(11))); +TEST_F(FormatTest, AlwaysFormatsEntireMacroDefinitions) { + EXPECT_EQ("int i;\n" + "#define A \\\n" + " int i; \\\n" + " int j\n" + "int k;", + format("int i;\n" + "#define A \\\n" + " int i ; \\\n" + " int j\n" + "int k;", + 8, 0, getGoogleStyle())); // 8: position of "#define". + EXPECT_EQ("int i;\n" + "#define A \\\n" + " int i; \\\n" + " int j\n" + "int k;", + format("int i;\n" + "#define A \\\n" + " int i ; \\\n" + " int j\n" + "int k;", + 45, 0, getGoogleStyle())); // 45: position of "j". } TEST_F(FormatTest, MacroDefinitionInsideStatement) { -- GitLab From fa94cbb70f2363ec487d033c99c681953d5e095c Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 10 May 2013 13:04:20 +0000 Subject: [PATCH 161/467] Minor clarifications in help messages and a comment. llvm-svn: 181591 --- clang/tools/clang-format/ClangFormat.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 5ae95781fb11..ea9482ea120c 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -29,10 +29,10 @@ using namespace llvm; static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); static cl::list -Offsets("offset", cl::desc("Format a range starting at this file offset. Can " +Offsets("offset", cl::desc("Format a range starting at this byte offset. Can " "only be used with one input file.")); static cl::list -Lengths("length", cl::desc("Format a range of this length. " +Lengths("length", cl::desc("Format a range of this length (in bytes). " "When it's not specified, end of file is used. " "Can only be used with one input file.")); static cl::opt Style( @@ -80,6 +80,8 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName) { llvm::sys::path::append(ConfigFile, ".clang-format"); DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n"); bool IsFile = false; + // Ignore errors from is_regular_file: we only need to know if we can read + // the file or not. llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile); if (IsFile) { OwningPtr Text; -- GitLab From 8236037d47b0355879b8a7990f5e559b6e64d7a4 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 13:06:58 +0000 Subject: [PATCH 162/467] ArrayRef'ize GenericSelectionExpr llvm-svn: 181592 --- clang/include/clang/Sema/Sema.h | 9 ++++----- clang/lib/Sema/SemaExpr.cpp | 29 +++++++++++++---------------- clang/lib/Sema/TreeTransform.h | 13 +++++-------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 618574207dec..81e00b81f107 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3144,15 +3144,14 @@ public: SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - MultiTypeArg ArgTypes, - MultiExprArg ArgExprs); + ArrayRef ArgTypes, + ArrayRef ArgExprs); ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - TypeSourceInfo **Types, - Expr **Exprs, - unsigned NumAssocs); + ArrayRef Types, + ArrayRef Exprs); // Binary/Unary Operators. 'Tok' is the token for the operator. ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ef7e0f2e33d1..b6b644473825 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1230,25 +1230,23 @@ Sema::ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - MultiTypeArg ArgTypes, - MultiExprArg ArgExprs) { + ArrayRef ArgTypes, + ArrayRef ArgExprs) { unsigned NumAssocs = ArgTypes.size(); assert(NumAssocs == ArgExprs.size()); - ParsedType *ParsedTypes = ArgTypes.data(); - Expr **Exprs = ArgExprs.data(); - TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs]; for (unsigned i = 0; i < NumAssocs; ++i) { - if (ParsedTypes[i]) - (void) GetTypeFromParser(ParsedTypes[i], &Types[i]); + if (ArgTypes[i]) + (void) GetTypeFromParser(ArgTypes[i], &Types[i]); else Types[i] = 0; } ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, - ControllingExpr, Types, Exprs, - NumAssocs); + ControllingExpr, + llvm::makeArrayRef(Types, NumAssocs), + ArgExprs); delete [] Types; return ER; } @@ -1258,9 +1256,10 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - TypeSourceInfo **Types, - Expr **Exprs, - unsigned NumAssocs) { + ArrayRef Types, + ArrayRef Exprs) { + unsigned NumAssocs = Types.size(); + assert(NumAssocs == Exprs.size()); if (ControllingExpr->getType()->isPlaceholderType()) { ExprResult result = CheckPlaceholderExpr(ControllingExpr); if (result.isInvalid()) return ExprError(); @@ -1328,8 +1327,7 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, if (IsResultDependent) return Owned(new (Context) GenericSelectionExpr( Context, KeyLoc, ControllingExpr, - llvm::makeArrayRef(Types, NumAssocs), - llvm::makeArrayRef(Exprs, NumAssocs), + Types, Exprs, DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack)); SmallVector CompatIndices; @@ -1384,8 +1382,7 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, return Owned(new (Context) GenericSelectionExpr( Context, KeyLoc, ControllingExpr, - llvm::makeArrayRef(Types, NumAssocs), - llvm::makeArrayRef(Exprs, NumAssocs), + Types, Exprs, DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack, ResultIndex)); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 89e23ef46052..253135ff70d8 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1767,12 +1767,10 @@ public: SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - TypeSourceInfo **Types, - Expr **Exprs, - unsigned NumAssocs) { + ArrayRef Types, + ArrayRef Exprs) { return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, - ControllingExpr, Types, Exprs, - NumAssocs); + ControllingExpr, Types, Exprs); } /// \brief Build a new overloaded operator call expression. @@ -6289,9 +6287,8 @@ TreeTransform::TransformGenericSelectionExpr(GenericSelectionExpr *E) { E->getDefaultLoc(), E->getRParenLoc(), ControllingExpr.release(), - AssocTypes.data(), - AssocExprs.data(), - E->getNumAssocs()); + AssocTypes, + AssocExprs); } template -- GitLab From 70f6b3b6311f93766d4717a2832840cd01e04499 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 10 May 2013 13:18:17 +0000 Subject: [PATCH 163/467] Updated clang-format help messages for -offset and -length llvm-svn: 181593 --- clang/tools/clang-format/ClangFormat.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index ea9482ea120c..ea70dafe0398 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -28,13 +28,19 @@ using namespace llvm; static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); -static cl::list -Offsets("offset", cl::desc("Format a range starting at this byte offset. Can " - "only be used with one input file.")); -static cl::list -Lengths("length", cl::desc("Format a range of this length (in bytes). " - "When it's not specified, end of file is used. " - "Can only be used with one input file.")); +static cl::list Offsets( + "offset", + cl::desc( + "Format a range starting at this byte offset. Multiple ranges can be " + "formatted by specifying several -offset and -length pairs. Can " + "only be used with one input file.")); +static cl::list Lengths( + "length", + cl::desc("Format a range of this length (in bytes). Multiple ranges can be " + "formatted by specifying several -offset and -length pairs. When " + "only a single -offset is specified without -length, clang-format " + "will format up to the end of the file. Can only be used with one " + "input file.")); static cl::opt Style( "style", cl::desc( -- GitLab From be0221067d0f27d294f6a1ecb0002f5e55a54d09 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 13:22:23 +0000 Subject: [PATCH 164/467] ArrayRef'ize Sema::FindAllocationFunctions Patch by Robert Wilhelm. llvm-svn: 181594 --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Sema/SemaExprCXX.cpp | 47 +++++++++++++-------------------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 81e00b81f107..8e1ebd844e1c 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3979,7 +3979,7 @@ public: SourceRange R); bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, bool UseGlobal, QualType AllocType, bool IsArray, - Expr **PlaceArgs, unsigned NumPlaceArgs, + MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete); bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index be5c00b8b947..cde2e4940b5c 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1306,16 +1306,13 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, FunctionDecl *OperatorNew = 0; FunctionDecl *OperatorDelete = 0; - Expr **PlaceArgs = PlacementArgs.data(); - unsigned NumPlaceArgs = PlacementArgs.size(); if (!AllocType->isDependentType() && - !Expr::hasAnyTypeDependentArguments( - llvm::makeArrayRef(PlaceArgs, NumPlaceArgs)) && + !Expr::hasAnyTypeDependentArguments(PlacementArgs) && FindAllocationFunctions(StartLoc, SourceRange(PlacementLParen, PlacementRParen), - UseGlobal, AllocType, ArraySize, PlaceArgs, - NumPlaceArgs, OperatorNew, OperatorDelete)) + UseGlobal, AllocType, ArraySize, PlacementArgs, + OperatorNew, OperatorDelete)) return ExprError(); // If this is an array allocation, compute whether the usual array @@ -1333,25 +1330,21 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, VariadicCallType CallType = Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply; - if (GatherArgumentsForCall(PlacementLParen, OperatorNew, - Proto, 1, - llvm::makeArrayRef(PlaceArgs, NumPlaceArgs), - AllPlaceArgs, CallType)) + if (GatherArgumentsForCall(PlacementLParen, OperatorNew, Proto, 1, + PlacementArgs, AllPlaceArgs, CallType)) return ExprError(); - NumPlaceArgs = AllPlaceArgs.size(); - if (NumPlaceArgs > 0) - PlaceArgs = &AllPlaceArgs[0]; + if (!AllPlaceArgs.empty()) + PlacementArgs = AllPlaceArgs; - DiagnoseSentinelCalls(OperatorNew, PlacementLParen, - llvm::makeArrayRef(PlaceArgs, NumPlaceArgs)); + DiagnoseSentinelCalls(OperatorNew, PlacementLParen, PlacementArgs); // FIXME: Missing call to CheckFunctionCall or equivalent } // Warn if the type is over-aligned and is being allocated by global operator // new. - if (NumPlaceArgs == 0 && OperatorNew && + if (PlacementArgs.empty() && OperatorNew && (OperatorNew->isImplicit() || getSourceManager().isInSystemHeader(OperatorNew->getLocStart()))) { if (unsigned Align = Context.getPreferredTypeAlign(AllocType.getTypePtr())){ @@ -1459,8 +1452,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, OperatorDelete, UsualArrayDeleteWantsSize, - llvm::makeArrayRef(PlaceArgs, NumPlaceArgs), - TypeIdParens, + PlacementArgs, TypeIdParens, ArraySize, initStyle, Initializer, ResultType, AllocTypeInfo, Range, DirectInitRange)); @@ -1521,8 +1513,7 @@ static bool isNonPlacementDeallocationFunction(FunctionDecl *FD) { /// that are appropriate for the allocation. bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, bool UseGlobal, QualType AllocType, - bool IsArray, Expr **PlaceArgs, - unsigned NumPlaceArgs, + bool IsArray, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete) { // --- Choosing an allocation function --- @@ -1534,7 +1525,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // 3) The first argument is always size_t. Append the arguments from the // placement form. - SmallVector AllocArgs(1 + NumPlaceArgs); + SmallVector AllocArgs(1 + PlaceArgs.size()); // We don't care about the actual value of this argument. // FIXME: Should the Sema create the expression and embed it in the syntax // tree? Or should the consumer just recalculate the value? @@ -1543,7 +1534,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, Context.getSizeType(), SourceLocation()); AllocArgs[0] = &Size; - std::copy(PlaceArgs, PlaceArgs + NumPlaceArgs, AllocArgs.begin() + 1); + std::copy(PlaceArgs.begin(), PlaceArgs.end(), AllocArgs.begin() + 1); // C++ [expr.new]p8: // If the allocated type is a non-array type, the allocation @@ -1583,8 +1574,8 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // FindAllocationOverload can change the passed in arguments, so we need to // copy them back. - if (NumPlaceArgs > 0) - std::copy(&AllocArgs[1], AllocArgs.end(), PlaceArgs); + if (!PlaceArgs.empty()) + std::copy(AllocArgs.begin() + 1, AllocArgs.end(), PlaceArgs.data()); // C++ [expr.new]p19: // @@ -1618,7 +1609,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // we had explicit placement arguments. This matters for things like // struct A { void *operator new(size_t, int = 0); ... }; // A *a = new A() - bool isPlacementNew = (NumPlaceArgs > 0 || OperatorNew->param_size() != 1); + bool isPlacementNew = (!PlaceArgs.empty() || OperatorNew->param_size() != 1); if (isPlacementNew) { // C++ [expr.new]p20: @@ -1693,11 +1684,11 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // as a placement deallocation function, would have been // selected as a match for the allocation function, the program // is ill-formed. - if (NumPlaceArgs && getLangOpts().CPlusPlus11 && + if (!PlaceArgs.empty() && getLangOpts().CPlusPlus11 && isNonPlacementDeallocationFunction(OperatorDelete)) { Diag(StartLoc, diag::err_placement_new_non_placement_delete) - << SourceRange(PlaceArgs[0]->getLocStart(), - PlaceArgs[NumPlaceArgs - 1]->getLocEnd()); + << SourceRange(PlaceArgs.front()->getLocStart(), + PlaceArgs.back()->getLocEnd()); Diag(OperatorDelete->getLocation(), diag::note_previous_decl) << DeleteName; } else { -- GitLab From 66e4f83c072b9dc552f35cf31add92d9f382feba Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 10 May 2013 13:37:16 +0000 Subject: [PATCH 165/467] When breaking at function calls, indent from function name. Otherwise (when indenting from the wrapped -> or .), this looks like a confusing indent. Before: aaaaaaa // .aaaaaaa( // aaaaaaa); After: aaaaaaa // .aaaaaaa( // aaaaaaa); llvm-svn: 181595 --- clang/lib/Format/Format.cpp | 5 ++++- clang/unittests/Format/FormatTest.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 98cb81ef4161..9a320f94bd13 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -496,6 +496,8 @@ private: } State.Stack.back().LastSpace = State.Column; + if (Current.isOneOf(tok::arrow, tok::period)) + State.Stack.back().LastSpace += Current.FormatTok.TokenLength; State.StartOfLineLevel = State.ParenLevel; // Any break on this level means that the parent level has been broken @@ -599,7 +601,8 @@ private: if (Current.isOneOf(tok::period, tok::arrow) && Line.Type == LT_BuilderTypeCall && State.ParenLevel == 0) State.Stack.back().StartOfFunctionCall = - Current.LastInChainOfCalls ? 0 : State.Column; + Current.LastInChainOfCalls ? 0 : State.Column + + Current.FormatTok.TokenLength; if (Current.Type == TT_CtorInitializerColon) { State.Stack.back().Indent = State.Column + 2; if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f8ccf8607042..f694c5b21414 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1976,7 +1976,7 @@ TEST_F(FormatTest, FormatsBuilderPattern) { verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()\n" " ->aaaaaaaaaaaaaaaa(\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" " ->aaaaaaaaaaaaaaaaa();"); } @@ -2296,8 +2296,8 @@ TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) { "aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" " .aaaaaaaaaaaaaaa(\n" - " aa(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaa));"); + " aa(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaa));"); verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" -- GitLab From b8c38756180df345534d4c816f648a9d74760f42 Mon Sep 17 00:00:00 2001 From: Edwin Vane Date: Fri, 10 May 2013 14:04:58 +0000 Subject: [PATCH 166/467] cpp11-migrate: Fix crash in AddOverride due to template instantiations This patch fixes different issues: - override is not added in template 'contexts' (this will be further improved to handle safe situations, a test for this has been written already) - the main file is now checked before the modifications are applied - override is not applied now when dealing with pure methods since it was misplaced (ignoring it isn't the perfect solution but it seems difficult to find the location just before the pure-specifier) Fixes PR15827 Author: Guillaume Papin llvm-svn: 181596 --- .../AddOverride/AddOverrideActions.cpp | 56 +++++++++++-------- .../test/cpp11-migrate/AddOverride/basic.cpp | 38 +++++++++++++ .../AddOverride/pure_specifier_fail.cpp | 20 +++++++ 3 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp diff --git a/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp b/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp index 3d1f1ff8c139..197befa4f4fa 100644 --- a/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp +++ b/clang-tools-extra/cpp11-migrate/AddOverride/AddOverrideActions.cpp @@ -36,28 +36,40 @@ void AddOverrideFixer::run(const MatchFinder::MatchResult &Result) { if (!SM.isFromMainFile(M->getLocStart())) return; + if (!SM.isFromMainFile(M->getLocStart())) + return; + // First check that there isn't already an override attribute. - if (!M->hasAttr()) { - if (M->getLocStart().isFileID()) { - SourceLocation StartLoc; - if (M->hasInlineBody()) { - // Start at the beginning of the body and rewind back to the last - // non-whitespace character. We will insert the override keyword - // after that character. - // FIXME: This transform won't work if there is a comment between - // the end of the function prototype and the start of the body. - StartLoc = M->getBody()->getLocStart(); - do { - StartLoc = StartLoc.getLocWithOffset(-1); - } while (isWhitespace(*FullSourceLoc(StartLoc, SM).getCharacterData())); - StartLoc = StartLoc.getLocWithOffset(1); - } else { - StartLoc = SM.getSpellingLoc(M->getLocEnd()); - StartLoc = Lexer::getLocForEndOfToken(StartLoc, 0, SM, LangOptions()); - } - Replace.insert(tooling::Replacement(SM, StartLoc, 0, " override")); - ++AcceptedChanges; - } + if (M->hasAttr()) + return; + + // FIXME: Pure methods are not supported yet as it is difficult to track down + // the location of '= 0'. + if (M->isPure()) + return; + + if (const FunctionDecl *TemplateMethod = M->getTemplateInstantiationPattern()) + M = cast(TemplateMethod); + + if (M->getParent()->hasAnyDependentBases()) + return; + + SourceLocation StartLoc; + if (M->hasInlineBody()) { + // Start at the beginning of the body and rewind back to the last + // non-whitespace character. We will insert the override keyword + // after that character. + // FIXME: This transform won't work if there is a comment between + // the end of the function prototype and the start of the body. + StartLoc = M->getBody()->getLocStart(); + do { + StartLoc = StartLoc.getLocWithOffset(-1); + } while (isWhitespace(*FullSourceLoc(StartLoc, SM).getCharacterData())); + StartLoc = StartLoc.getLocWithOffset(1); + } else { + StartLoc = SM.getSpellingLoc(M->getLocEnd()); + StartLoc = Lexer::getLocForEndOfToken(StartLoc, 0, SM, LangOptions()); } + Replace.insert(tooling::Replacement(SM, StartLoc, 0, " override")); + ++AcceptedChanges; } - diff --git a/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp b/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp index 1c3616bfcbb0..1c1c95d8146a 100644 --- a/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp +++ b/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp @@ -108,3 +108,41 @@ public: // CHECK: void h() const LLVM_OVERRIDE; }; +// Test that override isn't added at the wrong place for "pure overrides" +struct APure { + virtual APure *clone() = 0; +}; +struct BPure : APure { + virtual BPure *clone() { return new BPure(); } +}; +struct CPure : BPure { + virtual BPure *clone() = 0; + // CHECK: struct CPure : BPure { + // CHECK-NOT: virtual BPure *clone() = 0 override; + // CHECK: }; +}; +struct DPure : CPure { + virtual DPure *clone() { return new DPure(); } +}; + +// Test that override is not added on dangerous template constructs +struct Base1 { + virtual void f(); +}; +struct Base2 {}; +template struct Derived : T { + void f(); // adding 'override' here will break instantiation of Derived + // CHECK: struct Derived + // CHECK: void f(); +}; +Derived d1; +Derived d2; + +template +class M : public A { +public: + virtual void i(); + // CHECK: class M : public A { + // CHECK: virtual void i() override; +}; +M b; diff --git a/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp b/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp new file mode 100644 index 000000000000..a9d4c912ff13 --- /dev/null +++ b/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp @@ -0,0 +1,20 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: cpp11-migrate -add-override %t.cpp -- -I %S +// RUN: FileCheck -input-file=%t.cpp %s +// XFAIL: * + +// Test that override isn't placed correctly after "pure overrides" +struct A { + virtual A *clone() = 0; +}; +struct B : A { + virtual B *clone() { return new B(); } +}; +struct C : B { + virtual B *clone() = 0; + // CHECK: struct C : B { + // CHECK: virtual B *clone() override = 0; +}; +struct D : C { + virtual D *clone() { return new D(); } +}; -- GitLab From a5d59333b350ddb512359a65cefd59ced5c49b57 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 May 2013 14:09:52 +0000 Subject: [PATCH 167/467] DAGCombiner: Generate a correct constant for vector types when folding (xor (and)) into (and (not)). PR15948. llvm-svn: 181597 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 +-- llvm/test/CodeGen/X86/xor.ll | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 700ee12072c8..c54dffbb1324 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3464,8 +3464,7 @@ SDValue DAGCombiner::visitXOR(SDNode *N) { if (N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() && N0->getOperand(1) == N1) { SDValue X = N0->getOperand(0); - SDValue NotX = DAG.getNode(ISD::XOR, X.getDebugLoc(), VT, X, - DAG.getConstant(APInt::getAllOnesValue(VT.getSizeInBits()), VT)); + SDValue NotX = DAG.getNOT(X.getDebugLoc(), X, VT); AddToWorkList(NotX.getNode()); return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, NotX, N1); } diff --git a/llvm/test/CodeGen/X86/xor.ll b/llvm/test/CodeGen/X86/xor.ll index 2408bfe72c60..574bb7817e45 100644 --- a/llvm/test/CodeGen/X86/xor.ll +++ b/llvm/test/CodeGen/X86/xor.ll @@ -154,3 +154,14 @@ define i32 @test9(i32 %a) nounwind { ; X32: notl [[REG:%[a-z]+]] ; X32: andl {{.*}}[[REG:%[a-z]+]] } + +; PR15948 +define <4 x i32> @test10(<4 x i32> %a) nounwind { + %1 = and <4 x i32> %a, + %2 = xor <4 x i32> %1, + ret <4 x i32> %2 +; X64: test10: +; X64: andnps +; X32: test10: +; X32: andnps +} -- GitLab From 655d3fa3c17e58699141c1825c2464062b772169 Mon Sep 17 00:00:00 2001 From: Wei Pan Date: Fri, 10 May 2013 14:15:18 +0000 Subject: [PATCH 168/467] Codegen tests for captured statements with templates Differential-revision: llvm-reviews.chandlerc.com/D778 llvm-svn: 181598 --- clang/test/CodeGenCXX/captured-statements.cpp | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/clang/test/CodeGenCXX/captured-statements.cpp b/clang/test/CodeGenCXX/captured-statements.cpp index 389d8d0e0e12..91c7ff28f07a 100644 --- a/clang/test/CodeGenCXX/captured-statements.cpp +++ b/clang/test/CodeGenCXX/captured-statements.cpp @@ -3,6 +3,8 @@ // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-4 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-5 +// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-6 struct Foo { int x; @@ -95,3 +97,81 @@ void test4() { // CHECK-4: store i32 5, i32* // CHECK-4: call {{.*}}FooD1Ev } + +template +void touch(const T &) {} + +template +void template_capture_var() { + T x; + #pragma clang __debug captured + { + touch(x); + } +} + +template +class Val { + T v; +public: + void set() { + #pragma clang __debug captured + { + touch(v); + } + } + + template + void foo(U u) { + #pragma clang __debug captured + { + touch(u); + } + } +}; + +void test_capture_var() { + // CHECK-5: define {{.*}} void @_Z20template_capture_varIiLj201EEvv + // CHECK-5-NOT: } + // CHECK-5: store i32* + // CHECK-5: call void @__captured_stmt + // CHECK-5-NEXT: ret void + template_capture_var(); + + // CHECK-5: define {{.*}} void @_ZN3ValIfLi202EE3setEv + // CHECK-5-NOT: } + // CHECK-5: store %class.Val* + // CHECK-5: call void @__captured_stmt + // CHECK-5-NEXT: ret void + Val Obj; + Obj.set(); + + // CHECK-5: define {{.*}} void @_ZN3ValIfLi202EE3fooIdLi203EEEvT_ + // CHECK-5-NOT: } + // CHECK-5: store %class.Val* + // CHECK-5: store double + // CHECK-5: call void @__captured_stmt + // CHECK-5-NEXT: ret void + Obj.foo(1.0); +} + +template +void template_capture_lambda() { + T x, y; + [=, &y]() { + #pragma clang __debug captured + { + y += x; + } + }(); +} + +void test_capture_lambda() { + // CHECK-6: define {{.*}} void @_ZZ23template_capture_lambdaIiEvvENKS_IiEUlvE_clEv + // CHECK-6-NOT: } + // CHECK-6: store i32* + // CHECK-6: store i32* + // CHECK-6: call void @__captured_stmt + // CHECK-6-NEXT: ret void + template_capture_lambda(); +} -- GitLab From f19caa1227c7cae6796366576ef5ba3ea071dd2e Mon Sep 17 00:00:00 2001 From: Ashok Thirumurthi Date: Fri, 10 May 2013 14:37:49 +0000 Subject: [PATCH 169/467] Added an integration test to step through a crash and then test for globals, locals, arguments, registers and the back-trace. llvm-svn: 181599 --- .../inferior-crashing/TestInferiorCrashing.py | 71 +++++++++++++++++-- .../functionalities/inferior-crashing/main.c | 4 +- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py b/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py index 0f79cf9eaf6e..2068b93f2b30 100644 --- a/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py +++ b/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py @@ -2,7 +2,7 @@ import os, time import unittest2 -import lldb +import lldb, lldbutil from lldbtest import * class CrashingInferiorTestCase(TestBase): @@ -38,18 +38,34 @@ class CrashingInferiorTestCase(TestBase): self.inferior_crashing_python() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @unittest2.expectedFailure # bugzilla 15784? + @expectedFailureDarwin # bugzilla 15784 def test_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.buildDsym() self.inferior_crashing_expr() - @unittest2.expectedFailure # bugzilla 15784 + @expectedFailureDarwin # bugzilla 15784 def test_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.buildDwarf() self.inferior_crashing_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @expectedFailureDarwin # bugzilla 15784 + def test_inferior_crashing_step(self): + """Test that lldb functions correctly after stepping through a crash.""" + self.buildDsym() + self.inferior_crashing_step() + + @expectedFailureDarwin # bugzilla 15784 + def test_inferior_crashing_step(self): + """Test that lldb functions correctly after stepping through a crash.""" + self.buildDwarf() + self.inferior_crashing_step() + + def set_breakpoint(self, line): + lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True) + def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -130,9 +146,54 @@ class CrashingInferiorTestCase(TestBase): else: stop_reason = 'stop reason = invalid address' - # The lldb expression interpreter should be able to read from addresses of the inferior during process exit. + # The stop reason of the thread should be a bad access exception. + self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, + substrs = ['stopped', stop_reason]) + + # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. self.expect("p argc", - startstr = ['(int) $0 = 1']) + startstr = '(int) $0 = 1') + + self.expect("p hello_world", + substrs = ['Hello']) + + def inferior_crashing_step(self): + """Test that lldb functions correctly after stepping through a crash.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + self.set_breakpoint(self.line) + self.runCmd("run", RUN_SUCCEEDED) + + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['main.c:%d' % self.line, + 'stop reason = breakpoint']) + + self.runCmd("next") + + if sys.platform.startswith("darwin"): + stop_reason = 'stop reason = EXC_BAD_ACCESS' + else: + stop_reason = 'stop reason = invalid address' + + # The stop reason of the thread should be a bad access exception. + self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, + substrs = ['stopped', stop_reason]) + + # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + self.expect("p argv[0]", + substrs = ['a.out']) + self.expect("p null_ptr", + substrs = ['= 0x0']) + + # lldb should be able to read from registers from the inferior after crashing. + self.expect("register read eax", + substrs = ['eax = 0x']) + + # And it should report the correct line number. + self.expect("thread backtrace all", + substrs = [stop_reason, + 'main.c:%d' % self.line]) if __name__ == '__main__': import atexit diff --git a/lldb/test/functionalities/inferior-crashing/main.c b/lldb/test/functionalities/inferior-crashing/main.c index 9d0706a0862d..3b7cfe4012bd 100644 --- a/lldb/test/functionalities/inferior-crashing/main.c +++ b/lldb/test/functionalities/inferior-crashing/main.c @@ -8,9 +8,11 @@ //===----------------------------------------------------------------------===// #include +const char *hello_world = "Hello, segfault!"; + int main(int argc, const char* argv[]) { int *null_ptr = 0; - printf("Hello, segfault!\n"); + printf("%s\n", hello_world); printf("Now crash %d\n", *null_ptr); // Crash here. } -- GitLab From e42ccf32cc1efa446cad064501ace4c93570bffc Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 10 May 2013 14:42:16 +0000 Subject: [PATCH 170/467] XFAILing this test on Win32 to unbreak the build bots. llvm-svn: 181600 --- llvm/test/ExecutionEngine/MCJIT/eh.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/ExecutionEngine/MCJIT/eh.ll b/llvm/test/ExecutionEngine/MCJIT/eh.ll index 0c19b1bf2e5a..cd67dd70c54a 100644 --- a/llvm/test/ExecutionEngine/MCJIT/eh.ll +++ b/llvm/test/ExecutionEngine/MCJIT/eh.ll @@ -1,5 +1,5 @@ ; RUN: %lli_mcjit %s -; XFAIL: arm, cygwin +; XFAIL: arm, cygwin, win32 declare i8* @__cxa_allocate_exception(i64) declare void @__cxa_throw(i8*, i8*, i8*) declare i32 @__gxx_personality_v0(...) -- GitLab From 1fef0071ac49b820071d6d0cab5e8b757abc7c08 Mon Sep 17 00:00:00 2001 From: Ashok Thirumurthi Date: Fri, 10 May 2013 16:10:23 +0000 Subject: [PATCH 171/467] Removed expectedFailureDarwin, and added a note about the disparity between the automated tests and testing at the lldb command-line. llvm-svn: 181602 --- .../inferior-crashing/TestInferiorCrashing.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py b/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py index 2068b93f2b30..92f71476d387 100644 --- a/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py +++ b/lldb/test/functionalities/inferior-crashing/TestInferiorCrashing.py @@ -38,26 +38,24 @@ class CrashingInferiorTestCase(TestBase): self.inferior_crashing_python() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @expectedFailureDarwin # bugzilla 15784 def test_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.buildDsym() self.inferior_crashing_expr() - @expectedFailureDarwin # bugzilla 15784 + # bugzilla 15784 - the same commands fail when run on Linux from the lldb command line def test_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.buildDwarf() self.inferior_crashing_expr() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @expectedFailureDarwin # bugzilla 15784 def test_inferior_crashing_step(self): """Test that lldb functions correctly after stepping through a crash.""" self.buildDsym() self.inferior_crashing_step() - @expectedFailureDarwin # bugzilla 15784 + # bugzilla 15784 - the same commands fail when run on Linux from the lldb command line def test_inferior_crashing_step(self): """Test that lldb functions correctly after stepping through a crash.""" self.buildDwarf() -- GitLab From 4ea23b56c50da5e8c59604190bb1b145e4b3a335 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 10 May 2013 16:17:24 +0000 Subject: [PATCH 172/467] Implement AsmParser for ARM unwind directives. This commit implements the AsmParser for fnstart, fnend, cantunwind, personality, handlerdata, pad, setfp, save, and vsave directives. This commit fixes some minor issue in the ARMELFStreamer: * The switch back to corresponding section after the .fnend directive. * Emit the unwind opcode while processing .fnend directive if there is no .handlerdata directive. * Emit the unwind opcode to .ARM.extab while processing .handlerdata even if .personality directive does not exist. llvm-svn: 181603 --- .../lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 255 ++++++++++++++- .../ARM/MCTargetDesc/ARMELFStreamer.cpp | 56 ++-- llvm/test/MC/ARM/eh-compact-pr0.s | 104 ++++++ llvm/test/MC/ARM/eh-compact-pr1.s | 74 +++++ .../ARM/eh-directive-cantunwind-diagnostics.s | 106 +++++++ llvm/test/MC/ARM/eh-directive-cantunwind.s | 51 +++ .../MC/ARM/eh-directive-fnend-diagnostics.s | 17 + .../MC/ARM/eh-directive-fnstart-diagnostics.s | 31 ++ llvm/test/MC/ARM/eh-directive-handlerdata.s | 108 +++++++ .../MC/ARM/eh-directive-pad-diagnostics.s | 39 +++ llvm/test/MC/ARM/eh-directive-pad.s | 226 +++++++++++++ .../eh-directive-personality-diagnostics.s | 39 +++ llvm/test/MC/ARM/eh-directive-personality.s | 90 ++++++ .../MC/ARM/eh-directive-save-diagnoatics.s | 41 +++ llvm/test/MC/ARM/eh-directive-save.s | 298 ++++++++++++++++++ .../test/MC/ARM/eh-directive-section-comdat.s | 126 ++++++++ .../ARM/eh-directive-section-multiple-func.s | 129 ++++++++ llvm/test/MC/ARM/eh-directive-section.s | 164 ++++++++++ .../MC/ARM/eh-directive-setfp-diagnostics.s | 87 +++++ llvm/test/MC/ARM/eh-directive-setfp.s | 239 ++++++++++++++ .../eh-directive-text-section-multiple-func.s | 81 +++++ llvm/test/MC/ARM/eh-directive-text-section.s | 82 +++++ .../MC/ARM/eh-directive-vsave-diagnostics.s | 41 +++ llvm/test/MC/ARM/eh-directive-vsave.s | 130 ++++++++ 24 files changed, 2587 insertions(+), 27 deletions(-) create mode 100644 llvm/test/MC/ARM/eh-compact-pr0.s create mode 100644 llvm/test/MC/ARM/eh-compact-pr1.s create mode 100644 llvm/test/MC/ARM/eh-directive-cantunwind-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-cantunwind.s create mode 100644 llvm/test/MC/ARM/eh-directive-fnend-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-fnstart-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-handlerdata.s create mode 100644 llvm/test/MC/ARM/eh-directive-pad-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-pad.s create mode 100644 llvm/test/MC/ARM/eh-directive-personality-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-personality.s create mode 100644 llvm/test/MC/ARM/eh-directive-save-diagnoatics.s create mode 100644 llvm/test/MC/ARM/eh-directive-save.s create mode 100644 llvm/test/MC/ARM/eh-directive-section-comdat.s create mode 100644 llvm/test/MC/ARM/eh-directive-section-multiple-func.s create mode 100644 llvm/test/MC/ARM/eh-directive-section.s create mode 100644 llvm/test/MC/ARM/eh-directive-setfp-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-setfp.s create mode 100644 llvm/test/MC/ARM/eh-directive-text-section-multiple-func.s create mode 100644 llvm/test/MC/ARM/eh-directive-text-section.s create mode 100644 llvm/test/MC/ARM/eh-directive-vsave-diagnostics.s create mode 100644 llvm/test/MC/ARM/eh-directive-vsave.s diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 1dd2953b29b9..4d3bf34d48d3 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -49,6 +49,20 @@ class ARMAsmParser : public MCTargetAsmParser { MCAsmParser &Parser; const MCRegisterInfo *MRI; + // Unwind directives state + SMLoc FnStartLoc; + SMLoc CantUnwindLoc; + SMLoc PersonalityLoc; + SMLoc HandlerDataLoc; + int FPReg; + void resetUnwindDirectiveParserState() { + FnStartLoc = SMLoc(); + CantUnwindLoc = SMLoc(); + PersonalityLoc = SMLoc(); + HandlerDataLoc = SMLoc(); + FPReg = -1; + } + // Map of register aliases registers via the .req directive. StringMap RegisterReqs; @@ -113,6 +127,14 @@ class ARMAsmParser : public MCTargetAsmParser { bool parseDirectiveUnreq(SMLoc L); bool parseDirectiveArch(SMLoc L); bool parseDirectiveEabiAttr(SMLoc L); + bool parseDirectiveFnStart(SMLoc L); + bool parseDirectiveFnEnd(SMLoc L); + bool parseDirectiveCantUnwind(SMLoc L); + bool parseDirectivePersonality(SMLoc L); + bool parseDirectiveHandlerData(SMLoc L); + bool parseDirectiveSetFP(SMLoc L); + bool parseDirectivePad(SMLoc L); + bool parseDirectiveRegSave(SMLoc L, bool IsVector); StringRef splitMnemonic(StringRef Mnemonic, unsigned &PredicationCode, bool &CarrySetting, unsigned &ProcessorIMod, @@ -242,7 +264,7 @@ public: }; ARMAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser) - : MCTargetAsmParser(), STI(_STI), Parser(_Parser) { + : MCTargetAsmParser(), STI(_STI), Parser(_Parser), FPReg(-1) { MCAsmParserExtension::Initialize(_Parser); // Cache the MCRegisterInfo. @@ -7658,6 +7680,24 @@ bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) { return parseDirectiveArch(DirectiveID.getLoc()); else if (IDVal == ".eabi_attribute") return parseDirectiveEabiAttr(DirectiveID.getLoc()); + else if (IDVal == ".fnstart") + return parseDirectiveFnStart(DirectiveID.getLoc()); + else if (IDVal == ".fnend") + return parseDirectiveFnEnd(DirectiveID.getLoc()); + else if (IDVal == ".cantunwind") + return parseDirectiveCantUnwind(DirectiveID.getLoc()); + else if (IDVal == ".personality") + return parseDirectivePersonality(DirectiveID.getLoc()); + else if (IDVal == ".handlerdata") + return parseDirectiveHandlerData(DirectiveID.getLoc()); + else if (IDVal == ".setfp") + return parseDirectiveSetFP(DirectiveID.getLoc()); + else if (IDVal == ".pad") + return parseDirectivePad(DirectiveID.getLoc()); + else if (IDVal == ".save") + return parseDirectiveRegSave(DirectiveID.getLoc(), false); + else if (IDVal == ".vsave") + return parseDirectiveRegSave(DirectiveID.getLoc(), true); return true; } @@ -7858,6 +7898,219 @@ bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) { return true; } +/// parseDirectiveFnStart +/// ::= .fnstart +bool ARMAsmParser::parseDirectiveFnStart(SMLoc L) { + if (FnStartLoc.isValid()) { + Error(L, ".fnstart starts before the end of previous one"); + Error(FnStartLoc, "previous .fnstart starts here"); + return true; + } + + FnStartLoc = L; + getParser().getStreamer().EmitFnStart(); + return false; +} + +/// parseDirectiveFnEnd +/// ::= .fnend +bool ARMAsmParser::parseDirectiveFnEnd(SMLoc L) { + // Check the ordering of unwind directives + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .fnend directive"); + + // Reset the unwind directives parser state + resetUnwindDirectiveParserState(); + + getParser().getStreamer().EmitFnEnd(); + return false; +} + +/// parseDirectiveCantUnwind +/// ::= .cantunwind +bool ARMAsmParser::parseDirectiveCantUnwind(SMLoc L) { + // Check the ordering of unwind directives + CantUnwindLoc = L; + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .cantunwind directive"); + if (HandlerDataLoc.isValid()) { + Error(L, ".cantunwind can't be used with .handlerdata directive"); + Error(HandlerDataLoc, ".handlerdata was specified here"); + return true; + } + if (PersonalityLoc.isValid()) { + Error(L, ".cantunwind can't be used with .personality directive"); + Error(PersonalityLoc, ".personality was specified here"); + return true; + } + + getParser().getStreamer().EmitCantUnwind(); + return false; +} + +/// parseDirectivePersonality +/// ::= .personality name +bool ARMAsmParser::parseDirectivePersonality(SMLoc L) { + // Check the ordering of unwind directives + PersonalityLoc = L; + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .personality directive"); + if (CantUnwindLoc.isValid()) { + Error(L, ".personality can't be used with .cantunwind directive"); + Error(CantUnwindLoc, ".cantunwind was specified here"); + return true; + } + if (HandlerDataLoc.isValid()) { + Error(L, ".personality must precede .handlerdata directive"); + Error(HandlerDataLoc, ".handlerdata was specified here"); + return true; + } + + // Parse the name of the personality routine + if (Parser.getTok().isNot(AsmToken::Identifier)) { + Parser.eatToEndOfStatement(); + return Error(L, "unexpected input in .personality directive."); + } + StringRef Name(Parser.getTok().getIdentifier()); + Parser.Lex(); + + MCSymbol *PR = getParser().getContext().GetOrCreateSymbol(Name); + getParser().getStreamer().EmitPersonality(PR); + return false; +} + +/// parseDirectiveHandlerData +/// ::= .handlerdata +bool ARMAsmParser::parseDirectiveHandlerData(SMLoc L) { + // Check the ordering of unwind directives + HandlerDataLoc = L; + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .personality directive"); + if (CantUnwindLoc.isValid()) { + Error(L, ".handlerdata can't be used with .cantunwind directive"); + Error(CantUnwindLoc, ".cantunwind was specified here"); + return true; + } + + getParser().getStreamer().EmitHandlerData(); + return false; +} + +/// parseDirectiveSetFP +/// ::= .setfp fpreg, spreg [, offset] +bool ARMAsmParser::parseDirectiveSetFP(SMLoc L) { + // Check the ordering of unwind directives + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .setfp directive"); + if (HandlerDataLoc.isValid()) + return Error(L, ".setfp must precede .handlerdata directive"); + + // Parse fpreg + SMLoc NewFPRegLoc = Parser.getTok().getLoc(); + int NewFPReg = tryParseRegister(); + if (NewFPReg == -1) + return Error(NewFPRegLoc, "frame pointer register expected"); + + // Consume comma + if (!Parser.getTok().is(AsmToken::Comma)) + return Error(Parser.getTok().getLoc(), "comma expected"); + Parser.Lex(); // skip comma + + // Parse spreg + SMLoc NewSPRegLoc = Parser.getTok().getLoc(); + int NewSPReg = tryParseRegister(); + if (NewSPReg == -1) + return Error(NewSPRegLoc, "stack pointer register expected"); + + if (NewSPReg != ARM::SP && NewSPReg != FPReg) + return Error(NewSPRegLoc, + "register should be either $sp or the latest fp register"); + + // Update the frame pointer register + FPReg = NewFPReg; + + // Parse offset + int64_t Offset = 0; + if (Parser.getTok().is(AsmToken::Comma)) { + Parser.Lex(); // skip comma + + if (Parser.getTok().isNot(AsmToken::Hash) && + Parser.getTok().isNot(AsmToken::Dollar)) { + return Error(Parser.getTok().getLoc(), "'#' expected"); + } + Parser.Lex(); // skip hash token. + + const MCExpr *OffsetExpr; + SMLoc ExLoc = Parser.getTok().getLoc(); + SMLoc EndLoc; + if (getParser().parseExpression(OffsetExpr, EndLoc)) + return Error(ExLoc, "malformed setfp offset"); + const MCConstantExpr *CE = dyn_cast(OffsetExpr); + if (!CE) + return Error(ExLoc, "setfp offset must be an immediate"); + + Offset = CE->getValue(); + } + + getParser().getStreamer().EmitSetFP(static_cast(NewFPReg), + static_cast(NewSPReg), + Offset); + return false; +} + +/// parseDirective +/// ::= .pad offset +bool ARMAsmParser::parseDirectivePad(SMLoc L) { + // Check the ordering of unwind directives + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .pad directive"); + if (HandlerDataLoc.isValid()) + return Error(L, ".pad must precede .handlerdata directive"); + + // Parse the offset + if (Parser.getTok().isNot(AsmToken::Hash) && + Parser.getTok().isNot(AsmToken::Dollar)) { + return Error(Parser.getTok().getLoc(), "'#' expected"); + } + Parser.Lex(); // skip hash token. + + const MCExpr *OffsetExpr; + SMLoc ExLoc = Parser.getTok().getLoc(); + SMLoc EndLoc; + if (getParser().parseExpression(OffsetExpr, EndLoc)) + return Error(ExLoc, "malformed pad offset"); + const MCConstantExpr *CE = dyn_cast(OffsetExpr); + if (!CE) + return Error(ExLoc, "pad offset must be an immediate"); + + getParser().getStreamer().EmitPad(CE->getValue()); + return false; +} + +/// parseDirectiveRegSave +/// ::= .save { registers } +/// ::= .vsave { registers } +bool ARMAsmParser::parseDirectiveRegSave(SMLoc L, bool IsVector) { + // Check the ordering of unwind directives + if (!FnStartLoc.isValid()) + return Error(L, ".fnstart must precede .save or .vsave directives"); + if (HandlerDataLoc.isValid()) + return Error(L, ".save or .vsave must precede .handlerdata directive"); + + // Parse the register list + SmallVector Operands; + if (parseRegisterList(Operands)) + return true; + ARMOperand *Op = (ARMOperand*)Operands[0]; + if (!IsVector && !Op->isRegList()) + return Error(L, ".save expects GPR registers"); + if (IsVector && !Op->isDPRRegList()) + return Error(L, ".vsave expects DPR registers"); + + getParser().getStreamer().EmitRegSave(Op->getRegList(), IsVector); + return false; +} + /// Force static initialization. extern "C" void LLVMInitializeARMAsmParser() { RegisterMCAsmParser X(TheARMTarget); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp index 6c3d2476688c..82d296ffd7ed 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -204,6 +204,7 @@ private: void EmitPersonalityFixup(StringRef Name); void CollectUnwindOpcodes(); + void FlushUnwindOpcodes(bool AllowCompactModel0); void SwitchToEHSection(const char *Prefix, unsigned Type, unsigned Flags, SectionKind Kind, const MCSymbol &Fn); @@ -333,22 +334,8 @@ void ARMELFStreamer::EmitFnEnd() { assert(FnStart && ".fnstart must preceeds .fnend"); // Emit unwind opcodes if there is no .handlerdata directive - if (!ExTab && !CantUnwind) { - CollectUnwindOpcodes(); - - unsigned PersonalityIndex = UnwindOpAsm.getPersonalityIndex(); - if (PersonalityIndex == AEABI_UNWIND_CPP_PR1 || - PersonalityIndex == AEABI_UNWIND_CPP_PR2) { - // For the __aeabi_unwind_cpp_pr1 and __aeabi_unwind_cpp_pr2, we have to - // emit the unwind opcodes in the corresponding ".ARM.extab" section, and - // then emit a reference to these unwind opcodes in the second word of - // the exception index table entry. - SwitchToExTabSection(*FnStart); - ExTab = getContext().CreateTempSymbol(); - EmitLabel(ExTab); - EmitBytes(UnwindOpAsm.data(), 0); - } - } + if (!ExTab && !CantUnwind) + FlushUnwindOpcodes(true); // Emit the exception index table entry SwitchToExIdxSection(*FnStart); @@ -384,6 +371,9 @@ void ARMELFStreamer::EmitFnEnd() { EmitBytes(UnwindOpAsm.data(), 0); } + // Switch to the section containing FnStart + SwitchSection(&FnStart->getSection()); + // Clean exception handling frame information Reset(); } @@ -392,7 +382,18 @@ void ARMELFStreamer::EmitCantUnwind() { CantUnwind = true; } -void ARMELFStreamer::EmitHandlerData() { +void ARMELFStreamer::FlushUnwindOpcodes(bool AllowCompactModel0) { + // Collect and finalize the unwind opcodes + CollectUnwindOpcodes(); + + // For compact model 0, we have to emit the unwind opcodes in the .ARM.exidx + // section. Thus, we don't have to create an entry in the .ARM.extab + // section. + if (AllowCompactModel0 && + UnwindOpAsm.getPersonalityIndex() == AEABI_UNWIND_CPP_PR0) + return; + + // Switch to .ARM.extab section. SwitchToExTabSection(*FnStart); // Create .ARM.extab label for offset in .ARM.exidx @@ -400,21 +401,24 @@ void ARMELFStreamer::EmitHandlerData() { ExTab = getContext().CreateTempSymbol(); EmitLabel(ExTab); - // Emit Personality - assert(Personality && ".personality directive must preceed .handlerdata"); - - const MCSymbolRefExpr *PersonalityRef = - MCSymbolRefExpr::Create(Personality, - MCSymbolRefExpr::VK_ARM_PREL31, - getContext()); + // Emit personality + if (Personality) { + const MCSymbolRefExpr *PersonalityRef = + MCSymbolRefExpr::Create(Personality, + MCSymbolRefExpr::VK_ARM_PREL31, + getContext()); - EmitValue(PersonalityRef, 4, 0); + EmitValue(PersonalityRef, 4, 0); + } // Emit unwind opcodes - CollectUnwindOpcodes(); EmitBytes(UnwindOpAsm.data(), 0); } +void ARMELFStreamer::EmitHandlerData() { + FlushUnwindOpcodes(false); +} + void ARMELFStreamer::EmitPersonality(const MCSymbol *Per) { Personality = Per; UnwindOpAsm.setPersonality(Per); diff --git a/llvm/test/MC/ARM/eh-compact-pr0.s b/llvm/test/MC/ARM/eh-compact-pr0.s new file mode 100644 index 000000000000..6b866d5538d7 --- /dev/null +++ b/llvm/test/MC/ARM/eh-compact-pr0.s @@ -0,0 +1,104 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the compact pr0 model + + .syntax unified + + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function +func1: + .fnstart + .save {r11, lr} + push {r11, lr} + .setfp r11, sp + mov r11, sp + pop {r11, lr} + mov pc, lr + .fnend + + .section .TEST2 + .globl func2 + .align 2 + .type func2,%function +func2: + .fnstart + .save {r11, lr} + push {r11, lr} + pop {r11, pc} + .fnend + + + +@------------------------------------------------------------------------------- +@ Check .TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Name: .TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00482DE9 0DB0A0E1 0048BDE8 0EF0A0E1 |.H-......H......| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check .ARM.exidx.TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST1 +@------------------------------------------------------------------------------- +@ The first word should be relocated to .TEST1 section. Besides, there is +@ another relocation entry for __aeabi_unwind_cpp_pr0, so that the linker +@ will keep __aeabi_unwind_cpp_pr0. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr0 0x0 +@ CHECK: ] +@------------------------------------------------------------------------------- +@ 0x80 = Compact model 0, personality routine: __aeabi_unwind_cpp_pr0 +@ 0x9B = $sp can be found in $r11 +@ 0x8480 = pop {r11, r14} +@------------------------------------------------------------------------------- +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 80849B80 |........| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check .TEST2 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00482DE9 0088BDE8 |.H-.....| +@ CHECK: ) +@ CHECK: } +@------------------------------------------------------------------------------- +@ Check .ARM.exidx.TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST2 +@------------------------------------------------------------------------------- +@ The first word should be relocated to .TEST2 section. Besides, there is +@ another relocation entry for __aeabi_unwind_cpp_pr0, so that the linker +@ will keep __aeabi_unwind_cpp_pr0. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST2 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr0 0x0 +@ CHECK: ] +@------------------------------------------------------------------------------- +@ 0x80 = Compact model 0, personality routine: __aeabi_unwind_cpp_pr0 +@ 0x8480 = pop {r11, r14} +@ 0xB0 = finish +@------------------------------------------------------------------------------- +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0808480 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-compact-pr1.s b/llvm/test/MC/ARM/eh-compact-pr1.s new file mode 100644 index 000000000000..0fac3e210098 --- /dev/null +++ b/llvm/test/MC/ARM/eh-compact-pr1.s @@ -0,0 +1,74 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the compact pr1 model + + .syntax unified + + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function +func1: + .fnstart + .save {r4, r5, r11, lr} + push {r4, r5, r11, lr} + add r0, r1, r0 + .setfp r11, sp, #8 + add r11, sp, #8 + pop {r4, r5, r11, pc} + .fnend + + + +@------------------------------------------------------------------------------- +@ Check .TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Name: .TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 30482DE9 000081E0 08B08DE2 3088BDE8 |0H-.........0...| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check .ARM.extab.TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@------------------------------------------------------------------------------- +@ 0x81 = Compact model 1, personality routine: __aeabi_unwind_cpp_pr1 +@ 0x9B = $sp can be found in $r11 +@ 0x41 = $sp = $sp - 8 +@ 0x8483 = pop {r4, r5, r11, r14} +@ 0xB0 = finish +@------------------------------------------------------------------------------- +@ CHECK: SectionData ( +@ CHECK: 0000: 419B0181 B0B08384 |A.......| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check .ARM.exidx.TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST1 +@------------------------------------------------------------------------------- +@ The first word should be relocated to .TEST1 section, and the second word +@ should be relocated to .ARM.extab.TEST1 section. Besides, there is +@ another relocation entry for __aeabi_unwind_cpp_pr1, so that the linker +@ will keep __aeabi_unwind_cpp_pr1. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr1 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST1 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-cantunwind-diagnostics.s b/llvm/test/MC/ARM/eh-directive-cantunwind-diagnostics.s new file mode 100644 index 000000000000..5a6a46c69a5a --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-cantunwind-diagnostics.s @@ -0,0 +1,106 @@ +@ RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi < %s 2> %t +@ RUN: FileCheck < %t %s + +@ Check the diagnostics for .cantunwind, .handlerdata, and .personality + +@ .cantunwind directive can't be used with .handlerdata directive nor +@ .personality directive. This test case check for the diagnostics for +@ the conflicts. + + + .syntax unified + .text + +@------------------------------------------------------------------------------- +@ TEST1: cantunwind + personality +@------------------------------------------------------------------------------- + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + .cantunwind + .personality __gxx_personality_v0 +@ CHECK: error: .personality can't be used with .cantunwind directive +@ CEHCK: .personality __gxx_personality_v0 +@ CHECK: ^ +@ CHECK: error: .cantunwind was specified here +@ CHECK: .cantunwind +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST2: cantunwind + handlerdata +@------------------------------------------------------------------------------- + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + .cantunwind + .handlerdata +@ CHECK: error: .handlerdata can't be used with .cantunwind directive +@ CEHCK: .handlerdata +@ CHECK: ^ +@ CHECK: error: .cantunwind was specified here +@ CHECK: .cantunwind +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST3: personality + cantunwind +@------------------------------------------------------------------------------- + .globl func3 + .align 2 + .type func3,%function + .fnstart +func3: + .personality __gxx_personality_v0 + .cantunwind +@ CHECK: error: .cantunwind can't be used with .personality directive +@ CEHCK: .cantunwind +@ CHECK: ^ +@ CHECK: error: .personality was specified here +@ CHECK: .personality __gxx_personality_v0 +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST4: handlerdata + cantunwind +@------------------------------------------------------------------------------- + .globl func4 + .align 2 + .type func4,%function + .fnstart +func4: + .handlerdata + .cantunwind +@ CHECK: error: .cantunwind can't be used with .handlerdata directive +@ CEHCK: .cantunwind +@ CHECK: ^ +@ CHECK: error: .handlerdata was specified here +@ CHECK: .handlerdata +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST5: cantunwind + fnstart +@------------------------------------------------------------------------------- + .globl func5 + .align 2 + .type func5,%function + .cantunwind +@ CHECK: error: .fnstart must precede .cantunwind directive +@ CHECK: .cantunwind +@ CHECK: ^ + .fnstart +func5: + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-cantunwind.s b/llvm/test/MC/ARM/eh-directive-cantunwind.s new file mode 100644 index 000000000000..0545f6d3c8de --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-cantunwind.s @@ -0,0 +1,51 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the .cantunwind directive + +@ When a function contains a .cantunwind directive, we should create an entry +@ in corresponding .ARM.exidx, and its second word should be EXIDX_CANTUNWIND. + + .syntax unified + + .text + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .cantunwind + .fnend + + + +@------------------------------------------------------------------------------- +@ Check .text section +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Name: .text +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check .ARM.exidx section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .text 0x0 +@ CHECK: ] +@------------------------------------------------------------------------------- +@ The first word should be the offset to .text. +@ The second word should be EXIDX_CANTUNWIND (01000000). +@------------------------------------------------------------------------------- +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 01000000 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-fnend-diagnostics.s b/llvm/test/MC/ARM/eh-directive-fnend-diagnostics.s new file mode 100644 index 000000000000..a5e4d3bf5b2c --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-fnend-diagnostics.s @@ -0,0 +1,17 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi \ +@ RUN: -filetype=obj -o /dev/null 2>&1 | FileCheck %s + +@ Check the diagnostics for mismatched .fnend directive + + + .syntax unified + .text + + .globl func1 + .align 2 + .type func1,%function +func1: + .fnend +@ CHECK: error: .fnstart must precede .fnend directive +@ CHECK: .fnend +@ CHECK: ^ diff --git a/llvm/test/MC/ARM/eh-directive-fnstart-diagnostics.s b/llvm/test/MC/ARM/eh-directive-fnstart-diagnostics.s new file mode 100644 index 000000000000..29bcb0dd9c02 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-fnstart-diagnostics.s @@ -0,0 +1,31 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi \ +@ RUN: -filetype=obj -o /dev/null 2>&1 | FileCheck %s + +@ Check the diagnostics for the mismatched .fnstart directives. + +@ There should be some diagnostics when the previous .fnstart is not closed +@ by the .fnend directive. + + + .syntax unified + .text + + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + @ Intentionally miss the .fnend directive + + .globl func2 + .align 2 + .type func2,%function + .fnstart +@ CHECK: error: .fnstart starts before the end of previous one +@ CHECK: .fnstart +@ CHECK: ^ +@ CHECK: error: previous .fnstart starts here +@ CHECK: .fnstart +@ CHECK: ^ +func2: + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-handlerdata.s b/llvm/test/MC/ARM/eh-directive-handlerdata.s new file mode 100644 index 000000000000..45f22ddb6304 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-handlerdata.s @@ -0,0 +1,108 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the .handlerdata directive (without .personality directive) + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1 +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .handlerdata + .fnend + + +@ CHECK:Section { +@ CHECK: Name: .TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK:} + +@ CHECK:Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: B0B0B080 |....| +@ CHECK: ) +@ CHECK:} + +@ CHECK:Section { +@ CHECK: Name: .ARM.exidx.TEST1 +@------------------------------------------------------------------------------- +@ We should see a relocation entry to __aeabi_unwind_cpp_pr0, so that the +@ linker can keep __aeabi_unwind_cpp_pr0. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr0 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST1 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK:} + + + + +@------------------------------------------------------------------------------- +@ TEST2 +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: +@------------------------------------------------------------------------------- +@ Use a lot of unwind opcdes to get __aeabi_unwind_cpp_pr1. +@------------------------------------------------------------------------------- + .save {r4, r5, r6, r7, r8, r9, r10, r11, r12} + push {r4, r5, r6, r7, r8, r9, r10, r11, r12} + pop {r4, r5, r6, r7, r8, r9, r10, r11, r12} + .pad #0x240 + sub sp, sp, #0x240 + add sp, sp, #0x240 + bx lr + .handlerdata + .fnend + + + +@ CHECK:Section { +@ CHECK: Name: .TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: F01F2DE9 F01FBDE8 09DD4DE2 09DD8DE2 |..-.......M.....| +@ CHECK: 0010: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK:} + +@ CHECK:Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 0FB20181 B0B0FF81 |........| +@ CHECK: ) +@ CHECK:} + +@ CHECK:Section { +@ CHECK: Name: .ARM.exidx.TEST2 +@------------------------------------------------------------------------------- +@ We should see a relocation entry to __aeabi_unwind_cpp_pr0, so that the +@ linker can keep __aeabi_unwind_cpp_pr0. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST2 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr1 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST2 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK:} diff --git a/llvm/test/MC/ARM/eh-directive-pad-diagnostics.s b/llvm/test/MC/ARM/eh-directive-pad-diagnostics.s new file mode 100644 index 000000000000..707215962155 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-pad-diagnostics.s @@ -0,0 +1,39 @@ +@ RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi < %s 2> %t +@ RUN: FileCheck --check-prefix=CHECK < %t %s + +@ Check the diagnostics for .pad directive. + + + .syntax unified + .text + +@------------------------------------------------------------------------------- +@ TEST1: .pad before .fnstart +@------------------------------------------------------------------------------- + .globl func1 + .align 2 + .type func1,%function + .pad #0 +@ CHECK: error: .fnstart must precede .pad directive +@ CHECK: .pad #0 +@ CHECK: ^ + .fnstart +func1: + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST2: .pad after .handlerdata +@------------------------------------------------------------------------------- + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + .handlerdata + .pad #0 +@ CHECK: error: .pad must precede .handlerdata directive +@ CHECK: .pad #0 +@ CHECK: ^ + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-pad.s b/llvm/test/MC/ARM/eh-directive-pad.s new file mode 100644 index 000000000000..ba850ffe77b1 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-pad.s @@ -0,0 +1,226 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd | FileCheck %s + +@ Check for different stack pointer offsets. + +@ The .pad directive will track the stack pointer offsets. There are several +@ ways to encode the stack offsets. We have to test: +@ +@ offset < 0x00 +@ offset == 0x00 +@ 0x04 <= offset <= 0x100 +@ 0x104 <= offset <= 0x200 +@ 0x204 <= offset + + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1 +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + .pad #0 + sub sp, sp, #0 + add sp, sp, #0 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit nothing (will be filled up with finish opcode). +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B000 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST2 +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2a + .align 2 + .type func2a,%function + .fnstart +func2a: + .pad #0x4 + sub sp, sp, #0x4 + add sp, sp, #0x4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2b + .align 2 + .type func2b,%function + .fnstart +func2b: + .pad #0x100 + sub sp, sp, #0x100 + add sp, sp, #0x100 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit ((offset - 4) >> 2). +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B00000 00000000 B0B03F00 |..............?.| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ TEST3 +@------------------------------------------------------------------------------- + .section .TEST3 + .globl func3a + .align 2 + .type func3a,%function + .fnstart +func3a: + .pad #0x104 + sub sp, sp, #0x104 + add sp, sp, #0x104 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func3b + .align 2 + .type func3b,%function + .fnstart +func3b: + .pad #0x200 + sub sp, sp, #0x200 + add sp, sp, #0x200 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x3F and ((offset - 0x104) >> 2). +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST3 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0003F00 00000000 B03F3F00 |......?......??.| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST4 +@------------------------------------------------------------------------------- + .section .TEST4 + .globl func4a + .align 2 + .type func4a,%function + .fnstart +func4a: + .pad #0x204 + sub sp, sp, #0x204 + add sp, sp, #0x204 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func4b + .align 2 + .type func4b,%function + .fnstart +func4b: + .pad #0x580 + sub sp, sp, #0x580 + add sp, sp, #0x580 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0xB2 and the ULEB128 encoding of +@ ((offset - 0x204) >> 2). +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST4 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B000B200 00000000 01DFB200 |................| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST5 +@------------------------------------------------------------------------------- + .section .TEST5 + .globl func4a + .align 2 + .type func4a,%function + .fnstart +func5a: + .pad #-0x4 + add sp, sp, #0x4 + sub sp, sp, #0x4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func5b + .align 2 + .type func5b,%function + .fnstart +func5b: + .pad #-0x104 + add sp, sp, #0x104 + sub sp, sp, #0x4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func5c + .align 2 + .type func5c,%function + .fnstart +func5c: + .pad #-0x204 + add sp, sp, #0x204 + sub sp, sp, #0x4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit (0x40 | (-offset - 4)) >> 2. When (-offset - 4) +@ is greater than 0x3f, then multiple 0x7f should be emitted. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST5 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B04000 00000000 B0407F00 |......@......@..| +@ CHECK: 0010: 00000000 407F7F00 |....@...| +@ CHECK: ) +@ CHECK: } diff --git a/llvm/test/MC/ARM/eh-directive-personality-diagnostics.s b/llvm/test/MC/ARM/eh-directive-personality-diagnostics.s new file mode 100644 index 000000000000..83e9c25f0bd7 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-personality-diagnostics.s @@ -0,0 +1,39 @@ +@ RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi < %s 2> %t +@ RUN: FileCheck --check-prefix=CHECK < %t %s + +@ Check the diagnostics for .personality directive. + + + .syntax unified + .text + +@------------------------------------------------------------------------------- +@ TEST1: .personality before .fnstart +@------------------------------------------------------------------------------- + .globl func1 + .align 2 + .type func1,%function + .personality __gxx_personality_v0 +@ CHECK: error: .fnstart must precede .personality directive +@ CHECK: .personality __gxx_personality_v0 +@ CHECK: ^ + .fnstart +func1: + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST2: .personality after .handlerdata +@------------------------------------------------------------------------------- + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + .handlerdata + .personality __gxx_personality_v0 +@ CHECK: error: .personality must precede .handlerdata directive +@ CHECK: .personality __gxx_personality_v0 +@ CHECK: ^ + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-personality.s b/llvm/test/MC/ARM/eh-directive-personality.s new file mode 100644 index 000000000000..2267108b2864 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-personality.s @@ -0,0 +1,90 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the .personality directive. + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1 +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + +@ CHECK: Section { +@ CHECK: Name: .TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK: } +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 __gxx_personality_v0 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B000 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST1 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST1 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST2 +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + bx lr + .personality __gxx_personality_v0 + @ The .handlerdata directive is intentionally ignored. The .fnend @ directive should create the EXTAB entry and flush the unwind opcodes. + .fnend + + +@ CHECK: Section { +@ CHECK: Name: .TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK: } +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 __gxx_personality_v0 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B000 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST2 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST2 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST2 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK: } diff --git a/llvm/test/MC/ARM/eh-directive-save-diagnoatics.s b/llvm/test/MC/ARM/eh-directive-save-diagnoatics.s new file mode 100644 index 000000000000..0e6d7404a3af --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-save-diagnoatics.s @@ -0,0 +1,41 @@ +@ RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi < %s 2> %t +@ RUN: FileCheck --check-prefix=CHECK < %t %s + +@ Check the diagnostics for .save directive + +@ .save directive should always come after .fnstart directive and +@ before .handlerdata directive. + + .syntax unified + .text + +@------------------------------------------------------------------------------- +@ TEST1: .save before .fnstart +@------------------------------------------------------------------------------- + .globl func1 + .align 2 + .type func1,%function + .save {r4, r5, r6, r7} +@ CHECK: error: .fnstart must precede .save or .vsave directives +@ CHECK: .save {r4, r5, r6, r7} +@ CHECK: ^ + .fnstart +func1: + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST2: .save after .handlerdata +@------------------------------------------------------------------------------- + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + .handlerdata + .save {r4, r5, r6, r7} +@ CHECK: error: .save or .vsave must precede .handlerdata directive +@ CHECK: .save {r4, r5, r6, r7} +@ CHECK: ^ + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-save.s b/llvm/test/MC/ARM/eh-directive-save.s new file mode 100644 index 000000000000..f9c8c5f03f49 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-save.s @@ -0,0 +1,298 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd | FileCheck %s + +@ Check the .save directive + +@ The .save directive records the GPR registers which are pushed to the +@ stack. There are 4 different unwind opcodes: +@ +@ 0xB100: pop r[3:0] +@ 0xA0: pop r[(4+x):4] @ r[4+x]-r[4] must be consecutive. +@ 0xA8: pop r14, r[(4+x):4] @ r[4+x]-r[4] must be consecutive. +@ 0x8000: pop r[15:4] +@ +@ If register list specifed by .save directive is possible to be encoded +@ by 0xA0 or 0xA8, then the assembler should prefer them over 0x8000. + + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1 +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1a + .align 2 + .type func1a,%function + .fnstart +func1a: + .save {r0} + push {r0} + pop {r0} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1b + .align 2 + .type func1b,%function + .fnstart +func1b: + .save {r0, r1} + push {r0, r1} + pop {r0, r1} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1c + .align 2 + .type func1c,%function + .fnstart +func1c: + .save {r0, r2} + push {r0, r2} + pop {r0, r2} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1d + .align 2 + .type func1d,%function + .fnstart +func1d: + .save {r1, r2} + push {r1, r2} + pop {r1, r2} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1e + .align 2 + .type func1e,%function + .fnstart +func1e: + .save {r0, r1, r2, r3} + push {r0, r1, r2, r3} + pop {r0, r1, r2, r3} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0xB000 unwind opcode. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B001B100 00000000 B003B100 |................| +@ CHECK: 0010: 00000000 B005B100 00000000 B006B100 |................| +@ CHECK: 0020: 00000000 B00FB100 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST2 +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2a + .align 2 + .type func2a,%function + .fnstart +func2a: + .save {r4} + push {r4} + pop {r4} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2b + .align 2 + .type func2b,%function + .fnstart +func2b: + .save {r4, r5} + push {r4, r5} + pop {r4, r5} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2c + .align 2 + .type func2c,%function + .fnstart +func2c: + .save {r4, r5, r6, r7, r8, r9, r10, r11} + push {r4, r5, r6, r7, r8, r9, r10, r11} + pop {r4, r5, r6, r7, r8, r9, r10, r11} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0xA0 unwind opcode. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0A000 00000000 B0B0A100 |................| +@ CHECK: 0010: 00000000 B0B0A700 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST3 +@------------------------------------------------------------------------------- + .section .TEST3 + .globl func3a + .align 2 + .type func3a,%function + .fnstart +func3a: + .save {r4, r14} + push {r4, r14} + pop {r4, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func3b + .align 2 + .type func3b,%function + .fnstart +func3b: + .save {r4, r5, r14} + push {r4, r5, r14} + pop {r4, r5, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func3c + .align 2 + .type func3c,%function + .fnstart +func3c: + .save {r4, r5, r6, r7, r8, r9, r10, r11, r14} + push {r4, r5, r6, r7, r8, r9, r10, r11, r14} + pop {r4, r5, r6, r7, r8, r9, r10, r11, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0xA8 unwind opcode. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST3 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0A800 00000000 B0B0A900 |................| +@ CHECK: 0010: 00000000 B0B0AF00 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST4 +@------------------------------------------------------------------------------- + .section .TEST4 + .globl func4a + .align 2 + .type func4a,%function + .fnstart +func4a: + .save {r4, r5, r6, r7, r8, r9, r10, r11, r12, r14} + push {r4, r5, r6, r7, r8, r9, r10, r11, r12, r14} + pop {r4, r5, r6, r7, r8, r9, r10, r11, r12, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func4b + .align 2 + .type func4b,%function + .fnstart +func4b: + @ Note: r7 is missing intentionally. + .save {r4, r5, r6, r8, r9, r10, r11} + push {r4, r5, r6, r8, r9, r10, r11} + pop {r4, r5, r6, r8, r9, r10, r11} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func4c + .align 2 + .type func4c,%function + .fnstart +func4c: + @ Note: r7 is missing intentionally. + .save {r4, r5, r6, r8, r9, r10, r11, r14} + push {r4, r5, r6, r8, r9, r10, r11, r14} + pop {r4, r5, r6, r8, r9, r10, r11, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func4d + .align 2 + .type func4d,%function + .fnstart +func4d: + @ Note: The register list is not start with r4. + .save {r5, r6, r7} + push {r5, r6, r7} + pop {r5, r6, r7} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func4e + .align 2 + .type func4e,%function + .fnstart +func4e: + @ Note: The register list is not start with r4. + .save {r5, r6, r7, r14} + push {r5, r6, r7, r14} + pop {r5, r6, r7, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x8000 unwind opcode. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST4 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0FF8500 00000000 B0F78000 |................| +@ CHECK: 0010: 00000000 B0F78400 00000000 B00E8000 |................| +@ CHECK: 0020: 00000000 B00E8400 |........| +@ CHECK: ) +@ CHECK: } diff --git a/llvm/test/MC/ARM/eh-directive-section-comdat.s b/llvm/test/MC/ARM/eh-directive-section-comdat.s new file mode 100644 index 000000000000..296718f096ca --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-section-comdat.s @@ -0,0 +1,126 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr -t | FileCheck %s + +@ Check the .group section for the function in comdat section. + +@ In C++, the instantiation of the template will come with linkonce (or +@ linkonce_odr) linkage, so that the linker can remove the duplicated +@ instantiation. When the exception handling is enabled on those function, +@ we have to group the corresponding .ARM.extab and .ARM.exidx with the +@ text section together. +@ +@ This test case will check the content of .group section. The section index +@ of the grouped sections should be recorded in .group section. + + .syntax unified + .section .TEST1,"axG",%progbits,func1,comdat + .weak func1 + .align 2 + .type func1,%function +func1: + .fnstart + .save {r4, lr} + push {r4, lr} + .vsave {d8, d9, d10, d11, d12} + vpush {d8, d9, d10, d11, d12} + .pad #24 + sub sp, sp, #24 + + add sp, sp, #24 + vpop {d8, d9, d10, d11, d12} + pop {r4, pc} + + .globl __gxx_personality_v0 + .personality __gxx_personality_v0 + .handlerdata + .fnend + + + +@------------------------------------------------------------------------------- +@ Check the .group section +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Index: 1 +@ CHECK: Name: .group +@ CHECK: Type: SHT_GROUP (0x11) +@ CHECK: Flags [ (0x0) +@ CHECK: ] +@ CHECK: SectionData ( +@------------------------------------------------------------------------------- +@ The second, third, and fourth word should correspond to the section index +@ of .TEST1, .ARM.extab.TEST1, and .ARM.exidx.TEST1. +@------------------------------------------------------------------------------- +@ CHECK: 0000: 01000000 05000000 06000000 08000000 |................| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Index: 5 +@ CHECK: Name: .TEST1 +@ CHECK: Type: SHT_PROGBITS (0x1) +@------------------------------------------------------------------------------- +@ The flags should contain SHF_GROUP. +@------------------------------------------------------------------------------- +@ CHECK: Flags [ (0x206) +@ CHECK: SHF_ALLOC (0x2) +@ CHECK: SHF_EXECINSTR (0x4) +@ CHECK: SHF_GROUP (0x200) +@ CHECK: ] +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .ARM.extab.TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Index: 6 +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: Type: SHT_PROGBITS (0x1) +@------------------------------------------------------------------------------- +@ The flags should contain SHF_GROUP. +@------------------------------------------------------------------------------- +@ CHECK: Flags [ (0x202) +@ CHECK: SHF_ALLOC (0x2) +@ CHECK: SHF_GROUP (0x200) +@ CHECK: ] +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .ARM.exidx.TEST1 section +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Index: 8 +@ CHECK: Name: .ARM.exidx.TEST1 +@ CHECK: Type: SHT_ARM_EXIDX (0x70000001) +@------------------------------------------------------------------------------- +@ The flags should contain SHF_GROUP. +@------------------------------------------------------------------------------- +@ CHECK: Flags [ (0x282) +@ CHECK: SHF_ALLOC (0x2) +@ CHECK: SHF_GROUP (0x200) +@ CHECK: SHF_LINK_ORDER (0x80) +@ CHECK: ] +@ CHECK: Link: 5 +@ CHECK: } +@ CHECK: ] + + + +@------------------------------------------------------------------------------- +@ Check symbol func1. It should be weak binding, and belong to .TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Symbols [ +@ CHECK: Symbol { +@ CHECK: Name: func1 +@ CHECK: Binding: Weak (0x2) +@ CHECK: Type: Function (0x2) +@ CHECK: Section: .TEST1 (0x5) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-section-multiple-func.s b/llvm/test/MC/ARM/eh-directive-section-multiple-func.s new file mode 100644 index 000000000000..444099f8f648 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-section-multiple-func.s @@ -0,0 +1,129 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr -t | FileCheck %s + +@ Check whether the section is switched back properly. + +@ The assembler should switch the section back to the corresponding section +@ after it have emitted the exception handling indices and tables. In this +@ test case, we are checking whether the section is correct when .section +@ directives is used. + +@ In this example, func1 and func2 should be defined in .TEST1 section. +@ It is incorrect if the func2 is in .text, .ARM.extab.TEST1, or +@ .ARM.exidx.TEST1 sections. + + .syntax unified + + .section .TEST1 + + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + +@------------------------------------------------------------------------------- +@ Check the .text section. This should be empty. +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Name: .text +@ CHECK: SectionData ( +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .TEST1 section. There should be two "bx lr" instructions. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 1EFF2FE1 |../.../.| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ Check the .ARM.extab.TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 __gxx_personality_v0 0x0 +@ CHECK: 0x8 R_ARM_PREL31 __gxx_personality_v0 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B000 00000000 B0B0B000 |................| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .ARM.exidx.TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST1 +@ CHECK: Link: 4 +@------------------------------------------------------------------------------- +@ The first word of each entry should be relocated to .TEST1 section. +@ The second word of each entry should be relocated to +@ .ARM.extab.TESET1 section. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST1 0x0 +@ CHECK: 0x8 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0xC R_ARM_PREL31 .ARM.extab.TEST1 0x0 +@ CHECK: ] +@------------------------------------------------------------------------------- +@ The first word should be the offset to .TEST1. +@ The second word should be the offset to .ARM.extab.TEST1 +@------------------------------------------------------------------------------- +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 04000000 08000000 |................| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] + + + +@------------------------------------------------------------------------------- +@ Check the symbols "func1" and "func2". They should belong to .TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Symbols [ +@ CHECK: Symbol { +@ CHECK: Name: func1 +@ CHECK: Value: 0x0 +@ CHECK: Size: 0 +@ CHECK: Binding: Global (0x1) +@ CHECK: Type: Function (0x2) +@ CHECK: Other: 0 +@ CHECK: Section: .TEST1 (0x4) +@ CHECK: } +@ CHECK: Symbol { +@ CHECK: Name: func2 +@ CHECK: Value: 0x4 +@ CHECK: Size: 0 +@ CHECK: Binding: Global (0x1) +@ CHECK: Type: Function (0x2) +@ CHECK: Other: 0 +@ CHECK: Section: .TEST1 (0x4) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-section.s b/llvm/test/MC/ARM/eh-directive-section.s new file mode 100644 index 000000000000..5f5d1252f858 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-section.s @@ -0,0 +1,164 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr -t | FileCheck %s + +@ Check the combination of .section, .fnstart, and .fnend directives. + +@ For the functions in .text section, the exception handling index (EXIDX) +@ should be generated in .ARM.exidx, and the exception handling table (EXTAB) +@ should be generated in .ARM.extab. + +@ For the functions in custom section specified by .section directives, +@ the EXIDX should be generated in ".ARM.exidx[[SECTION_NAME]]", and the EXTAB +@ should be generated in ".ARM.extab[[SECTION_NAME]]". + + .syntax unified + +@------------------------------------------------------------------------------- +@ .TEST1 section +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + +@------------------------------------------------------------------------------- +@ TEST2 section (without the dot in the beginning) +@------------------------------------------------------------------------------- + .section TEST2 + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + +@------------------------------------------------------------------------------- +@ Check the .TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Index: 4 +@ CHECK: Name: .TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK: } + +@------------------------------------------------------------------------------- +@ Check the .ARM.extab.TEST1 section, the EXTAB of .TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 __gxx_personality_v0 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B000 |........| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the.ARM.exidx.TEST1 section, the EXIDX of .TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx.TEST1 + +@------------------------------------------------------------------------------- +@ This section should linked with .TEST1 section. +@------------------------------------------------------------------------------- +@ CHECK: Link: 4 + +@------------------------------------------------------------------------------- +@ The first word should be relocated to the code address in .TEST1 section. +@ The second word should be relocated to the EHTAB entry in .ARM.extab.TEST1 +@ section. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .TEST1 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extab.TEST1 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ Check the TEST2 section (without the dot in the beginning) +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Index: 9 +@ CHECK: Name: TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK: } + +@------------------------------------------------------------------------------- +@ Check the .ARM.extabTEST2 section, the EXTAB of TEST2 section. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extabTEST2 +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 __gxx_personality_v0 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B000 |........| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .ARM.exidxTEST2 section, the EXIDX of TEST2 section. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidxTEST2 + +@------------------------------------------------------------------------------- +@ This section should linked with TEST2 section. +@------------------------------------------------------------------------------- +@ CHECK: Link: 9 + +@------------------------------------------------------------------------------- +@ The first word should be relocated to the code address in TEST2 section. +@ The second word should be relocated to the EHTAB entry in .ARM.extabTEST2 +@ section. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 TEST2 0x0 +@ CHECK: 0x4 R_ARM_PREL31 .ARM.extabTEST2 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00000000 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] + + + +@------------------------------------------------------------------------------- +@ Check the symbols and the sections they belong to +@------------------------------------------------------------------------------- +@ CHECK: Symbols [ +@ CHECK: Symbol { +@ CHECK: Name: func1 +@ CHECK: Section: .TEST1 (0x4) +@ CHECK: } +@ CHECK: Symbol { +@ CHECK: Name: func2 +@ CHECK: Section: TEST2 (0x9) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-setfp-diagnostics.s b/llvm/test/MC/ARM/eh-directive-setfp-diagnostics.s new file mode 100644 index 000000000000..a5b8aa2386a5 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-setfp-diagnostics.s @@ -0,0 +1,87 @@ +@ RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi < %s 2> %t +@ RUN: FileCheck --check-prefix=CHECK < %t %s + +@ Check the diagnostics for .setfp directive. + + + .syntax unified + .text + +@------------------------------------------------------------------------------- +@ TEST1: .setfp before .fnstart +@------------------------------------------------------------------------------- + .globl func1 + .align 2 + .type func1,%function + .setfp fp, sp, #0 +@ CHECK: error: .fnstart must precede .setfp directive +@ CHECK: .setfp fp, sp, #0 +@ CHECK: ^ + .fnstart +func1: + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST2: .setfp after .handlerdata +@------------------------------------------------------------------------------- + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + .handlerdata + .setfp fp, sp, #0 +@ CHECK: error: .setfp must precede .handlerdata directive +@ CHECK: .setfp fp, sp, #0 +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST3: .setfp with bad fp register +@------------------------------------------------------------------------------- + .globl func3 + .align 2 + .type func3,%function + .fnstart +func3: + .setfp 0, r0, #0 +@ CHECK: error: frame pointer register expected +@ CHECK: .setfp 0, r0, #0 +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST4: .setfp with bad sp register +@------------------------------------------------------------------------------- + .globl func4 + .align 2 + .type func4,%function + .fnstart +func4: + .setfp fp, 0, #0 +@ CHECK: error: stack pointer register expected +@ CHECK: .setfp fp, 0, #0 +@ CHECK: ^ + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST5: .setfp with non-sp register as second operand +@------------------------------------------------------------------------------- + .globl func5 + .align 2 + .type func5,%function + .fnstart +func5: + .setfp fp, r0, #0 +@ CHECK: error: register should be either $sp or the latest fp register +@ CHECK: .setfp fp, r0, #0 +@ CHECK: ^ + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-setfp.s b/llvm/test/MC/ARM/eh-directive-setfp.s new file mode 100644 index 000000000000..3fbab5a3e724 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-setfp.s @@ -0,0 +1,239 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd | FileCheck %s + +@ Check for .setfp directive. + +@ The .setfp directive will track the offset between the frame pointer and +@ the stack pointer. This is required for the function that will change +@ the stack pointer out of the function prologue. If the exception is thrown, +@ then libunwind will reconstruct the stack pointer from the frame pointer. +@ The reconstruction code is implemented by two different unwind opcode: +@ (i) the unwind opcode to copy stack offset from the other register, and +@ (ii) the unwind opcode to add or substract the stack offset. +@ +@ This file includes several cases separated by different range of -offset +@ +@ (-offset) < 0x00 +@ (-offset) == 0x00 +@ 0x04 <= (-offset) <= 0x100 +@ 0x104 <= (-offset) <= 0x200 +@ 0x204 <= (-offset) + + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1 +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + .setfp fp, sp, #0 + add fp, sp, #0 + sub sp, fp, #0 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x9B to copy stack pointer from r11. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B09B00 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST2 +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2a + .align 2 + .type func2a,%function + .fnstart +func2a: + .setfp fp, sp, #-4 + add fp, sp, #4 + sub sp, fp, #4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2b + .align 2 + .type func2b,%function + .fnstart +func2b: + .setfp fp, sp, #-0x100 + add fp, sp, #0x100 + sub sp, fp, #0x100 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x9B to copy stack pointer from r11. +@ The assembler should emit ((-offset - 4) >> 2) for offset. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0009B00 00000000 B03F9B00 |.............?..| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST3 +@------------------------------------------------------------------------------- + .section .TEST3 + .globl func3a + .align 2 + .type func3a,%function + .fnstart +func3a: + .setfp fp, sp, #-0x104 + sub fp, sp, #0x104 + add sp, fp, #0x104 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func3b + .align 2 + .type func3b,%function + .fnstart +func3b: + .setfp fp, sp, #-0x200 + sub fp, sp, #0x200 + add sp, fp, #0x200 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x9B to copy stack pointer from r11. +@ The assembler should emit 0x3F and ((-offset - 0x104) >> 2) for offset. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST3 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 003F9B00 00000000 3F3F9B00 |.....?......??..| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST4 +@------------------------------------------------------------------------------- + .section .TEST4 + .globl func4a + .align 2 + .type func4a,%function + .fnstart +func4a: + .setfp fp, sp, #-0x204 + sub fp, sp, #0x204 + add sp, fp, #0x204 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func4b + .align 2 + .type func4b,%function + .fnstart +func4b: + .setfp fp, sp, #-0x580 + sub fp, sp, #0x580 + add sp, fp, #0x580 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x9B to copy stack pointer from r11. +@ The assembler should emit 0xB2 and the ULEB128 encoding of +@ ((-offset - 0x204) >> 2) for offset. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST4 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 00B29B00 00000000 DFB29B01 |................| +@ CHECK: 0010: B0B0B001 |....| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST5 +@------------------------------------------------------------------------------- + .section .TEST5 + .globl func5a + .align 2 + .type func5a,%function + .fnstart +func5a: + .setfp fp, sp, #0x4 + add fp, sp, #0x4 + sub sp, fp, #0x4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func5b + .align 2 + .type func5b,%function + .fnstart +func5b: + .setfp fp, sp, #0x104 + add fp, sp, #0x104 + sub sp, fp, #0x104 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func5c + .align 2 + .type func5c,%function + .fnstart +func5c: + .setfp fp, sp, #0x204 + add fp, sp, #0x204 + sub sp, fp, #0x204 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ The assembler should emit 0x9B to copy stack pointer from r11. +@ The assembler should emit (0x40 | (offset - 4)) >> 2 for offset. +@ If (offset - 4) is greater than 0x3f, then multiple 0x7f should be emitted. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST5 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0409B00 00000000 407F9B00 |.....@......@...| +@ CHECK: 0010: 00000000 7F7F9B01 B0B0B040 |...........@| +@ CHECK: ) +@ CHECK: } diff --git a/llvm/test/MC/ARM/eh-directive-text-section-multiple-func.s b/llvm/test/MC/ARM/eh-directive-text-section-multiple-func.s new file mode 100644 index 000000000000..c9412763a803 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-text-section-multiple-func.s @@ -0,0 +1,81 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr -r -t | FileCheck %s + +@ Check whether the section is switched back or not. + +@ The assembler should emit the machine code of "func2" in .text section. +@ It is incorrect if the machine code is emitted in .ARM.exidx or .ARM.extab. +@ Besides, there should be two entries in .ARM.exidx section. + + .syntax unified + + .text + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .fnend + + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + bx lr + .fnend + + +@------------------------------------------------------------------------------- +@ Check the .text section. There should be two "bx lr" instructions. +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Name: .text +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 1EFF2FE1 |../.../.| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the .ARM.exidx section. +@ There should be two entries (two words per entry.) +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx +@------------------------------------------------------------------------------- +@ The first word of each entry should be relocated to .text section. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .text 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr0 0x0 +@ CHECK: 0x8 R_ARM_PREL31 .text 0x0 +@ CHECK: ] +@ CHECK: SectionData ( +@------------------------------------------------------------------------------- +@ The first word should be the offset to .text. The second word should be +@ 0xB0B0B080, which means compact model 0 is used (0x80) and the rest of the +@ word is filled with FINISH opcode (0xB0). +@------------------------------------------------------------------------------- +@ CHECK: 0000: 00000000 B0B0B080 04000000 B0B0B080 |................| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] + + + +@------------------------------------------------------------------------------- +@ Check the symbols "func1" and "func2". They should belong to .text section. +@------------------------------------------------------------------------------- +@ CHECK: Symbols [ +@ CHECK: Symbol { +@ CHECK: Name: func1 +@ CHECK: Section: .text (0x1) +@ CHECK: } +@ CHECK: Symbol { +@ CHECK: Name: func2 +@ CHECK: Section: .text (0x1) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-text-section.s b/llvm/test/MC/ARM/eh-directive-text-section.s new file mode 100644 index 000000000000..5ab1baa592f5 --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-text-section.s @@ -0,0 +1,82 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the .fnstart directive and the .fnend directive. + +@ The .fnstart directive and .fnend directive should create an entry in +@ exception handling table. For example, if the function is defined in .text +@ section, then there should be an entry in .ARM.exidx section. + + .syntax unified + + .text + .globl func1 + .align 2 + .type func1,%function + .fnstart +func1: + bx lr + .fnend + + + +@------------------------------------------------------------------------------- +@ Check the .text section. +@------------------------------------------------------------------------------- +@ CHECK: Sections [ +@ CHECK: Section { + +@------------------------------------------------------------------------------- +@ Check the index of .text section. This will be used in .ARM.exidx. +@------------------------------------------------------------------------------- +@ CHECK: Index: 1 +@ CHECK: Name: .text +@ CHECK: Type: SHT_PROGBITS (0x1) +@ CHECK: Flags [ (0x6) +@ CHECK: SHF_ALLOC (0x2) +@ CHECK: SHF_EXECINSTR (0x4) +@ CHECK: ] +@ CHECK: SectionData ( +@ CHECK: 0000: 1EFF2FE1 |../.| +@ CHECK: ) +@ CHECK: } + + +@------------------------------------------------------------------------------- +@ Check the name of the EXIDX section. For the function in the .text section, +@ this should be .ARM.exidx. It is incorrect to see .ARM.exidx.text here. +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.exidx +@ CHECK: Type: SHT_ARM_EXIDX (0x70000001) +@ CHECK: Flags [ (0x82) +@ CHECK: SHF_ALLOC (0x2) +@ CHECK: SHF_LINK_ORDER (0x80) +@ CHECK: ] + +@------------------------------------------------------------------------------- +@ Check the linked section of the EXIDX section. This should be the index +@ of the .text section. +@------------------------------------------------------------------------------- +@ CHECK: Link: 1 + +@------------------------------------------------------------------------------- +@ The first word should be relocated to the code address in .text section. +@ Besides, since this function is using compact model 0, thus we have to +@ add an relocation to __aeabi_unwind_cpp_pr0. +@------------------------------------------------------------------------------- +@ CHECK: Relocations [ +@ CHECK: 0x0 R_ARM_PREL31 .text 0x0 +@ CHECK: 0x0 R_ARM_NONE __aeabi_unwind_cpp_pr0 0x0 +@ CHECK: ] + +@------------------------------------------------------------------------------- +@ The first word should be the offset to .text. The second word should be +@ 0xB0B0B080, which means compact model 0 is used (0x80) and the rest of the +@ word is filled with FINISH opcode (0xB0). +@------------------------------------------------------------------------------- +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0B0B080 |........| +@ CHECK: ) +@ CHECK: } +@ CHECK: ] diff --git a/llvm/test/MC/ARM/eh-directive-vsave-diagnostics.s b/llvm/test/MC/ARM/eh-directive-vsave-diagnostics.s new file mode 100644 index 000000000000..62787f37c27f --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-vsave-diagnostics.s @@ -0,0 +1,41 @@ +@ RUN: not llvm-mc -triple=armv7-unknown-linux-gnueabi < %s 2> %t +@ RUN: FileCheck --check-prefix=CHECK < %t %s + +@ Check the diagnostics for .vsave directive + +@ .vsave directive should always come after .fnstart directive +@ and before .handlerdata directive. + + .syntax unified + .text + +@------------------------------------------------------------------------------- +@ TEST1: .vsave before .fnstart +@------------------------------------------------------------------------------- + .globl func1 + .align 2 + .type func1,%function + .vsave {d0, d1, d2, d3} +@ CHECK: error: .fnstart must precede .save or .vsave directives +@ CHECK: .vsave {d0, d1, d2, d3} +@ CHECK: ^ + .fnstart +func1: + .fnend + + + +@------------------------------------------------------------------------------- +@ TEST2: .vsave after .handlerdata +@------------------------------------------------------------------------------- + .globl func2 + .align 2 + .type func2,%function + .fnstart +func2: + .handlerdata + .vsave {d0, d1, d2, d3} +@ CHECK: error: .save or .vsave must precede .handlerdata directive +@ CHECK: .vsave {d0, d1, d2, d3} +@ CHECK: ^ + .fnend diff --git a/llvm/test/MC/ARM/eh-directive-vsave.s b/llvm/test/MC/ARM/eh-directive-vsave.s new file mode 100644 index 000000000000..c9b78d7e276b --- /dev/null +++ b/llvm/test/MC/ARM/eh-directive-vsave.s @@ -0,0 +1,130 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd -sr | FileCheck %s + +@ Check the .vsave directive + +@ The .vsave directive records the VFP registers which are pushed to the +@ stack. There are two different opcodes: +@ +@ 0xC800: pop d[(16+x+y):(16+x)] @ d[16+x+y]-d[16+x] must be consecutive +@ 0xC900: pop d[(x+y):x] @ d[x+y]-d[x] must be consecutive + + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1 +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1a + .align 2 + .type func1a,%function + .fnstart +func1a: + .vsave {d0} + vpush {d0} + vpop {d0} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1b + .align 2 + .type func1b,%function + .fnstart +func1b: + .vsave {d0, d1, d2, d3} + vpush {d0, d1, d2, d3} + vpop {d0, d1, d2, d3} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1c + .align 2 + .type func1c,%function + .fnstart +func1c: + .vsave {d0, d1, d2, d3, d4, d5, d6, d7} + vpush {d0, d1, d2, d3, d4, d5, d6, d7} + vpop {d0, d1, d2, d3, d4, d5, d6, d7} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func1d + .align 2 + .type func1d,%function + .fnstart +func1d: + .vsave {d2, d3, d4, d5, d6, d7} + vpush {d2, d3, d4, d5, d6, d7} + vpop {d2, d3, d4, d5, d6, d7} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B000C900 00000000 B003C900 |................| +@ CHECK: 0010: 00000000 B007C900 00000000 B025C900 |.............%..| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST2 +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2a + .align 2 + .type func2a,%function + .fnstart +func2a: + .vsave {d16} + vpush {d16} + vpop {d16} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2b + .align 2 + .type func2b,%function + .fnstart +func2b: + .vsave {d16, d17, d18, d19} + vpush {d16, d17, d18, d19} + vpop {d16, d17, d18, d19} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func2c + .align 2 + .type func2c,%function + .fnstart +func2c: + .vsave {d16, d17, d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29, d30, d31} + vpush {d16, d17, d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29, d30, d31} + vpop {d16, d17, d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29, d30, d31} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B000C800 00000000 B003C800 |................| +@ CHECK: 0010: 00000000 B00FC800 |........| +@ CHECK: ) +@ CHECK: } -- GitLab From 14e915f7b45eab991952e044901c32fbb1efabc8 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 May 2013 16:26:37 +0000 Subject: [PATCH 173/467] InstCombine: Don't claim to be able to evaluate any shl in a zexted type. The shift amount may be larger than the type leading to undefined behavior. Limit the transform to constant shift amounts. While there update the bits to clear in the result which may enable additional optimizations. PR15959. llvm-svn: 181604 --- .../InstCombine/InstCombineCasts.cpp | 12 +++++++- llvm/test/Transforms/InstCombine/cast.ll | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 2ee1278d23dc..361acdde81fb 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -677,7 +677,6 @@ static bool CanEvaluateZExtd(Value *V, Type *Ty, unsigned &BitsToClear) { case Instruction::Add: case Instruction::Sub: case Instruction::Mul: - case Instruction::Shl: if (!CanEvaluateZExtd(I->getOperand(0), Ty, BitsToClear) || !CanEvaluateZExtd(I->getOperand(1), Ty, Tmp)) return false; @@ -701,6 +700,17 @@ static bool CanEvaluateZExtd(Value *V, Type *Ty, unsigned &BitsToClear) { // Otherwise, we don't know how to analyze this BitsToClear case yet. return false; + case Instruction::Shl: + // We can promote shl(x, cst) if we can promote x. Since shl overwrites the + // upper bits we can reduce BitsToClear by the shift amount. + if (ConstantInt *Amt = dyn_cast(I->getOperand(1))) { + if (!CanEvaluateZExtd(I->getOperand(0), Ty, BitsToClear)) + return false; + uint64_t ShiftAmt = Amt->getZExtValue(); + BitsToClear = ShiftAmt < BitsToClear ? BitsToClear - ShiftAmt : 0; + return true; + } + return false; case Instruction::LShr: // We can promote lshr(x, cst) if we can promote x. This requires the // ultimate 'and' to clear out the high zero bits we're clearing out though. diff --git a/llvm/test/Transforms/InstCombine/cast.ll b/llvm/test/Transforms/InstCombine/cast.ll index de738bb7c06d..ff2c0a928984 100644 --- a/llvm/test/Transforms/InstCombine/cast.ll +++ b/llvm/test/Transforms/InstCombine/cast.ll @@ -898,3 +898,31 @@ define double @test81(double *%p, float %f) { %l = load double* %r ret double %l } + +define i64 @test82(i64 %A) nounwind { + %B = trunc i64 %A to i32 + %C = lshr i32 %B, 8 + %D = shl i32 %C, 9 + %E = zext i32 %D to i64 + ret i64 %E + +; CHECK: @test82 +; CHECK-NEXT: [[REG:%[0-9]*]] = shl i64 %A, 1 +; CHECK-NEXT: %E = and i64 [[REG]], 4294966784 +; CHECK-NEXT: ret i64 %E +} + +; PR15959 +define i64 @test83(i16 %a, i64 %k) { + %conv = sext i16 %a to i32 + %sub = add nsw i64 %k, -1 + %sh_prom = trunc i64 %sub to i32 + %shl = shl i32 %conv, %sh_prom + %sh_prom1 = zext i32 %shl to i64 + ret i64 %sh_prom1 + +; CHECK: @test83 +; CHECK: %sub = add nsw i64 %k, 4294967295 +; CHECK: %sh_prom = trunc i64 %sub to i32 +; CHECK: %shl = shl i32 %conv, %sh_prom +} -- GitLab From 3c5d2c8a241928f2cba24711471ca17369c09295 Mon Sep 17 00:00:00 2001 From: Shankar Easwaran Date: Fri, 10 May 2013 16:44:02 +0000 Subject: [PATCH 174/467] [lld][LayoutPass] This commit fixes a problem in the Layoutpass by ordering atoms if they appear in the override list first and then looking at the way of ordering atoms in the default way. The fix also fixes issues with the sizes of the sections, that appear in the output properly too. The commit also adds a testcase(orderatoms-by-override.test) to test it and fixes all the other relevant testcases. llvm-svn: 181605 --- lld/lib/Passes/LayoutPass.cpp | 48 +++---- lld/test/elf/Hexagon/dynlib-gotoff.test | 131 +++++++++--------- lld/test/elf/X86_64/Inputs/constint.c | 1 + lld/test/elf/X86_64/Inputs/constint.o | Bin 0 -> 734 bytes lld/test/elf/X86_64/Inputs/rwint.c | 1 + lld/test/elf/X86_64/Inputs/rwint.o | Bin 0 -> 667 bytes lld/test/elf/X86_64/multi-weak-override.test | 4 +- .../elf/X86_64/multi-weak-syms-order.test | 8 +- .../elf/X86_64/orderatoms-by-override.test | 8 ++ lld/test/elf/X86_64/weak-override.test | 2 +- lld/test/elf/check.objtxt | 42 +++--- lld/test/elf/dynamic.test | 9 +- lld/test/elf/gotpcrel.test | 20 +-- lld/test/elf/ifunc.test | 15 +- lld/test/elf/mergeatoms.objtxt | 3 +- lld/test/elf/phdr.objtxt | 3 +- lld/test/elf/sections.objtxt | 6 +- lld/test/elf/tls.test | 12 +- lld/test/elf/x86-64-dynamic.test | 28 ++-- 19 files changed, 183 insertions(+), 158 deletions(-) create mode 100644 lld/test/elf/X86_64/Inputs/constint.c create mode 100644 lld/test/elf/X86_64/Inputs/constint.o create mode 100644 lld/test/elf/X86_64/Inputs/rwint.c create mode 100644 lld/test/elf/X86_64/Inputs/rwint.o create mode 100644 lld/test/elf/X86_64/orderatoms-by-override.test diff --git a/lld/lib/Passes/LayoutPass.cpp b/lld/lib/Passes/LayoutPass.cpp index 5f241f33b27c..d13551ae431d 100644 --- a/lld/lib/Passes/LayoutPass.cpp +++ b/lld/lib/Passes/LayoutPass.cpp @@ -31,6 +31,30 @@ bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left, if (left == right) return false; + DEBUG(llvm::dbgs() << "Sorting by override\n"); + + AtomToOrdinalT::const_iterator lPos = _layout._ordinalOverrideMap.find(left); + AtomToOrdinalT::const_iterator rPos = _layout._ordinalOverrideMap.find(right); + AtomToOrdinalT::const_iterator end = _layout._ordinalOverrideMap.end(); + if (lPos != end) { + if (rPos != end) { + // both left and right are overridden, so compare overridden ordinals + if (lPos->second != rPos->second) + return lPos->second < rPos->second; + } else { + // left is overridden and right is not, so left < right + return true; + } + } else { + if (rPos != end) { + // right is overridden and left is not, so right < left + return false; + } else { + // neither are overridden, + // fall into default sorting below + } + } + // Sort same permissions together. DefinedAtom::ContentPermissions leftPerms = left->permissions(); DefinedAtom::ContentPermissions rightPerms = right->permissions(); @@ -67,30 +91,6 @@ bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left, return leftPos < rightPos; } - DEBUG(llvm::dbgs() << "Sorting by override\n"); - - AtomToOrdinalT::const_iterator lPos = _layout._ordinalOverrideMap.find(left); - AtomToOrdinalT::const_iterator rPos = _layout._ordinalOverrideMap.find(right); - AtomToOrdinalT::const_iterator end = _layout._ordinalOverrideMap.end(); - if (lPos != end) { - if (rPos != end) { - // both left and right are overridden, so compare overridden ordinals - if (lPos->second != rPos->second) - return lPos->second < rPos->second; - } else { - // left is overridden and right is not, so left < right - return true; - } - } else { - if (rPos != end) { - // right is overridden and left is not, so right < left - return false; - } else { - // neither are overridden, - // fall into default sorting below - } - } - // Sort by .o order. const File *leftFile = &left->file(); const File *rightFile = &right->file(); diff --git a/lld/test/elf/Hexagon/dynlib-gotoff.test b/lld/test/elf/Hexagon/dynlib-gotoff.test index f2d143fbb23f..f2590788b522 100644 --- a/lld/test/elf/Hexagon/dynlib-gotoff.test +++ b/lld/test/elf/Hexagon/dynlib-gotoff.test @@ -1,72 +1,8 @@ +# This tests GOT's and PLT's for dynamic libraries for Hexagon RUN: lld -flavor gnu -target hexagon %p/Inputs/dynobj.o \ RUN: -o %t -emit-yaml -shared --noinhibit-exec RUN: FileCheck -check-prefix=CHECKGOTPLT %s < %t - - name: __got0 -CHECKGOTPLT: type: got -CHECKGOTPLT: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, -CHECKGOTPLT: 00, 00, 00, 00 ] -CHECKGOTPLT: alignment: 2^3 -CHECKGOTPLT: section-name: .got.plt - - name: __got_c -CHECKGOTPLT: type: got -CHECKGOTPLT: content: [ 00, 00, 00, 00 ] -CHECKGOTPLT: alignment: 2^2 -CHECKGOTPLT: section-name: .got -CHECKGOTPLT: permissions: rw- -CHECKGOTPLT: references: -CHECKGOTPLT: - kind: R_HEX_GLOB_DAT -CHECKGOTPLT: offset: 0 -CHECKGOTPLT: target: c - - name: __got_shankar -CHECKGOTPLT: type: got -CHECKGOTPLT: content: [ 00, 00, 00, 00 ] -CHECKGOTPLT: alignment: 2^2 -CHECKGOTPLT: section-name: .got -CHECKGOTPLT: permissions: rw- -CHECKGOTPLT: references: -CHECKGOTPLT: - kind: R_HEX_GLOB_DAT -CHECKGOTPLT: offset: 0 -CHECKGOTPLT: target: shankar - - name: __got_fn -CHECKGOTPLT: type: got -CHECKGOTPLT: content: [ 00, 00, 00, 00 ] -CHECKGOTPLT: alignment: 2^2 -CHECKGOTPLT: section-name: .got.plt -CHECKGOTPLT: permissions: rw- -CHECKGOTPLT: references: -CHECKGOTPLT: - kind: R_HEX_JMP_SLOT -CHECKGOTPLT: offset: 0 -CHECKGOTPLT: target: fn -CHECKGOTPLT: - kind: R_HEX_32 -CHECKGOTPLT: offset: 0 - target: .PLT0 - - name: __got_fn1 -CHECKGOTPLT: type: got -CHECKGOTPLT: content: [ 00, 00, 00, 00 ] -CHECKGOTPLT: alignment: 2^2 -CHECKGOTPLT: section-name: .got.plt -CHECKGOTPLT: permissions: rw- -CHECKGOTPLT: references: -CHECKGOTPLT: - kind: R_HEX_JMP_SLOT -CHECKGOTPLT: offset: 0 -CHECKGOTPLT: target: fn1 -CHECKGOTPLT: - kind: R_HEX_32 -CHECKGOTPLT: offset: 0 - target: .PLT0 - - name: __got_fn2 -CHECKGOTPLT: type: got -CHECKGOTPLT: content: [ 00, 00, 00, 00 ] -CHECKGOTPLT: alignment: 2^2 -CHECKGOTPLT: section-name: .got.plt -CHECKGOTPLT: permissions: rw- -CHECKGOTPLT: references: -CHECKGOTPLT: - kind: R_HEX_JMP_SLOT -CHECKGOTPLT: offset: 0 -CHECKGOTPLT: target: fn2 -CHECKGOTPLT: - kind: R_HEX_32 -CHECKGOTPLT: offset: 0 - target: .PLT0 CHECKGOTPLT: - ref-name: {{[0-9A-Z]+}} CHECKGOTPLT: alignment: 2^2 CHECKGOTPLT: section-name: .text @@ -146,6 +82,71 @@ CHECKGOTPLT: offset: 8 CHECKGOTPLT: - kind: R_HEX_B22_PCREL CHECKGOTPLT: offset: 12 target: __plt_fn2 + - name: __got0 +CHECKGOTPLT: type: got +CHECKGOTPLT: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, +CHECKGOTPLT: 00, 00, 00, 00 ] +CHECKGOTPLT: alignment: 2^3 +CHECKGOTPLT: section-name: .got.plt + - name: __got_c +CHECKGOTPLT: type: got +CHECKGOTPLT: content: [ 00, 00, 00, 00 ] +CHECKGOTPLT: alignment: 2^2 +CHECKGOTPLT: section-name: .got +CHECKGOTPLT: permissions: rw- +CHECKGOTPLT: references: +CHECKGOTPLT: - kind: R_HEX_GLOB_DAT +CHECKGOTPLT: offset: 0 +CHECKGOTPLT: target: c + - name: __got_shankar +CHECKGOTPLT: type: got +CHECKGOTPLT: content: [ 00, 00, 00, 00 ] +CHECKGOTPLT: alignment: 2^2 +CHECKGOTPLT: section-name: .got +CHECKGOTPLT: permissions: rw- +CHECKGOTPLT: references: +CHECKGOTPLT: - kind: R_HEX_GLOB_DAT +CHECKGOTPLT: offset: 0 +CHECKGOTPLT: target: shankar + - name: __got_fn +CHECKGOTPLT: type: got +CHECKGOTPLT: content: [ 00, 00, 00, 00 ] +CHECKGOTPLT: alignment: 2^2 +CHECKGOTPLT: section-name: .got.plt +CHECKGOTPLT: permissions: rw- +CHECKGOTPLT: references: +CHECKGOTPLT: - kind: R_HEX_JMP_SLOT +CHECKGOTPLT: offset: 0 +CHECKGOTPLT: target: fn +CHECKGOTPLT: - kind: R_HEX_32 +CHECKGOTPLT: offset: 0 + target: .PLT0 + - name: __got_fn1 +CHECKGOTPLT: type: got +CHECKGOTPLT: content: [ 00, 00, 00, 00 ] +CHECKGOTPLT: alignment: 2^2 +CHECKGOTPLT: section-name: .got.plt +CHECKGOTPLT: permissions: rw- +CHECKGOTPLT: references: +CHECKGOTPLT: - kind: R_HEX_JMP_SLOT +CHECKGOTPLT: offset: 0 +CHECKGOTPLT: target: fn1 +CHECKGOTPLT: - kind: R_HEX_32 +CHECKGOTPLT: offset: 0 + target: .PLT0 + - name: __got_fn2 +CHECKGOTPLT: type: got +CHECKGOTPLT: content: [ 00, 00, 00, 00 ] +CHECKGOTPLT: alignment: 2^2 +CHECKGOTPLT: section-name: .got.plt +CHECKGOTPLT: permissions: rw- +CHECKGOTPLT: references: +CHECKGOTPLT: - kind: R_HEX_JMP_SLOT +CHECKGOTPLT: offset: 0 +CHECKGOTPLT: target: fn2 +CHECKGOTPLT: - kind: R_HEX_32 +CHECKGOTPLT: offset: 0 + target: .PLT0 - name: .PLT0 CHECKGOTPLT: type: stub CHECKGOTPLT: content: [ 00, 40, 00, 00, 1C, C0, 49, 6A, 0E, 42, 9C, E2, diff --git a/lld/test/elf/X86_64/Inputs/constint.c b/lld/test/elf/X86_64/Inputs/constint.c new file mode 100644 index 000000000000..9fc0ebcf6591 --- /dev/null +++ b/lld/test/elf/X86_64/Inputs/constint.c @@ -0,0 +1 @@ +const int b = 20; diff --git a/lld/test/elf/X86_64/Inputs/constint.o b/lld/test/elf/X86_64/Inputs/constint.o new file mode 100644 index 0000000000000000000000000000000000000000..9c709e07a465369a755a31a4a1f3826525b7bd78 GIT binary patch literal 734 zcma)4!AiqG5S^H6RYWX!>!qHoXjiKRMG%Cdy;N`gfMgpmXf}{+Ku`WcKgCb+SNsB< zm))`PAUZI4@6EhSW|O?$OmBlAAc=rNS}LM9-x$@{r%h_pF8E|TzU=j9ab;|EJWWkh ziVa?nHJ>-=~S0&OyJi>$MaLO5=;kyIzAwHn&hSoKU1>*)M&WHVWyl&2WXWus0 zC1jpx!DhWhAD>bO{`|9`o0~v4p9n2)%S{QtzozI_+H$mZc5v0XDQ#-3(iGDd^5QeS literal 0 HcmV?d00001 diff --git a/lld/test/elf/X86_64/Inputs/rwint.c b/lld/test/elf/X86_64/Inputs/rwint.c new file mode 100644 index 000000000000..d1cf7d62c801 --- /dev/null +++ b/lld/test/elf/X86_64/Inputs/rwint.c @@ -0,0 +1 @@ +int a = 10; diff --git a/lld/test/elf/X86_64/Inputs/rwint.o b/lld/test/elf/X86_64/Inputs/rwint.o new file mode 100644 index 0000000000000000000000000000000000000000..cbf371d5d6f14de0e452bae0007dbc518417e01f GIT binary patch literal 667 zcmah{K~BRk5ZusEC|uezmvW*AYA6&Haji-(6}LXXaU&5y94T=GoZtyOgYWSI*h##q zIkD1eW_HK+9Q?jm-A7SGQW14%tBAh*V%p${deo%@@a24dHyo{#+PeB;m04XD!>O97 ztMO#=T$^ljecEawRlVg-CycIa@llvdUmdB9cA8XDRisRj=c(nHEnKRW59@K|w0ZI= z{)Z#BAb;0e+uYl8v8Tt3@O8X~Pj(myKViPlExubUgA(64&v4(R-@$k0IRHEKjYo#2 zj1Z6Tpa$IXCNz8t5MSa0?#Pg_&*Fm-nfJJnug~4%4)6P9-yzSW5_5IF}pU%q74DMOlm0dB7@vj6}9 literal 0 HcmV?d00001 diff --git a/lld/test/elf/X86_64/multi-weak-override.test b/lld/test/elf/X86_64/multi-weak-override.test index 3be37cdda85e..ab5b472c09d0 100644 --- a/lld/test/elf/X86_64/multi-weak-override.test +++ b/lld/test/elf/X86_64/multi-weak-override.test @@ -6,8 +6,8 @@ RUN: lld -flavor gnu -target x86_64 %p/Inputs/multi-weak.o \ RUN: %p/Inputs/multi-ovrd.o -emit-yaml -o %t2 --noinhibit-exec RUN: FileCheck -check-prefix=WEAKATOMSORDER %s < %t2 -WEAKORDER: 0040020c T f -WEAKORDER: 0040021c T g +WEAKORDER: {{[0-9a-f]+}} T f +WEAKORDER: {{[0-9a-f]+}} T g WEAKATOMSORDER: - ref-name: {{[A-Z0-9]+}} WEAKATOMSORDER: - ref-name: {{[A-Z0-9]+}} diff --git a/lld/test/elf/X86_64/multi-weak-syms-order.test b/lld/test/elf/X86_64/multi-weak-syms-order.test index 1b5301ad0fd4..ac15bf0fedf6 100644 --- a/lld/test/elf/X86_64/multi-weak-syms-order.test +++ b/lld/test/elf/X86_64/multi-weak-syms-order.test @@ -4,10 +4,10 @@ RUN: llvm-nm -n %t | FileCheck -check-prefix=WEAKORDER %s RUN: lld -flavor gnu -target x86_64 %p/Inputs/multi-weak.o -o %t2 -emit-yaml --noinhibit-exec RUN: FileCheck -check-prefix=WEAKATOMSORDER %s < %t2 -WEAKORDER: 004001b0 T fn -WEAKORDER: 004001bb T f -WEAKORDER: 004001cb T g -WEAKORDER: 004001db T main +WEAKORDER: {{[0-9a-f]+}} T fn +WEAKORDER: {{[0-9a-f]+}} T f +WEAKORDER: {{[0-9a-f]+}} T g +WEAKORDER: {{[0-9a-f]+}} T main WEAKATOMSORDER: - name: f WEAKATOMSORDER: - ref-name: {{[A-Z0-9]+}} diff --git a/lld/test/elf/X86_64/orderatoms-by-override.test b/lld/test/elf/X86_64/orderatoms-by-override.test new file mode 100644 index 000000000000..ab333b73c9a2 --- /dev/null +++ b/lld/test/elf/X86_64/orderatoms-by-override.test @@ -0,0 +1,8 @@ +# This testcase tests the behaviour of the layoutpass so that the atoms that +# appear by their override take preference before proceeding to default behaviour +RUN: lld -flavor gnu -target x86_64 %p/Inputs/rwint.o \ +RUN: %p/Inputs/constint.o -emit-yaml -o %t --noinhibit-exec +RUN: FileCheck %s -check-prefix=CHECKORDER < %t + +CHECKORDER: - name: a +CHECKORDER: - name: b diff --git a/lld/test/elf/X86_64/weak-override.test b/lld/test/elf/X86_64/weak-override.test index b8264ccb0d1d..544c3cd42476 100644 --- a/lld/test/elf/X86_64/weak-override.test +++ b/lld/test/elf/X86_64/weak-override.test @@ -6,7 +6,7 @@ RUN: lld -flavor gnu -target x86_64 %p/Inputs/weak.o \ RUN: %p/Inputs/ovrd.o -o %t2 -emit-yaml --noinhibit-exec RUN: FileCheck -check-prefix=WEAKATOMSORDER %s < %t2 -WEAKORDER: 004001ec T f +WEAKORDER: {{[0-9a-c]+}} T f WEAKATOMSORDER: references: WEAKATOMSORDER: - kind: layout-after diff --git a/lld/test/elf/check.objtxt b/lld/test/elf/check.objtxt index 0d27be7a97ea..fcf9d7d6a038 100644 --- a/lld/test/elf/check.objtxt +++ b/lld/test/elf/check.objtxt @@ -1,3 +1,5 @@ +# This tests the basic functionality of ordering data and functions as they +# appear in the inputs RUN: lld -flavor gnu -target i386 -e global_func --noinhibit-exec -emit-yaml \ RUN: %p/Inputs/object-test.elf-i386 -o %t RUN: FileCheck %s -check-prefix ELF-i386 < %t @@ -5,16 +7,6 @@ RUN: lld -flavor gnu -target hexagon -e global_func --noinhibit-exec -emit-yaml RUN: %p/Inputs/object-test.elf-hexagon | FileCheck %s -check-prefix ELF-hexagon ELF-i386:defined-atoms: -ELF-i386: - name: tentative -ELF-i386: scope: global -ELF-i386: type: zero-fill -ELF-i386: merge: as-tentative - -ELF-i386: - name: common_symbol -ELF-i386: scope: global -ELF-i386: type: zero-fill -ELF-i386: merge: as-tentative - ELF-i386: - name: global_func ELF-i386: scope: global ELF-i386: content: [ 55, 89, E5, 83, EC, 18, C7, 04, 24, 00, 00, 00, @@ -49,6 +41,17 @@ ELF-i386: content: [ 55, 89, E5, 5D, C3 ] ELF-i386: section-choice: custom-required ELF-i386: section-name: special_section +ELF-i386: - name: tentative +ELF-i386: scope: global +ELF-i386: type: zero-fill +ELF-i386: merge: as-tentative + +ELF-i386: - name: common_symbol +ELF-i386: scope: global +ELF-i386: type: zero-fill +ELF-i386: merge: as-tentative + + ELF-i386:undefined-atoms: ELF-i386: - name: puts @@ -57,15 +60,6 @@ ELF-i386: - name: sample.c ELF-i386: value: 0x0 ELF-hexagon:defined-atoms: -ELF-hexagon: - name: tentative -ELF-hexagon: scope: global -ELF-hexagon: type: zero-fill -ELF-hexagon: merge: as-tentative - -ELF-hexagon: - name: common_symbol -ELF-hexagon: scope: global -ELF-hexagon: type: zero-fill -ELF-hexagon: merge: as-tentative ELF-hexagon: - name: global_func ELF-hexagon: scope: global @@ -101,6 +95,16 @@ ELF-hexagon: content: [ 00, C0, 9D, A0, 1E, C0, 1E, 96 ] ELF-hexagon: section-choice: custom-required ELF-hexagon: section-name: special_section +ELF-hexagon: - name: tentative +ELF-hexagon: scope: global +ELF-hexagon: type: zero-fill +ELF-hexagon: merge: as-tentative + +ELF-hexagon: - name: common_symbol +ELF-hexagon: scope: global +ELF-hexagon: type: zero-fill +ELF-hexagon: merge: as-tentative + ELF-hexagon: undefined-atoms: ELF-hexagon: - name: puts diff --git a/lld/test/elf/dynamic.test b/lld/test/elf/dynamic.test index 74f335f2122e..f784d09d7fa2 100644 --- a/lld/test/elf/dynamic.test +++ b/lld/test/elf/dynamic.test @@ -1,3 +1,4 @@ +# Checks functionality of dynamic executables RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared.x86-64 \ RUN: %p/Inputs/shared.so-x86-64 -o %t -e main --allow-shlib-undefined RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared.x86-64 \ @@ -7,15 +8,15 @@ RUN: llvm-objdump -p %t >> %t2 RUN: llvm-readobj -s -dyn-symbols -dynamic-table %t >> %t2 RUN: FileCheck %s < %t2 -CHECK: type: got -CHECK: references: -CHECK: kind: R_X86_64_JUMP_SLOT - CHECK: name: main CHECK: kind: R_X86_64_PC32 CHECK: offset: 18 CHECK: target: [[PLTNAME:[-a-zA-Z0-9_]+]] +CHECK: type: got +CHECK: references: +CHECK: kind: R_X86_64_JUMP_SLOT + CHECK: name: [[PLTNAME]] CHECK: type: stub diff --git a/lld/test/elf/gotpcrel.test b/lld/test/elf/gotpcrel.test index a2a87b0fddc0..e6353bde14b2 100644 --- a/lld/test/elf/gotpcrel.test +++ b/lld/test/elf/gotpcrel.test @@ -1,21 +1,21 @@ +# This test checks that GOTPCREL entries are being handled properly RUN: lld -flavor gnu -target x86_64-linux -static -e main -emit-yaml \ RUN: --noinhibit-exec %p/Inputs/gotpcrel.x86-64 \ RUN: | FileCheck %s -check-prefix=YAML -YAML: name: [[NULLGOT:[a-zA-Z0-9_]+]] -YAML: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ] -YAML-NOT: references: - -YAML: name: [[MAINGOT:[a-zA-Z0-9_]+]] -YAML: kind: R_X86_64_64 -YAML: target: main - YAML: name: main YAML: references: YAML: kind: R_X86_64_PC32 YAML: offset: 3 -YAML: target: [[NULLGOT]] +YAML: target: [[NULLGOT:[a-zA-Z0-9_]+]] YAML: kind: R_X86_64_PC32 YAML: offset: 10 -YAML: target: [[MAINGOT]] +YAML: target: [[MAINGOT:[a-zA-Z0-9_]+]] +YAML: name: [[NULLGOT]] +YAML: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ] +YAML-NOT: references: + +YAML: name: [[MAINGOT]] +YAML: kind: R_X86_64_64 +YAML: target: main diff --git a/lld/test/elf/ifunc.test b/lld/test/elf/ifunc.test index e67cfbf79105..1d497a67a409 100644 --- a/lld/test/elf/ifunc.test +++ b/lld/test/elf/ifunc.test @@ -1,3 +1,5 @@ +# This test checks that IRELATIVE relocations are created for symbols that +# need relocation even for static links. RUN: lld -flavor gnu -target x86_64-linux -emit-yaml -r \ RUN: %p/Inputs/ifunc.x86-64 | FileCheck %s @@ -12,12 +14,6 @@ RUN: && llvm-objdump -d -s %t| FileCheck %s --check-prefix=BIN PLT: defined-atoms: -// Make sure there's a got entry with a IRELATIVE relocation. -PLT: type: got -PLT: references: -PLT: kind: R_X86_64_IRELATIVE -PLT: target: hey - PLT: name: plt PLT: scope: global PLT: references: @@ -25,12 +21,19 @@ PLT: kind: R_X86_64_PC32 PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]] PLT: kind: layout-before PLT: target: __hey_1 + PLT: name: main PLT: scope: global PLT: references: PLT: kind: R_X86_64_PC32 PLT: target: [[PLTNAME]] +// Make sure there's a got entry with a IRELATIVE relocation. +PLT: type: got +PLT: references: +PLT: kind: R_X86_64_IRELATIVE +PLT: target: hey + // Make sure the target of main's relocation is a stub with a PC32 relocation. // This relocation is to the got atom, but you can't really write that check in // FileCheck. diff --git a/lld/test/elf/mergeatoms.objtxt b/lld/test/elf/mergeatoms.objtxt index f2aadefaf577..50bce6e23802 100644 --- a/lld/test/elf/mergeatoms.objtxt +++ b/lld/test/elf/mergeatoms.objtxt @@ -1,5 +1,6 @@ +# Tests that atoms are merged by testing it with --merge-strings option RUN: lld -flavor gnu --merge-strings -o %t1 \ RUN: %p/Inputs/foo.o.x86-64 %p/Inputs/bar.o.x86-64 -e bar1 RUN: llvm-objdump -s %t1 | FileCheck -check-prefix=mergeAtoms %s -mergeAtoms: 62617200 666f6f00 bar.foo. +mergeAtoms: 666f6f00 62617200 foo.bar. diff --git a/lld/test/elf/phdr.objtxt b/lld/test/elf/phdr.objtxt index 6d481bb79b39..2b64c99849ab 100644 --- a/lld/test/elf/phdr.objtxt +++ b/lld/test/elf/phdr.objtxt @@ -1,3 +1,4 @@ +# This test checks emission for program header for ELF binaries RUN: lld -flavor gnu -target i386-linux -o %t1 -e main %p/Inputs/phdr.i386 \ RUN: && llvm-readobj -program-headers %t1 | FileCheck -check-prefix=I386 %s RUN: lld -flavor gnu -target x86_64-linux -o %t1 -e _start %p/Inputs/relocs.x86-64 -static \ @@ -62,7 +63,7 @@ I386-NEXT: Offset: 0x4000 I386-NEXT: VirtualAddress: 0x4000 I386-NEXT: PhysicalAddress: 0x4000 I386-NEXT: FileSize: 4 -I386-NEXT: MemSize: 16392 +I386-NEXT: MemSize: 16389 I386-NEXT: Flags [ (0x6) I386-NEXT: PF_R (0x4) I386-NEXT: PF_W (0x2) diff --git a/lld/test/elf/sections.objtxt b/lld/test/elf/sections.objtxt index 784d86108558..a1953d80b942 100644 --- a/lld/test/elf/sections.objtxt +++ b/lld/test/elf/sections.objtxt @@ -1,3 +1,5 @@ +# This test checks if sections are created properly in the output that appear in +# the input RUN: lld -flavor gnu -target i386 -o %t1 %p/Inputs/section-test.i386 \ RUN: -static -e baz RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix=OBJDUMP %s @@ -8,7 +10,7 @@ OBJDUMP: 1 .text 0000000a 0000000000000074 TEXT DATA OBJDUMP: 2 .data 00000004 0000000000001000 DATA OBJDUMP: 3 .special 00000004 0000000000001004 DATA OBJDUMP: 4 .anotherspecial 00000004 0000000000001008 DATA -OBJDUMP: 5 .bss 00000004 000000000000100c BSS +OBJDUMP: 5 .bss 00000001 000000000000100c BSS OBJDUMP: 6 .shstrtab {{[0-9a-f]+}} 0000000000000000 OBJDUMP: 7 .symtab {{[0-9a-f]+}} 0000000000000000 OBJDUMP: 8 .strtab {{[0-9a-f]+}} 0000000000000000 @@ -88,7 +90,7 @@ READOBJ: SHF_ALLOC READOBJ: SHF_WRITE READOBJ: ] READOBJ: Address: 0x100C -READOBJ: Size: 4 +READOBJ: Size: 1 READOBJ: } READOBJ: Section { READOBJ: Index: 6 diff --git a/lld/test/elf/tls.test b/lld/test/elf/tls.test index 722dba193b55..0748fea0b213 100644 --- a/lld/test/elf/tls.test +++ b/lld/test/elf/tls.test @@ -1,3 +1,4 @@ +# This tests verifies that TLS variables have correct offsets RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/tls.x86-64 -static \ RUN: -emit-yaml --noinhibit-exec | FileCheck %s -check-prefix=YAML @@ -6,12 +7,6 @@ RUN: --noinhibit-exec -e main -static && llvm-objdump -d %t | FileCheck %s // Verify that the TLS accesses have the correct offsets. -YAML: defined-atoms: -YAML: type: got -YAML: references: -YAML: kind: R_X86_64_TPOFF64 -YAML: target: tls2 - YAML: name: main YAML: references: YAML: kind: R_X86_64_TPOFF32 @@ -28,6 +23,11 @@ YAML: name: GOTTPOFF YAML: kind: R_X86_64_PC32 YAML: target: [[GOTNAME:[a-zA-Z0-9_]+]] +YAML: type: got +YAML: references: +YAML: kind: R_X86_64_TPOFF64 +YAML: target: tls2 + // main CHECK: addl %fs:-4 diff --git a/lld/test/elf/x86-64-dynamic.test b/lld/test/elf/x86-64-dynamic.test index 5a3b02c74e4f..8d4f0911b2d1 100644 --- a/lld/test/elf/x86-64-dynamic.test +++ b/lld/test/elf/x86-64-dynamic.test @@ -1,32 +1,34 @@ +# Checks that linking an object file with a shared object creates the necessary +# PLT/GOT Entries RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared.x86-64 \ RUN: %p/Inputs/shared.so-x86-64 -emit-yaml -o %t1 --noinhibit-exec RUN: FileCheck %s < %t1 // Don't check the GOT and PLT names as they are only present in assert builds. -CHECK: name: [[GOTNAME:[-a-zA-Z0-9_]+]] -CHECK: type: got -CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ] -CHECK: section-choice: custom-required -CHECK: section-name: .got.dyn -CHECK: permissions: rw- -CHECK: references: -CHECK: - kind: R_X86_64_GLOB_DAT -CHECK: offset: 0 -CHECK: target: i - CHECK: - name: main CHECK: scope: global CHECK: references: CHECK: - kind: R_X86_64_PC32 CHECK: offset: 18 - target: [[PLTNAME:[-a-zA-Z0-9_]+]] +CHECK: target: [[PLTNAME:[-a-zA-Z0-9_]+]] CHECK: addend: -4 CHECK: - kind: R_X86_64_PC32 CHECK: offset: 25 - target: [[GOTNAME]] +CHECK: target: [[GOTNAME:[-a-zA-Z0-9_]+]] CHECK: addend: -4 +CHECK: name: [[GOTNAME]] +CHECK: type: got +CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ] +CHECK: section-choice: custom-required +CHECK: section-name: .got.dyn +CHECK: permissions: rw- +CHECK: references: +CHECK: - kind: R_X86_64_GLOB_DAT +CHECK: offset: 0 +CHECK: target: i + - name: .PLT0 CHECK: type: stub CHECK: content: [ FF, 35, 00, 00, 00, 00, FF, 25, 00, 00, 00, 00, -- GitLab From 7501a81a50fce5c6bb2ac202189a1f72d4493768 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 10 May 2013 16:53:12 +0000 Subject: [PATCH 175/467] Remove unused function. llvm-svn: 181606 --- llvm/lib/Target/Hexagon/HexagonRegisterInfo.cpp | 10 ---------- llvm/lib/Target/Hexagon/HexagonRegisterInfo.h | 1 - 2 files changed, 11 deletions(-) diff --git a/llvm/lib/Target/Hexagon/HexagonRegisterInfo.cpp b/llvm/lib/Target/Hexagon/HexagonRegisterInfo.cpp index d8b4e2fcb368..d59d7d3382f8 100644 --- a/llvm/lib/Target/Hexagon/HexagonRegisterInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonRegisterInfo.cpp @@ -295,16 +295,6 @@ unsigned HexagonRegisterInfo::getStackRegister() const { return Hexagon::R29; } -void HexagonRegisterInfo::getInitialFrameState(std::vector - &Moves) const -{ - // VirtualFP = (R30 + #0). - unsigned FPReg = getFrameRegister(); - MachineLocation Dst(MachineLocation::VirtualFP); - MachineLocation Src(FPReg, 0); - Moves.push_back(MachineMove(0, Dst, Src)); -} - unsigned HexagonRegisterInfo::getEHExceptionRegister() const { llvm_unreachable("What is the exception register"); } diff --git a/llvm/lib/Target/Hexagon/HexagonRegisterInfo.h b/llvm/lib/Target/Hexagon/HexagonRegisterInfo.h index 8a3f94a3fd12..c74155ac3ba8 100644 --- a/llvm/lib/Target/Hexagon/HexagonRegisterInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonRegisterInfo.h @@ -78,7 +78,6 @@ struct HexagonRegisterInfo : public HexagonGenRegisterInfo { unsigned getRARegister() const; unsigned getFrameRegister(const MachineFunction &MF) const; unsigned getFrameRegister() const; - void getInitialFrameState(std::vector &Moves) const; unsigned getStackRegister() const; // Exception handling queries. -- GitLab From 757fbb0b144114810af70ee69972a2bf302873cd Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 10 May 2013 17:07:16 +0000 Subject: [PATCH 176/467] [analyzer] Indirect invalidation counts as an escape for leak checkers. Consider this example: char *p = malloc(sizeof(char)); systemFunction(&p); free(p); In this case, when we call systemFunction, we know (because it's a system function) that it won't free 'p'. However, we /don't/ know whether or not it will /change/ 'p', so the analyzer is forced to invalidate 'p', wiping out any bindings it contains. But now the malloc'd region looks like a leak, since there are no more bindings pointing to it, and we'll get a spurious leak warning. The fix for this is to notice when something is becoming inaccessible due to invalidation (i.e. an imperfect model, as opposed to being explicitly overwritten) and stop tracking it at that point. Currently, the best way to determine this for a call is the "indirect escape" pointer-escape kind. In practice, all the patch does is take the "system functions don't free memory" special case and limit it to direct parameters, i.e. just the arguments to a call and not other regions accessible to them. This is a conservative change that should only cause us to escape regions more eagerly, which means fewer leak warnings. This isn't perfect for several reasons, the main one being that this example is treated the same as the one above: char **p = malloc(sizeof(char *)); systemFunction(p + 1); // leak Currently, "addresses accessible by offsets of the starting region" and "addresses accessible through bindings of the starting region" are both considered "indirect" regions, hence this uniform treatment. Another issue is our longstanding problem of not distinguishing const and non-const bindings; if in the first example systemFunction's parameter were a char * const *, we should know that the function will not overwrite 'p', and thus we can safely report the leak. llvm-svn: 181607 --- .../StaticAnalyzer/Checkers/MallocChecker.cpp | 3 +- .../Checkers/SimpleStreamChecker.cpp | 4 +- .../Analysis/Inputs/system-header-simulator.h | 3 +- clang/test/Analysis/malloc.c | 42 +++++++++++++++---- clang/test/Analysis/simple-stream-checks.c | 4 +- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 5d3eb65148dc..11abe9a41b79 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2012,8 +2012,7 @@ ProgramStateRef MallocChecker::checkPointerEscapeAux(ProgramStateRef State, bool(*CheckRefState)(const RefState*)) const { // If we know that the call does not free memory, or we want to process the // call later, keep tracking the top level arguments. - if ((Kind == PSK_DirectEscapeOnCall || - Kind == PSK_IndirectEscapeOnCall) && + if (Kind == PSK_DirectEscapeOnCall && doesNotFreeMemOrInteresting(Call, State)) { return State; } diff --git a/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp index 1ccf339bacc1..c2786e184b3c 100644 --- a/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -259,9 +259,7 @@ SimpleStreamChecker::checkPointerEscape(ProgramStateRef State, const CallEvent *Call, PointerEscapeKind Kind) const { // If we know that the call cannot close a file, there is nothing to do. - if ((Kind == PSK_DirectEscapeOnCall || - Kind == PSK_IndirectEscapeOnCall) && - guaranteedNotToCloseFile(*Call)) { + if (Kind == PSK_DirectEscapeOnCall && guaranteedNotToCloseFile(*Call)) { return State; } diff --git a/clang/test/Analysis/Inputs/system-header-simulator.h b/clang/test/Analysis/Inputs/system-header-simulator.h index dd1cd4942f85..ef9c1c7e5108 100644 --- a/clang/test/Analysis/Inputs/system-header-simulator.h +++ b/clang/test/Analysis/Inputs/system-header-simulator.h @@ -77,8 +77,9 @@ void xpc_connection_set_context(xpc_connection_t connection, void *context); void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); void xpc_connection_resume(xpc_connection_t connection); -//The following is a fake system header function +//The following are fake system header functions for generic testing. void fakeSystemHeaderCallInt(int *); +void fakeSystemHeaderCallIntPtr(int **); typedef struct __SomeStruct { char * p; diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 6071d1d43582..76f59fda1995 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -1057,12 +1057,6 @@ void testPassConstPointerIndirectly() { return; // expected-warning {{leak}} } -void testPassToSystemHeaderFunctionIndirectly() { - int *p = malloc(4); - p++; - fakeSystemHeaderCallInt(p); -} // expected-warning {{leak}} - void testPassConstPointerIndirectlyStruct() { struct HasPtr hp; hp.p = malloc(10); @@ -1073,8 +1067,32 @@ void testPassConstPointerIndirectlyStruct() { void testPassToSystemHeaderFunctionIndirectlyStruct() { SomeStruct ss; ss.p = malloc(1); - fakeSystemHeaderCall(&ss); -} // expected-warning {{Potential leak of memory pointed to by 'ss.p'}} + fakeSystemHeaderCall(&ss); // invalidates ss, making ss.p unreachable + // Technically a false negative here -- we know the system function won't free + // ss.p, but nothing else will either! +} // no-warning + +void testPassToSystemHeaderFunctionIndirectlyStructFree() { + SomeStruct ss; + ss.p = malloc(1); + fakeSystemHeaderCall(&ss); // invalidates ss, making ss.p unreachable + free(ss.p); +} // no-warning + +void testPassToSystemHeaderFunctionIndirectlyArray() { + int *p[1]; + p[0] = malloc(sizeof(int)); + fakeSystemHeaderCallIntPtr(p); // invalidates p, making p[0] unreachable + // Technically a false negative here -- we know the system function won't free + // p[0], but nothing else will either! +} // no-warning + +void testPassToSystemHeaderFunctionIndirectlyArrayFree() { + int *p[1]; + p[0] = malloc(sizeof(int)); + fakeSystemHeaderCallIntPtr(p); // invalidates p, making p[0] unreachable + free(p[0]); +} // no-warning int *testOffsetAllocate(size_t size) { int *memoryBlock = (int *)malloc(size + sizeof(int)); @@ -1200,3 +1218,11 @@ void testMallocWithParam(int **p) { void testMallocWithParam_2(int **p) { *p = (int*) malloc(sizeof(int)); // no-warning } + +void testPassToSystemHeaderFunctionIndirectly() { + int *p = malloc(4); + p++; + fakeSystemHeaderCallInt(p); + // FIXME: This is a leak: if we think a system function won't free p, it + // won't free (p-1) either. +} diff --git a/clang/test/Analysis/simple-stream-checks.c b/clang/test/Analysis/simple-stream-checks.c index ce57fa7ac34e..2f725745a5ba 100644 --- a/clang/test/Analysis/simple-stream-checks.c +++ b/clang/test/Analysis/simple-stream-checks.c @@ -87,5 +87,5 @@ void testPassConstPointer() { void testPassToSystemHeaderFunctionIndirectly() { FileStruct fs; fs.p = fopen("myfile.txt", "w"); - fakeSystemHeaderCall(&fs); -} // expected-warning {{Opened file is never closed; potential resource leak}} + fakeSystemHeaderCall(&fs); // invalidates fs, making fs.p unreachable +} // no-warning -- GitLab From 72a196a159b28f26f84d9afec8b2baac11d367bc Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 10 May 2013 17:15:51 +0000 Subject: [PATCH 177/467] Better output for long help strings for command-line options. Summary: This patch allows using \n inside long help strings for command-line options, so that all lines are equally indented. This is not a perfect solution, as we don't (and probably don't want to) know about terminal width, but it allows to format long help strings somehow readable without manually padding them with spaces. A motivating example is -help output from clang-format (source code in tools/clang-format/ClangFormat.cpp, see cl options offset, length, style, and dump-config). Reviewers: atrick, alexfh Reviewed By: alexfh CC: llvm-commits, rafael Differential Revision: http://llvm-reviews.chandlerc.com/D779 llvm-svn: 181608 --- llvm/docs/CommandLine.rst | 3 ++- llvm/lib/Support/CommandLine.cpp | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/llvm/docs/CommandLine.rst b/llvm/docs/CommandLine.rst index 9b77a9890826..653555184483 100644 --- a/llvm/docs/CommandLine.rst +++ b/llvm/docs/CommandLine.rst @@ -930,7 +930,8 @@ This section describes the basic attributes that you can specify on options. .. _cl::desc(...): * The **cl::desc** attribute specifies a description for the option to be - shown in the ``-help`` output for the program. + shown in the ``-help`` output for the program. This attribute supports + multi-line descriptions with lines separated by '\n'. .. _cl::value_desc: diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 18d3db527bec..f09705e69a19 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -913,11 +913,20 @@ size_t alias::getOptionWidth() const { return std::strlen(ArgStr)+6; } +static void printHelpStr(StringRef HelpStr, size_t Indent, + size_t FirstLineIndentedBy) { + std::pair Split = HelpStr.split('\n'); + outs().indent(Indent - FirstLineIndentedBy) << " - " << Split.first << "\n"; + while (!Split.second.empty()) { + Split = Split.second.split('\n'); + outs().indent(Indent) << Split.first << "\n"; + } +} + // Print out the option for the alias. void alias::printOptionInfo(size_t GlobalWidth) const { - size_t L = std::strlen(ArgStr); outs() << " -" << ArgStr; - outs().indent(GlobalWidth-L-6) << " - " << HelpStr << "\n"; + printHelpStr(HelpStr, GlobalWidth, std::strlen(ArgStr) + 6); } //===----------------------------------------------------------------------===// @@ -946,7 +955,7 @@ void basic_parser_impl::printOptionInfo(const Option &O, if (const char *ValName = getValueName()) outs() << "=<" << getValueStr(O, ValName) << '>'; - outs().indent(GlobalWidth-getOptionWidth(O)) << " - " << O.HelpStr << '\n'; + printHelpStr(O.HelpStr, GlobalWidth, getOptionWidth(O)); } void basic_parser_impl::printOptionName(const Option &O, @@ -1087,9 +1096,8 @@ size_t generic_parser_base::getOptionWidth(const Option &O) const { void generic_parser_base::printOptionInfo(const Option &O, size_t GlobalWidth) const { if (O.hasArgStr()) { - size_t L = std::strlen(O.ArgStr); outs() << " -" << O.ArgStr; - outs().indent(GlobalWidth-L-6) << " - " << O.HelpStr << '\n'; + printHelpStr(O.HelpStr, GlobalWidth, std::strlen(O.ArgStr) + 6); for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { size_t NumSpaces = GlobalWidth-strlen(getOption(i))-8; @@ -1100,9 +1108,9 @@ void generic_parser_base::printOptionInfo(const Option &O, if (O.HelpStr[0]) outs() << " " << O.HelpStr << '\n'; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { - size_t L = std::strlen(getOption(i)); - outs() << " -" << getOption(i); - outs().indent(GlobalWidth-L-8) << " - " << getDescription(i) << '\n'; + const char *Option = getOption(i); + outs() << " -" << Option; + printHelpStr(getDescription(i), GlobalWidth, std::strlen(Option) + 8); } } } -- GitLab From 29d65744c9290f901cc86a096be942a97a649b61 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Fri, 10 May 2013 17:19:04 +0000 Subject: [PATCH 178/467] Adding support for setting thread stop state when a process stops. This re-submission of this patch fixes a problem where the code sometimes caused a deadlock. The Process::SetPrivateState method was locking the Process::m_private_state variable and then later calling ThreadList::DidStop, which locks the ThreadList mutex. Other methods in ThreadList which were being called from other threads lock the ThreadList mutex and then call Process::GetPrivateState which locks the Process::m_private_state mutex. To avoid deadlocks, Process::SetPrivateState now locks the ThreadList mutex before locking the Process::m_private_state mutex. llvm-svn: 181609 --- lldb/include/lldb/Target/Thread.h | 4 ++++ lldb/include/lldb/Target/ThreadList.h | 3 +++ lldb/source/Target/Process.cpp | 14 ++++++++++++ lldb/source/Target/Thread.cpp | 6 +++++ lldb/source/Target/ThreadList.cpp | 22 +++++++++++++++++++ .../thread/state/TestThreadStates.py | 2 -- 6 files changed, 49 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index e2207a0036c6..fc58a6903b6f 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -277,6 +277,10 @@ public: virtual void DidResume (); + // This notifies the thread when a private stop occurs. + virtual void + DidStop (); + virtual void RefreshStateAfterStop() = 0; diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index 959091c81bfe..ddf49b002ecf 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -119,6 +119,9 @@ public: void DidResume (); + void + DidStop (); + void DiscardThreadPlans(); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 93fd93a71de4..01ee7e482d18 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1699,6 +1699,7 @@ Process::SetPrivateState (StateType new_state) if (log) log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state)); + Mutex::Locker thread_locker(m_thread_list.GetMutex()); Mutex::Locker locker(m_private_state.GetMutex()); const StateType old_state = m_private_state.GetValueNoLock (); @@ -1722,6 +1723,19 @@ Process::SetPrivateState (StateType new_state) m_private_state.SetValueNoLock (new_state); if (StateIsStoppedState(new_state, false)) { + // Note, this currently assumes that all threads in the list + // stop when the process stops. In the future we will want to + // support a debugging model where some threads continue to run + // while others are stopped. When that happens we will either need + // a way for the thread list to identify which threads are stopping + // or create a special thread list containing only threads which + // actually stopped. + // + // The process plugin is responsible for managing the actual + // behavior of the threads and should have stopped any threads + // that are going to stop before we get here. + m_thread_list.DidStop(); + m_mod_id.BumpStopID(); m_memory_cache.Clear(); if (log) diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 646a63511e93..c4aa25446823 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -658,6 +658,12 @@ Thread::DidResume () SetResumeSignal (LLDB_INVALID_SIGNAL_NUMBER); } +void +Thread::DidStop () +{ + SetState (eStateStopped); +} + bool Thread::ShouldStop (Event* event_ptr) { diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index d84a2340cbcc..1f8b351100a6 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -11,6 +11,7 @@ #include #include "lldb/Core/Log.h" +#include "lldb/Core/State.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/ThreadList.h" #include "lldb/Target/Thread.h" @@ -643,6 +644,27 @@ ThreadList::DidResume () } } +void +ThreadList::DidStop () +{ + Mutex::Locker locker(GetMutex()); + collection::iterator pos, end = m_threads.end(); + for (pos = m_threads.begin(); pos != end; ++pos) + { + // Notify threads that the process just stopped. + // Note, this currently assumes that all threads in the list + // stop when the process stops. In the future we will want to support + // a debugging model where some threads continue to run while others + // are stopped. We either need to handle that somehow here or + // create a special thread list containing only threads which will + // stop in the code that calls this method (currently + // Process::SetPrivateState). + ThreadSP thread_sp(*pos); + if (StateIsRunningState(thread_sp->GetState())) + thread_sp->DidStop (); + } +} + ThreadSP ThreadList::GetSelectedThread () { diff --git a/lldb/test/functionalities/thread/state/TestThreadStates.py b/lldb/test/functionalities/thread/state/TestThreadStates.py index 7e59b22aaee6..185eb50106ac 100644 --- a/lldb/test/functionalities/thread/state/TestThreadStates.py +++ b/lldb/test/functionalities/thread/state/TestThreadStates.py @@ -14,14 +14,12 @@ class StopThreadsTestCase(TestBase): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @dsym_test - @unittest2.expectedFailure("PR-15824") # thread states not properly maintained def test_state_after_breakpoint_with_dsym(self): """Test thread state after breakpoint.""" self.buildDsym() self.thread_state_after_breakpoint_test() @dwarf_test - @unittest2.expectedFailure("PR-15824") # thread states not properly maintained def test_state_after_breakpoint_with_dwarf(self): """Test thread state after breakpoint.""" self.buildDwarf() -- GitLab From a9ac51836467036cb5971bb0feef2ef1a42694f1 Mon Sep 17 00:00:00 2001 From: David Dean Date: Fri, 10 May 2013 17:25:57 +0000 Subject: [PATCH 179/467] XFAIL this test when using the darwin12 system library. Reviewed by Howard llvm-svn: 181610 --- .../locale.num.get/facet.num.get.members/get_double.pass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp index 4e0f2b8f94ad..e6ebb9d7a777 100644 --- a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp +++ b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 // -- GitLab From 48d6daf856dd39d8a04863a1d91d09ca7b9da402 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 17:30:13 +0000 Subject: [PATCH 180/467] Allocate memory for the new number of subexpressions. Fixup for r181572 llvm-svn: 181611 --- clang/lib/AST/Expr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 545d5fe28c8a..15cf5ac4ab00 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3568,8 +3568,8 @@ ShuffleVectorExpr::ShuffleVectorExpr(ASTContext &C, ArrayRef args, void ShuffleVectorExpr::setExprs(ASTContext &C, ArrayRef Exprs) { if (SubExprs) C.Deallocate(SubExprs); - SubExprs = new (C) Stmt* [NumExprs]; this->NumExprs = Exprs.size(); + SubExprs = new (C) Stmt*[NumExprs]; memcpy(SubExprs, Exprs.data(), sizeof(Expr *) * Exprs.size()); } -- GitLab From 9449989601041a0698dcc5c11bf2bcaa176e65da Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 10 May 2013 17:36:59 +0000 Subject: [PATCH 181/467] =?UTF-8?q?=C4=B0smail=20D=C3=B6nmez:=20Enable=20q?= =?UTF-8?q?uick=5Fexit=20on=20linux.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llvm-svn: 181612 --- libcxx/include/__config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index dcddae8d1b19..6b8475b7e31a 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -278,7 +278,7 @@ typedef __char32_t char32_t; #define _LIBCPP_HAS_NO_CONSTEXPR #endif -#if defined(__FreeBSD__) && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L) +#if ( defined(__FreeBSD__) || defined(__linux__) ) && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES #endif -- GitLab From d608996610023818fb8ceb8287afa3f634736d37 Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Fri, 10 May 2013 17:53:48 +0000 Subject: [PATCH 182/467] Add temporary fix for calling c++ global/anonymous functions on Linux. llvm-svn: 181613 --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 30 +++++++++++++++++++ .../test/expression_command/test/TestExprs.py | 1 - .../cpp/call-function/TestCallCPPFunction.py | 1 - .../TestOverloadedFunctions.py | 1 - 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index dd34a364c730..d0b1a5ac00d4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3542,8 +3542,38 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, Index (); if (name_type_mask & eFunctionNameTypeFull) + { FindFunctions (name, m_function_fullname_index, sc_list); + // Temporary workaround for global/anonymous namespace functions on linux +#if defined (__linux__) + // If we didn't find any functions in the global namespace try + // looking in the basename index but ignore any returned + // functions that have a namespace (ie. mangled names starting with + // '_ZN') but keep functions which have an anonymous namespace + if (sc_list.GetSize() == 0) + { + SymbolContextList temp_sc_list; + FindFunctions (name, m_function_basename_index, temp_sc_list); + if (!namespace_decl) + { + SymbolContext sc; + for (uint32_t i = 0; i < temp_sc_list.GetSize(); i++) + { + if (temp_sc_list.GetContextAtIndex(i, sc)) + { + ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); + if (!strncmp(name.GetCString(), "_ZN", 3) || + strncmp(name.GetCString(), "(anonymous namespace)", 21)) + { + sc_list.Append(sc); + } + } + } + } + } +#endif + } DIEArray die_offsets; DWARFCompileUnit *dwarf_cu = NULL; diff --git a/lldb/test/expression_command/test/TestExprs.py b/lldb/test/expression_command/test/TestExprs.py index 2c00d58a02b3..422e05e3e2e6 100644 --- a/lldb/test/expression_command/test/TestExprs.py +++ b/lldb/test/expression_command/test/TestExprs.py @@ -80,7 +80,6 @@ class BasicExprCommandsTestCase(TestBase): "a.out"]) # (const char *) $8 = 0x... "/Volumes/data/lldb/svn/trunk/test/expression_command/test/a.out" - @expectedFailureLinux # bugzilla 15854 @python_api_test def test_evaluate_expression_python(self): """Test SBFrame.EvaluateExpression() API for evaluating an expression.""" diff --git a/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py b/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py index 6abe9854ccf2..c573770334d3 100644 --- a/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py +++ b/lldb/test/lang/cpp/call-function/TestCallCPPFunction.py @@ -17,7 +17,6 @@ class CallCPPFunctionTestCase(TestBase): self.buildDsym() self.call_cpp_function() - @expectedFailureLinux # bugzilla 15854 @dwarf_test def test_with_dwarf_and_run_command(self): """Test calling a function by basename""" diff --git a/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py b/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py index 5b45851b6378..634c28c02ed4 100644 --- a/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py +++ b/lldb/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py @@ -17,7 +17,6 @@ class CPPStaticMethodsTestCase(TestBase): self.buildDsym() self.static_method_commands() - @expectedFailureLinux # bugzilla 15854 @dwarf_test def test_with_dwarf_and_run_command(self): """Test that functions with the same name are resolved correctly""" -- GitLab From b3a25fa5801160c75cc00f6fb2aef3a81adb0456 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Fri, 10 May 2013 17:58:41 +0000 Subject: [PATCH 183/467] Fix MCJITCAPITest.cpp unit test on Windows. MCJIT on Windows requires an explicit target triple with "-elf" appended to generate objects in ELF format. The common test framework was setting up this triple, but it wasn't passed to the C API in the test. llvm-svn: 181614 --- llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp index d8cf6c592d3b..07ea1afe1a85 100644 --- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp +++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp @@ -48,6 +48,8 @@ TEST_F(MCJITCAPITest, simple_function) { // Creates a function that returns 42, compiles it, and runs it. LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); + + LLVMSetTarget(module, HostTriple.c_str()); LLVMValueRef function = LLVMAddFunction( module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0)); -- GitLab From 3feb2cd5bbbeeba4a7dba3179ec6f93fc3cbb6c8 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 10 May 2013 18:04:43 +0000 Subject: [PATCH 184/467] [analyzer] Do not check if sys/queue.h file is a system header. In most cases it is, by just looking at the name. Also, this check prevents the heuristic from working in strange user settings. radar://13839692 llvm-svn: 181615 --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 5 ++--- clang/test/Analysis/diagnostics/Inputs/include/sys/queue.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index a397f33c9928..00c92d8153ea 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -1539,12 +1539,11 @@ LikelyFalsePositiveSuppressionBRVisitor::getEndPath(BugReporterContext &BRC, SourceManager &SM = BRC.getSourceManager(); FullSourceLoc Loc = BR.getLocation(SM).asLocation(); while (Loc.isMacroID()) { - if (SM.isInSystemMacro(Loc) && - (SM.getFilename(SM.getSpellingLoc(Loc)).endswith("sys/queue.h"))) { + Loc = Loc.getSpellingLoc(); + if (SM.getFilename(Loc).endswith("sys/queue.h")) { BR.markInvalid(getTag(), 0); return 0; } - Loc = Loc.getSpellingLoc(); } return 0; diff --git a/clang/test/Analysis/diagnostics/Inputs/include/sys/queue.h b/clang/test/Analysis/diagnostics/Inputs/include/sys/queue.h index e5698ed443b7..2740e174f257 100644 --- a/clang/test/Analysis/diagnostics/Inputs/include/sys/queue.h +++ b/clang/test/Analysis/diagnostics/Inputs/include/sys/queue.h @@ -1,4 +1,3 @@ -#pragma clang system_header void free(void *); #define FREE_POINTER(x) free(x) -- GitLab From 4063fa1cdc0782c5d90c2c0a5bc05036d9587915 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 10 May 2013 18:04:46 +0000 Subject: [PATCH 185/467] [analyzer] Assume [NSNull null] does not return nil. llvm-svn: 181616 --- .../Checkers/BasicObjCFoundationChecks.cpp | 15 ++++++++++++++- clang/test/Analysis/NSContainers.m | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index fba14a0fc498..6388a8df6487 100644 --- a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -58,6 +58,7 @@ enum FoundationClass { FC_NSArray, FC_NSDictionary, FC_NSEnumerator, + FC_NSNull, FC_NSOrderedSet, FC_NSSet, FC_NSString @@ -69,6 +70,7 @@ static FoundationClass findKnownClass(const ObjCInterfaceDecl *ID) { Classes["NSArray"] = FC_NSArray; Classes["NSDictionary"] = FC_NSDictionary; Classes["NSEnumerator"] = FC_NSEnumerator; + Classes["NSNull"] = FC_NSNull; Classes["NSOrderedSet"] = FC_NSOrderedSet; Classes["NSSet"] = FC_NSSet; Classes["NSString"] = FC_NSString; @@ -845,6 +847,7 @@ class ObjCNonNilReturnValueChecker mutable bool Initialized; mutable Selector ObjectAtIndex; mutable Selector ObjectAtIndexedSubscript; + mutable Selector NullSelector; public: ObjCNonNilReturnValueChecker() : Initialized(false) {} @@ -870,6 +873,7 @@ void ObjCNonNilReturnValueChecker::checkPostObjCMessage(const ObjCMethodCall &M, ASTContext &Ctx = C.getASTContext(); ObjectAtIndex = GetUnarySelector("objectAtIndex", Ctx); ObjectAtIndexedSubscript = GetUnarySelector("objectAtIndexedSubscript", Ctx); + NullSelector = GetNullarySelector("null", Ctx); } // Check the receiver type. @@ -889,10 +893,11 @@ void ObjCNonNilReturnValueChecker::checkPostObjCMessage(const ObjCMethodCall &M, State = assumeExprIsNonNull(M.getOriginExpr(), State, C); } + FoundationClass Cl = findKnownClass(Interface); + // Objects returned from // [NSArray|NSOrderedSet]::[ObjectAtIndex|ObjectAtIndexedSubscript] // are never 'nil'. - FoundationClass Cl = findKnownClass(Interface); if (Cl == FC_NSArray || Cl == FC_NSOrderedSet) { Selector Sel = M.getSelector(); if (Sel == ObjectAtIndex || Sel == ObjectAtIndexedSubscript) { @@ -900,6 +905,14 @@ void ObjCNonNilReturnValueChecker::checkPostObjCMessage(const ObjCMethodCall &M, State = assumeExprIsNonNull(M.getOriginExpr(), State, C); } } + + // Objects returned from [NSNull null] are not nil. + if (Cl == FC_NSNull) { + if (M.getSelector() == NullSelector) { + // Go ahead and assume the value is non-nil. + State = assumeExprIsNonNull(M.getOriginExpr(), State, C); + } + } } C.addTransition(State); } diff --git a/clang/test/Analysis/NSContainers.m b/clang/test/Analysis/NSContainers.m index 540c7a4eabdd..6b4089b3e529 100644 --- a/clang/test/Analysis/NSContainers.m +++ b/clang/test/Analysis/NSContainers.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NilArg -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg -verify -Wno-objc-root-class %s typedef unsigned long NSUInteger; typedef signed char BOOL; typedef struct _NSZone NSZone; @@ -81,6 +81,10 @@ typedef struct _NSZone NSZone; @end +@interface NSNull : NSObject ++ (NSNull *)null; +@end + // NSMutableArray API void testNilArgNSMutableArray1() { NSMutableArray *marray = [[NSMutableArray alloc] init]; @@ -197,4 +201,13 @@ void testNilReceiverRetNil2(NSMutableDictionary *D, Foo *FooPtrIn, id value) { [D setObject: value forKey: key]; // no-warning } +void testAssumeNSNullNullReturnsNonNil(NSMutableDictionary *Table, id Object, + id InValue) { + id Value = Object ? [Table objectForKey:Object] : [NSNull null]; + if (!Value) { + Value = InValue; + [Table setObject:Value forKey:Object]; // no warning + } +} + -- GitLab From 88a0d939ded5cfdff221468887bd1da089ceb0fe Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 10 May 2013 18:12:00 +0000 Subject: [PATCH 186/467] Reformat clang-format help strings, filter out irrelevant options. Summary: +updated ClangFormat.rst Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D780 llvm-svn: 181617 --- clang/docs/ClangFormat.rst | 46 ++++++++++---- clang/tools/clang-format/ClangFormat.cpp | 79 ++++++++++++++++-------- 2 files changed, 86 insertions(+), 39 deletions(-) diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst index 964fc84d7bca..a9687bc9e4e5 100644 --- a/clang/docs/ClangFormat.rst +++ b/clang/docs/ClangFormat.rst @@ -20,21 +20,43 @@ to format C/C++/Obj-C code. If no arguments are specified, it formats the code from standard input and writes the result to the standard output. - If is given, it reformats the file. If -i is specified together - with , the file is edited in-place. Otherwise, the result is - written to the standard output. + If s are given, it reformats the files. If -i is specified + together with s, the files are edited in-place. Otherwise, the + result is written to the standard output. - USAGE: clang-format [options] [] + USAGE: clang-format [options] [ ...] OPTIONS: - -fatal-assembler-warnings - Consider warnings as error - -help - Display available options (-help-hidden for more) - -i - Inplace edit , if specified. - -length= - Format a range of this length, -1 for end of file. - -offset= - Format a range starting at this file offset. - -stats - Enable statistics output from program - -style= - Coding style, currently supports: LLVM, Google, Chromium. - -version - Display the version of this program + + Clang-format options: + + -dump-config - Dump configuration options to stdout and exit. + Can be used with -style option. + -i - Inplace edit s, if specified. + -length= - Format a range of this length (in bytes). + Multiple ranges can be formatted by specifying + several -offset and -length pairs. + When only a single -offset is specified without + -length, clang-format will format up to the end + of the file. + Can only be used with one input file. + -offset= - Format a range starting at this byte offset. + Multiple ranges can be formatted by specifying + several -offset and -length pairs. + Can only be used with one input file. + -output-replacements-xml - Output replacements as XML. + -style= - Coding style, currently supports: + LLVM, Google, Chromium, Mozilla. + Use '-style file' to load style configuration from + .clang-format file located in one of the parent + directories of the source file (or current + directory for stdin). + + General options: + + -help - Display available options (-help-hidden for more) + -help-list - Display list of available options (-help-list-hidden for more) + -version - Display the version of this program Vim Integration diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index ea70dafe0398..f779348f0fcc 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -23,43 +23,57 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Signals.h" +#include "llvm/ADT/StringMap.h" using namespace llvm; static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); -static cl::list Offsets( - "offset", - cl::desc( - "Format a range starting at this byte offset. Multiple ranges can be " - "formatted by specifying several -offset and -length pairs. Can " - "only be used with one input file.")); -static cl::list Lengths( - "length", - cl::desc("Format a range of this length (in bytes). Multiple ranges can be " - "formatted by specifying several -offset and -length pairs. When " - "only a single -offset is specified without -length, clang-format " - "will format up to the end of the file. Can only be used with one " - "input file.")); -static cl::opt Style( - "style", - cl::desc( - "Coding style, currently supports: LLVM, Google, Chromium, Mozilla. " - "Use '-style file' to load style configuration from .clang-format file " - "located in one of the parent directories of the source file (or " - "current directory for stdin)."), - cl::init("LLVM")); +// Mark all our options with this category, everything else (except for -version +// and -help) will be hidden. +cl::OptionCategory ClangFormatCategory("Clang-format options"); + +static cl::list + Offsets("offset", + cl::desc("Format a range starting at this byte offset.\n" + "Multiple ranges can be formatted by specifying\n" + "several -offset and -length pairs.\n" + "Can only be used with one input file."), + cl::cat(ClangFormatCategory)); +static cl::list + Lengths("length", + cl::desc("Format a range of this length (in bytes).\n" + "Multiple ranges can be formatted by specifying\n" + "several -offset and -length pairs.\n" + "When only a single -offset is specified without\n" + "-length, clang-format will format up to the end\n" + "of the file.\n" + "Can only be used with one input file."), + cl::cat(ClangFormatCategory)); +static cl::opt + Style("style", + cl::desc("Coding style, currently supports:\n" + " LLVM, Google, Chromium, Mozilla.\n" + "Use '-style file' to load style configuration from\n" + ".clang-format file located in one of the parent\n" + "directories of the source file (or current\n" + "directory for stdin)."), + cl::init("LLVM"), cl::cat(ClangFormatCategory)); static cl::opt Inplace("i", - cl::desc("Inplace edit s, if specified.")); + cl::desc("Inplace edit s, if specified."), + cl::cat(ClangFormatCategory)); -static cl::opt OutputXML( - "output-replacements-xml", cl::desc("Output replacements as XML.")); +static cl::opt OutputXML("output-replacements-xml", + cl::desc("Output replacements as XML."), + cl::cat(ClangFormatCategory)); static cl::opt DumpConfig("dump-config", - cl::desc("Dump configuration options to stdout and exit. Can be used with -style option.")); + cl::desc("Dump configuration options to stdout and exit.\n" + "Can be used with -style option."), + cl::cat(ClangFormatCategory)); -static cl::list FileNames(cl::Positional, - cl::desc("[ ...]")); +static cl::list FileNames(cl::Positional, cl::desc("[ ...]"), + cl::cat(ClangFormatCategory)); namespace clang { namespace format { @@ -196,6 +210,17 @@ static bool format(std::string FileName) { int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(); + + // Hide unrelated options. + StringMap Options; + cl::getRegisteredOptions(Options); + for (StringMap::iterator I = Options.begin(), E = Options.end(); + I != E; ++I) { + if (I->second->Category != &ClangFormatCategory && I->first() != "help" && + I->first() != "version") + I->second->setHiddenFlag(cl::ReallyHidden); + } + cl::ParseCommandLineOptions( argc, argv, "A tool to format C/C++/Obj-C code.\n\n" -- GitLab From 140a837acd3651032d8160ccfda1e5ccbe8eb14e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 10 May 2013 18:16:59 +0000 Subject: [PATCH 187/467] Remove unused argument. llvm-svn: 181618 --- llvm/include/llvm/Support/TargetRegistry.h | 9 ++++----- .../Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp | 2 +- llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp | 2 +- .../lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp | 2 +- llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.h | 4 +--- .../Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp | 4 ++-- .../Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp | 2 +- llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp | 2 +- llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.h | 3 +-- llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp | 2 +- llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h | 3 +-- llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp | 4 ++-- llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp | 2 +- llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h | 2 +- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp | 2 +- llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp | 2 +- llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h | 3 +-- .../lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp | 2 +- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h | 3 +-- .../Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp | 4 ++-- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp | 2 +- llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.cpp | 2 +- llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.h | 2 +- llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp | 4 ++-- 24 files changed, 31 insertions(+), 38 deletions(-) diff --git a/llvm/include/llvm/Support/TargetRegistry.h b/llvm/include/llvm/Support/TargetRegistry.h index b06676d4d2f5..5bfb8ad41d43 100644 --- a/llvm/include/llvm/Support/TargetRegistry.h +++ b/llvm/include/llvm/Support/TargetRegistry.h @@ -70,8 +70,7 @@ namespace llvm { typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT); - typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const Target &T, - StringRef TT); + typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(StringRef TT); typedef MCCodeGenInfo *(*MCCodeGenInfoCtorFnTy)(StringRef TT, Reloc::Model RM, CodeModel::Model CM, @@ -269,7 +268,7 @@ namespace llvm { MCAsmInfo *createMCAsmInfo(StringRef Triple) const { if (!MCAsmInfoCtorFn) return 0; - return MCAsmInfoCtorFn(*this, Triple); + return MCAsmInfoCtorFn(Triple); } /// createMCCodeGenInfo - Create a MCCodeGenInfo implementation. @@ -804,8 +803,8 @@ namespace llvm { TargetRegistry::RegisterMCAsmInfo(T, &Allocator); } private: - static MCAsmInfo *Allocator(const Target &T, StringRef TT) { - return new MCAsmInfoImpl(T, TT); + static MCAsmInfo *Allocator(StringRef TT) { + return new MCAsmInfoImpl(TT); } }; diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp index 819eeadb44e4..3435217bb24f 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -57,7 +57,7 @@ static MCRegisterInfo *createAArch64MCRegisterInfo(StringRef Triple) { return X; } -static MCAsmInfo *createAArch64MCAsmInfo(const Target &T, StringRef TT) { +static MCAsmInfo *createAArch64MCAsmInfo(StringRef TT) { Triple TheTriple(TT); MCAsmInfo *MAI = new AArch64ELFMCAsmInfo(); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index f09fb5a94fd8..57239f801163 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -159,7 +159,7 @@ static MCRegisterInfo *createARMMCRegisterInfo(StringRef Triple) { return X; } -static MCAsmInfo *createARMMCAsmInfo(const Target &T, StringRef TT) { +static MCAsmInfo *createARMMCAsmInfo(StringRef TT) { Triple TheTriple(TT); if (TheTriple.isOSDarwin()) diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp index 3deb8d1deb42..495dbb97b028 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp @@ -15,7 +15,7 @@ using namespace llvm; -HexagonMCAsmInfo::HexagonMCAsmInfo(const Target &T, StringRef TT) { +HexagonMCAsmInfo::HexagonMCAsmInfo(StringRef TT) { Data16bitsDirective = "\t.half\t"; Data32bitsDirective = "\t.word\t"; Data64bitsDirective = 0; // .xword is only supported by V9. diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.h b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.h index d336cd5be917..0b94d2141c0c 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.h +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.h @@ -18,11 +18,9 @@ #include "llvm/MC/MCAsmInfo.h" namespace llvm { - class Target; - class HexagonMCAsmInfo : public MCAsmInfo { public: - explicit HexagonMCAsmInfo(const Target &T, StringRef TT); + explicit HexagonMCAsmInfo(StringRef TT); }; } // namespace llvm diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index 6b1d2d161958..273bc22b8ebe 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -54,8 +54,8 @@ static MCSubtargetInfo *createHexagonMCSubtargetInfo(StringRef TT, return X; } -static MCAsmInfo *createHexagonMCAsmInfo(const Target &T, StringRef TT) { - MCAsmInfo *MAI = new HexagonMCAsmInfo(T, TT); +static MCAsmInfo *createHexagonMCAsmInfo(StringRef TT) { + MCAsmInfo *MAI = new HexagonMCAsmInfo(TT); // VirtualFP = (R30 + #0). MachineLocation Dst(MachineLocation::VirtualFP); diff --git a/llvm/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp b/llvm/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp index 380750d50f4c..ec76dba49136 100644 --- a/llvm/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp +++ b/llvm/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp @@ -53,7 +53,7 @@ static MCSubtargetInfo *createMBlazeMCSubtargetInfo(StringRef TT, StringRef CPU, return X; } -static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { +static MCAsmInfo *createMCAsmInfo(StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { default: diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp index 3c9576056946..d213a45bb9f2 100644 --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp @@ -17,7 +17,7 @@ using namespace llvm; void MSP430MCAsmInfo::anchor() { } -MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, StringRef TT) { +MSP430MCAsmInfo::MSP430MCAsmInfo(StringRef TT) { PointerSize = CalleeSaveStackSlotSize = 2; PrivateGlobalPrefix = ".L"; diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.h b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.h index e5c2fc283b17..feb040d13b90 100644 --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.h +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.h @@ -18,12 +18,11 @@ namespace llvm { class StringRef; - class Target; class MSP430MCAsmInfo : public MCAsmInfo { virtual void anchor(); public: - explicit MSP430MCAsmInfo(const Target &T, StringRef TT); + explicit MSP430MCAsmInfo(StringRef TT); }; } // namespace llvm diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp index 5d4b32d30578..33f6f9620ecd 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp @@ -18,7 +18,7 @@ using namespace llvm; void MipsMCAsmInfo::anchor() { } -MipsMCAsmInfo::MipsMCAsmInfo(const Target &T, StringRef TT) { +MipsMCAsmInfo::MipsMCAsmInfo(StringRef TT) { Triple TheTriple(TT); if ((TheTriple.getArch() == Triple::mips) || (TheTriple.getArch() == Triple::mips64)) diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h index e1d878936f31..772234eb718a 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h @@ -18,12 +18,11 @@ namespace llvm { class StringRef; - class Target; class MipsMCAsmInfo : public MCAsmInfo { virtual void anchor(); public: - explicit MipsMCAsmInfo(const Target &T, StringRef TT); + explicit MipsMCAsmInfo(StringRef TT); }; } // namespace llvm diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp index be83b54b6124..26694ffdac0c 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -93,8 +93,8 @@ static MCSubtargetInfo *createMipsMCSubtargetInfo(StringRef TT, StringRef CPU, return X; } -static MCAsmInfo *createMipsMCAsmInfo(const Target &T, StringRef TT) { - MCAsmInfo *MAI = new MipsMCAsmInfo(T, TT); +static MCAsmInfo *createMipsMCAsmInfo(StringRef TT) { + MCAsmInfo *MAI = new MipsMCAsmInfo(TT); MachineLocation Dst(MachineLocation::VirtualFP); MachineLocation Src(Mips::SP, 0); diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp index 459cd96cb0cd..fa33a75c61b0 100644 --- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp +++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp @@ -27,7 +27,7 @@ Debug("debug-compile", cl::desc("Compile for debugging"), cl::Hidden, void NVPTXMCAsmInfo::anchor() {} -NVPTXMCAsmInfo::NVPTXMCAsmInfo(const Target &T, const StringRef &TT) { +NVPTXMCAsmInfo::NVPTXMCAsmInfo(const StringRef &TT) { Triple TheTriple(TT); if (TheTriple.getArch() == Triple::nvptx64) { PointerSize = CalleeSaveStackSlotSize = 8; diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h index 82097daa4ae5..7d1633f60d2c 100644 --- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h +++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h @@ -23,7 +23,7 @@ class StringRef; class NVPTXMCAsmInfo : public MCAsmInfo { virtual void anchor(); public: - explicit NVPTXMCAsmInfo(const Target &T, const StringRef &TT); + explicit NVPTXMCAsmInfo(const StringRef &TT); }; } // namespace llvm diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp index 2209f936ec33..a01fa44a9a47 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -58,7 +58,7 @@ static MCSubtargetInfo *createPPCMCSubtargetInfo(StringRef TT, StringRef CPU, return X; } -static MCAsmInfo *createPPCMCAsmInfo(const Target &T, StringRef TT) { +static MCAsmInfo *createPPCMCAsmInfo(StringRef TT) { Triple TheTriple(TT); bool isPPC64 = TheTriple.getArch() == Triple::ppc64; diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp index 3d4bfdcd5e6d..5a52abee03a4 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp @@ -18,7 +18,7 @@ using namespace llvm; void SparcELFMCAsmInfo::anchor() { } -SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, StringRef TT) { +SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) { IsLittleEndian = false; Triple TheTriple(TT); if (TheTriple.getArch() == Triple::sparcv9) { diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h index f0e1354c212b..621e8ffadfaf 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h @@ -18,12 +18,11 @@ namespace llvm { class StringRef; - class Target; class SparcELFMCAsmInfo : public MCAsmInfo { virtual void anchor(); public: - explicit SparcELFMCAsmInfo(const Target &T, StringRef TT); + explicit SparcELFMCAsmInfo(StringRef TT); }; } // namespace llvm diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp index c96a0d4c67d5..9e27aa004a92 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp @@ -13,7 +13,7 @@ using namespace llvm; -SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, StringRef TT) { +SystemZMCAsmInfo::SystemZMCAsmInfo(StringRef TT) { PointerSize = 8; CalleeSaveStackSlotSize = 8; IsLittleEndian = false; diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h index bac1bca38128..d440787de548 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h @@ -14,12 +14,11 @@ #include "llvm/Support/Compiler.h" namespace llvm { -class Target; class StringRef; class SystemZMCAsmInfo : public MCAsmInfo { public: - explicit SystemZMCAsmInfo(const Target &T, StringRef TT); + explicit SystemZMCAsmInfo(StringRef TT); // Override MCAsmInfo; virtual const MCSection *getNonexecutableStackSection(MCContext &Ctx) const diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp index 49a7f47e7d5f..6844f92ec987 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -27,8 +27,8 @@ using namespace llvm; -static MCAsmInfo *createSystemZMCAsmInfo(const Target &T, StringRef TT) { - MCAsmInfo *MAI = new SystemZMCAsmInfo(T, TT); +static MCAsmInfo *createSystemZMCAsmInfo(StringRef TT) { + MCAsmInfo *MAI = new SystemZMCAsmInfo(TT); MachineLocation FPDst(MachineLocation::VirtualFP); MachineLocation FPSrc(SystemZ::R15D, -SystemZMC::CFAOffsetFromInitialSP); MAI->addInitialFrameState(0, FPDst, FPSrc); diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index 5e84530cd729..226ebca8cb42 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -263,7 +263,7 @@ static MCRegisterInfo *createX86MCRegisterInfo(StringRef TT) { return X; } -static MCAsmInfo *createX86MCAsmInfo(const Target &T, StringRef TT) { +static MCAsmInfo *createX86MCAsmInfo(StringRef TT) { Triple TheTriple(TT); bool is64Bit = TheTriple.getArch() == Triple::x86_64; diff --git a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.cpp b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.cpp index 1cfdbda003b5..6f4455117a0c 100644 --- a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.cpp +++ b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.cpp @@ -13,7 +13,7 @@ using namespace llvm; void XCoreMCAsmInfo::anchor() { } -XCoreMCAsmInfo::XCoreMCAsmInfo(const Target &T, StringRef TT) { +XCoreMCAsmInfo::XCoreMCAsmInfo(StringRef TT) { SupportsDebugInformation = true; Data16bitsDirective = "\t.short\t"; Data32bitsDirective = "\t.long\t"; diff --git a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.h b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.h index 076777541e33..b5a9660d5fb2 100644 --- a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.h +++ b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCAsmInfo.h @@ -23,7 +23,7 @@ namespace llvm { class XCoreMCAsmInfo : public MCAsmInfo { virtual void anchor(); public: - explicit XCoreMCAsmInfo(const Target &T, StringRef TT); + explicit XCoreMCAsmInfo(StringRef TT); }; } // namespace llvm diff --git a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp index c1773653f5fb..e38da34a81da 100644 --- a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -51,8 +51,8 @@ static MCSubtargetInfo *createXCoreMCSubtargetInfo(StringRef TT, StringRef CPU, return X; } -static MCAsmInfo *createXCoreMCAsmInfo(const Target &T, StringRef TT) { - MCAsmInfo *MAI = new XCoreMCAsmInfo(T, TT); +static MCAsmInfo *createXCoreMCAsmInfo(StringRef TT) { + MCAsmInfo *MAI = new XCoreMCAsmInfo(TT); // Initial state of the frame pointer is SP. MachineLocation Dst(MachineLocation::VirtualFP); -- GitLab From c8569cba93b9f25c5d3bfa3e24ba926ca65c2910 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 10 May 2013 18:24:17 +0000 Subject: [PATCH 188/467] [ms-inline asm] Fix a crasher when we fail on a direct match. The issue was that the MatchingInlineAsm and VariantID args to the MatchInstructionImpl function weren't being set properly. Specifically, when parsing intel syntax, the parser thought it was parsing inline assembly in the at&t dialect; that will never be the case. The crash was caused when the emitter tried to emit the instruction, but the operands weren't set. When parsing inline assembly we only set the opcode, not the operands, which is used to lookup the instruction descriptor. rdar://13854391 and PR15945 Also, this commit reverts r176036. Now that we're correctly parsing the intel syntax the pushad/popad don't match properly. I've reimplemented that fix using a MnemonicAlias. llvm-svn: 181620 --- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 8 ++++---- llvm/lib/Target/X86/X86InstrInfo.td | 7 +++++-- llvm/test/MC/X86/x86_errors.s | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 520c4c0048e2..019a6700837f 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -2308,25 +2308,25 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, unsigned Match1, Match2, Match3, Match4; Match1 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore, - isParsingIntelSyntax()); + MatchingInlineAsm, isParsingIntelSyntax()); // If this returned as a missing feature failure, remember that. if (Match1 == Match_MissingFeature) ErrorInfoMissingFeature = ErrorInfoIgnore; Tmp[Base.size()] = Suffixes[1]; Match2 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore, - isParsingIntelSyntax()); + MatchingInlineAsm, isParsingIntelSyntax()); // If this returned as a missing feature failure, remember that. if (Match2 == Match_MissingFeature) ErrorInfoMissingFeature = ErrorInfoIgnore; Tmp[Base.size()] = Suffixes[2]; Match3 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore, - isParsingIntelSyntax()); + MatchingInlineAsm, isParsingIntelSyntax()); // If this returned as a missing feature failure, remember that. if (Match3 == Match_MissingFeature) ErrorInfoMissingFeature = ErrorInfoIgnore; Tmp[Base.size()] = Suffixes[3]; Match4 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore, - isParsingIntelSyntax()); + MatchingInlineAsm, isParsingIntelSyntax()); // If this returned as a missing feature failure, remember that. if (Match4 == Match_MissingFeature) ErrorInfoMissingFeature = ErrorInfoIgnore; diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td index 3380d8c64ea7..ad26bce01bad 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -884,12 +884,12 @@ def PUSHF64 : I<0x9C, RawFrm, (outs), (ins), "pushfq", [], IIC_PUSH_F>, let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP], mayLoad = 1, neverHasSideEffects = 1, SchedRW = [WriteLoad] in { -def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l|d}", [], IIC_POP_A>, +def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", [], IIC_POP_A>, Requires<[In32BitMode]>; } let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], mayStore = 1, neverHasSideEffects = 1, SchedRW = [WriteStore] in { -def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l|d}", [], IIC_PUSH_A>, +def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", [], IIC_PUSH_A>, Requires<[In32BitMode]>; } @@ -1867,6 +1867,9 @@ def : MnemonicAlias<"pushf", "pushfl", "att">, Requires<[In32BitMode]>; def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>; def : MnemonicAlias<"pushfd", "pushfl", "att">; +def : MnemonicAlias<"popad", "popa", "intel">, Requires<[In32BitMode]>; +def : MnemonicAlias<"pushad", "pusha", "intel">, Requires<[In32BitMode]>; + def : MnemonicAlias<"repe", "rep", "att">; def : MnemonicAlias<"repz", "rep", "att">; def : MnemonicAlias<"repnz", "repne", "att">; diff --git a/llvm/test/MC/X86/x86_errors.s b/llvm/test/MC/X86/x86_errors.s index 6e14d62fda4c..a974233d2f49 100644 --- a/llvm/test/MC/X86/x86_errors.s +++ b/llvm/test/MC/X86/x86_errors.s @@ -28,3 +28,6 @@ lea (%rsp, %rbp, $4), %rax // rdar://10423777 // 64: error: index register is 32-bit, but base register is 64-bit movq (%rsi,%ecx),%xmm0 + +// 32: error: invalid operand for instruction +outb al, 4 -- GitLab From 86067ad6a9798918d8061c8b6f4d226b77bcd543 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 10 May 2013 18:31:42 +0000 Subject: [PATCH 189/467] Fix the R600 build. llvm-svn: 181621 --- llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp | 2 +- llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp b/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp index 2aae26aa12dc..f1c44df975e0 100644 --- a/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp +++ b/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp @@ -11,7 +11,7 @@ #include "AMDGPUMCAsmInfo.h" using namespace llvm; -AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Target &T, StringRef &TT) : MCAsmInfo() { +AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(StringRef &TT) : MCAsmInfo() { HasSingleParameterDotFile = false; WeakDefDirective = 0; //===------------------------------------------------------------------===// diff --git a/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.h b/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.h index 3ad0fa6824ab..485167b3da24 100644 --- a/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.h +++ b/llvm/lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.h @@ -17,12 +17,11 @@ #include "llvm/MC/MCAsmInfo.h" namespace llvm { -class Target; class StringRef; class AMDGPUMCAsmInfo : public MCAsmInfo { public: - explicit AMDGPUMCAsmInfo(const Target &T, StringRef &TT); + explicit AMDGPUMCAsmInfo(StringRef &TT); const char* getDataASDirective(unsigned int Size, unsigned int AS) const; const MCSection* getNonexecutableStackSection(MCContext &CTX) const; }; -- GitLab From bd525a3f63040f84886d7651e34fe731dc420783 Mon Sep 17 00:00:00 2001 From: Shankar Easwaran Date: Fri, 10 May 2013 18:52:29 +0000 Subject: [PATCH 190/467] [lld][ELF] set ordinals for mergeAtoms and fix testcase llvm-svn: 181622 --- lld/lib/ReaderWriter/ELF/Atoms.h | 2 ++ lld/lib/ReaderWriter/ELF/File.h | 13 +++++++------ lld/test/elf/mergeatoms.objtxt | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/Atoms.h b/lld/lib/ReaderWriter/ELF/Atoms.h index a5d2dfc4c0c6..d40227f80a6b 100644 --- a/lld/lib/ReaderWriter/ELF/Atoms.h +++ b/lld/lib/ReaderWriter/ELF/Atoms.h @@ -520,6 +520,8 @@ public: virtual uint64_t offset() const { return _offset; } + void setOrdinal(uint64_t ord) { _ordinal = ord; } + virtual uint64_t ordinal() const { return _ordinal; } virtual uint64_t size() const { return _contentData.size(); } diff --git a/lld/lib/ReaderWriter/ELF/File.h b/lld/lib/ReaderWriter/ELF/File.h index 545f547bb35c..581fe907453b 100644 --- a/lld/lib/ReaderWriter/ELF/File.h +++ b/lld/lib/ReaderWriter/ELF/File.h @@ -122,7 +122,7 @@ public: ELFFile(const ELFTargetInfo &ti, std::unique_ptr MB, llvm::error_code &EC) : File(MB->getBufferIdentifier(), kindObject), _elfTargetInfo(ti), - _doStringsMerge(false) { + _ordinal(0), _doStringsMerge(false) { llvm::OwningPtr binaryFile; EC = createBinary(MB.release(), binaryFile); if (EC) @@ -261,6 +261,7 @@ public: const MergeSectionKey mergedSectionKey(tai->_shdr, tai->_offset); if (_mergedSectionMap.find(mergedSectionKey) == _mergedSectionMap.end()) _mergedSectionMap.insert(std::make_pair(mergedSectionKey, mergeAtom)); + mergeAtom->setOrdinal(++_ordinal); _definedAtoms._atoms.push_back(mergeAtom); _mergeAtoms.push_back(mergeAtom); } @@ -332,8 +333,6 @@ public: /// \brief Create individual atoms bool createAtoms(llvm::error_code &EC) { - int64_t ordinal = 0; - // Cached value of the targetHandler TargetHandler &targetHandler = _elfTargetInfo.template getTargetHandler(); @@ -368,7 +367,7 @@ public: sectionContents.size()); auto newAtom = new (_readerStorage) ELFDefinedAtom( *this, "", sectionName, sym, i.first, content, 0, 0, _references); - newAtom->setOrdinal(++ordinal); + newAtom->setOrdinal(++_ordinal); _definedAtoms._atoms.push_back(newAtom); continue; } @@ -441,7 +440,7 @@ public: ArrayRef( (uint8_t *)sectionContents.data() + (*si)->st_value, contentSize)); - anonAtom->setOrdinal(++ordinal); + anonAtom->setOrdinal(++_ordinal); // If this is the last atom, lets not create a followon // reference @@ -479,7 +478,7 @@ public: auto newAtom = createDefinedAtomAndAssignRelocations( symbolName, sectionName, *si, i.first, symbolData); - newAtom->setOrdinal(++ordinal); + newAtom->setOrdinal(++_ordinal); // If the atom was a weak symbol, lets create a followon // reference to the anonymous atom that we created @@ -720,6 +719,8 @@ private: /// \brief Sections that have merge string property std::vector _mergeStringSections; + int64_t _ordinal; + /// \brief the cached options relevant while reading the ELF File bool _doStringsMerge : 1; }; diff --git a/lld/test/elf/mergeatoms.objtxt b/lld/test/elf/mergeatoms.objtxt index 50bce6e23802..8a29b65c815c 100644 --- a/lld/test/elf/mergeatoms.objtxt +++ b/lld/test/elf/mergeatoms.objtxt @@ -3,4 +3,4 @@ RUN: lld -flavor gnu --merge-strings -o %t1 \ RUN: %p/Inputs/foo.o.x86-64 %p/Inputs/bar.o.x86-64 -e bar1 RUN: llvm-objdump -s %t1 | FileCheck -check-prefix=mergeAtoms %s -mergeAtoms: 666f6f00 62617200 foo.bar. +mergeAtoms: 62617200 666f6f00 bar.foo. -- GitLab From 300f0b966cdf8848535437fb3d2f844b93bd8547 Mon Sep 17 00:00:00 2001 From: Jyotsna Verma Date: Fri, 10 May 2013 20:27:34 +0000 Subject: [PATCH 191/467] Hexagon: Fix switch cases in HexagonVLIWPacketizer.cpp. llvm-svn: 181624 --- llvm/lib/Target/Hexagon/Hexagon.td | 6 +- .../Target/Hexagon/HexagonFrameLowering.cpp | 54 +- .../lib/Target/Hexagon/HexagonInstrFormats.td | 2 + llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 147 ++--- llvm/lib/Target/Hexagon/HexagonInstrInfo.h | 2 + llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td | 87 +-- llvm/lib/Target/Hexagon/HexagonInstrInfoV5.td | 23 +- .../Target/Hexagon/HexagonVLIWPacketizer.cpp | 552 +----------------- llvm/test/CodeGen/Hexagon/pred-gp.ll | 28 + 9 files changed, 198 insertions(+), 703 deletions(-) create mode 100644 llvm/test/CodeGen/Hexagon/pred-gp.ll diff --git a/llvm/lib/Target/Hexagon/Hexagon.td b/llvm/lib/Target/Hexagon/Hexagon.td index 9b3a64316aa0..6c7f963b5341 100644 --- a/llvm/lib/Target/Hexagon/Hexagon.td +++ b/llvm/lib/Target/Hexagon/Hexagon.td @@ -126,9 +126,9 @@ def getPredNewOpcode : InstrMapping { def getNewValueOpcode : InstrMapping { let FilterClass = "NewValueRel"; let RowFields = ["BaseOpcode", "PredSense", "PNewValue"]; - let ColFields = ["isNVStore"]; - let KeyCol = ["0"]; - let ValueCols = [["1"]]; + let ColFields = ["NValueST"]; + let KeyCol = ["false"]; + let ValueCols = [["true"]]; } def getBasedWithImmOffset : InstrMapping { diff --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp index de993ee8751a..77ad70dd6cf1 100644 --- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -174,30 +174,56 @@ void HexagonFrameLowering::emitEpilogue(MachineFunction &MF, MachineBasicBlock::iterator MBBI = prior(MBB.end()); DebugLoc dl = MBBI->getDebugLoc(); // - // Only insert deallocframe if we need to. + // Only insert deallocframe if we need to. Also at -O0. See comment + // in emitPrologue above. // - if (hasFP(MF)) { + if (hasFP(MF) || MF.getTarget().getOptLevel() == CodeGenOpt::None) { MachineBasicBlock::iterator MBBI = prior(MBB.end()); MachineBasicBlock::iterator MBBI_end = MBB.end(); - // - // For Hexagon, we don't need the frame size. - // - MachineFrameInfo *MFI = MF.getFrameInfo(); - int NumBytes = (int) MFI->getStackSize(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); - + // Handle EH_RETURN. + if (MBBI->getOpcode() == Hexagon::EH_RETURN_JMPR) { + MachineOperand &OffsetReg = MBBI->getOperand(0); + assert(OffsetReg.isReg() && "Offset should be in register!"); + BuildMI(MBB, MBBI, dl, TII.get(Hexagon::DEALLOCFRAME)); + BuildMI(MBB, MBBI, dl, TII.get(Hexagon::ADD_rr), + Hexagon::R29).addReg(Hexagon::R29).addReg(Hexagon::R28); + return; + } // Replace 'jumpr r31' instruction with dealloc_return for V4 and higher // versions. if (STI.hasV4TOps() && MBBI->getOpcode() == Hexagon::JMPret && !DisableDeallocRet) { - // Remove jumpr node. - MBB.erase(MBBI); + // Check for RESTORE_DEALLOC_RET_JMP_V4 call. Don't emit an extra DEALLOC + // instruction if we encounter it. + MachineBasicBlock::iterator BeforeJMPR = + MBB.begin() == MBBI ? MBBI : prior(MBBI); + if (BeforeJMPR != MBBI && + BeforeJMPR->getOpcode() == Hexagon::RESTORE_DEALLOC_RET_JMP_V4) { + // Remove the JMPR node. + MBB.erase(MBBI); + return; + } + // Add dealloc_return. - BuildMI(MBB, MBBI_end, dl, TII.get(Hexagon::DEALLOC_RET_V4)) - .addImm(NumBytes); - } else { // Add deallocframe for V2 and V3. - BuildMI(MBB, MBBI, dl, TII.get(Hexagon::DEALLOCFRAME)).addImm(NumBytes); + MachineInstrBuilder MIB = + BuildMI(MBB, MBBI_end, dl, TII.get(Hexagon::DEALLOC_RET_V4)); + // Transfer the function live-out registers. + MIB->copyImplicitOps(*MBB.getParent(), &*MBBI); + // Remove the JUMPR node. + MBB.erase(MBBI); + } else { // Add deallocframe for V2 and V3, and V4 tail calls. + // Check for RESTORE_DEALLOC_BEFORE_TAILCALL_V4. We don't need an extra + // DEALLOCFRAME instruction after it. + MachineBasicBlock::iterator Term = MBB.getFirstTerminator(); + MachineBasicBlock::iterator I = + Term == MBB.begin() ? MBB.end() : prior(Term); + if (I != MBB.end() && + I->getOpcode() == Hexagon::RESTORE_DEALLOC_BEFORE_TAILCALL_V4) + return; + + BuildMI(MBB, MBBI, dl, TII.get(Hexagon::DEALLOCFRAME)); } } } diff --git a/llvm/lib/Target/Hexagon/HexagonInstrFormats.td b/llvm/lib/Target/Hexagon/HexagonInstrFormats.td index f97143ff01aa..e71386ada2fa 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrFormats.td +++ b/llvm/lib/Target/Hexagon/HexagonInstrFormats.td @@ -158,6 +158,7 @@ class InstHexagon pattern, string CextOpcode = ""; string PredSense = ""; string PNewValue = ""; + string NValueST = ""; // Set to "true" for new-value stores. string InputType = ""; // Input is "imm" or "reg" type. string isMEMri = "false"; // Set to "true" for load/store with MEMri operand. string isFloat = "false"; // Set to "true" for the floating-point load/store. @@ -166,6 +167,7 @@ class InstHexagon pattern, let PredSense = !if(isPredicated, !if(isPredicatedFalse, "false", "true"), ""); let PNewValue = !if(isPredicatedNew, "new", ""); + let NValueST = !if(isNVStore, "true", "false"); // *** Must match MCTargetDesc/HexagonBaseInfo.h *** } diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp index 469e8021fae0..7dec127453cf 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -630,111 +630,6 @@ bool HexagonInstrInfo::isBranch (const MachineInstr *MI) const { return MI->getDesc().isBranch(); } -bool HexagonInstrInfo::isNewValueStore(const MachineInstr *MI) const { - switch (MI->getOpcode()) { - default: return false; - // Store Byte - case Hexagon::STrib_nv_V4: - case Hexagon::STrib_indexed_nv_V4: - case Hexagon::STrib_indexed_shl_nv_V4: - case Hexagon::STrib_shl_nv_V4: - case Hexagon::STb_GP_nv_V4: - case Hexagon::POST_STbri_nv_V4: - case Hexagon::STrib_cPt_nv_V4: - case Hexagon::STrib_cdnPt_nv_V4: - case Hexagon::STrib_cNotPt_nv_V4: - case Hexagon::STrib_cdnNotPt_nv_V4: - case Hexagon::STrib_indexed_cPt_nv_V4: - case Hexagon::STrib_indexed_cdnPt_nv_V4: - case Hexagon::STrib_indexed_cNotPt_nv_V4: - case Hexagon::STrib_indexed_cdnNotPt_nv_V4: - case Hexagon::STrib_indexed_shl_cPt_nv_V4: - case Hexagon::STrib_indexed_shl_cdnPt_nv_V4: - case Hexagon::STrib_indexed_shl_cNotPt_nv_V4: - case Hexagon::STrib_indexed_shl_cdnNotPt_nv_V4: - case Hexagon::POST_STbri_cPt_nv_V4: - case Hexagon::POST_STbri_cdnPt_nv_V4: - case Hexagon::POST_STbri_cNotPt_nv_V4: - case Hexagon::POST_STbri_cdnNotPt_nv_V4: - case Hexagon::STb_GP_cPt_nv_V4: - case Hexagon::STb_GP_cNotPt_nv_V4: - case Hexagon::STb_GP_cdnPt_nv_V4: - case Hexagon::STb_GP_cdnNotPt_nv_V4: - case Hexagon::STrib_abs_nv_V4: - case Hexagon::STrib_abs_cPt_nv_V4: - case Hexagon::STrib_abs_cdnPt_nv_V4: - case Hexagon::STrib_abs_cNotPt_nv_V4: - case Hexagon::STrib_abs_cdnNotPt_nv_V4: - - // Store Halfword - case Hexagon::STrih_nv_V4: - case Hexagon::STrih_indexed_nv_V4: - case Hexagon::STrih_indexed_shl_nv_V4: - case Hexagon::STrih_shl_nv_V4: - case Hexagon::STh_GP_nv_V4: - case Hexagon::POST_SThri_nv_V4: - case Hexagon::STrih_cPt_nv_V4: - case Hexagon::STrih_cdnPt_nv_V4: - case Hexagon::STrih_cNotPt_nv_V4: - case Hexagon::STrih_cdnNotPt_nv_V4: - case Hexagon::STrih_indexed_cPt_nv_V4: - case Hexagon::STrih_indexed_cdnPt_nv_V4: - case Hexagon::STrih_indexed_cNotPt_nv_V4: - case Hexagon::STrih_indexed_cdnNotPt_nv_V4: - case Hexagon::STrih_indexed_shl_cPt_nv_V4: - case Hexagon::STrih_indexed_shl_cdnPt_nv_V4: - case Hexagon::STrih_indexed_shl_cNotPt_nv_V4: - case Hexagon::STrih_indexed_shl_cdnNotPt_nv_V4: - case Hexagon::POST_SThri_cPt_nv_V4: - case Hexagon::POST_SThri_cdnPt_nv_V4: - case Hexagon::POST_SThri_cNotPt_nv_V4: - case Hexagon::POST_SThri_cdnNotPt_nv_V4: - case Hexagon::STh_GP_cPt_nv_V4: - case Hexagon::STh_GP_cNotPt_nv_V4: - case Hexagon::STh_GP_cdnPt_nv_V4: - case Hexagon::STh_GP_cdnNotPt_nv_V4: - case Hexagon::STrih_abs_nv_V4: - case Hexagon::STrih_abs_cPt_nv_V4: - case Hexagon::STrih_abs_cdnPt_nv_V4: - case Hexagon::STrih_abs_cNotPt_nv_V4: - case Hexagon::STrih_abs_cdnNotPt_nv_V4: - - // Store Word - case Hexagon::STriw_nv_V4: - case Hexagon::STriw_indexed_nv_V4: - case Hexagon::STriw_indexed_shl_nv_V4: - case Hexagon::STriw_shl_nv_V4: - case Hexagon::STw_GP_nv_V4: - case Hexagon::POST_STwri_nv_V4: - case Hexagon::STriw_cPt_nv_V4: - case Hexagon::STriw_cdnPt_nv_V4: - case Hexagon::STriw_cNotPt_nv_V4: - case Hexagon::STriw_cdnNotPt_nv_V4: - case Hexagon::STriw_indexed_cPt_nv_V4: - case Hexagon::STriw_indexed_cdnPt_nv_V4: - case Hexagon::STriw_indexed_cNotPt_nv_V4: - case Hexagon::STriw_indexed_cdnNotPt_nv_V4: - case Hexagon::STriw_indexed_shl_cPt_nv_V4: - case Hexagon::STriw_indexed_shl_cdnPt_nv_V4: - case Hexagon::STriw_indexed_shl_cNotPt_nv_V4: - case Hexagon::STriw_indexed_shl_cdnNotPt_nv_V4: - case Hexagon::POST_STwri_cPt_nv_V4: - case Hexagon::POST_STwri_cdnPt_nv_V4: - case Hexagon::POST_STwri_cNotPt_nv_V4: - case Hexagon::POST_STwri_cdnNotPt_nv_V4: - case Hexagon::STw_GP_cPt_nv_V4: - case Hexagon::STw_GP_cNotPt_nv_V4: - case Hexagon::STw_GP_cdnPt_nv_V4: - case Hexagon::STw_GP_cdnNotPt_nv_V4: - case Hexagon::STriw_abs_nv_V4: - case Hexagon::STriw_abs_cPt_nv_V4: - case Hexagon::STriw_abs_cdnPt_nv_V4: - case Hexagon::STriw_abs_cNotPt_nv_V4: - case Hexagon::STriw_abs_cdnNotPt_nv_V4: - return true; - } -} - bool HexagonInstrInfo::isNewValueInst(const MachineInstr *MI) const { if (isNewValueJump(MI)) return true; @@ -862,6 +757,18 @@ unsigned HexagonInstrInfo::getInvertedPredicatedOpcode(const int Opc) const { } } +// New Value Store instructions. +bool HexagonInstrInfo::isNewValueStore(const MachineInstr *MI) const { + const uint64_t F = MI->getDesc().TSFlags; + + return ((F >> HexagonII::NVStorePos) & HexagonII::NVStoreMask); +} + +bool HexagonInstrInfo::isNewValueStore(unsigned Opcode) const { + const uint64_t F = get(Opcode).TSFlags; + + return ((F >> HexagonII::NVStorePos) & HexagonII::NVStoreMask); +} int HexagonInstrInfo:: getMatchingCondBranchOpcode(int Opc, bool invertPredicate) const { @@ -1304,6 +1211,8 @@ isValidAutoIncImm(const EVT VT, const int Offset) const { bool HexagonInstrInfo:: isMemOp(const MachineInstr *MI) const { +// return MI->getDesc().mayLoad() && MI->getDesc().mayStore(); + switch (MI->getOpcode()) { default: return false; @@ -1611,6 +1520,34 @@ bool HexagonInstrInfo::isDotNewInst (const MachineInstr* MI) const { (isPredicated(MI) && isPredicatedNew(MI))); } +// Return the new value instruction for a given store. +int HexagonInstrInfo::GetDotNewOp(const MachineInstr* MI) const { + int NVOpcode = Hexagon::getNewValueOpcode(MI->getOpcode()); + if (NVOpcode >= 0) // Valid new-value store instruction. + return NVOpcode; + + switch (MI->getOpcode()) { + default: llvm_unreachable("Unknown .new type"); + // store new value byte + case Hexagon::STrib_shl_V4: + return Hexagon::STrib_shl_nv_V4; + + case Hexagon::STrih_shl_V4: + return Hexagon::STrih_shl_nv_V4; + + case Hexagon::STriw_f: + return Hexagon::STriw_nv_V4; + + case Hexagon::STriw_indexed_f: + return Hexagon::STriw_indexed_nv_V4; + + case Hexagon::STriw_shl_V4: + return Hexagon::STriw_shl_nv_V4; + + } + return 0; +} + // Return .new predicate version for an instruction. int HexagonInstrInfo::GetDotNewPredOp(MachineInstr *MI, const MachineBranchProbabilityInfo diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h index 2becc025705a..f3297fbd335d 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h @@ -185,6 +185,7 @@ public: bool isNewValueInst(const MachineInstr* MI) const; bool isNewValue(const MachineInstr* MI) const; bool isDotNewInst(const MachineInstr* MI) const; + int GetDotNewOp(const MachineInstr* MI) const; int GetDotNewPredOp(MachineInstr *MI, const MachineBranchProbabilityInfo *MBPI) const; @@ -194,6 +195,7 @@ public: bool isExtended(const MachineInstr* MI) const; bool isPostIncrement(const MachineInstr* MI) const; bool isNewValueStore(const MachineInstr* MI) const; + bool isNewValueStore(unsigned Opcode) const; bool isNewValueJump(const MachineInstr* MI) const; bool isNewValueJumpCandidate(const MachineInstr *MI) const; diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td b/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td index c7f4edfe674a..022a7f613658 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td @@ -2564,8 +2564,9 @@ def NTSTBIT_ri : SInst<(outs PredRegs:$dst), (ins IntRegs:$src1, u5Imm:$src2), //Deallocate frame and return. // dealloc_return let isReturn = 1, isTerminator = 1, isBarrier = 1, isPredicable = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1 in { - def DEALLOC_RET_V4 : NVInst_V4<(outs), (ins i32imm:$amt1), + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1 in { +let validSubTargets = HasV4SubT in + def DEALLOC_RET_V4 : LD0Inst<(outs), (ins), "dealloc_return", []>, Requires<[HasV4T]>; @@ -2574,9 +2575,10 @@ let isReturn = 1, isTerminator = 1, isBarrier = 1, isPredicable = 1, // Restore registers and dealloc return function call. let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1, Defs = [R29, R30, R31, PC] in { +let validSubTargets = HasV4SubT in def RESTORE_DEALLOC_RET_JMP_V4 : JInst<(outs), (ins calltarget:$dst), - "jump $dst // Restore_and_dealloc_return", + "jump $dst", []>, Requires<[HasV4T]>; } @@ -2584,9 +2586,10 @@ let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1, // Restore registers and dealloc frame before a tail call. let isCall = 1, isBarrier = 1, Defs = [R29, R30, R31, PC] in { +let validSubTargets = HasV4SubT in def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : JInst<(outs), (ins calltarget:$dst), - "call $dst // Restore_and_dealloc_before_tailcall", + "call $dst", []>, Requires<[HasV4T]>; } @@ -2603,10 +2606,11 @@ let isCall = 1, isBarrier = 1, // if (Ps) dealloc_return let isReturn = 1, isTerminator = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1, + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1, isPredicated = 1 in { - def DEALLOC_RET_cPt_V4 : NVInst_V4<(outs), - (ins PredRegs:$src1, i32imm:$amt1), +let validSubTargets = HasV4SubT in + def DEALLOC_RET_cPt_V4 : LD0Inst<(outs), + (ins PredRegs:$src1), "if ($src1) dealloc_return", []>, Requires<[HasV4T]>; @@ -2614,10 +2618,10 @@ let isReturn = 1, isTerminator = 1, // if (!Ps) dealloc_return let isReturn = 1, isTerminator = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1, - isPredicated = 1 in { - def DEALLOC_RET_cNotPt_V4 : NVInst_V4<(outs), (ins PredRegs:$src1, - i32imm:$amt1), + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1, + isPredicated = 1, isPredicatedFalse = 1 in { +let validSubTargets = HasV4SubT in + def DEALLOC_RET_cNotPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if (!$src1) dealloc_return", []>, Requires<[HasV4T]>; @@ -2625,10 +2629,10 @@ let isReturn = 1, isTerminator = 1, // if (Ps.new) dealloc_return:nt let isReturn = 1, isTerminator = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1, + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1, isPredicated = 1 in { - def DEALLOC_RET_cdnPnt_V4 : NVInst_V4<(outs), (ins PredRegs:$src1, - i32imm:$amt1), +let validSubTargets = HasV4SubT in + def DEALLOC_RET_cdnPnt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if ($src1.new) dealloc_return:nt", []>, Requires<[HasV4T]>; @@ -2636,10 +2640,10 @@ let isReturn = 1, isTerminator = 1, // if (!Ps.new) dealloc_return:nt let isReturn = 1, isTerminator = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1, - isPredicated = 1 in { - def DEALLOC_RET_cNotdnPnt_V4 : NVInst_V4<(outs), (ins PredRegs:$src1, - i32imm:$amt1), + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1, + isPredicated = 1, isPredicatedFalse = 1 in { +let validSubTargets = HasV4SubT in + def DEALLOC_RET_cNotdnPnt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if (!$src1.new) dealloc_return:nt", []>, Requires<[HasV4T]>; @@ -2647,21 +2651,21 @@ let isReturn = 1, isTerminator = 1, // if (Ps.new) dealloc_return:t let isReturn = 1, isTerminator = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1, + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1, isPredicated = 1 in { - def DEALLOC_RET_cdnPt_V4 : NVInst_V4<(outs), (ins PredRegs:$src1, - i32imm:$amt1), +let validSubTargets = HasV4SubT in + def DEALLOC_RET_cdnPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if ($src1.new) dealloc_return:t", []>, Requires<[HasV4T]>; } -// if (!Ps.new) dealloc_return:nt +// if (!Ps.new) dealloc_return:nt let isReturn = 1, isTerminator = 1, - Defs = [R29, R30, R31, PC], Uses = [R29, R31], neverHasSideEffects = 1, - isPredicated = 1 in { - def DEALLOC_RET_cNotdnPt_V4 : NVInst_V4<(outs), (ins PredRegs:$src1, - i32imm:$amt1), + Defs = [R29, R30, R31, PC], Uses = [R30], neverHasSideEffects = 1, + isPredicated = 1, isPredicatedFalse = 1 in { +let validSubTargets = HasV4SubT in + def DEALLOC_RET_cNotdnPt_V4 : LD0Inst<(outs), (ins PredRegs:$src1), "if (!$src1.new) dealloc_return:t", []>, Requires<[HasV4T]>; @@ -3063,37 +3067,42 @@ def : Pat<(HexagonCONST32_GP tblockaddress:$src1), (TFRI_V4 tblockaddress:$src1)>, Requires<[HasV4T]>; -let AddedComplexity=50, neverHasSideEffects = 1, isPredicated = 1 in +let isExtended = 1, opExtendable = 2, AddedComplexity=50, +neverHasSideEffects = 1, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cPt_V4 : ALU32_ri<(outs IntRegs:$dst), - (ins PredRegs:$src1, globaladdress:$src2), - "if($src1) $dst = ##$src2", + (ins PredRegs:$src1, s16Ext:$src2), + "if($src1) $dst = #$src2", []>, Requires<[HasV4T]>; -let AddedComplexity=50, neverHasSideEffects = 1, isPredicated = 1 in +let isExtended = 1, opExtendable = 2, AddedComplexity=50, isPredicatedFalse = 1, +neverHasSideEffects = 1, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cNotPt_V4 : ALU32_ri<(outs IntRegs:$dst), - (ins PredRegs:$src1, globaladdress:$src2), - "if(!$src1) $dst = ##$src2", + (ins PredRegs:$src1, s16Ext:$src2), + "if(!$src1) $dst = #$src2", []>, Requires<[HasV4T]>; -let AddedComplexity=50, neverHasSideEffects = 1, isPredicated = 1 in +let isExtended = 1, opExtendable = 2, AddedComplexity=50, +neverHasSideEffects = 1, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cdnPt_V4 : ALU32_ri<(outs IntRegs:$dst), - (ins PredRegs:$src1, globaladdress:$src2), - "if($src1.new) $dst = ##$src2", + (ins PredRegs:$src1, s16Ext:$src2), + "if($src1.new) $dst = #$src2", []>, Requires<[HasV4T]>; -let AddedComplexity=50, neverHasSideEffects = 1, isPredicated = 1 in +let isExtended = 1, opExtendable = 2, AddedComplexity=50, isPredicatedFalse = 1, +neverHasSideEffects = 1, isPredicated = 1, validSubTargets = HasV4SubT in def TFRI_cdnNotPt_V4 : ALU32_ri<(outs IntRegs:$dst), - (ins PredRegs:$src1, globaladdress:$src2), - "if(!$src1.new) $dst = ##$src2", + (ins PredRegs:$src1, s16Ext:$src2), + "if(!$src1.new) $dst = #$src2", []>, Requires<[HasV4T]>; let AddedComplexity = 50, Predicates = [HasV4T] in def : Pat<(HexagonCONST32_GP tglobaladdr:$src1), - (TFRI_V4 tglobaladdr:$src1)>; + (TFRI_V4 tglobaladdr:$src1)>, + Requires<[HasV4T]>; // Load - Indirect with long offset: These instructions take global address diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfoV5.td b/llvm/lib/Target/Hexagon/HexagonInstrInfoV5.td index 92d098cc0446..9da607455811 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfoV5.td +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfoV5.td @@ -26,22 +26,29 @@ def CONST32_Float_Real : LDInst<(outs IntRegs:$dst), (ins f32imm:$src1), // Only works with single precision fp value. // For double precision, use CONST64_float_real, as 64bit transfer // can only hold 40-bit values - 32 from const ext + 8 bit immediate. -let isMoveImm = 1, isReMaterializable = 1, isPredicable = 1 in -def TFRI_f : ALU32_ri<(outs IntRegs:$dst), (ins f32imm:$src1), - "$dst = ##$src1", +// Make sure that complexity is more than the CONST32 pattern in +// HexagonInstrInfo.td patterns. +let isExtended = 1, opExtendable = 1, isMoveImm = 1, isReMaterializable = 1, +isPredicable = 1, AddedComplexity = 30, validSubTargets = HasV5SubT, +isCodeGenOnly = 1 in +def TFRI_f : ALU32_ri<(outs IntRegs:$dst), (ins f32Ext:$src1), + "$dst = #$src1", [(set IntRegs:$dst, fpimm:$src1)]>, Requires<[HasV5T]>; +let isExtended = 1, opExtendable = 2, isPredicated = 1, +neverHasSideEffects = 1, validSubTargets = HasV5SubT in def TFRI_cPt_f : ALU32_ri<(outs IntRegs:$dst), - (ins PredRegs:$src1, f32imm:$src2), - "if ($src1) $dst = ##$src2", + (ins PredRegs:$src1, f32Ext:$src2), + "if ($src1) $dst = #$src2", []>, Requires<[HasV5T]>; -let isPredicated = 1 in +let isExtended = 1, opExtendable = 2, isPredicated = 1, isPredicatedFalse = 1, +neverHasSideEffects = 1, validSubTargets = HasV5SubT in def TFRI_cNotPt_f : ALU32_ri<(outs IntRegs:$dst), - (ins PredRegs:$src1, f32imm:$src2), - "if (!$src1) $dst = ##$src2", + (ins PredRegs:$src1, f32Ext:$src2), + "if (!$src1) $dst =#$src2", []>, Requires<[HasV5T]>; diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index fbe67e3882fe..6ed9d551352c 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -498,250 +498,6 @@ static bool DoesModifyCalleeSavedReg(MachineInstr *MI, return false; } -// Return the new value instruction for a given store. -static int GetDotNewOp(const int opc) { - switch (opc) { - default: llvm_unreachable("Unknown .new type"); - // store new value byte - case Hexagon::STrib: - return Hexagon::STrib_nv_V4; - - case Hexagon::STrib_indexed: - return Hexagon::STrib_indexed_nv_V4; - - case Hexagon::STrib_indexed_shl_V4: - return Hexagon::STrib_indexed_shl_nv_V4; - - case Hexagon::STrib_shl_V4: - return Hexagon::STrib_shl_nv_V4; - - case Hexagon::STb_GP_V4: - return Hexagon::STb_GP_nv_V4; - - case Hexagon::POST_STbri: - return Hexagon::POST_STbri_nv_V4; - - case Hexagon::STrib_cPt: - return Hexagon::STrib_cPt_nv_V4; - - case Hexagon::STrib_cdnPt_V4: - return Hexagon::STrib_cdnPt_nv_V4; - - case Hexagon::STrib_cNotPt: - return Hexagon::STrib_cNotPt_nv_V4; - - case Hexagon::STrib_cdnNotPt_V4: - return Hexagon::STrib_cdnNotPt_nv_V4; - - case Hexagon::STrib_indexed_cPt: - return Hexagon::STrib_indexed_cPt_nv_V4; - - case Hexagon::STrib_indexed_cdnPt_V4: - return Hexagon::STrib_indexed_cdnPt_nv_V4; - - case Hexagon::STrib_indexed_cNotPt: - return Hexagon::STrib_indexed_cNotPt_nv_V4; - - case Hexagon::STrib_indexed_cdnNotPt_V4: - return Hexagon::STrib_indexed_cdnNotPt_nv_V4; - - case Hexagon::STrib_indexed_shl_cPt_V4: - return Hexagon::STrib_indexed_shl_cPt_nv_V4; - - case Hexagon::STrib_indexed_shl_cdnPt_V4: - return Hexagon::STrib_indexed_shl_cdnPt_nv_V4; - - case Hexagon::STrib_indexed_shl_cNotPt_V4: - return Hexagon::STrib_indexed_shl_cNotPt_nv_V4; - - case Hexagon::STrib_indexed_shl_cdnNotPt_V4: - return Hexagon::STrib_indexed_shl_cdnNotPt_nv_V4; - - case Hexagon::POST_STbri_cPt: - return Hexagon::POST_STbri_cPt_nv_V4; - - case Hexagon::POST_STbri_cdnPt_V4: - return Hexagon::POST_STbri_cdnPt_nv_V4; - - case Hexagon::POST_STbri_cNotPt: - return Hexagon::POST_STbri_cNotPt_nv_V4; - - case Hexagon::POST_STbri_cdnNotPt_V4: - return Hexagon::POST_STbri_cdnNotPt_nv_V4; - - case Hexagon::STb_GP_cPt_V4: - return Hexagon::STb_GP_cPt_nv_V4; - - case Hexagon::STb_GP_cNotPt_V4: - return Hexagon::STb_GP_cNotPt_nv_V4; - - case Hexagon::STb_GP_cdnPt_V4: - return Hexagon::STb_GP_cdnPt_nv_V4; - - case Hexagon::STb_GP_cdnNotPt_V4: - return Hexagon::STb_GP_cdnNotPt_nv_V4; - - // store new value halfword - case Hexagon::STrih: - return Hexagon::STrih_nv_V4; - - case Hexagon::STrih_indexed: - return Hexagon::STrih_indexed_nv_V4; - - case Hexagon::STrih_indexed_shl_V4: - return Hexagon::STrih_indexed_shl_nv_V4; - - case Hexagon::STrih_shl_V4: - return Hexagon::STrih_shl_nv_V4; - - case Hexagon::STh_GP_V4: - return Hexagon::STh_GP_nv_V4; - - case Hexagon::POST_SThri: - return Hexagon::POST_SThri_nv_V4; - - case Hexagon::STrih_cPt: - return Hexagon::STrih_cPt_nv_V4; - - case Hexagon::STrih_cdnPt_V4: - return Hexagon::STrih_cdnPt_nv_V4; - - case Hexagon::STrih_cNotPt: - return Hexagon::STrih_cNotPt_nv_V4; - - case Hexagon::STrih_cdnNotPt_V4: - return Hexagon::STrih_cdnNotPt_nv_V4; - - case Hexagon::STrih_indexed_cPt: - return Hexagon::STrih_indexed_cPt_nv_V4; - - case Hexagon::STrih_indexed_cdnPt_V4: - return Hexagon::STrih_indexed_cdnPt_nv_V4; - - case Hexagon::STrih_indexed_cNotPt: - return Hexagon::STrih_indexed_cNotPt_nv_V4; - - case Hexagon::STrih_indexed_cdnNotPt_V4: - return Hexagon::STrih_indexed_cdnNotPt_nv_V4; - - case Hexagon::STrih_indexed_shl_cPt_V4: - return Hexagon::STrih_indexed_shl_cPt_nv_V4; - - case Hexagon::STrih_indexed_shl_cdnPt_V4: - return Hexagon::STrih_indexed_shl_cdnPt_nv_V4; - - case Hexagon::STrih_indexed_shl_cNotPt_V4: - return Hexagon::STrih_indexed_shl_cNotPt_nv_V4; - - case Hexagon::STrih_indexed_shl_cdnNotPt_V4: - return Hexagon::STrih_indexed_shl_cdnNotPt_nv_V4; - - case Hexagon::POST_SThri_cPt: - return Hexagon::POST_SThri_cPt_nv_V4; - - case Hexagon::POST_SThri_cdnPt_V4: - return Hexagon::POST_SThri_cdnPt_nv_V4; - - case Hexagon::POST_SThri_cNotPt: - return Hexagon::POST_SThri_cNotPt_nv_V4; - - case Hexagon::POST_SThri_cdnNotPt_V4: - return Hexagon::POST_SThri_cdnNotPt_nv_V4; - - case Hexagon::STh_GP_cPt_V4: - return Hexagon::STh_GP_cPt_nv_V4; - - case Hexagon::STh_GP_cNotPt_V4: - return Hexagon::STh_GP_cNotPt_nv_V4; - - case Hexagon::STh_GP_cdnPt_V4: - return Hexagon::STh_GP_cdnPt_nv_V4; - - case Hexagon::STh_GP_cdnNotPt_V4: - return Hexagon::STh_GP_cdnNotPt_nv_V4; - - // store new value word - case Hexagon::STriw: - return Hexagon::STriw_nv_V4; - - case Hexagon::STriw_indexed: - return Hexagon::STriw_indexed_nv_V4; - - case Hexagon::STriw_indexed_shl_V4: - return Hexagon::STriw_indexed_shl_nv_V4; - - case Hexagon::STriw_shl_V4: - return Hexagon::STriw_shl_nv_V4; - - case Hexagon::STw_GP_V4: - return Hexagon::STw_GP_nv_V4; - - case Hexagon::POST_STwri: - return Hexagon::POST_STwri_nv_V4; - - case Hexagon::STriw_cPt: - return Hexagon::STriw_cPt_nv_V4; - - case Hexagon::STriw_cdnPt_V4: - return Hexagon::STriw_cdnPt_nv_V4; - - case Hexagon::STriw_cNotPt: - return Hexagon::STriw_cNotPt_nv_V4; - - case Hexagon::STriw_cdnNotPt_V4: - return Hexagon::STriw_cdnNotPt_nv_V4; - - case Hexagon::STriw_indexed_cPt: - return Hexagon::STriw_indexed_cPt_nv_V4; - - case Hexagon::STriw_indexed_cdnPt_V4: - return Hexagon::STriw_indexed_cdnPt_nv_V4; - - case Hexagon::STriw_indexed_cNotPt: - return Hexagon::STriw_indexed_cNotPt_nv_V4; - - case Hexagon::STriw_indexed_cdnNotPt_V4: - return Hexagon::STriw_indexed_cdnNotPt_nv_V4; - - case Hexagon::STriw_indexed_shl_cPt_V4: - return Hexagon::STriw_indexed_shl_cPt_nv_V4; - - case Hexagon::STriw_indexed_shl_cdnPt_V4: - return Hexagon::STriw_indexed_shl_cdnPt_nv_V4; - - case Hexagon::STriw_indexed_shl_cNotPt_V4: - return Hexagon::STriw_indexed_shl_cNotPt_nv_V4; - - case Hexagon::STriw_indexed_shl_cdnNotPt_V4: - return Hexagon::STriw_indexed_shl_cdnNotPt_nv_V4; - - case Hexagon::POST_STwri_cPt: - return Hexagon::POST_STwri_cPt_nv_V4; - - case Hexagon::POST_STwri_cdnPt_V4: - return Hexagon::POST_STwri_cdnPt_nv_V4; - - case Hexagon::POST_STwri_cNotPt: - return Hexagon::POST_STwri_cNotPt_nv_V4; - - case Hexagon::POST_STwri_cdnNotPt_V4: - return Hexagon::POST_STwri_cdnNotPt_nv_V4; - - case Hexagon::STw_GP_cPt_V4: - return Hexagon::STw_GP_cPt_nv_V4; - - case Hexagon::STw_GP_cNotPt_V4: - return Hexagon::STw_GP_cNotPt_nv_V4; - - case Hexagon::STw_GP_cdnPt_V4: - return Hexagon::STw_GP_cdnPt_nv_V4; - - case Hexagon::STw_GP_cdnNotPt_V4: - return Hexagon::STw_GP_cdnNotPt_nv_V4; - - } -} - // Returns true if an instruction can be promoted to .new predicate // or new-value store. bool HexagonPacketizerList::isNewifiable(MachineInstr* MI) { @@ -781,7 +537,7 @@ bool HexagonPacketizerList::PromoteToDotNew(MachineInstr* MI, if (RC == &Hexagon::PredRegsRegClass) NewOpcode = QII->GetDotNewPredOp(MI, MBPI); else - NewOpcode = GetDotNewOp(MI->getOpcode()); + NewOpcode = QII->GetDotNewOp(MI); MI->setDesc(QII->get(NewOpcode)); return true; @@ -1380,295 +1136,23 @@ bool HexagonPacketizerList::DemoteToDotOld(MachineInstr* MI) { return true; } -// Returns true if an instruction is predicated on p0 and false if it's -// predicated on !p0. - -static bool GetPredicateSense(MachineInstr* MI, - const HexagonInstrInfo *QII) { +enum PredicateKind { + PK_False, + PK_True, + PK_Unknown +}; - switch (MI->getOpcode()) { - default: llvm_unreachable("Unknown predicate sense of the instruction"); - case Hexagon::TFR_cPt: - case Hexagon::TFR_cdnPt: - case Hexagon::TFRI_cPt: - case Hexagon::TFRI_cdnPt: - case Hexagon::STrib_cPt : - case Hexagon::STrib_cdnPt_V4 : - case Hexagon::STrib_indexed_cPt : - case Hexagon::STrib_indexed_cdnPt_V4 : - case Hexagon::STrib_indexed_shl_cPt_V4 : - case Hexagon::STrib_indexed_shl_cdnPt_V4 : - case Hexagon::POST_STbri_cPt : - case Hexagon::POST_STbri_cdnPt_V4 : - case Hexagon::STrih_cPt : - case Hexagon::STrih_cdnPt_V4 : - case Hexagon::STrih_indexed_cPt : - case Hexagon::STrih_indexed_cdnPt_V4 : - case Hexagon::STrih_indexed_shl_cPt_V4 : - case Hexagon::STrih_indexed_shl_cdnPt_V4 : - case Hexagon::POST_SThri_cPt : - case Hexagon::POST_SThri_cdnPt_V4 : - case Hexagon::STriw_cPt : - case Hexagon::STriw_cdnPt_V4 : - case Hexagon::STriw_indexed_cPt : - case Hexagon::STriw_indexed_cdnPt_V4 : - case Hexagon::STriw_indexed_shl_cPt_V4 : - case Hexagon::STriw_indexed_shl_cdnPt_V4 : - case Hexagon::POST_STwri_cPt : - case Hexagon::POST_STwri_cdnPt_V4 : - case Hexagon::STrib_imm_cPt_V4 : - case Hexagon::STrib_imm_cdnPt_V4 : - case Hexagon::STrid_cPt : - case Hexagon::STrid_cdnPt_V4 : - case Hexagon::STrid_indexed_cPt : - case Hexagon::STrid_indexed_cdnPt_V4 : - case Hexagon::STrid_indexed_shl_cPt_V4 : - case Hexagon::STrid_indexed_shl_cdnPt_V4 : - case Hexagon::POST_STdri_cPt : - case Hexagon::POST_STdri_cdnPt_V4 : - case Hexagon::STrih_imm_cPt_V4 : - case Hexagon::STrih_imm_cdnPt_V4 : - case Hexagon::STriw_imm_cPt_V4 : - case Hexagon::STriw_imm_cdnPt_V4 : - case Hexagon::JMP_tnew_t : - case Hexagon::LDrid_cPt : - case Hexagon::LDrid_cdnPt : - case Hexagon::LDrid_indexed_cPt : - case Hexagon::LDrid_indexed_cdnPt : - case Hexagon::POST_LDrid_cPt : - case Hexagon::POST_LDrid_cdnPt_V4 : - case Hexagon::LDriw_cPt : - case Hexagon::LDriw_cdnPt : - case Hexagon::LDriw_indexed_cPt : - case Hexagon::LDriw_indexed_cdnPt : - case Hexagon::POST_LDriw_cPt : - case Hexagon::POST_LDriw_cdnPt_V4 : - case Hexagon::LDrih_cPt : - case Hexagon::LDrih_cdnPt : - case Hexagon::LDrih_indexed_cPt : - case Hexagon::LDrih_indexed_cdnPt : - case Hexagon::POST_LDrih_cPt : - case Hexagon::POST_LDrih_cdnPt_V4 : - case Hexagon::LDrib_cPt : - case Hexagon::LDrib_cdnPt : - case Hexagon::LDrib_indexed_cPt : - case Hexagon::LDrib_indexed_cdnPt : - case Hexagon::POST_LDrib_cPt : - case Hexagon::POST_LDrib_cdnPt_V4 : - case Hexagon::LDriuh_cPt : - case Hexagon::LDriuh_cdnPt : - case Hexagon::LDriuh_indexed_cPt : - case Hexagon::LDriuh_indexed_cdnPt : - case Hexagon::POST_LDriuh_cPt : - case Hexagon::POST_LDriuh_cdnPt_V4 : - case Hexagon::LDriub_cPt : - case Hexagon::LDriub_cdnPt : - case Hexagon::LDriub_indexed_cPt : - case Hexagon::LDriub_indexed_cdnPt : - case Hexagon::POST_LDriub_cPt : - case Hexagon::POST_LDriub_cdnPt_V4 : - case Hexagon::LDrid_indexed_shl_cPt_V4 : - case Hexagon::LDrid_indexed_shl_cdnPt_V4 : - case Hexagon::LDrib_indexed_shl_cPt_V4 : - case Hexagon::LDrib_indexed_shl_cdnPt_V4 : - case Hexagon::LDriub_indexed_shl_cPt_V4 : - case Hexagon::LDriub_indexed_shl_cdnPt_V4 : - case Hexagon::LDrih_indexed_shl_cPt_V4 : - case Hexagon::LDrih_indexed_shl_cdnPt_V4 : - case Hexagon::LDriuh_indexed_shl_cPt_V4 : - case Hexagon::LDriuh_indexed_shl_cdnPt_V4 : - case Hexagon::LDriw_indexed_shl_cPt_V4 : - case Hexagon::LDriw_indexed_shl_cdnPt_V4 : - case Hexagon::ADD_ri_cPt : - case Hexagon::ADD_ri_cdnPt : - case Hexagon::ADD_rr_cPt : - case Hexagon::ADD_rr_cdnPt : - case Hexagon::XOR_rr_cPt : - case Hexagon::XOR_rr_cdnPt : - case Hexagon::AND_rr_cPt : - case Hexagon::AND_rr_cdnPt : - case Hexagon::OR_rr_cPt : - case Hexagon::OR_rr_cdnPt : - case Hexagon::SUB_rr_cPt : - case Hexagon::SUB_rr_cdnPt : - case Hexagon::COMBINE_rr_cPt : - case Hexagon::COMBINE_rr_cdnPt : - case Hexagon::ASLH_cPt_V4 : - case Hexagon::ASLH_cdnPt_V4 : - case Hexagon::ASRH_cPt_V4 : - case Hexagon::ASRH_cdnPt_V4 : - case Hexagon::SXTB_cPt_V4 : - case Hexagon::SXTB_cdnPt_V4 : - case Hexagon::SXTH_cPt_V4 : - case Hexagon::SXTH_cdnPt_V4 : - case Hexagon::ZXTB_cPt_V4 : - case Hexagon::ZXTB_cdnPt_V4 : - case Hexagon::ZXTH_cPt_V4 : - case Hexagon::ZXTH_cdnPt_V4 : - case Hexagon::LDd_GP_cPt_V4 : - case Hexagon::LDb_GP_cPt_V4 : - case Hexagon::LDub_GP_cPt_V4 : - case Hexagon::LDh_GP_cPt_V4 : - case Hexagon::LDuh_GP_cPt_V4 : - case Hexagon::LDw_GP_cPt_V4 : - case Hexagon::STd_GP_cPt_V4 : - case Hexagon::STb_GP_cPt_V4 : - case Hexagon::STh_GP_cPt_V4 : - case Hexagon::STw_GP_cPt_V4 : - case Hexagon::LDd_GP_cdnPt_V4 : - case Hexagon::LDb_GP_cdnPt_V4 : - case Hexagon::LDub_GP_cdnPt_V4 : - case Hexagon::LDh_GP_cdnPt_V4 : - case Hexagon::LDuh_GP_cdnPt_V4 : - case Hexagon::LDw_GP_cdnPt_V4 : - case Hexagon::STd_GP_cdnPt_V4 : - case Hexagon::STb_GP_cdnPt_V4 : - case Hexagon::STh_GP_cdnPt_V4 : - case Hexagon::STw_GP_cdnPt_V4 : - return true; +/// Returns true if an instruction is predicated on p0 and false if it's +/// predicated on !p0. +static PredicateKind getPredicateSense(MachineInstr* MI, + const HexagonInstrInfo *QII) { + if (!QII->isPredicated(MI)) + return PK_Unknown; - case Hexagon::TFR_cNotPt: - case Hexagon::TFR_cdnNotPt: - case Hexagon::TFRI_cNotPt: - case Hexagon::TFRI_cdnNotPt: - case Hexagon::STrib_cNotPt : - case Hexagon::STrib_cdnNotPt_V4 : - case Hexagon::STrib_indexed_cNotPt : - case Hexagon::STrib_indexed_cdnNotPt_V4 : - case Hexagon::STrib_indexed_shl_cNotPt_V4 : - case Hexagon::STrib_indexed_shl_cdnNotPt_V4 : - case Hexagon::POST_STbri_cNotPt : - case Hexagon::POST_STbri_cdnNotPt_V4 : - case Hexagon::STrih_cNotPt : - case Hexagon::STrih_cdnNotPt_V4 : - case Hexagon::STrih_indexed_cNotPt : - case Hexagon::STrih_indexed_cdnNotPt_V4 : - case Hexagon::STrih_indexed_shl_cNotPt_V4 : - case Hexagon::STrih_indexed_shl_cdnNotPt_V4 : - case Hexagon::POST_SThri_cNotPt : - case Hexagon::POST_SThri_cdnNotPt_V4 : - case Hexagon::STriw_cNotPt : - case Hexagon::STriw_cdnNotPt_V4 : - case Hexagon::STriw_indexed_cNotPt : - case Hexagon::STriw_indexed_cdnNotPt_V4 : - case Hexagon::STriw_indexed_shl_cNotPt_V4 : - case Hexagon::STriw_indexed_shl_cdnNotPt_V4 : - case Hexagon::POST_STwri_cNotPt : - case Hexagon::POST_STwri_cdnNotPt_V4 : - case Hexagon::STrib_imm_cNotPt_V4 : - case Hexagon::STrib_imm_cdnNotPt_V4 : - case Hexagon::STrid_cNotPt : - case Hexagon::STrid_cdnNotPt_V4 : - case Hexagon::STrid_indexed_cdnNotPt_V4 : - case Hexagon::STrid_indexed_cNotPt : - case Hexagon::STrid_indexed_shl_cNotPt_V4 : - case Hexagon::STrid_indexed_shl_cdnNotPt_V4 : - case Hexagon::POST_STdri_cNotPt : - case Hexagon::POST_STdri_cdnNotPt_V4 : - case Hexagon::STrih_imm_cNotPt_V4 : - case Hexagon::STrih_imm_cdnNotPt_V4 : - case Hexagon::STriw_imm_cNotPt_V4 : - case Hexagon::STriw_imm_cdnNotPt_V4 : - case Hexagon::JMP_fnew_t : - case Hexagon::LDrid_cNotPt : - case Hexagon::LDrid_cdnNotPt : - case Hexagon::LDrid_indexed_cNotPt : - case Hexagon::LDrid_indexed_cdnNotPt : - case Hexagon::POST_LDrid_cNotPt : - case Hexagon::POST_LDrid_cdnNotPt_V4 : - case Hexagon::LDriw_cNotPt : - case Hexagon::LDriw_cdnNotPt : - case Hexagon::LDriw_indexed_cNotPt : - case Hexagon::LDriw_indexed_cdnNotPt : - case Hexagon::POST_LDriw_cNotPt : - case Hexagon::POST_LDriw_cdnNotPt_V4 : - case Hexagon::LDrih_cNotPt : - case Hexagon::LDrih_cdnNotPt : - case Hexagon::LDrih_indexed_cNotPt : - case Hexagon::LDrih_indexed_cdnNotPt : - case Hexagon::POST_LDrih_cNotPt : - case Hexagon::POST_LDrih_cdnNotPt_V4 : - case Hexagon::LDrib_cNotPt : - case Hexagon::LDrib_cdnNotPt : - case Hexagon::LDrib_indexed_cNotPt : - case Hexagon::LDrib_indexed_cdnNotPt : - case Hexagon::POST_LDrib_cNotPt : - case Hexagon::POST_LDrib_cdnNotPt_V4 : - case Hexagon::LDriuh_cNotPt : - case Hexagon::LDriuh_cdnNotPt : - case Hexagon::LDriuh_indexed_cNotPt : - case Hexagon::LDriuh_indexed_cdnNotPt : - case Hexagon::POST_LDriuh_cNotPt : - case Hexagon::POST_LDriuh_cdnNotPt_V4 : - case Hexagon::LDriub_cNotPt : - case Hexagon::LDriub_cdnNotPt : - case Hexagon::LDriub_indexed_cNotPt : - case Hexagon::LDriub_indexed_cdnNotPt : - case Hexagon::POST_LDriub_cNotPt : - case Hexagon::POST_LDriub_cdnNotPt_V4 : - case Hexagon::LDrid_indexed_shl_cNotPt_V4 : - case Hexagon::LDrid_indexed_shl_cdnNotPt_V4 : - case Hexagon::LDrib_indexed_shl_cNotPt_V4 : - case Hexagon::LDrib_indexed_shl_cdnNotPt_V4 : - case Hexagon::LDriub_indexed_shl_cNotPt_V4 : - case Hexagon::LDriub_indexed_shl_cdnNotPt_V4 : - case Hexagon::LDrih_indexed_shl_cNotPt_V4 : - case Hexagon::LDrih_indexed_shl_cdnNotPt_V4 : - case Hexagon::LDriuh_indexed_shl_cNotPt_V4 : - case Hexagon::LDriuh_indexed_shl_cdnNotPt_V4 : - case Hexagon::LDriw_indexed_shl_cNotPt_V4 : - case Hexagon::LDriw_indexed_shl_cdnNotPt_V4 : - case Hexagon::ADD_ri_cNotPt : - case Hexagon::ADD_ri_cdnNotPt : - case Hexagon::ADD_rr_cNotPt : - case Hexagon::ADD_rr_cdnNotPt : - case Hexagon::XOR_rr_cNotPt : - case Hexagon::XOR_rr_cdnNotPt : - case Hexagon::AND_rr_cNotPt : - case Hexagon::AND_rr_cdnNotPt : - case Hexagon::OR_rr_cNotPt : - case Hexagon::OR_rr_cdnNotPt : - case Hexagon::SUB_rr_cNotPt : - case Hexagon::SUB_rr_cdnNotPt : - case Hexagon::COMBINE_rr_cNotPt : - case Hexagon::COMBINE_rr_cdnNotPt : - case Hexagon::ASLH_cNotPt_V4 : - case Hexagon::ASLH_cdnNotPt_V4 : - case Hexagon::ASRH_cNotPt_V4 : - case Hexagon::ASRH_cdnNotPt_V4 : - case Hexagon::SXTB_cNotPt_V4 : - case Hexagon::SXTB_cdnNotPt_V4 : - case Hexagon::SXTH_cNotPt_V4 : - case Hexagon::SXTH_cdnNotPt_V4 : - case Hexagon::ZXTB_cNotPt_V4 : - case Hexagon::ZXTB_cdnNotPt_V4 : - case Hexagon::ZXTH_cNotPt_V4 : - case Hexagon::ZXTH_cdnNotPt_V4 : + if (QII->isPredicatedTrue(MI)) + return PK_True; - case Hexagon::LDd_GP_cNotPt_V4 : - case Hexagon::LDb_GP_cNotPt_V4 : - case Hexagon::LDub_GP_cNotPt_V4 : - case Hexagon::LDh_GP_cNotPt_V4 : - case Hexagon::LDuh_GP_cNotPt_V4 : - case Hexagon::LDw_GP_cNotPt_V4 : - case Hexagon::STd_GP_cNotPt_V4 : - case Hexagon::STb_GP_cNotPt_V4 : - case Hexagon::STh_GP_cNotPt_V4 : - case Hexagon::STw_GP_cNotPt_V4 : - case Hexagon::LDd_GP_cdnNotPt_V4 : - case Hexagon::LDb_GP_cdnNotPt_V4 : - case Hexagon::LDub_GP_cdnNotPt_V4 : - case Hexagon::LDh_GP_cdnNotPt_V4 : - case Hexagon::LDuh_GP_cdnNotPt_V4 : - case Hexagon::LDw_GP_cdnNotPt_V4 : - case Hexagon::STd_GP_cdnNotPt_V4 : - case Hexagon::STb_GP_cdnNotPt_V4 : - case Hexagon::STh_GP_cdnNotPt_V4 : - case Hexagon::STw_GP_cdnNotPt_V4 : - return false; - } - // return *some value* to avoid compiler warning - return false; + return PK_False; } static MachineOperand& GetPostIncrementOperand(MachineInstr *MI, @@ -1842,7 +1326,7 @@ bool HexagonPacketizerList::CanPromoteToNewValueStore( MachineInstr *MI, if (( predRegNumDst != predRegNumSrc) || QII->isDotNewInst(PacketMI) != QII->isDotNewInst(MI) || - GetPredicateSense(MI, QII) != GetPredicateSense(PacketMI, QII)) { + getPredicateSense(MI, QII) != getPredicateSense(PacketMI, QII)) { return false; } } @@ -1968,7 +1452,7 @@ bool HexagonPacketizerList::CanPromoteToDotNew( MachineInstr *MI, else { // Create a dot new machine instruction to see if resources can be // allocated. If not, bail out now. - int NewOpcode = GetDotNewOp(MI->getOpcode()); + int NewOpcode = QII->GetDotNewOp(MI); const MCInstrDesc &desc = QII->get(NewOpcode); DebugLoc dl; MachineInstr *NewMI = @@ -2109,7 +1593,7 @@ bool HexagonPacketizerList::ArePredicatesComplements (MachineInstr* MI1, // We also need to differentiate .old vs. .new: // !p0 is not complimentary to p0.new return ((MI1->getOperand(1).getReg() == MI2->getOperand(1).getReg()) && - (GetPredicateSense(MI1, QII) != GetPredicateSense(MI2, QII)) && + (getPredicateSense(MI1, QII) != getPredicateSense(MI2, QII)) && (QII->isDotNewInst(MI1) == QII->isDotNewInst(MI2))); } diff --git a/llvm/test/CodeGen/Hexagon/pred-gp.ll b/llvm/test/CodeGen/Hexagon/pred-gp.ll new file mode 100644 index 000000000000..299bd8679dad --- /dev/null +++ b/llvm/test/CodeGen/Hexagon/pred-gp.ll @@ -0,0 +1,28 @@ +; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s +; Check that we are able to predicate instructions with gp-relative +; addressing mode. + +@d = external global i32 +@c = common global i32 0, align 4 + +; Function Attrs: nounwind +define i32 @test2(i8 zeroext %a, i8 zeroext %b) #0 { +; CHECK: if{{ *}}({{!*}}p{{[0-3]+}}{{[.new]*}}){{ *}}r{{[0-9]+}}{{ *}}={{ *}}memw(##{{[cd]}}) +; CHECK: if{{ *}}({{!*}}p{{[0-3]+}}){{ *}}r{{[0-9]+}}{{ *}}={{ *}}memw(##{{[cd]}}) +entry: + %cmp = icmp eq i8 %a, %b + br i1 %cmp, label %if.then, label %entry.if.end_crit_edge + +entry.if.end_crit_edge: + %.pre = load i32* @c, align 4 + br label %if.end + +if.then: + %0 = load i32* @d, align 4 + store i32 %0, i32* @c, align 4 + br label %if.end + +if.end: + %1 = phi i32 [ %.pre, %entry.if.end_crit_edge ], [ %0, %if.then ] + ret i32 %1 +} -- GitLab From b8a98241fce39b598799e4d2c79540e79e408b76 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 10 May 2013 20:29:50 +0000 Subject: [PATCH 192/467] PR15966: don't get confused by a complex integer -> complex integer conversion and misclassify it as a complex-real conversion. llvm-svn: 181626 --- clang/lib/Sema/SemaOverload.cpp | 2 +- clang/test/SemaCXX/complex-overload.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 3461f91ff316..dbe151c7828d 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1591,7 +1591,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, // Integral conversions (C++ 4.7). SCS.Second = ICK_Integral_Conversion; FromType = ToType.getUnqualifiedType(); - } else if (FromType->isAnyComplexType() && ToType->isComplexType()) { + } else if (FromType->isAnyComplexType() && ToType->isAnyComplexType()) { // Complex conversions (C99 6.3.1.6) SCS.Second = ICK_Complex_Conversion; FromType = ToType.getUnqualifiedType(); diff --git a/clang/test/SemaCXX/complex-overload.cpp b/clang/test/SemaCXX/complex-overload.cpp index 719a850dbf77..1381968751af 100644 --- a/clang/test/SemaCXX/complex-overload.cpp +++ b/clang/test/SemaCXX/complex-overload.cpp @@ -42,9 +42,15 @@ void test_promote_or_convert2(float _Complex fc) { int *cp = promote_or_convert2(fc); } -char *promote_or_convert3(int _Complex); -int *promote_or_convert3(long _Complex); +char *promote_or_convert3(int _Complex); // expected-note {{candidate}} +int *promote_or_convert3(long _Complex); // expected-note {{candidate}} void test_promote_or_convert3(short _Complex sc) { - char *cp = promote_or_convert3(sc); + char *cp1 = promote_or_convert3(sc); + char *cp2 = promote_or_convert3(1i); + int *cp3 = promote_or_convert3(1il); + int *cp4 = promote_or_convert3(1ill); // expected-error {{ambiguous}} } + +char &convert4(short _Complex); +char &test_convert4 = convert4(1i); -- GitLab From 28f36ba693841146514e7f4c11112827587f1952 Mon Sep 17 00:00:00 2001 From: Enea Zaffanella Date: Fri, 10 May 2013 20:34:44 +0000 Subject: [PATCH 193/467] Avoid patching storage class for block scope thread_local variables. llvm-svn: 181627 --- clang/include/clang/AST/Decl.h | 8 +++-- clang/lib/Sema/SemaDecl.cpp | 33 ++++++++++--------- .../test/SemaCXX/cxx11-thread-local-print.cpp | 6 ++++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index a0c76c069b86..d5e6ebee4a70 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -797,7 +797,8 @@ public: /// is a non-static local variable. bool hasLocalStorage() const { if (getStorageClass() == SC_None) - return !isFileVarDecl(); + // Second check is for C++11 [dcl.stc]p4. + return !isFileVarDecl() && getTSCSpec() != TSCS_thread_local; // Return true for: Auto, Register. // Return false for: Extern, Static, PrivateExtern, OpenCLWorkGroupLocal. @@ -808,7 +809,10 @@ public: /// isStaticLocal - Returns true if a variable with function scope is a /// static local variable. bool isStaticLocal() const { - return getStorageClass() == SC_Static && !isFileVarDecl(); + return (getStorageClass() == SC_Static || + // C++11 [dcl.stc]p4 + (getStorageClass() == SC_None && getTSCSpec() == TSCS_thread_local)) + && !isFileVarDecl(); } /// \brief Returns true if a variable has extern or __private_extern__ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d14b10559d9a..5d8839a65b2d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4718,16 +4718,6 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, SC = SC_None; } - // C++11 [dcl.stc]p4: - // When thread_local is applied to a variable of block scope the - // storage-class-specifier static is implied if it does not appear - // explicitly. - // Core issue: 'static' is not implied if the variable is declared 'extern'. - if (SCSpec == DeclSpec::SCS_unspecified && - D.getDeclSpec().getThreadStorageClassSpec() == - DeclSpec::TSCS_thread_local && DC->isFunctionOrMethod()) - SC = SC_Static; - IdentifierInfo *II = Name.getAsIdentifierInfo(); if (!II) { Diag(D.getIdentifierLoc(), diag::err_bad_variable_name) @@ -4885,11 +4875,22 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, NewVD->setLexicalDeclContext(CurContext); if (DeclSpec::TSCS TSCS = D.getDeclSpec().getThreadStorageClassSpec()) { - if (NewVD->hasLocalStorage()) - Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), - diag::err_thread_non_global) - << DeclSpec::getSpecifierName(TSCS); - else if (!Context.getTargetInfo().isTLSSupported()) + if (NewVD->hasLocalStorage()) { + // C++11 [dcl.stc]p4: + // When thread_local is applied to a variable of block scope the + // storage-class-specifier static is implied if it does not appear + // explicitly. + // Core issue: 'static' is not implied if the variable is declared + // 'extern'. + if (SCSpec == DeclSpec::SCS_unspecified && + TSCS == DeclSpec::TSCS_thread_local && + DC->isFunctionOrMethod()) + NewVD->setTSCSpec(TSCS); + else + Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), + diag::err_thread_non_global) + << DeclSpec::getSpecifierName(TSCS); + } else if (!Context.getTargetInfo().isTLSSupported()) Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_thread_unsupported); else @@ -5237,7 +5238,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { if (NewVD->isFileVarDecl()) Diag(NewVD->getLocation(), diag::err_vla_decl_in_file_scope) << SizeRange; - else if (NewVD->getStorageClass() == SC_Static) + else if (NewVD->isStaticLocal()) Diag(NewVD->getLocation(), diag::err_vla_decl_has_static_storage) << SizeRange; else diff --git a/clang/test/SemaCXX/cxx11-thread-local-print.cpp b/clang/test/SemaCXX/cxx11-thread-local-print.cpp index 9d9a82b7e6a4..1adafbda4905 100644 --- a/clang/test/SemaCXX/cxx11-thread-local-print.cpp +++ b/clang/test/SemaCXX/cxx11-thread-local-print.cpp @@ -7,3 +7,9 @@ __thread int gnu_tl; _Thread_local int c11_tl; thread_local int cxx11_tl; +// CHECK: void foo() { +// CHECK: thread_local int cxx11_tl; +// CHECK: } +void foo() { + thread_local int cxx11_tl; +} -- GitLab From 438cec566b97e8815a26ebd8bbe56c64a8bca687 Mon Sep 17 00:00:00 2001 From: Jyotsna Verma Date: Fri, 10 May 2013 20:58:11 +0000 Subject: [PATCH 194/467] Hexagon: Fix switch statements in GetDotOldOp and IsNewifyStore. No functionality change. llvm-svn: 181628 --- llvm/lib/Target/Hexagon/Hexagon.td | 24 + llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 35 + llvm/lib/Target/Hexagon/HexagonInstrInfo.h | 2 + .../Target/Hexagon/HexagonVLIWPacketizer.cpp | 727 +----------------- 4 files changed, 81 insertions(+), 707 deletions(-) diff --git a/llvm/lib/Target/Hexagon/Hexagon.td b/llvm/lib/Target/Hexagon/Hexagon.td index 6c7f963b5341..568798c3a412 100644 --- a/llvm/lib/Target/Hexagon/Hexagon.td +++ b/llvm/lib/Target/Hexagon/Hexagon.td @@ -119,6 +119,18 @@ def getPredNewOpcode : InstrMapping { let ValueCols = [["new"]]; } +//===----------------------------------------------------------------------===// +// Generate mapping table to relate .new predicated instructions with their old +// format. +// +def getPredOldOpcode : InstrMapping { + let FilterClass = "PredNewRel"; + let RowFields = ["BaseOpcode", "PredSense", "isNVStore"]; + let ColFields = ["PNewValue"]; + let KeyCol = ["new"]; + let ValueCols = [[""]]; +} + //===----------------------------------------------------------------------===// // Generate mapping table to relate store instructions with their new-value // format. @@ -131,6 +143,18 @@ def getNewValueOpcode : InstrMapping { let ValueCols = [["true"]]; } +//===----------------------------------------------------------------------===// +// Generate mapping table to relate new-value store instructions with their old +// format. +// +def getNonNVStore : InstrMapping { + let FilterClass = "NewValueRel"; + let RowFields = ["BaseOpcode", "PredSense", "PNewValue"]; + let ColFields = ["NValueST"]; + let KeyCol = ["true"]; + let ValueCols = [["false"]]; +} + def getBasedWithImmOffset : InstrMapping { let FilterClass = "AddrModeRel"; let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore", diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp index 7dec127453cf..33a937308d4f 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -1027,6 +1027,16 @@ bool HexagonInstrInfo::isPredicatedNew(unsigned Opcode) const { return ((F >> HexagonII::PredicatedNewPos) & HexagonII::PredicatedNewMask); } +// Returns true, if a ST insn can be promoted to a new-value store. +bool HexagonInstrInfo::mayBeNewStore(const MachineInstr *MI) const { + const HexagonRegisterInfo& QRI = getRegisterInfo(); + const uint64_t F = MI->getDesc().TSFlags; + + return ((F >> HexagonII::mayNVStorePos) & + HexagonII::mayNVStoreMask & + QRI.Subtarget.hasV4TOps()); +} + bool HexagonInstrInfo::DefinesPredicate(MachineInstr *MI, std::vector &Pred) const { @@ -1520,6 +1530,31 @@ bool HexagonInstrInfo::isDotNewInst (const MachineInstr* MI) const { (isPredicated(MI) && isPredicatedNew(MI))); } +// Returns the most basic instruction for the .new predicated instructions and +// new-value stores. +// For example, all of the following instructions will be converted back to the +// same instruction: +// 1) if (p0.new) memw(R0+#0) = R1.new ---> +// 2) if (p0) memw(R0+#0)= R1.new -------> if (p0) memw(R0+#0) = R1 +// 3) if (p0.new) memw(R0+#0) = R1 ---> +// + +int HexagonInstrInfo::GetDotOldOp(const int opc) const { + int NewOp = opc; + if (isPredicated(NewOp) && isPredicatedNew(NewOp)) { // Get predicate old form + NewOp = Hexagon::getPredOldOpcode(NewOp); + if (NewOp < 0) + assert(0 && "Couldn't change predicate new instruction to its old form."); + } + + if (isNewValueStore(NewOp)) { // Convert into non new-value format + NewOp = Hexagon::getNonNVStore(NewOp); + if (NewOp < 0) + assert(0 && "Couldn't change new-value store to its old form."); + } + return NewOp; +} + // Return the new value instruction for a given store. int HexagonInstrInfo::GetDotNewOp(const MachineInstr* MI) const { int NVOpcode = Hexagon::getNewValueOpcode(MI->getOpcode()); diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h index f3297fbd335d..d1209dec3b3a 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h @@ -185,10 +185,12 @@ public: bool isNewValueInst(const MachineInstr* MI) const; bool isNewValue(const MachineInstr* MI) const; bool isDotNewInst(const MachineInstr* MI) const; + int GetDotOldOp(const int opc) const; int GetDotNewOp(const MachineInstr* MI) const; int GetDotNewPredOp(MachineInstr *MI, const MachineBranchProbabilityInfo *MBPI) const; + bool mayBeNewStore(const MachineInstr* MI) const; bool isDeallocRet(const MachineInstr *MI) const; unsigned getInvertedPredicatedOpcode(const int Opc) const; bool isExtendable(const MachineInstr* MI) const; diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index 6ed9d551352c..c508d124b333 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -164,7 +164,6 @@ namespace { unsigned, std::map ); bool isNewifiable(MachineInstr* MI); bool isCondInst(MachineInstr* MI); - bool IsNewifyStore (MachineInstr* MI); bool tryAllocateResourcesForConstExt(MachineInstr* MI); bool canReserveResourcesForConstExt(MachineInstr *MI); void reserveResourcesForConstExt(MachineInstr* MI); @@ -383,104 +382,6 @@ static bool IsControlFlow(MachineInstr* MI) { return (MI->getDesc().isTerminator() || MI->getDesc().isCall()); } -// Function returns true if an instruction can be promoted to the new-value -// store. It will always return false for v2 and v3. -// It lists all the conditional and unconditional stores that can be promoted -// to the new-value stores. - -bool HexagonPacketizerList::IsNewifyStore (MachineInstr* MI) { - const HexagonRegisterInfo* QRI = - (const HexagonRegisterInfo *) TM.getRegisterInfo(); - switch (MI->getOpcode()) - { - // store byte - case Hexagon::STrib: - case Hexagon::STrib_indexed: - case Hexagon::STrib_indexed_shl_V4: - case Hexagon::STrib_shl_V4: - case Hexagon::STb_GP_V4: - case Hexagon::POST_STbri: - case Hexagon::STrib_cPt: - case Hexagon::STrib_cdnPt_V4: - case Hexagon::STrib_cNotPt: - case Hexagon::STrib_cdnNotPt_V4: - case Hexagon::STrib_indexed_cPt: - case Hexagon::STrib_indexed_cdnPt_V4: - case Hexagon::STrib_indexed_cNotPt: - case Hexagon::STrib_indexed_cdnNotPt_V4: - case Hexagon::STrib_indexed_shl_cPt_V4: - case Hexagon::STrib_indexed_shl_cdnPt_V4: - case Hexagon::STrib_indexed_shl_cNotPt_V4: - case Hexagon::STrib_indexed_shl_cdnNotPt_V4: - case Hexagon::POST_STbri_cPt: - case Hexagon::POST_STbri_cdnPt_V4: - case Hexagon::POST_STbri_cNotPt: - case Hexagon::POST_STbri_cdnNotPt_V4: - case Hexagon::STb_GP_cPt_V4: - case Hexagon::STb_GP_cNotPt_V4: - case Hexagon::STb_GP_cdnPt_V4: - case Hexagon::STb_GP_cdnNotPt_V4: - - // store halfword - case Hexagon::STrih: - case Hexagon::STrih_indexed: - case Hexagon::STrih_indexed_shl_V4: - case Hexagon::STrih_shl_V4: - case Hexagon::STh_GP_V4: - case Hexagon::POST_SThri: - case Hexagon::STrih_cPt: - case Hexagon::STrih_cdnPt_V4: - case Hexagon::STrih_cNotPt: - case Hexagon::STrih_cdnNotPt_V4: - case Hexagon::STrih_indexed_cPt: - case Hexagon::STrih_indexed_cdnPt_V4: - case Hexagon::STrih_indexed_cNotPt: - case Hexagon::STrih_indexed_cdnNotPt_V4: - case Hexagon::STrih_indexed_shl_cPt_V4: - case Hexagon::STrih_indexed_shl_cdnPt_V4: - case Hexagon::STrih_indexed_shl_cNotPt_V4: - case Hexagon::STrih_indexed_shl_cdnNotPt_V4: - case Hexagon::POST_SThri_cPt: - case Hexagon::POST_SThri_cdnPt_V4: - case Hexagon::POST_SThri_cNotPt: - case Hexagon::POST_SThri_cdnNotPt_V4: - case Hexagon::STh_GP_cPt_V4: - case Hexagon::STh_GP_cNotPt_V4: - case Hexagon::STh_GP_cdnPt_V4: - case Hexagon::STh_GP_cdnNotPt_V4: - - // store word - case Hexagon::STriw: - case Hexagon::STriw_indexed: - case Hexagon::STriw_indexed_shl_V4: - case Hexagon::STriw_shl_V4: - case Hexagon::STw_GP_V4: - case Hexagon::POST_STwri: - case Hexagon::STriw_cPt: - case Hexagon::STriw_cdnPt_V4: - case Hexagon::STriw_cNotPt: - case Hexagon::STriw_cdnNotPt_V4: - case Hexagon::STriw_indexed_cPt: - case Hexagon::STriw_indexed_cdnPt_V4: - case Hexagon::STriw_indexed_cNotPt: - case Hexagon::STriw_indexed_cdnNotPt_V4: - case Hexagon::STriw_indexed_shl_cPt_V4: - case Hexagon::STriw_indexed_shl_cdnPt_V4: - case Hexagon::STriw_indexed_shl_cNotPt_V4: - case Hexagon::STriw_indexed_shl_cdnNotPt_V4: - case Hexagon::POST_STwri_cPt: - case Hexagon::POST_STwri_cdnPt_V4: - case Hexagon::POST_STwri_cNotPt: - case Hexagon::POST_STwri_cdnNotPt_V4: - case Hexagon::STw_GP_cPt_V4: - case Hexagon::STw_GP_cNotPt_V4: - case Hexagon::STw_GP_cdnPt_V4: - case Hexagon::STw_GP_cdnNotPt_V4: - return QRI->Subtarget.hasV4TOps(); - } - return false; -} - static bool IsLoopN(MachineInstr *MI) { return (MI->getOpcode() == Hexagon::LOOP0_i || MI->getOpcode() == Hexagon::LOOP0_r); @@ -501,7 +402,8 @@ static bool DoesModifyCalleeSavedReg(MachineInstr *MI, // Returns true if an instruction can be promoted to .new predicate // or new-value store. bool HexagonPacketizerList::isNewifiable(MachineInstr* MI) { - if ( isCondInst(MI) || IsNewifyStore(MI)) + const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII; + if ( isCondInst(MI) || QII->mayBeNewStore(MI)) return true; else return false; @@ -543,595 +445,9 @@ bool HexagonPacketizerList::PromoteToDotNew(MachineInstr* MI, return true; } -// Returns the most basic instruction for the .new predicated instructions and -// new-value stores. -// For example, all of the following instructions will be converted back to the -// same instruction: -// 1) if (p0.new) memw(R0+#0) = R1.new ---> -// 2) if (p0) memw(R0+#0)= R1.new -------> if (p0) memw(R0+#0) = R1 -// 3) if (p0.new) memw(R0+#0) = R1 ---> -// -// To understand the translation of instruction 1 to its original form, consider -// a packet with 3 instructions. -// { p0 = cmp.eq(R0,R1) -// if (p0.new) R2 = add(R3, R4) -// R5 = add (R3, R1) -// } -// if (p0) memw(R5+#0) = R2 <--- trying to include it in the previous packet -// -// This instruction can be part of the previous packet only if both p0 and R2 -// are promoted to .new values. This promotion happens in steps, first -// predicate register is promoted to .new and in the next iteration R2 is -// promoted. Therefore, in case of dependence check failure (due to R5) during -// next iteration, it should be converted back to its most basic form. - -static int GetDotOldOp(const int opc) { - switch (opc) { - default: llvm_unreachable("Unknown .old type"); - case Hexagon::TFR_cdnPt: - return Hexagon::TFR_cPt; - - case Hexagon::TFR_cdnNotPt: - return Hexagon::TFR_cNotPt; - - case Hexagon::TFRI_cdnPt: - return Hexagon::TFRI_cPt; - - case Hexagon::TFRI_cdnNotPt: - return Hexagon::TFRI_cNotPt; - - case Hexagon::JMP_tnew_t: - return Hexagon::JMP_t; - - case Hexagon::JMP_fnew_t: - return Hexagon::JMP_f; - - case Hexagon::JMPR_tnew_tV3: - return Hexagon::JMPR_t; - - case Hexagon::JMPR_fnew_tV3: - return Hexagon::JMPR_f; - - // Load double word - - case Hexagon::LDrid_cdnPt : - return Hexagon::LDrid_cPt; - - case Hexagon::LDrid_cdnNotPt : - return Hexagon::LDrid_cNotPt; - - case Hexagon::LDrid_indexed_cdnPt : - return Hexagon::LDrid_indexed_cPt; - - case Hexagon::LDrid_indexed_cdnNotPt : - return Hexagon::LDrid_indexed_cNotPt; - - case Hexagon::POST_LDrid_cdnPt_V4 : - return Hexagon::POST_LDrid_cPt; - - case Hexagon::POST_LDrid_cdnNotPt_V4 : - return Hexagon::POST_LDrid_cNotPt; - - // Load word - - case Hexagon::LDriw_cdnPt : - return Hexagon::LDriw_cPt; - - case Hexagon::LDriw_cdnNotPt : - return Hexagon::LDriw_cNotPt; - - case Hexagon::LDriw_indexed_cdnPt : - return Hexagon::LDriw_indexed_cPt; - - case Hexagon::LDriw_indexed_cdnNotPt : - return Hexagon::LDriw_indexed_cNotPt; - - case Hexagon::POST_LDriw_cdnPt_V4 : - return Hexagon::POST_LDriw_cPt; - - case Hexagon::POST_LDriw_cdnNotPt_V4 : - return Hexagon::POST_LDriw_cNotPt; - - // Load half - - case Hexagon::LDrih_cdnPt : - return Hexagon::LDrih_cPt; - - case Hexagon::LDrih_cdnNotPt : - return Hexagon::LDrih_cNotPt; - - case Hexagon::LDrih_indexed_cdnPt : - return Hexagon::LDrih_indexed_cPt; - - case Hexagon::LDrih_indexed_cdnNotPt : - return Hexagon::LDrih_indexed_cNotPt; - - case Hexagon::POST_LDrih_cdnPt_V4 : - return Hexagon::POST_LDrih_cPt; - - case Hexagon::POST_LDrih_cdnNotPt_V4 : - return Hexagon::POST_LDrih_cNotPt; - - // Load byte - - case Hexagon::LDrib_cdnPt : - return Hexagon::LDrib_cPt; - - case Hexagon::LDrib_cdnNotPt : - return Hexagon::LDrib_cNotPt; - - case Hexagon::LDrib_indexed_cdnPt : - return Hexagon::LDrib_indexed_cPt; - - case Hexagon::LDrib_indexed_cdnNotPt : - return Hexagon::LDrib_indexed_cNotPt; - - case Hexagon::POST_LDrib_cdnPt_V4 : - return Hexagon::POST_LDrib_cPt; - - case Hexagon::POST_LDrib_cdnNotPt_V4 : - return Hexagon::POST_LDrib_cNotPt; - - // Load unsigned half - - case Hexagon::LDriuh_cdnPt : - return Hexagon::LDriuh_cPt; - - case Hexagon::LDriuh_cdnNotPt : - return Hexagon::LDriuh_cNotPt; - - case Hexagon::LDriuh_indexed_cdnPt : - return Hexagon::LDriuh_indexed_cPt; - - case Hexagon::LDriuh_indexed_cdnNotPt : - return Hexagon::LDriuh_indexed_cNotPt; - - case Hexagon::POST_LDriuh_cdnPt_V4 : - return Hexagon::POST_LDriuh_cPt; - - case Hexagon::POST_LDriuh_cdnNotPt_V4 : - return Hexagon::POST_LDriuh_cNotPt; - - // Load unsigned byte - case Hexagon::LDriub_cdnPt : - return Hexagon::LDriub_cPt; - - case Hexagon::LDriub_cdnNotPt : - return Hexagon::LDriub_cNotPt; - - case Hexagon::LDriub_indexed_cdnPt : - return Hexagon::LDriub_indexed_cPt; - - case Hexagon::LDriub_indexed_cdnNotPt : - return Hexagon::LDriub_indexed_cNotPt; - - case Hexagon::POST_LDriub_cdnPt_V4 : - return Hexagon::POST_LDriub_cPt; - - case Hexagon::POST_LDriub_cdnNotPt_V4 : - return Hexagon::POST_LDriub_cNotPt; - - // V4 indexed+scaled Load - - case Hexagon::LDrid_indexed_shl_cdnPt_V4 : - return Hexagon::LDrid_indexed_shl_cPt_V4; - - case Hexagon::LDrid_indexed_shl_cdnNotPt_V4 : - return Hexagon::LDrid_indexed_shl_cNotPt_V4; - - case Hexagon::LDrib_indexed_shl_cdnPt_V4 : - return Hexagon::LDrib_indexed_shl_cPt_V4; - - case Hexagon::LDrib_indexed_shl_cdnNotPt_V4 : - return Hexagon::LDrib_indexed_shl_cNotPt_V4; - - case Hexagon::LDriub_indexed_shl_cdnPt_V4 : - return Hexagon::LDriub_indexed_shl_cPt_V4; - - case Hexagon::LDriub_indexed_shl_cdnNotPt_V4 : - return Hexagon::LDriub_indexed_shl_cNotPt_V4; - - case Hexagon::LDrih_indexed_shl_cdnPt_V4 : - return Hexagon::LDrih_indexed_shl_cPt_V4; - - case Hexagon::LDrih_indexed_shl_cdnNotPt_V4 : - return Hexagon::LDrih_indexed_shl_cNotPt_V4; - - case Hexagon::LDriuh_indexed_shl_cdnPt_V4 : - return Hexagon::LDriuh_indexed_shl_cPt_V4; - - case Hexagon::LDriuh_indexed_shl_cdnNotPt_V4 : - return Hexagon::LDriuh_indexed_shl_cNotPt_V4; - - case Hexagon::LDriw_indexed_shl_cdnPt_V4 : - return Hexagon::LDriw_indexed_shl_cPt_V4; - - case Hexagon::LDriw_indexed_shl_cdnNotPt_V4 : - return Hexagon::LDriw_indexed_shl_cNotPt_V4; - - // V4 global address load - - case Hexagon::LDd_GP_cdnPt_V4: - return Hexagon::LDd_GP_cPt_V4; - - case Hexagon::LDd_GP_cdnNotPt_V4: - return Hexagon::LDd_GP_cNotPt_V4; - - case Hexagon::LDb_GP_cdnPt_V4: - return Hexagon::LDb_GP_cPt_V4; - - case Hexagon::LDb_GP_cdnNotPt_V4: - return Hexagon::LDb_GP_cNotPt_V4; - - case Hexagon::LDub_GP_cdnPt_V4: - return Hexagon::LDub_GP_cPt_V4; - - case Hexagon::LDub_GP_cdnNotPt_V4: - return Hexagon::LDub_GP_cNotPt_V4; - - case Hexagon::LDh_GP_cdnPt_V4: - return Hexagon::LDh_GP_cPt_V4; - - case Hexagon::LDh_GP_cdnNotPt_V4: - return Hexagon::LDh_GP_cNotPt_V4; - - case Hexagon::LDuh_GP_cdnPt_V4: - return Hexagon::LDuh_GP_cPt_V4; - - case Hexagon::LDuh_GP_cdnNotPt_V4: - return Hexagon::LDuh_GP_cNotPt_V4; - - case Hexagon::LDw_GP_cdnPt_V4: - return Hexagon::LDw_GP_cPt_V4; - - case Hexagon::LDw_GP_cdnNotPt_V4: - return Hexagon::LDw_GP_cNotPt_V4; - - // Conditional add - - case Hexagon::ADD_ri_cdnPt : - return Hexagon::ADD_ri_cPt; - case Hexagon::ADD_ri_cdnNotPt : - return Hexagon::ADD_ri_cNotPt; - - case Hexagon::ADD_rr_cdnPt : - return Hexagon::ADD_rr_cPt; - case Hexagon::ADD_rr_cdnNotPt: - return Hexagon::ADD_rr_cNotPt; - - // Conditional logical Operations - - case Hexagon::XOR_rr_cdnPt : - return Hexagon::XOR_rr_cPt; - case Hexagon::XOR_rr_cdnNotPt : - return Hexagon::XOR_rr_cNotPt; - - case Hexagon::AND_rr_cdnPt : - return Hexagon::AND_rr_cPt; - case Hexagon::AND_rr_cdnNotPt : - return Hexagon::AND_rr_cNotPt; - - case Hexagon::OR_rr_cdnPt : - return Hexagon::OR_rr_cPt; - case Hexagon::OR_rr_cdnNotPt : - return Hexagon::OR_rr_cNotPt; - - // Conditional Subtract - - case Hexagon::SUB_rr_cdnPt : - return Hexagon::SUB_rr_cPt; - case Hexagon::SUB_rr_cdnNotPt : - return Hexagon::SUB_rr_cNotPt; - - // Conditional combine - - case Hexagon::COMBINE_rr_cdnPt : - return Hexagon::COMBINE_rr_cPt; - case Hexagon::COMBINE_rr_cdnNotPt : - return Hexagon::COMBINE_rr_cNotPt; - -// Conditional shift operations - - case Hexagon::ASLH_cdnPt_V4 : - return Hexagon::ASLH_cPt_V4; - case Hexagon::ASLH_cdnNotPt_V4 : - return Hexagon::ASLH_cNotPt_V4; - - case Hexagon::ASRH_cdnPt_V4 : - return Hexagon::ASRH_cPt_V4; - case Hexagon::ASRH_cdnNotPt_V4 : - return Hexagon::ASRH_cNotPt_V4; - - case Hexagon::SXTB_cdnPt_V4 : - return Hexagon::SXTB_cPt_V4; - case Hexagon::SXTB_cdnNotPt_V4 : - return Hexagon::SXTB_cNotPt_V4; - - case Hexagon::SXTH_cdnPt_V4 : - return Hexagon::SXTH_cPt_V4; - case Hexagon::SXTH_cdnNotPt_V4 : - return Hexagon::SXTH_cNotPt_V4; - - case Hexagon::ZXTB_cdnPt_V4 : - return Hexagon::ZXTB_cPt_V4; - case Hexagon::ZXTB_cdnNotPt_V4 : - return Hexagon::ZXTB_cNotPt_V4; - - case Hexagon::ZXTH_cdnPt_V4 : - return Hexagon::ZXTH_cPt_V4; - case Hexagon::ZXTH_cdnNotPt_V4 : - return Hexagon::ZXTH_cNotPt_V4; - - // Store byte - - case Hexagon::STrib_imm_cdnPt_V4 : - return Hexagon::STrib_imm_cPt_V4; - - case Hexagon::STrib_imm_cdnNotPt_V4 : - return Hexagon::STrib_imm_cNotPt_V4; - - case Hexagon::STrib_cdnPt_nv_V4 : - case Hexagon::STrib_cPt_nv_V4 : - case Hexagon::STrib_cdnPt_V4 : - return Hexagon::STrib_cPt; - - case Hexagon::STrib_cdnNotPt_nv_V4 : - case Hexagon::STrib_cNotPt_nv_V4 : - case Hexagon::STrib_cdnNotPt_V4 : - return Hexagon::STrib_cNotPt; - - case Hexagon::STrib_indexed_cdnPt_V4 : - case Hexagon::STrib_indexed_cPt_nv_V4 : - case Hexagon::STrib_indexed_cdnPt_nv_V4 : - return Hexagon::STrib_indexed_cPt; - - case Hexagon::STrib_indexed_cdnNotPt_V4 : - case Hexagon::STrib_indexed_cNotPt_nv_V4 : - case Hexagon::STrib_indexed_cdnNotPt_nv_V4 : - return Hexagon::STrib_indexed_cNotPt; - - case Hexagon::STrib_indexed_shl_cdnPt_nv_V4: - case Hexagon::STrib_indexed_shl_cPt_nv_V4 : - case Hexagon::STrib_indexed_shl_cdnPt_V4 : - return Hexagon::STrib_indexed_shl_cPt_V4; - - case Hexagon::STrib_indexed_shl_cdnNotPt_nv_V4: - case Hexagon::STrib_indexed_shl_cNotPt_nv_V4 : - case Hexagon::STrib_indexed_shl_cdnNotPt_V4 : - return Hexagon::STrib_indexed_shl_cNotPt_V4; - - case Hexagon::POST_STbri_cdnPt_nv_V4 : - case Hexagon::POST_STbri_cPt_nv_V4 : - case Hexagon::POST_STbri_cdnPt_V4 : - return Hexagon::POST_STbri_cPt; - - case Hexagon::POST_STbri_cdnNotPt_nv_V4 : - case Hexagon::POST_STbri_cNotPt_nv_V4: - case Hexagon::POST_STbri_cdnNotPt_V4 : - return Hexagon::POST_STbri_cNotPt; - - case Hexagon::STb_GP_cdnPt_nv_V4: - case Hexagon::STb_GP_cdnPt_V4: - case Hexagon::STb_GP_cPt_nv_V4: - return Hexagon::STb_GP_cPt_V4; - - case Hexagon::STb_GP_cdnNotPt_nv_V4: - case Hexagon::STb_GP_cdnNotPt_V4: - case Hexagon::STb_GP_cNotPt_nv_V4: - return Hexagon::STb_GP_cNotPt_V4; - - // Store new-value byte - unconditional - case Hexagon::STrib_nv_V4: - return Hexagon::STrib; - - case Hexagon::STrib_indexed_nv_V4: - return Hexagon::STrib_indexed; - - case Hexagon::STrib_indexed_shl_nv_V4: - return Hexagon::STrib_indexed_shl_V4; - - case Hexagon::STrib_shl_nv_V4: - return Hexagon::STrib_shl_V4; - - case Hexagon::STb_GP_nv_V4: - return Hexagon::STb_GP_V4; - - case Hexagon::POST_STbri_nv_V4: - return Hexagon::POST_STbri; - - // Store halfword - case Hexagon::STrih_imm_cdnPt_V4 : - return Hexagon::STrih_imm_cPt_V4; - - case Hexagon::STrih_imm_cdnNotPt_V4 : - return Hexagon::STrih_imm_cNotPt_V4; - - case Hexagon::STrih_cdnPt_nv_V4 : - case Hexagon::STrih_cPt_nv_V4 : - case Hexagon::STrih_cdnPt_V4 : - return Hexagon::STrih_cPt; - - case Hexagon::STrih_cdnNotPt_nv_V4 : - case Hexagon::STrih_cNotPt_nv_V4 : - case Hexagon::STrih_cdnNotPt_V4 : - return Hexagon::STrih_cNotPt; - - case Hexagon::STrih_indexed_cdnPt_nv_V4: - case Hexagon::STrih_indexed_cPt_nv_V4 : - case Hexagon::STrih_indexed_cdnPt_V4 : - return Hexagon::STrih_indexed_cPt; - - case Hexagon::STrih_indexed_cdnNotPt_nv_V4: - case Hexagon::STrih_indexed_cNotPt_nv_V4 : - case Hexagon::STrih_indexed_cdnNotPt_V4 : - return Hexagon::STrih_indexed_cNotPt; - - case Hexagon::STrih_indexed_shl_cdnPt_nv_V4 : - case Hexagon::STrih_indexed_shl_cPt_nv_V4 : - case Hexagon::STrih_indexed_shl_cdnPt_V4 : - return Hexagon::STrih_indexed_shl_cPt_V4; - - case Hexagon::STrih_indexed_shl_cdnNotPt_nv_V4 : - case Hexagon::STrih_indexed_shl_cNotPt_nv_V4 : - case Hexagon::STrih_indexed_shl_cdnNotPt_V4 : - return Hexagon::STrih_indexed_shl_cNotPt_V4; - - case Hexagon::POST_SThri_cdnPt_nv_V4 : - case Hexagon::POST_SThri_cPt_nv_V4 : - case Hexagon::POST_SThri_cdnPt_V4 : - return Hexagon::POST_SThri_cPt; - - case Hexagon::POST_SThri_cdnNotPt_nv_V4 : - case Hexagon::POST_SThri_cNotPt_nv_V4 : - case Hexagon::POST_SThri_cdnNotPt_V4 : - return Hexagon::POST_SThri_cNotPt; - - case Hexagon::STh_GP_cdnPt_nv_V4: - case Hexagon::STh_GP_cdnPt_V4: - case Hexagon::STh_GP_cPt_nv_V4: - return Hexagon::STh_GP_cPt_V4; - - case Hexagon::STh_GP_cdnNotPt_nv_V4: - case Hexagon::STh_GP_cdnNotPt_V4: - case Hexagon::STh_GP_cNotPt_nv_V4: - return Hexagon::STh_GP_cNotPt_V4; - - // Store new-value halfword - unconditional - - case Hexagon::STrih_nv_V4: - return Hexagon::STrih; - - case Hexagon::STrih_indexed_nv_V4: - return Hexagon::STrih_indexed; - - case Hexagon::STrih_indexed_shl_nv_V4: - return Hexagon::STrih_indexed_shl_V4; - - case Hexagon::STrih_shl_nv_V4: - return Hexagon::STrih_shl_V4; - - case Hexagon::STh_GP_nv_V4: - return Hexagon::STh_GP_V4; - - case Hexagon::POST_SThri_nv_V4: - return Hexagon::POST_SThri; - - // Store word - - case Hexagon::STriw_imm_cdnPt_V4 : - return Hexagon::STriw_imm_cPt_V4; - - case Hexagon::STriw_imm_cdnNotPt_V4 : - return Hexagon::STriw_imm_cNotPt_V4; - - case Hexagon::STriw_cdnPt_nv_V4 : - case Hexagon::STriw_cPt_nv_V4 : - case Hexagon::STriw_cdnPt_V4 : - return Hexagon::STriw_cPt; - - case Hexagon::STriw_cdnNotPt_nv_V4 : - case Hexagon::STriw_cNotPt_nv_V4 : - case Hexagon::STriw_cdnNotPt_V4 : - return Hexagon::STriw_cNotPt; - - case Hexagon::STriw_indexed_cdnPt_nv_V4 : - case Hexagon::STriw_indexed_cPt_nv_V4 : - case Hexagon::STriw_indexed_cdnPt_V4 : - return Hexagon::STriw_indexed_cPt; - - case Hexagon::STriw_indexed_cdnNotPt_nv_V4 : - case Hexagon::STriw_indexed_cNotPt_nv_V4 : - case Hexagon::STriw_indexed_cdnNotPt_V4 : - return Hexagon::STriw_indexed_cNotPt; - - case Hexagon::STriw_indexed_shl_cdnPt_nv_V4 : - case Hexagon::STriw_indexed_shl_cPt_nv_V4 : - case Hexagon::STriw_indexed_shl_cdnPt_V4 : - return Hexagon::STriw_indexed_shl_cPt_V4; - - case Hexagon::STriw_indexed_shl_cdnNotPt_nv_V4 : - case Hexagon::STriw_indexed_shl_cNotPt_nv_V4 : - case Hexagon::STriw_indexed_shl_cdnNotPt_V4 : - return Hexagon::STriw_indexed_shl_cNotPt_V4; - - case Hexagon::POST_STwri_cdnPt_nv_V4 : - case Hexagon::POST_STwri_cPt_nv_V4 : - case Hexagon::POST_STwri_cdnPt_V4 : - return Hexagon::POST_STwri_cPt; - - case Hexagon::POST_STwri_cdnNotPt_nv_V4 : - case Hexagon::POST_STwri_cNotPt_nv_V4 : - case Hexagon::POST_STwri_cdnNotPt_V4 : - return Hexagon::POST_STwri_cNotPt; - - case Hexagon::STw_GP_cdnPt_nv_V4: - case Hexagon::STw_GP_cdnPt_V4: - case Hexagon::STw_GP_cPt_nv_V4: - return Hexagon::STw_GP_cPt_V4; - - case Hexagon::STw_GP_cdnNotPt_nv_V4: - case Hexagon::STw_GP_cdnNotPt_V4: - case Hexagon::STw_GP_cNotPt_nv_V4: - return Hexagon::STw_GP_cNotPt_V4; - - // Store new-value word - unconditional - - case Hexagon::STriw_nv_V4: - return Hexagon::STriw; - - case Hexagon::STriw_indexed_nv_V4: - return Hexagon::STriw_indexed; - - case Hexagon::STriw_indexed_shl_nv_V4: - return Hexagon::STriw_indexed_shl_V4; - - case Hexagon::STriw_shl_nv_V4: - return Hexagon::STriw_shl_V4; - - case Hexagon::STw_GP_nv_V4: - return Hexagon::STw_GP_V4; - - case Hexagon::POST_STwri_nv_V4: - return Hexagon::POST_STwri; - - // Store doubleword - - case Hexagon::STrid_cdnPt_V4 : - return Hexagon::STrid_cPt; - - case Hexagon::STrid_cdnNotPt_V4 : - return Hexagon::STrid_cNotPt; - - case Hexagon::STrid_indexed_cdnPt_V4 : - return Hexagon::STrid_indexed_cPt; - - case Hexagon::STrid_indexed_cdnNotPt_V4 : - return Hexagon::STrid_indexed_cNotPt; - - case Hexagon::STrid_indexed_shl_cdnPt_V4 : - return Hexagon::STrid_indexed_shl_cPt_V4; - - case Hexagon::STrid_indexed_shl_cdnNotPt_V4 : - return Hexagon::STrid_indexed_shl_cNotPt_V4; - - case Hexagon::POST_STdri_cdnPt_V4 : - return Hexagon::POST_STdri_cPt; - - case Hexagon::POST_STdri_cdnNotPt_V4 : - return Hexagon::POST_STdri_cNotPt; - - case Hexagon::STd_GP_cdnPt_V4 : - return Hexagon::STd_GP_cPt_V4; - - case Hexagon::STd_GP_cdnNotPt_V4 : - return Hexagon::STd_GP_cNotPt_V4; - - } -} - bool HexagonPacketizerList::DemoteToDotOld(MachineInstr* MI) { const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII; - int NewOpcode = GetDotOldOp(MI->getOpcode()); + int NewOpcode = QII->GetDotOldOp(MI->getOpcode()); MI->setDesc(QII->get(NewOpcode)); return true; } @@ -1221,10 +537,10 @@ static MachineOperand& GetStoreValueOperand(MachineInstr *MI) { // Arch Spec: 3.4.4.2 bool HexagonPacketizerList::CanPromoteToNewValueStore( MachineInstr *MI, MachineInstr *PacketMI, unsigned DepReg, - std::map MIToSUnit) -{ - // Make sure we are looking at the store - if (!IsNewifyStore(MI)) + std::map MIToSUnit) { + const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII; + // Make sure we are looking at the store, that can be promoted. + if (!QII->mayBeNewStore(MI)) return false; // Make sure there is dependency and can be new value'ed @@ -1232,12 +548,11 @@ bool HexagonPacketizerList::CanPromoteToNewValueStore( MachineInstr *MI, GetStoreValueOperand(MI).getReg() != DepReg) return false; - const HexagonRegisterInfo* QRI = + const HexagonRegisterInfo* QRI = (const HexagonRegisterInfo *) TM.getRegisterInfo(); const MCInstrDesc& MCID = PacketMI->getDesc(); // first operand is always the result - const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII; const TargetRegisterClass* PacketRC = QII->getRegClass(MCID, 0, QRI, MF); // if there is already an store in the packet, no can do new value store @@ -1280,7 +595,7 @@ bool HexagonPacketizerList::CanPromoteToNewValueStore( MachineInstr *MI, } // If the source that feeds the store is predicated, new value store must - // also be also predicated. + // also be predicated. if (QII->isPredicated(PacketMI)) { if (!QII->isPredicated(MI)) return false; @@ -1407,10 +722,11 @@ bool HexagonPacketizerList::CanPromoteToNewValue( MachineInstr *MI, MachineBasicBlock::iterator &MII) { + const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII; const HexagonRegisterInfo* QRI = (const HexagonRegisterInfo *) TM.getRegisterInfo(); if (!QRI->Subtarget.hasV4TOps() || - !IsNewifyStore(MI)) + !QII->mayBeNewStore(MI)) return false; MachineInstr *PacketMI = PacketSU->getInstr(); @@ -1437,7 +753,7 @@ bool HexagonPacketizerList::CanPromoteToDotNew( MachineInstr *MI, { const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII; // Already a dot new instruction. - if (QII->isDotNewInst(MI) && !IsNewifyStore(MI)) + if (QII->isDotNewInst(MI) && !QII->mayBeNewStore(MI)) return false; if (!isNewifiable(MI)) @@ -1447,7 +763,7 @@ bool HexagonPacketizerList::CanPromoteToDotNew( MachineInstr *MI, if (RC == &Hexagon::PredRegsRegClass && isCondInst(MI)) return true; else if (RC != &Hexagon::PredRegsRegClass && - !IsNewifyStore(MI)) // MI is not a new-value store + !QII->mayBeNewStore(MI)) // MI is not a new-value store return false; else { // Create a dot new machine instruction to see if resources can be @@ -1691,24 +1007,21 @@ bool HexagonPacketizerList::isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) { } // A LoopN instruction cannot appear in the same packet as a jump or call. - if (IsLoopN(I) && ( IsDirectJump(J) - || MCIDJ.isCall() - || QII->isDeallocRet(J))) { + if (IsLoopN(I) && + (IsDirectJump(J) || MCIDJ.isCall() || QII->isDeallocRet(J))) { Dependence = true; return false; } - if (IsLoopN(J) && ( IsDirectJump(I) - || MCIDI.isCall() - || QII->isDeallocRet(I))) { + if (IsLoopN(J) && + (IsDirectJump(I) || MCIDI.isCall() || QII->isDeallocRet(I))) { Dependence = true; return false; } // dealloc_return cannot appear in the same packet as a conditional or // unconditional jump. - if (QII->isDeallocRet(I) && ( MCIDJ.isBranch() - || MCIDJ.isCall() - || MCIDJ.isBarrier())) { + if (QII->isDeallocRet(I) && + (MCIDJ.isBranch() || MCIDJ.isCall() || MCIDJ.isBarrier())) { Dependence = true; return false; } @@ -1733,7 +1046,7 @@ bool HexagonPacketizerList::isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) { } //if dealloc_return - if (MCIDJ.mayStore() && QII->isDeallocRet(I)){ + if (MCIDJ.mayStore() && QII->isDeallocRet(I)) { Dependence = true; return false; } -- GitLab From 7bec903850806b942967ba3a5eaa37cb4629cf62 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 10 May 2013 21:08:31 +0000 Subject: [PATCH 195/467] ObjC debug info: Substitute the class type for methods that return a related type (e.g., if they use the instancetype keyword). rdar://problem/13359718 llvm-svn: 181629 --- clang/lib/CodeGen/CGDebugInfo.cpp | 5 +++- .../CodeGenObjC/debug-info-instancetype.m | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGenObjC/debug-info-instancetype.m diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 6678aa7198b1..d9ab0902e355 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2154,7 +2154,10 @@ llvm::DIType CGDebugInfo::getOrCreateFunctionType(const Decl *D, SmallVector Elts; // First element is always return type. For 'void' functions it is NULL. - Elts.push_back(getOrCreateType(OMethod->getResultType(), F)); + QualType ResultTy = OMethod->hasRelatedResultType() + ? QualType(OMethod->getClassInterface()->getTypeForDecl(), 0) + : OMethod->getResultType(); + Elts.push_back(getOrCreateType(ResultTy, F)); // "self" pointer is always first argument. QualType SelfDeclTy = OMethod->getSelfDecl()->getType(); llvm::DIType SelfTy = getOrCreateType(SelfDeclTy, F); diff --git a/clang/test/CodeGenObjC/debug-info-instancetype.m b/clang/test/CodeGenObjC/debug-info-instancetype.m new file mode 100644 index 000000000000..7275b63d17a9 --- /dev/null +++ b/clang/test/CodeGenObjC/debug-info-instancetype.m @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// rdar://problem/13359718 +// Substitute the actual type for a method returning instancetype. +@interface NSObject ++ (id)alloc; +- (id)init; +- (id)retain; +@end + +@interface Foo : NSObject ++ (instancetype)defaultFoo; +@end + +@implementation Foo ++(instancetype)defaultFoo {return 0;} +// CHECK: ![[FOO:[0-9]+]] = metadata {{.*}}; [ DW_TAG_structure_type ] [Foo] +// CHECK: metadata !"+[Foo defaultFoo]", metadata !"", i32 [[@LINE-2]], metadata ![[TYPE:[0-9]+]] +// CHECK: ![[TYPE]] = {{.*}} metadata ![[RESULT:[0-9]+]], i32 {{.*}}, i32 {{.*}}} ; [ DW_TAG_subroutine_type ] +// CHECK: ![[RESULT]] = metadata !{metadata ![[FOO]], +@end + + +int main (int argc, const char *argv[]) +{ + Foo *foo = [Foo defaultFoo]; + return 0; +} -- GitLab From bf0bd1f4ab2b9b4826d58407962260256d4b3709 Mon Sep 17 00:00:00 2001 From: Jyotsna Verma Date: Fri, 10 May 2013 21:44:02 +0000 Subject: [PATCH 196/467] Fix unused variable error. Earlier, this variable was used in an assert and was causing failure on darwin. llvm-svn: 181630 --- llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp index 77ad70dd6cf1..0fda4edf8630 100644 --- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -184,8 +184,7 @@ void HexagonFrameLowering::emitEpilogue(MachineFunction &MF, const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); // Handle EH_RETURN. if (MBBI->getOpcode() == Hexagon::EH_RETURN_JMPR) { - MachineOperand &OffsetReg = MBBI->getOperand(0); - assert(OffsetReg.isReg() && "Offset should be in register!"); + assert(MBBI->getOperand(0).isReg() && "Offset should be in register!"); BuildMI(MBB, MBBI, dl, TII.get(Hexagon::DEALLOCFRAME)); BuildMI(MBB, MBBI, dl, TII.get(Hexagon::ADD_rr), Hexagon::R29).addReg(Hexagon::R29).addReg(Hexagon::R28); -- GitLab From 57abc5d6a6f393f488903c5a35e5a898fc201d3a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 10 May 2013 21:47:16 +0000 Subject: [PATCH 197/467] Main changes in this patch include: - cleanup plug-in interface and use ConstStrings for plug-in names - Modfiied the BSD Archive plug-in to be able to pick out the correct .o file when .a files contain multiple .o files with the same name by using the timestamp - Modified SymbolFileDWARFDebugMap to properly verify the timestamp on .o files it loads to ensure we don't load updated .o files and cause problems when debugging The plug-in interface changes: Modified the lldb_private::PluginInterface class that all plug-ins inherit from: Changed: virtual const char * GetPluginName() = 0; To: virtual ConstString GetPluginName() = 0; Removed: virtual const char * GetShortPluginName() = 0; - Fixed up all plug-in to adhere to the new interface and to return lldb_private::ConstString values for the plug-in names. - Fixed all plug-ins to return simple names with no prefixes. Some plug-ins had prefixes and most ones didn't, so now they all don't have prefixed names, just simple names like "linux", "gdb-remote", etc. llvm-svn: 181631 --- lldb/include/lldb/API/SBProcess.h | 1 + lldb/include/lldb/Core/Log.h | 6 +- lldb/include/lldb/Core/Module.h | 23 +- lldb/include/lldb/Core/ModuleSpec.h | 19 ++ lldb/include/lldb/Core/PluginInterface.h | 5 +- lldb/include/lldb/Core/PluginManager.h | 58 ++--- lldb/include/lldb/Symbol/SymbolVendor.h | 14 +- lldb/include/lldb/Target/Platform.h | 4 +- lldb/include/lldb/Target/Process.h | 28 +-- lldb/source/API/SBProcess.cpp | 4 +- lldb/source/Commands/CommandObjectLog.cpp | 4 +- .../source/Commands/CommandObjectPlatform.cpp | 14 +- lldb/source/Commands/CommandObjectTarget.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- lldb/source/Core/Disassembler.cpp | 3 +- lldb/source/Core/DynamicLoader.cpp | 3 +- lldb/source/Core/EmulateInstruction.cpp | 3 +- lldb/source/Core/Log.cpp | 13 +- lldb/source/Core/Module.cpp | 15 +- lldb/source/Core/PluginManager.cpp | 208 ++++++++---------- .../Interpreter/OptionGroupPlatform.cpp | 4 +- .../Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 28 +-- .../Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h | 8 +- .../ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 26 +-- .../Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h | 8 +- .../ABI/SysV-x86_64/ABISysV_x86_64.cpp | 26 +-- .../Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h | 8 +- .../Disassembler/llvm/DisassemblerLLVMC.cpp | 21 +- .../Disassembler/llvm/DisassemblerLLVMC.h | 10 +- .../DynamicLoaderDarwinKernel.cpp | 22 +- .../Darwin-Kernel/DynamicLoaderDarwinKernel.h | 7 +- .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp | 13 +- .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h | 7 +- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 15 +- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.h | 7 +- .../Static/DynamicLoaderStatic.cpp | 13 +- .../Static/DynamicLoaderStatic.h | 7 +- .../Instruction/ARM/EmulateInstructionARM.cpp | 5 +- .../Instruction/ARM/EmulateInstructionARM.h | 11 +- .../ItaniumABI/ItaniumABILanguageRuntime.cpp | 24 +- .../ItaniumABI/ItaniumABILanguageRuntime.h | 8 +- .../AppleObjCRuntime/AppleObjCRuntimeV1.cpp | 26 +-- .../AppleObjCRuntime/AppleObjCRuntimeV1.h | 8 +- .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 26 +-- .../AppleObjCRuntime/AppleObjCRuntimeV2.h | 8 +- .../BSD-Archive/ObjectContainerBSDArchive.cpp | 48 ++-- .../BSD-Archive/ObjectContainerBSDArchive.h | 10 +- .../ObjectContainerUniversalMachO.cpp | 13 +- .../ObjectContainerUniversalMachO.h | 7 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 13 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.h | 7 +- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 13 +- .../ObjectFile/Mach-O/ObjectFileMachO.h | 7 +- .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 13 +- .../ObjectFile/PECOFF/ObjectFilePECOFF.h | 7 +- .../Python/OperatingSystemPython.cpp | 13 +- .../Python/OperatingSystemPython.h | 7 +- .../Platform/FreeBSD/PlatformFreeBSD.cpp | 28 +-- .../Platform/FreeBSD/PlatformFreeBSD.h | 19 +- .../Plugins/Platform/Linux/PlatformLinux.cpp | 29 ++- .../Plugins/Platform/Linux/PlatformLinux.h | 22 +- .../Platform/MacOSX/PlatformDarwin.cpp | 6 +- .../Platform/MacOSX/PlatformDarwinKernel.cpp | 13 +- .../Platform/MacOSX/PlatformDarwinKernel.h | 13 +- .../Platform/MacOSX/PlatformMacOSX.cpp | 23 +- .../Plugins/Platform/MacOSX/PlatformMacOSX.h | 17 +- .../Platform/MacOSX/PlatformRemoteiOS.cpp | 17 +- .../Platform/MacOSX/PlatformRemoteiOS.h | 13 +- .../Platform/MacOSX/PlatformiOSSimulator.cpp | 17 +- .../Platform/MacOSX/PlatformiOSSimulator.h | 13 +- .../gdb-server/PlatformRemoteGDBServer.cpp | 9 +- .../gdb-server/PlatformRemoteGDBServer.h | 14 +- .../Process/FreeBSD/ProcessFreeBSD.cpp | 15 +- .../Plugins/Process/FreeBSD/ProcessFreeBSD.h | 7 +- .../Plugins/Process/Linux/ProcessLinux.cpp | 15 +- .../Plugins/Process/Linux/ProcessLinux.h | 7 +- .../Process/MacOSX-Kernel/ProcessKDP.cpp | 13 +- .../Process/MacOSX-Kernel/ProcessKDP.h | 7 +- .../Process/MacOSX-Kernel/ProcessKDPLog.cpp | 3 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 15 +- .../Process/gdb-remote/ProcessGDBRemote.h | 7 +- .../gdb-remote/ProcessGDBRemoteLog.cpp | 2 +- .../Process/mach-core/ProcessMachCore.cpp | 13 +- .../Process/mach-core/ProcessMachCore.h | 7 +- .../SymbolFile/DWARF/LogChannelDWARF.cpp | 12 +- .../SymbolFile/DWARF/LogChannelDWARF.h | 7 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 13 +- .../SymbolFile/DWARF/SymbolFileDWARF.h | 7 +- .../DWARF/SymbolFileDWARFDebugMap.cpp | 57 +++-- .../DWARF/SymbolFileDWARFDebugMap.h | 17 +- .../SymbolFile/Symtab/SymbolFileSymtab.cpp | 13 +- .../SymbolFile/Symtab/SymbolFileSymtab.h | 7 +- .../MacOSX/SymbolVendorMacOSX.cpp | 13 +- .../SymbolVendor/MacOSX/SymbolVendorMacOSX.h | 7 +- .../UnwindAssemblyInstEmulation.cpp | 17 +- .../UnwindAssemblyInstEmulation.h | 7 +- .../UnwindAssembly/x86/UnwindAssembly-x86.cpp | 15 +- .../UnwindAssembly/x86/UnwindAssembly-x86.h | 7 +- lldb/source/Symbol/SymbolVendor.cpp | 11 +- lldb/source/Target/OperatingSystem.cpp | 3 +- lldb/source/Target/Platform.cpp | 21 +- lldb/source/Target/Process.cpp | 3 +- 102 files changed, 653 insertions(+), 881 deletions(-) diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 288d7d0290d1..784f362122a9 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -51,6 +51,7 @@ public: const char * GetPluginName (); + // DEPRECATED: use GetPluginName() const char * GetShortPluginName (); diff --git a/lldb/include/lldb/Core/Log.h b/lldb/include/lldb/Core/Log.h index dafb5b5aa51a..ced6f2565d9a 100644 --- a/lldb/include/lldb/Core/Log.h +++ b/lldb/include/lldb/Core/Log.h @@ -78,14 +78,14 @@ public: // Static accessors for logging channels //------------------------------------------------------------------ static void - RegisterLogChannel (const char *channel, + RegisterLogChannel (const ConstString &channel, const Log::Callbacks &log_callbacks); static bool - UnregisterLogChannel (const char *channel); + UnregisterLogChannel (const ConstString &channel); static bool - GetLogChannelCallbacks (const char *channel, + GetLogChannelCallbacks (const ConstString &channel, Log::Callbacks &log_callbacks); diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 9b59703135ac..7ba9856fbeb9 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -88,7 +88,8 @@ public: Module (const FileSpec& file_spec, const ArchSpec& arch, const ConstString *object_name = NULL, - off_t object_offset = 0); + off_t object_offset = 0, + const TimeValue *object_mod_time_ptr = NULL); Module (const ModuleSpec &module_spec); //------------------------------------------------------------------ @@ -552,8 +553,23 @@ public: SetSymbolFileFileSpec (const FileSpec &file); const TimeValue & - GetModificationTime () const; - + GetModificationTime () const + { + return m_mod_time; + } + + const TimeValue & + GetObjectModificationTime () const + { + return m_object_mod_time; + } + + void + SetObjectModificationTime (const TimeValue &mod_time) + { + m_mod_time = mod_time; + } + //------------------------------------------------------------------ /// Tells whether this module is capable of being the main executable /// for a process. @@ -963,6 +979,7 @@ protected: FileSpec m_symfile_spec; ///< If this path is valid, then this is the file that _will_ be used as the symbol file for this module ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file. uint64_t m_object_offset; + TimeValue m_object_mod_time; lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file parser for this module as it may or may not be shared with the SymbolFile std::unique_ptr m_symfile_ap; ///< A pointer to the symbol vendor for this module. ClangASTContext m_ast; ///< The AST context for this module. diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index 52e9499b464c..9882b243ca42 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -28,6 +28,7 @@ public: m_uuid (), m_object_name (), m_object_offset (0), + m_object_mod_time (), m_source_mappings () { } @@ -40,6 +41,7 @@ public: m_uuid (), m_object_name (), m_object_offset (0), + m_object_mod_time (), m_source_mappings () { } @@ -52,6 +54,7 @@ public: m_uuid (), m_object_name (), m_object_offset (0), + m_object_mod_time (), m_source_mappings () { } @@ -64,6 +67,7 @@ public: m_uuid (rhs.m_uuid), m_object_name (rhs.m_object_name), m_object_offset (rhs.m_object_offset), + m_object_mod_time (rhs.m_object_mod_time), m_source_mappings (rhs.m_source_mappings) { } @@ -80,6 +84,7 @@ public: m_uuid = rhs.m_uuid; m_object_name = rhs.m_object_name; m_object_offset = rhs.m_object_offset; + m_object_mod_time = rhs.m_object_mod_time; m_source_mappings = rhs.m_source_mappings; } return *this; @@ -248,6 +253,18 @@ public: { m_object_offset = object_offset; } + + TimeValue & + GetObjectModificationTime () + { + return m_object_mod_time; + } + + const TimeValue & + GetObjectModificationTime () const + { + return m_object_mod_time; + } PathMappingList & GetSourceMappingList () const @@ -266,6 +283,7 @@ public: m_object_name.Clear(); m_object_offset = 0; m_source_mappings.Clear(false); + m_object_mod_time.Clear(); } protected: @@ -276,6 +294,7 @@ protected: UUID m_uuid; ConstString m_object_name; uint64_t m_object_offset; + TimeValue m_object_mod_time; mutable PathMappingList m_source_mappings; }; diff --git a/lldb/include/lldb/Core/PluginInterface.h b/lldb/include/lldb/Core/PluginInterface.h index 97f6a37556ed..19371ca98601 100644 --- a/lldb/include/lldb/Core/PluginInterface.h +++ b/lldb/include/lldb/Core/PluginInterface.h @@ -24,12 +24,9 @@ public: virtual ~PluginInterface () {} - virtual const char * + virtual ConstString GetPluginName() = 0; - virtual const char * - GetShortPluginName() = 0; - virtual uint32_t GetPluginVersion() = 0; diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index 93f2c32a7aa7..c13a85830c02 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -29,7 +29,7 @@ public: // ABI //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, ABICreateInstance create_callback); @@ -40,14 +40,14 @@ public: GetABICreateCallbackAtIndex (uint32_t idx); static ABICreateInstance - GetABICreateCallbackForPluginName (const char *name); + GetABICreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // Disassembler //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, DisassemblerCreateInstance create_callback); @@ -58,14 +58,14 @@ public: GetDisassemblerCreateCallbackAtIndex (uint32_t idx); static DisassemblerCreateInstance - GetDisassemblerCreateCallbackForPluginName (const char *name); + GetDisassemblerCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // DynamicLoader //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, DynamicLoaderCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = NULL); @@ -77,13 +77,13 @@ public: GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx); static DynamicLoaderCreateInstance - GetDynamicLoaderCreateCallbackForPluginName (const char *name); + GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // EmulateInstruction //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, EmulateInstructionCreateInstance create_callback); @@ -94,13 +94,13 @@ public: GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx); static EmulateInstructionCreateInstance - GetEmulateInstructionCreateCallbackForPluginName (const char *name); + GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // OperatingSystem //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, OperatingSystemCreateInstance create_callback); @@ -111,13 +111,13 @@ public: GetOperatingSystemCreateCallbackAtIndex (uint32_t idx); static OperatingSystemCreateInstance - GetOperatingSystemCreateCallbackForPluginName (const char *name); + GetOperatingSystemCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // LanguageRuntime //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, LanguageRuntimeCreateInstance create_callback); @@ -128,14 +128,14 @@ public: GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx); static LanguageRuntimeCreateInstance - GetLanguageRuntimeCreateCallbackForPluginName (const char *name); + GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // ObjectFile //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, ObjectFileCreateInstance create_callback, ObjectFileCreateMemoryInstance create_memory_callback, @@ -154,17 +154,17 @@ public: GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx); static ObjectFileCreateInstance - GetObjectFileCreateCallbackForPluginName (const char *name); + GetObjectFileCreateCallbackForPluginName (const ConstString &name); static ObjectFileCreateMemoryInstance - GetObjectFileCreateMemoryCallbackForPluginName (const char *name); + GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // ObjectContainer //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, ObjectContainerCreateInstance create_callback, ObjectFileGetModuleSpecifications get_module_specifications); @@ -176,7 +176,7 @@ public: GetObjectContainerCreateCallbackAtIndex (uint32_t idx); static ObjectContainerCreateInstance - GetObjectContainerCreateCallbackForPluginName (const char *name); + GetObjectContainerCreateCallbackForPluginName (const ConstString &name); static ObjectFileGetModuleSpecifications GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx); @@ -185,7 +185,7 @@ public: // LogChannel //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, LogChannelCreateInstance create_callback); @@ -196,7 +196,7 @@ public: GetLogChannelCreateCallbackAtIndex (uint32_t idx); static LogChannelCreateInstance - GetLogChannelCreateCallbackForPluginName (const char *name); + GetLogChannelCreateCallbackForPluginName (const ConstString &name); static const char * GetLogChannelCreateNameAtIndex (uint32_t idx); @@ -205,7 +205,7 @@ public: // Platform //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, PlatformCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = NULL); @@ -217,7 +217,7 @@ public: GetPlatformCreateCallbackAtIndex (uint32_t idx); static PlatformCreateInstance - GetPlatformCreateCallbackForPluginName (const char *name); + GetPlatformCreateCallbackForPluginName (const ConstString &name); static const char * GetPlatformPluginNameAtIndex (uint32_t idx); @@ -232,7 +232,7 @@ public: // Process //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, ProcessCreateInstance create_callback); @@ -243,7 +243,7 @@ public: GetProcessCreateCallbackAtIndex (uint32_t idx); static ProcessCreateInstance - GetProcessCreateCallbackForPluginName (const char *name); + GetProcessCreateCallbackForPluginName (const ConstString &name); static const char * GetProcessPluginNameAtIndex (uint32_t idx); @@ -255,7 +255,7 @@ public: // SymbolFile //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, SymbolFileCreateInstance create_callback); @@ -266,14 +266,14 @@ public: GetSymbolFileCreateCallbackAtIndex (uint32_t idx); static SymbolFileCreateInstance - GetSymbolFileCreateCallbackForPluginName (const char *name); + GetSymbolFileCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // SymbolVendor //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, SymbolVendorCreateInstance create_callback); @@ -284,13 +284,13 @@ public: GetSymbolVendorCreateCallbackAtIndex (uint32_t idx); static SymbolVendorCreateInstance - GetSymbolVendorCreateCallbackForPluginName (const char *name); + GetSymbolVendorCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // UnwindAssembly //------------------------------------------------------------------ static bool - RegisterPlugin (const char *name, + RegisterPlugin (const ConstString &name, const char *description, UnwindAssemblyCreateInstance create_callback); @@ -301,7 +301,7 @@ public: GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx); static UnwindAssemblyCreateInstance - GetUnwindAssemblyCreateCallbackForPluginName (const char *name); + GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // Some plug-ins might register a DebuggerInitializeCallback diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h index 9567c514ebd5..4c17e0f55cd8 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -36,15 +36,6 @@ class SymbolVendor : public PluginInterface { public: - static bool - RegisterPlugin (const char *name, - const char *description, - SymbolVendorCreateInstance create_callback); - - static bool - UnregisterPlugin (SymbolVendorCreateInstance create_callback); - - static SymbolVendor* FindPlugin (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); @@ -171,12 +162,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index e7e6dd5242f3..b0a07946e74e 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -108,7 +108,7 @@ namespace lldb_private { /// should be used. If NULL, pick the best plug-in. //------------------------------------------------------------------ static Platform* - FindPlugin (Process *process, const char *plugin_name); + FindPlugin (Process *process, const ConstString &plugin_name); //------------------------------------------------------------------ /// Set the target's executable based off of the existing @@ -215,7 +215,7 @@ namespace lldb_private { // Returns the the hostname if we are connected, else the short plugin // name. - const char * + ConstString GetName (); virtual const char * diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 9190ec80eef5..97a399594280 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1747,7 +1747,7 @@ public: DoLoadCore () { Error error; - error.SetErrorStringWithFormat("error: %s does not support loading core files.", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support loading core files.", GetPluginName().GetCString()); return error; } @@ -2059,7 +2059,7 @@ public: DoAttachToProcessWithID (lldb::pid_t pid) { Error error; - error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetPluginName().GetCString()); return error; } @@ -2082,7 +2082,7 @@ public: DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info) { Error error; - error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetPluginName().GetCString()); return error; } @@ -2208,7 +2208,7 @@ public: const ProcessLaunchInfo &launch_info) { Error error; - error.SetErrorStringWithFormat("error: %s does not support launching processes", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support launching processes", GetPluginName().GetCString()); return error; } @@ -2257,7 +2257,7 @@ public: DoResume () { Error error; - error.SetErrorStringWithFormat("error: %s does not support resuming processes", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support resuming processes", GetPluginName().GetCString()); return error; } @@ -2306,7 +2306,7 @@ public: DoHalt (bool &caused_stop) { Error error; - error.SetErrorStringWithFormat("error: %s does not support halting processes", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support halting processes", GetPluginName().GetCString()); return error; } @@ -2346,7 +2346,7 @@ public: DoDetach (bool keep_stopped) { Error error; - error.SetErrorStringWithFormat("error: %s does not support detaching from processes", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support detaching from processes", GetPluginName().GetCString()); return error; } @@ -2387,7 +2387,7 @@ public: DoSignal (int signal) { Error error; - error.SetErrorStringWithFormat("error: %s does not support senging signals to processes", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support senging signals to processes", GetPluginName().GetCString()); return error; } @@ -2817,7 +2817,7 @@ public: virtual size_t DoWriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error) { - error.SetErrorStringWithFormat("error: %s does not support writing to processes", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support writing to processes", GetPluginName().GetCString()); return 0; } @@ -2914,7 +2914,7 @@ public: virtual lldb::addr_t DoAllocateMemory (size_t size, uint32_t permissions, Error &error) { - error.SetErrorStringWithFormat("error: %s does not support allocating in the debug process", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support allocating in the debug process", GetPluginName().GetCString()); return LLDB_INVALID_ADDRESS; } @@ -2963,7 +2963,7 @@ public: virtual lldb::addr_t ResolveIndirectFunction(const Address *address, Error &error) { - error.SetErrorStringWithFormat("error: %s does not support indirect functions in the debug process", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support indirect functions in the debug process", GetPluginName().GetCString()); return LLDB_INVALID_ADDRESS; } @@ -3084,7 +3084,7 @@ public: DoDeallocateMemory (lldb::addr_t ptr) { Error error; - error.SetErrorStringWithFormat("error: %s does not support deallocating in the debug process", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support deallocating in the debug process", GetPluginName().GetCString()); return error; } @@ -3189,7 +3189,7 @@ public: EnableBreakpointSite (BreakpointSite *bp_site) { Error error; - error.SetErrorStringWithFormat("error: %s does not support enabling breakpoints", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support enabling breakpoints", GetPluginName().GetCString()); return error; } @@ -3198,7 +3198,7 @@ public: DisableBreakpointSite (BreakpointSite *bp_site) { Error error; - error.SetErrorStringWithFormat("error: %s does not support disabling breakpoints", GetShortPluginName()); + error.SetErrorStringWithFormat("error: %s does not support disabling breakpoints", GetPluginName().GetCString()); return error; } diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 6b4559a50359..d41ad6190d2f 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -89,7 +89,7 @@ SBProcess::GetPluginName () ProcessSP process_sp(GetSP()); if (process_sp) { - return process_sp->GetPluginName(); + return process_sp->GetPluginName().GetCString(); } return ""; } @@ -100,7 +100,7 @@ SBProcess::GetShortPluginName () ProcessSP process_sp(GetSP()); if (process_sp) { - return process_sp->GetShortPluginName(); + return process_sp->GetPluginName().GetCString(); } return ""; } diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index 221c975bc992..5fb79154c4ef 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -282,7 +282,7 @@ protected: std::string channel(args.GetArgumentAtIndex(0)); args.Shift (); // Shift off the channel - if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks)) + if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks)) { log_callbacks.disable (args.GetConstArgumentVector(), &result.GetErrorStream()); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -356,7 +356,7 @@ protected: Log::Callbacks log_callbacks; std::string channel(args.GetArgumentAtIndex(i)); - if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks)) + if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks)) { log_callbacks.list_categories (&result.GetOutputStream()); result.SetStatus(eReturnStatusSuccessFinishResult); diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 60bcece95d6e..c2185e598ad4 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -155,7 +155,7 @@ protected: PlatformSP host_platform_sp (Platform::GetDefaultPlatform()); ostrm.Printf ("%s: %s\n", - host_platform_sp->GetShortPluginName(), + host_platform_sp->GetPluginName().GetCString(), host_platform_sp->GetDescription()); uint32_t idx; @@ -326,7 +326,7 @@ protected: { Stream &ostrm = result.GetOutputStream(); if (hostname.empty()) - ostrm.Printf ("Disconnected from \"%s\"\n", platform_sp->GetShortPluginName()); + ostrm.Printf ("Disconnected from \"%s\"\n", platform_sp->GetPluginName().GetCString()); else ostrm.Printf ("Disconnected from \"%s\"\n", hostname.c_str()); result.SetStatus (eReturnStatusSuccessFinishResult); @@ -340,7 +340,7 @@ protected: else { // Not connected... - result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetShortPluginName()); + result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetPluginName().GetCString()); result.SetStatus (eReturnStatusFailed); } } @@ -570,9 +570,9 @@ protected: result.AppendErrorWithFormat ("no processes were found that %s \"%s\" on the \"%s\" platform\n", match_desc, match_name, - platform_sp->GetShortPluginName()); + platform_sp->GetPluginName().GetCString()); else - result.AppendErrorWithFormat ("no processes were found on the \"%s\" platform\n", platform_sp->GetShortPluginName()); + result.AppendErrorWithFormat ("no processes were found on the \"%s\" platform\n", platform_sp->GetPluginName().GetCString()); result.SetStatus (eReturnStatusFailed); } else @@ -580,7 +580,7 @@ protected: result.AppendMessageWithFormat ("%u matching process%s found on \"%s\"", matches, matches > 1 ? "es were" : " was", - platform_sp->GetName()); + platform_sp->GetName().GetCString()); if (match_desc) result.AppendMessageWithFormat (" whose name %s \"%s\"", match_desc, @@ -848,7 +848,7 @@ protected: else { // Not connected... - result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetShortPluginName()); + result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetPluginName().GetCString()); result.SetStatus (eReturnStatusFailed); } } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 522a4828624c..0ad802d7a084 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -81,7 +81,7 @@ DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bo } PlatformSP platform_sp (target->GetPlatform()); if (platform_sp) - strm.Printf ("%splatform=%s", properties++ > 0 ? ", " : " ( ", platform_sp->GetName()); + strm.Printf ("%splatform=%s", properties++ > 0 ? ", " : " ( ", platform_sp->GetName().GetCString()); ProcessSP process_sp (target->GetProcessSP()); bool show_process_status = false; diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 9e6fc2369deb..7455f0058d05 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2644,7 +2644,7 @@ Debugger::EnableLog (const char *channel, const char **categories, const char *l if (log_options == 0) log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE; - if (Log::GetLogChannelCallbacks (channel, log_callbacks)) + if (Log::GetLogChannelCallbacks (ConstString(channel), log_callbacks)) { log_callbacks.enable (log_stream_sp, log_options, categories, &error_stream); return true; diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index f06062ec6534..b5497b4a9fd3 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -56,7 +56,8 @@ Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char * if (plugin_name) { - create_callback = PluginManager::GetDisassemblerCreateCallbackForPluginName (plugin_name); + ConstString const_plugin_name (plugin_name); + create_callback = PluginManager::GetDisassemblerCreateCallbackForPluginName (const_plugin_name); if (create_callback) { DisassemblerSP disassembler_sp(create_callback(arch, flavor)); diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 1943c80b2f0c..82f84048b32a 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -21,7 +21,8 @@ DynamicLoader::FindPlugin (Process *process, const char *plugin_name) DynamicLoaderCreateInstance create_callback = NULL; if (plugin_name) { - create_callback = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (plugin_name); + ConstString const_plugin_name(plugin_name); + create_callback = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const_plugin_name); if (create_callback) { std::unique_ptr instance_ap(create_callback(process, true)); diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp index 73763f5ceec9..bf6c6d88b563 100644 --- a/lldb/source/Core/EmulateInstruction.cpp +++ b/lldb/source/Core/EmulateInstruction.cpp @@ -32,7 +32,8 @@ EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_ EmulateInstructionCreateInstance create_callback = NULL; if (plugin_name) { - create_callback = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (plugin_name); + ConstString const_plugin_name (plugin_name); + create_callback = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const_plugin_name); if (create_callback) { EmulateInstruction *emulate_insn_ptr = create_callback(arch, supported_inst_type); diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp index 881d9892fd75..d73ab15f697a 100644 --- a/lldb/source/Core/Log.cpp +++ b/lldb/source/Core/Log.cpp @@ -313,7 +313,7 @@ Log::Warning (const char *format, ...) } } -typedef std::map CallbackMap; +typedef std::map CallbackMap; typedef CallbackMap::iterator CallbackMapIter; typedef std::map LogChannelMap; @@ -337,19 +337,19 @@ GetChannelMap () } void -Log::RegisterLogChannel (const char *channel, const Log::Callbacks &log_callbacks) +Log::RegisterLogChannel (const ConstString &channel, const Log::Callbacks &log_callbacks) { GetCallbackMap().insert(std::make_pair(channel, log_callbacks)); } bool -Log::UnregisterLogChannel (const char *channel) +Log::UnregisterLogChannel (const ConstString &channel) { return GetCallbackMap().erase(channel) != 0; } bool -Log::GetLogChannelCallbacks (const char *channel, Log::Callbacks &log_callbacks) +Log::GetLogChannelCallbacks (const ConstString &channel, Log::Callbacks &log_callbacks) { CallbackMap &callback_map = GetCallbackMap (); CallbackMapIter pos = callback_map.find(channel); @@ -427,7 +427,7 @@ void Log::Initialize() { Log::Callbacks log_callbacks = { DisableLog, EnableLog, ListLogCategories }; - Log::RegisterLogChannel ("lldb", log_callbacks); + Log::RegisterLogChannel (ConstString("lldb"), log_callbacks); } void @@ -495,7 +495,8 @@ LogChannel::FindPlugin (const char *plugin_name) LogChannelMapIter pos = channel_map.find (log_channel_name); if (pos == channel_map.end()) { - LogChannelCreateInstance create_callback = PluginManager::GetLogChannelCreateCallbackForPluginName (plugin_name); + ConstString const_plugin_name (plugin_name); + LogChannelCreateInstance create_callback = PluginManager::GetLogChannelCreateCallbackForPluginName (const_plugin_name); if (create_callback) { log_channel_sp.reset(create_callback()); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 7f403472cdaa..b5874daeb80d 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -136,6 +136,7 @@ Module::Module (const ModuleSpec &module_spec) : m_symfile_spec (module_spec.GetSymbolFileSpec()), m_object_name (module_spec.GetObjectName()), m_object_offset (module_spec.GetObjectOffset()), + m_object_mod_time (module_spec.GetObjectModificationTime()), m_objfile_sp (), m_symfile_ap (), m_ast (), @@ -168,7 +169,8 @@ Module::Module (const ModuleSpec &module_spec) : Module::Module(const FileSpec& file_spec, const ArchSpec& arch, const ConstString *object_name, - off_t object_offset) : + off_t object_offset, + const TimeValue *object_mod_time_ptr) : m_mutex (Mutex::eMutexTypeRecursive), m_mod_time (file_spec.GetModificationTime()), m_arch (arch), @@ -178,6 +180,7 @@ Module::Module(const FileSpec& file_spec, m_symfile_spec (), m_object_name (), m_object_offset (object_offset), + m_object_mod_time (), m_objfile_sp (), m_symfile_ap (), m_ast (), @@ -198,6 +201,10 @@ Module::Module(const FileSpec& file_spec, if (object_name) m_object_name = *object_name; + + if (object_mod_time_ptr) + m_object_mod_time = *object_mod_time_ptr; + Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES)); if (log) log->Printf ("%p Module::Module((%s) '%s%s%s%s')", @@ -1186,12 +1193,6 @@ Module::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex, SymbolT return sc_list.GetSize() - initial_size; } -const TimeValue & -Module::GetModificationTime () const -{ - return m_mod_time; -} - void Module::SetSymbolFileFileSpec (const FileSpec &file) { diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 0cc916b115d8..a143b95d93c8 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -233,7 +233,7 @@ struct ABIInstance { } - std::string name; + ConstString name; std::string description; ABICreateInstance create_callback; }; @@ -257,7 +257,7 @@ GetABIInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, ABICreateInstance create_callback ) @@ -265,8 +265,8 @@ PluginManager::RegisterPlugin if (create_callback) { ABIInstance instance; - assert (name && name[0]); - instance.name.assign (name); + assert ((bool)name); + instance.name = name; if (description && description[0]) instance.description = description; instance.create_callback = create_callback; @@ -309,18 +309,17 @@ PluginManager::GetABICreateCallbackAtIndex (uint32_t idx) } ABICreateInstance -PluginManager::GetABICreateCallbackForPluginName (const char *name) +PluginManager::GetABICreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { Mutex::Locker locker (GetABIInstancesMutex ()); - llvm::StringRef name_sref(name); ABIInstances &instances = GetABIInstances (); ABIInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -340,7 +339,7 @@ struct DisassemblerInstance { } - std::string name; + ConstString name; std::string description; DisassemblerCreateInstance create_callback; }; @@ -364,7 +363,7 @@ GetDisassemblerInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, DisassemblerCreateInstance create_callback ) @@ -372,7 +371,7 @@ PluginManager::RegisterPlugin if (create_callback) { DisassemblerInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -416,18 +415,17 @@ PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx) } DisassemblerCreateInstance -PluginManager::GetDisassemblerCreateCallbackForPluginName (const char *name) +PluginManager::GetDisassemblerCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetDisassemblerMutex ()); DisassemblerInstances &instances = GetDisassemblerInstances (); DisassemblerInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -449,7 +447,7 @@ struct DynamicLoaderInstance { } - std::string name; + ConstString name; std::string description; DynamicLoaderCreateInstance create_callback; DebuggerInitializeCallback debugger_init_callback; @@ -476,7 +474,7 @@ GetDynamicLoaderInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, DynamicLoaderCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback @@ -485,7 +483,7 @@ PluginManager::RegisterPlugin if (create_callback) { DynamicLoaderInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -529,18 +527,17 @@ PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx) } DynamicLoaderCreateInstance -PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const char *name) +PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetDynamicLoaderMutex ()); DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); DynamicLoaderInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -559,7 +556,7 @@ struct EmulateInstructionInstance { } - std::string name; + ConstString name; std::string description; EmulateInstructionCreateInstance create_callback; }; @@ -584,7 +581,7 @@ GetEmulateInstructionInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, EmulateInstructionCreateInstance create_callback ) @@ -592,7 +589,7 @@ PluginManager::RegisterPlugin if (create_callback) { EmulateInstructionInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -635,18 +632,17 @@ PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx) } EmulateInstructionCreateInstance -PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const char *name) +PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetEmulateInstructionMutex ()); EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); EmulateInstructionInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -664,7 +660,7 @@ struct OperatingSystemInstance { } - std::string name; + ConstString name; std::string description; OperatingSystemCreateInstance create_callback; }; @@ -686,17 +682,14 @@ GetOperatingSystemInstances () } bool -PluginManager::RegisterPlugin -( - const char *name, - const char *description, - OperatingSystemCreateInstance create_callback - ) +PluginManager::RegisterPlugin (const ConstString &name, + const char *description, + OperatingSystemCreateInstance create_callback) { if (create_callback) { OperatingSystemInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -739,18 +732,17 @@ PluginManager::GetOperatingSystemCreateCallbackAtIndex (uint32_t idx) } OperatingSystemCreateInstance -PluginManager::GetOperatingSystemCreateCallbackForPluginName (const char *name) +PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetOperatingSystemMutex ()); OperatingSystemInstances &instances = GetOperatingSystemInstances (); OperatingSystemInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -770,7 +762,7 @@ struct LanguageRuntimeInstance { } - std::string name; + ConstString name; std::string description; LanguageRuntimeCreateInstance create_callback; }; @@ -794,7 +786,7 @@ GetLanguageRuntimeInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, LanguageRuntimeCreateInstance create_callback ) @@ -802,7 +794,7 @@ PluginManager::RegisterPlugin if (create_callback) { LanguageRuntimeInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -845,18 +837,17 @@ PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx) } LanguageRuntimeCreateInstance -PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const char *name) +PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetLanguageRuntimeMutex ()); LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); LanguageRuntimeInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -876,7 +867,7 @@ struct ObjectFileInstance { } - std::string name; + ConstString name; std::string description; ObjectFileCreateInstance create_callback; ObjectFileCreateMemoryInstance create_memory_callback; @@ -901,7 +892,7 @@ GetObjectFileInstances () bool -PluginManager::RegisterPlugin (const char *name, +PluginManager::RegisterPlugin (const ConstString &name, const char *description, ObjectFileCreateInstance create_callback, ObjectFileCreateMemoryInstance create_memory_callback, @@ -910,7 +901,7 @@ PluginManager::RegisterPlugin (const char *name, if (create_callback) { ObjectFileInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -976,18 +967,17 @@ PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx } ObjectFileCreateInstance -PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name) +PluginManager::GetObjectFileCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetObjectFileMutex ()); ObjectFileInstances &instances = GetObjectFileInstances (); ObjectFileInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -996,18 +986,17 @@ PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name) ObjectFileCreateMemoryInstance -PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const char *name) +PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetObjectFileMutex ()); ObjectFileInstances &instances = GetObjectFileInstances (); ObjectFileInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_memory_callback; } } @@ -1028,7 +1017,7 @@ struct ObjectContainerInstance { } - std::string name; + ConstString name; std::string description; ObjectContainerCreateInstance create_callback; ObjectFileGetModuleSpecifications get_module_specifications; @@ -1052,7 +1041,7 @@ GetObjectContainerInstances () } bool -PluginManager::RegisterPlugin (const char *name, +PluginManager::RegisterPlugin (const ConstString &name, const char *description, ObjectContainerCreateInstance create_callback, ObjectFileGetModuleSpecifications get_module_specifications) @@ -1060,7 +1049,7 @@ PluginManager::RegisterPlugin (const char *name, if (create_callback) { ObjectContainerInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1104,18 +1093,17 @@ PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx) } ObjectContainerCreateInstance -PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name) +PluginManager::GetObjectContainerCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetObjectContainerMutex ()); ObjectContainerInstances &instances = GetObjectContainerInstances (); ObjectContainerInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -1143,7 +1131,7 @@ struct LogInstance { } - std::string name; + ConstString name; std::string description; LogChannelCreateInstance create_callback; }; @@ -1169,7 +1157,7 @@ GetLogInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, LogChannelCreateInstance create_callback ) @@ -1177,7 +1165,7 @@ PluginManager::RegisterPlugin if (create_callback) { LogInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1215,7 +1203,7 @@ PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx) Mutex::Locker locker (GetLogMutex ()); LogInstances &instances = GetLogInstances (); if (idx < instances.size()) - return instances[idx].name.c_str(); + return instances[idx].name.GetCString(); return NULL; } @@ -1231,18 +1219,17 @@ PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx) } LogChannelCreateInstance -PluginManager::GetLogChannelCreateCallbackForPluginName (const char *name) +PluginManager::GetLogChannelCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetLogMutex ()); LogInstances &instances = GetLogInstances (); LogInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -1261,7 +1248,7 @@ struct PlatformInstance { } - std::string name; + ConstString name; std::string description; PlatformCreateInstance create_callback; DebuggerInitializeCallback debugger_init_callback; @@ -1285,7 +1272,7 @@ GetPlatformInstances () bool -PluginManager::RegisterPlugin (const char *name, +PluginManager::RegisterPlugin (const ConstString &name, const char *description, PlatformCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback) @@ -1295,7 +1282,7 @@ PluginManager::RegisterPlugin (const char *name, Mutex::Locker locker (GetPlatformInstancesMutex ()); PlatformInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1314,7 +1301,7 @@ PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx) Mutex::Locker locker (GetPlatformInstancesMutex ()); PlatformInstances &instances = GetPlatformInstances (); if (idx < instances.size()) - return instances[idx].name.c_str(); + return instances[idx].name.GetCString(); return NULL; } @@ -1360,18 +1347,17 @@ PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx) } PlatformCreateInstance -PluginManager::GetPlatformCreateCallbackForPluginName (const char *name) +PluginManager::GetPlatformCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { Mutex::Locker locker (GetPlatformInstancesMutex ()); PlatformInstances &instances = GetPlatformInstances (); - llvm::StringRef name_sref(name); PlatformInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -1381,7 +1367,7 @@ PluginManager::GetPlatformCreateCallbackForPluginName (const char *name) size_t PluginManager::AutoCompletePlatformName (const char *name, StringList &matches) { - if (name && name[0]) + if (name) { Mutex::Locker locker (GetPlatformInstancesMutex ()); PlatformInstances &instances = GetPlatformInstances (); @@ -1390,7 +1376,7 @@ PluginManager::AutoCompletePlatformName (const char *name, StringList &matches) PlatformInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - llvm::StringRef plugin_name (pos->name); + llvm::StringRef plugin_name (pos->name.GetCString()); if (plugin_name.startswith(name_sref)) matches.AppendString (plugin_name.data()); } @@ -1408,7 +1394,7 @@ struct ProcessInstance { } - std::string name; + ConstString name; std::string description; ProcessCreateInstance create_callback; }; @@ -1433,7 +1419,7 @@ GetProcessInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, ProcessCreateInstance create_callback ) @@ -1441,7 +1427,7 @@ PluginManager::RegisterPlugin if (create_callback) { ProcessInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1458,7 +1444,7 @@ PluginManager::GetProcessPluginNameAtIndex (uint32_t idx) Mutex::Locker locker (GetProcessMutex ()); ProcessInstances &instances = GetProcessInstances (); if (idx < instances.size()) - return instances[idx].name.c_str(); + return instances[idx].name.GetCString(); return NULL; } @@ -1505,18 +1491,17 @@ PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx) ProcessCreateInstance -PluginManager::GetProcessCreateCallbackForPluginName (const char *name) +PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetProcessMutex ()); ProcessInstances &instances = GetProcessInstances (); ProcessInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -1534,7 +1519,7 @@ struct SymbolFileInstance { } - std::string name; + ConstString name; std::string description; SymbolFileCreateInstance create_callback; }; @@ -1559,7 +1544,7 @@ GetSymbolFileInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, SymbolFileCreateInstance create_callback ) @@ -1567,7 +1552,7 @@ PluginManager::RegisterPlugin if (create_callback) { SymbolFileInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1610,18 +1595,17 @@ PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx) } SymbolFileCreateInstance -PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name) +PluginManager::GetSymbolFileCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetSymbolFileMutex ()); SymbolFileInstances &instances = GetSymbolFileInstances (); SymbolFileInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -1641,7 +1625,7 @@ struct SymbolVendorInstance { } - std::string name; + ConstString name; std::string description; SymbolVendorCreateInstance create_callback; }; @@ -1665,7 +1649,7 @@ GetSymbolVendorInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, SymbolVendorCreateInstance create_callback ) @@ -1673,7 +1657,7 @@ PluginManager::RegisterPlugin if (create_callback) { SymbolVendorInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1717,18 +1701,17 @@ PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx) SymbolVendorCreateInstance -PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name) +PluginManager::GetSymbolVendorCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetSymbolVendorMutex ()); SymbolVendorInstances &instances = GetSymbolVendorInstances (); SymbolVendorInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } @@ -1747,7 +1730,7 @@ struct UnwindAssemblyInstance { } - std::string name; + ConstString name; std::string description; UnwindAssemblyCreateInstance create_callback; }; @@ -1771,7 +1754,7 @@ GetUnwindAssemblyInstances () bool PluginManager::RegisterPlugin ( - const char *name, + const ConstString &name, const char *description, UnwindAssemblyCreateInstance create_callback ) @@ -1779,7 +1762,7 @@ PluginManager::RegisterPlugin if (create_callback) { UnwindAssemblyInstance instance; - assert (name && name[0]); + assert ((bool)name); instance.name = name; if (description && description[0]) instance.description = description; @@ -1823,18 +1806,17 @@ PluginManager::GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx) UnwindAssemblyCreateInstance -PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name) +PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name) { - if (name && name[0]) + if (name) { - llvm::StringRef name_sref(name); Mutex::Locker locker (GetUnwindAssemblyMutex ()); UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); UnwindAssemblyInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (name_sref.equals (pos->name)) + if (name == pos->name) return pos->create_callback; } } diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp index 8dc64fb54c35..a54edafd0196 100644 --- a/lldb/source/Interpreter/OptionGroupPlatform.cpp +++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp @@ -38,7 +38,9 @@ OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, { if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) { - error.SetErrorStringWithFormat("platform '%s' doesn't support '%s'", platform_sp->GetName(), arch.GetTriple().getTriple().c_str()); + error.SetErrorStringWithFormat ("platform '%s' doesn't support '%s'", + platform_sp->GetName().GetCString(), + arch.GetTriple().getTriple().c_str()); platform_sp.reset(); return platform_sp; } diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 3a9f767cfc70..bc63e591cc2b 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -35,12 +35,7 @@ using namespace lldb; using namespace lldb_private; -static const char *pluginName = "ABIMacOSX_arm"; -static const char *pluginDesc = "Mac OS X ABI for arm targets"; -static const char *pluginShort = "abi.macosx-arm"; - - -static RegisterInfo g_register_infos[] = +static RegisterInfo g_register_infos[] = { // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE VALUE REGS INVALIDATE REGS // ========== ======= == === ============= ============ ======================= =================== =========================== ======================= ====================== ========== =============== @@ -841,8 +836,8 @@ ABIMacOSX_arm::RegisterIsVolatile (const RegisterInfo *reg_info) void ABIMacOSX_arm::Initialize() { - PluginManager::RegisterPlugin (pluginName, - pluginDesc, + PluginManager::RegisterPlugin (GetPluginNameStatic(), + "Mac OS X ABI for arm targets", CreateInstance); } @@ -852,19 +847,20 @@ ABIMacOSX_arm::Terminate() PluginManager::UnregisterPlugin (CreateInstance); } +lldb_private::ConstString +ABIMacOSX_arm::GetPluginNameStatic() +{ + static ConstString g_name("macosx-arm"); + return g_name; +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ABIMacOSX_arm::GetPluginName() { - return pluginName; -} - -const char * -ABIMacOSX_arm::GetShortPluginName() -{ - return pluginShort; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h index c1edb6edd624..27cea85aaf6f 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -114,15 +114,15 @@ public: static lldb::ABISP CreateInstance (const lldb_private::ArchSpec &arch); + static lldb_private::ConstString + GetPluginNameStatic(); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index 035925228334..d2126bf3556f 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -30,10 +30,6 @@ using namespace lldb; using namespace lldb_private; -static const char *pluginName = "ABIMacOSX_i386"; -static const char *pluginDesc = "Mac OS X ABI for i386 targets"; -static const char *pluginShort = "abi.macosx-i386"; - enum { gcc_eax = 0, @@ -974,8 +970,8 @@ ABIMacOSX_i386::RegisterIsCalleeSaved (const RegisterInfo *reg_info) void ABIMacOSX_i386::Initialize() { - PluginManager::RegisterPlugin (pluginName, - pluginDesc, + PluginManager::RegisterPlugin (GetPluginNameStatic(), + "Mac OS X ABI for i386 targets", CreateInstance); } @@ -985,19 +981,21 @@ ABIMacOSX_i386::Terminate() PluginManager::UnregisterPlugin (CreateInstance); } +lldb_private::ConstString +ABIMacOSX_i386::GetPluginNameStatic () +{ + static ConstString g_short_name("abi.macosx-i386"); + return g_short_name; + +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ABIMacOSX_i386::GetPluginName() { - return pluginName; -} - -const char * -ABIMacOSX_i386::GetShortPluginName() -{ - return pluginShort; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h index 4cc94ab0348c..8c2d945e6342 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -118,12 +118,12 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + static lldb_private::ConstString + GetPluginNameStatic (); + + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 2cd7bdf82f7e..a9b002c03dfd 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -33,11 +33,6 @@ using namespace lldb; using namespace lldb_private; -static const char *pluginName = "ABISysV_x86_64"; -static const char *pluginDesc = "System V ABI for x86_64 targets"; -static const char *pluginShort = "abi.sysv-x86_64"; - - enum gcc_dwarf_regnums { gcc_dwarf_rax = 0, @@ -1269,8 +1264,8 @@ ABISysV_x86_64::RegisterIsCalleeSaved (const RegisterInfo *reg_info) void ABISysV_x86_64::Initialize() { - PluginManager::RegisterPlugin (pluginName, - pluginDesc, + PluginManager::RegisterPlugin (GetPluginNameStatic(), + "System V ABI for x86_64 targets", CreateInstance); } @@ -1280,19 +1275,20 @@ ABISysV_x86_64::Terminate() PluginManager::UnregisterPlugin (CreateInstance); } +lldb_private::ConstString +ABISysV_x86_64::GetPluginNameStatic() +{ + static ConstString g_name("sysv-x86_64"); + return g_name; +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ABISysV_x86_64::GetPluginName() { - return pluginName; -} - -const char * -ABISysV_x86_64::GetShortPluginName() -{ - return pluginShort; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h index 2cc3fbcca32b..b10181960e89 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -112,15 +112,15 @@ public: static lldb::ABISP CreateInstance (const lldb_private::ArchSpec &arch); + static lldb_private::ConstString + GetPluginNameStatic(); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp index b3647044b27d..6999b2a75bfe 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -694,7 +694,7 @@ void DisassemblerLLVMC::Initialize() { PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), + "Disassembler that uses LLVM MC to disassemble i386, x86_64 and ARM.", CreateInstance); llvm::InitializeAllTargetInfos(); @@ -710,16 +710,11 @@ DisassemblerLLVMC::Terminate() } -const char * +ConstString DisassemblerLLVMC::GetPluginNameStatic() { - return "llvm-mc"; -} - -const char * -DisassemblerLLVMC::GetPluginDescriptionStatic() -{ - return "Disassembler that uses LLVM MC to disassemble i386, x86_64 and ARM."; + static ConstString g_name("llvm-mc"); + return g_name; } int DisassemblerLLVMC::OpInfoCallback (void *disassembler, @@ -813,14 +808,8 @@ const char *DisassemblerLLVMC::SymbolLookup (uint64_t value, //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +ConstString DisassemblerLLVMC::GetPluginName() -{ - return "DisassemblerLLVMC"; -} - -const char * -DisassemblerLLVMC::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h index 4a265c573d81..29b28ade81a4 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h @@ -74,12 +74,9 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); - static const char * - GetPluginDescriptionStatic(); - static lldb_private::Disassembler * CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor); @@ -99,12 +96,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 5913b3293153..873eec85ce0d 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -26,7 +26,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanRunToAddress.h" - +#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" #include "DynamicLoaderDarwinKernel.h" @@ -460,7 +460,7 @@ DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::ad m_mutex(Mutex::eMutexTypeRecursive), m_break_id (LLDB_INVALID_BREAK_ID) { - PlatformSP platform_sp(Platform::FindPlugin (process, "darwin-kernel")); + PlatformSP platform_sp(Platform::FindPlugin (process, PlatformDarwinKernel::GetPluginNameStatic ())); // Only select the darwin-kernel Platform if we've been asked to load kexts. // It can take some time to scan over all of the kext info.plists and that // shouldn't be done if kext loading is explicitly disabled. @@ -811,8 +811,9 @@ DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule (Process *p PlatformSP platform_sp (target.GetPlatform()); if (platform_sp) { - const char *pname = platform_sp->GetShortPluginName(); - if (pname && strcmp (pname, "darwin-kernel") == 0) + ConstString platform_name (platform_sp->GetPluginName()); + static ConstString g_platform_name (PlatformDarwinKernel::GetPluginNameStatic()); + if (platform_name == g_platform_name) { ModuleSpec kext_bundle_module_spec(module_spec); FileSpec kext_filespec(m_name.c_str(), false); @@ -1594,10 +1595,11 @@ DynamicLoaderDarwinKernel::DebuggerInitialize (lldb_private::Debugger &debugger) } } -const char * +lldb_private::ConstString DynamicLoaderDarwinKernel::GetPluginNameStatic() { - return "dynamic-loader.darwin-kernel"; + static ConstString g_name("darwin-kernel"); + return g_name; } const char * @@ -1610,14 +1612,8 @@ DynamicLoaderDarwinKernel::GetPluginDescriptionStatic() //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString DynamicLoaderDarwinKernel::GetPluginName() -{ - return "DynamicLoaderDarwinKernel"; -} - -const char * -DynamicLoaderDarwinKernel::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h index d65622cff03a..c34ac6562ab5 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -38,7 +38,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -80,12 +80,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 94c824a8a054..170d50217faa 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -1760,10 +1760,11 @@ DynamicLoaderMacOSXDYLD::Terminate() } -const char * +lldb_private::ConstString DynamicLoaderMacOSXDYLD::GetPluginNameStatic() { - return "dynamic-loader.macosx-dyld"; + static ConstString g_name("macosx-dyld"); + return g_name; } const char * @@ -1776,14 +1777,8 @@ DynamicLoaderMacOSXDYLD::GetPluginDescriptionStatic() //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString DynamicLoaderMacOSXDYLD::GetPluginName() -{ - return "DynamicLoaderMacOSXDYLD"; -} - -const char * -DynamicLoaderMacOSXDYLD::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h index 0b1a9a6a5931..6405ed8f1a52 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -37,7 +37,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -80,12 +80,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 889419558477..58173f897ebf 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -40,22 +40,17 @@ DynamicLoaderPOSIXDYLD::Terminate() { } -const char * +lldb_private::ConstString DynamicLoaderPOSIXDYLD::GetPluginName() { - return "DynamicLoaderPOSIXDYLD"; -} - -const char * -DynamicLoaderPOSIXDYLD::GetShortPluginName() -{ - return "linux-dyld"; + return GetPluginNameStatic(); } -const char * +lldb_private::ConstString DynamicLoaderPOSIXDYLD::GetPluginNameStatic() { - return "dynamic-loader.linux-dyld"; + static ConstString g_name("linux-dyld"); + return g_name; } const char * diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h index 709eacac161b..c046798b102e 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h @@ -30,7 +30,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -64,12 +64,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp index 0a828ed0e2cf..274ba328ad1f 100644 --- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp +++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp @@ -178,10 +178,11 @@ DynamicLoaderStatic::Terminate() } -const char * +lldb_private::ConstString DynamicLoaderStatic::GetPluginNameStatic() { - return "dynamic-loader.static"; + static ConstString g_name("static"); + return g_name; } const char * @@ -194,14 +195,8 @@ DynamicLoaderStatic::GetPluginDescriptionStatic() //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString DynamicLoaderStatic::GetPluginName() -{ - return "DynamicLoaderStatic"; -} - -const char * -DynamicLoaderStatic::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h index 3bdb016f22cb..a99435fa32ad 100644 --- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h +++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h @@ -37,7 +37,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -72,12 +72,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index 860e633f8ebf..a9d94afcc322 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -174,10 +174,11 @@ EmulateInstructionARM::Terminate () PluginManager::UnregisterPlugin (CreateInstance); } -const char * +ConstString EmulateInstructionARM::GetPluginNameStatic () { - return "lldb.emulate-instruction.arm"; + static ConstString g_name("arm"); + return g_name; } const char * diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h index 8c7cb3685f37..b926dc0deb4a 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h @@ -11,6 +11,7 @@ #define lldb_EmulateInstructionARM_h_ #include "lldb/Core/EmulateInstruction.h" +#include "lldb/Core/ConstString.h" #include "lldb/Core/Error.h" #include "Plugins/Process/Utility/ARMDefines.h" @@ -67,7 +68,7 @@ public: static void Terminate (); - static const char * + static lldb_private::ConstString GetPluginNameStatic (); static const char * @@ -93,14 +94,8 @@ public: return false; } - virtual const char * + virtual lldb_private::ConstString GetPluginName() - { - return "EmulateInstructionARM"; - } - - virtual const char * - GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 05e66f389742..8a0d218ab34e 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -32,9 +32,6 @@ using namespace lldb; using namespace lldb_private; -static const char *pluginName = "ItaniumABILanguageRuntime"; -static const char *pluginDesc = "Itanium ABI for the C++ language"; -static const char *pluginShort = "language.itanium"; static const char *vtable_demangled_prefix = "vtable for "; bool @@ -306,8 +303,8 @@ ItaniumABILanguageRuntime::CreateInstance (Process *process, lldb::LanguageType void ItaniumABILanguageRuntime::Initialize() { - PluginManager::RegisterPlugin (pluginName, - pluginDesc, + PluginManager::RegisterPlugin (GetPluginNameStatic(), + "Itanium ABI for the C++ language", CreateInstance); } @@ -317,19 +314,20 @@ ItaniumABILanguageRuntime::Terminate() PluginManager::UnregisterPlugin (CreateInstance); } +lldb_private::ConstString +ItaniumABILanguageRuntime::GetPluginNameStatic() +{ + static ConstString g_name("itanium"); + return g_name; +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ItaniumABILanguageRuntime::GetPluginName() { - return pluginName; -} - -const char * -ItaniumABILanguageRuntime::GetShortPluginName() -{ - return pluginShort; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h index c9165f446ee9..6b2c437de252 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h @@ -52,15 +52,15 @@ namespace lldb_private { static lldb_private::LanguageRuntime * CreateInstance (Process *process, lldb::LanguageType language); + static lldb_private::ConstString + GetPluginNameStatic(); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 76398f548861..0de4cb9428fa 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -37,11 +37,6 @@ using namespace lldb; using namespace lldb_private; -static const char *pluginName = "AppleObjCRuntimeV1"; -static const char *pluginDesc = "Apple Objective C Language Runtime - Version 1"; -static const char *pluginShort = "language.apple.objc.v1"; - - AppleObjCRuntimeV1::AppleObjCRuntimeV1(Process *process) : AppleObjCRuntime (process), m_hash_signature (), @@ -96,8 +91,8 @@ AppleObjCRuntimeV1::CreateInstance (Process *process, lldb::LanguageType languag void AppleObjCRuntimeV1::Initialize() { - PluginManager::RegisterPlugin (pluginName, - pluginDesc, + PluginManager::RegisterPlugin (GetPluginNameStatic(), + "Apple Objective C Language Runtime - Version 1", CreateInstance); } @@ -107,19 +102,20 @@ AppleObjCRuntimeV1::Terminate() PluginManager::UnregisterPlugin (CreateInstance); } +lldb_private::ConstString +AppleObjCRuntimeV1::GetPluginNameStatic() +{ + static ConstString g_name("apple-objc-v1"); + return g_name; +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +ConstString AppleObjCRuntimeV1::GetPluginName() { - return pluginName; -} - -const char * -AppleObjCRuntimeV1::GetShortPluginName() -{ - return pluginShort; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h index af58ac7e7686..ba8ecc2bbcb5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h @@ -114,15 +114,15 @@ public: static lldb_private::LanguageRuntime * CreateInstance (Process *process, lldb::LanguageType language); + static lldb_private::ConstString + GetPluginNameStatic(); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index daa566eb2bcf..2df1ac9d03b9 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -50,10 +50,6 @@ using namespace lldb; using namespace lldb_private; -static const char *pluginName = "AppleObjCRuntimeV2"; -static const char *pluginDesc = "Apple Objective C Language Runtime - Version 2"; -static const char *pluginShort = "language.apple.objc.v2"; - // 2 second timeout when running utility functions #define UTILITY_FUNCTION_TIMEOUT_USEC 2*1000*1000 @@ -427,8 +423,8 @@ AppleObjCRuntimeV2::CreateInstance (Process *process, LanguageType language) void AppleObjCRuntimeV2::Initialize() { - PluginManager::RegisterPlugin (pluginName, - pluginDesc, + PluginManager::RegisterPlugin (GetPluginNameStatic(), + "Apple Objective C Language Runtime - Version 2", CreateInstance); } @@ -438,19 +434,21 @@ AppleObjCRuntimeV2::Terminate() PluginManager::UnregisterPlugin (CreateInstance); } +lldb_private::ConstString +AppleObjCRuntimeV2::GetPluginNameStatic() +{ + static ConstString g_name("apple-objc-v2"); + return g_name; +} + + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString AppleObjCRuntimeV2::GetPluginName() { - return pluginName; -} - -const char * -AppleObjCRuntimeV2::GetShortPluginName() -{ - return pluginShort; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index ae2e6f35ab02..54cc3b86b1a8 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -55,15 +55,15 @@ public: static lldb_private::LanguageRuntime * CreateInstance (Process *process, lldb::LanguageType language); + static lldb_private::ConstString + GetPluginNameStatic(); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index a5e87fc358db..109e429fc7f7 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -148,11 +148,29 @@ ObjectContainerBSDArchive::Archive::ParseObjects () } ObjectContainerBSDArchive::Object * -ObjectContainerBSDArchive::Archive::FindObject (const ConstString &object_name) +ObjectContainerBSDArchive::Archive::FindObject (const ConstString &object_name, const TimeValue &object_mod_time) { const ObjectNameToIndexMap::Entry *match = m_object_name_to_index_map.FindFirstValueForName (object_name.GetCString()); if (match) - return &m_objects[match->value]; + { + if (object_mod_time.IsValid()) + { + const uint64_t object_date = object_mod_time.GetAsSecondsSinceJan1_1970(); + if (m_objects[match->value].ar_date == object_date) + return &m_objects[match->value]; + const ObjectNameToIndexMap::Entry *next_match = m_object_name_to_index_map.FindNextValueForName (match); + while (next_match) + { + if (m_objects[next_match->value].ar_date == object_date) + return &m_objects[next_match->value]; + next_match = m_object_name_to_index_map.FindNextValueForName (next_match); + } + } + else + { + return &m_objects[match->value]; + } + } return NULL; } @@ -250,10 +268,11 @@ ObjectContainerBSDArchive::Terminate() } -const char * +lldb_private::ConstString ObjectContainerBSDArchive::GetPluginNameStatic() { - return "object-container.bsd-archive"; + static ConstString g_name("bsd-archive"); + return g_name; } const char * @@ -297,11 +316,11 @@ ObjectContainerBSDArchive::CreateInstance Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module_sp->GetArchitecture(), module_sp->GetModificationTime())); std::unique_ptr container_ap(new ObjectContainerBSDArchive (module_sp, - archive_data_sp, - archive_data_offset, - file, - file_offset, - length)); + archive_data_sp, + archive_data_offset, + file, + file_offset, + length)); if (container_ap.get()) { @@ -434,7 +453,8 @@ ObjectContainerBSDArchive::GetObjectFile (const FileSpec *file) { if (module_sp->GetObjectName() && m_archive_sp) { - Object *object = m_archive_sp->FindObject (module_sp->GetObjectName()); + Object *object = m_archive_sp->FindObject (module_sp->GetObjectName(), + module_sp->GetObjectModificationTime()); if (object) { lldb::offset_t data_offset = m_offset + object->ar_file_offset; @@ -454,14 +474,8 @@ ObjectContainerBSDArchive::GetObjectFile (const FileSpec *file) //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ObjectContainerBSDArchive::GetPluginName() -{ - return "object-container.bsd-archive"; -} - -const char * -ObjectContainerBSDArchive::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h index 7802eb152d56..a44bb80a9650 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h @@ -32,7 +32,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -89,12 +89,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); @@ -163,7 +160,8 @@ protected: ParseObjects (); Object * - FindObject (const lldb_private::ConstString &object_name); + FindObject (const lldb_private::ConstString &object_name, + const lldb_private::TimeValue &object_mod_time); const lldb_private::TimeValue & GetModificationTime() diff --git a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp index d1f4434c987a..f28aa3bed05e 100644 --- a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp +++ b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp @@ -37,10 +37,11 @@ ObjectContainerUniversalMachO::Terminate() } -const char * +lldb_private::ConstString ObjectContainerUniversalMachO::GetPluginNameStatic() { - return "object-container.mach-o"; + static ConstString g_name("mach-o"); + return g_name; } const char * @@ -259,14 +260,8 @@ ObjectContainerUniversalMachO::GetObjectFile (const FileSpec *file) //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ObjectContainerUniversalMachO::GetPluginName() -{ - return "ObjectContainerUniversalMachO"; -} - -const char * -ObjectContainerUniversalMachO::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h index 1fe1a2d2165c..0c4a3d47c7a5 100644 --- a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h +++ b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h @@ -28,7 +28,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -84,12 +84,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 4ba081a7b7ca..f4af192e38b9 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -160,10 +160,11 @@ ObjectFileELF::Terminate() PluginManager::UnregisterPlugin(CreateInstance); } -const char * +lldb_private::ConstString ObjectFileELF::GetPluginNameStatic() { - return "object-file.elf"; + static ConstString g_name("elf"); + return g_name; } const char * @@ -236,14 +237,8 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ObjectFileELF::GetPluginName() -{ - return "ObjectFileELF"; -} - -const char * -ObjectFileELF::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h index 78cfb3f5157c..cdf2731b2541 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -38,7 +38,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -68,12 +68,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index b94ebca297d8..7047395bdc79 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -379,10 +379,11 @@ ObjectFileMachO::Terminate() } -const char * +lldb_private::ConstString ObjectFileMachO::GetPluginNameStatic() { - return "object-file.mach-o"; + static ConstString g_name("mach-o"); + return g_name; } const char * @@ -4169,14 +4170,8 @@ ObjectFileMachO::GetLLDBSharedCacheUUID () //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString ObjectFileMachO::GetPluginName() -{ - return "ObjectFileMachO"; -} - -const char * -ObjectFileMachO::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h index 2226e3dd6959..349928e9538d 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -35,7 +35,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -122,12 +122,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 157b148ee5c9..b25db97d498e 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -133,10 +133,11 @@ ObjectFilePECOFF::Terminate() } -const char * +lldb_private::ConstString ObjectFilePECOFF::GetPluginNameStatic() { - return "object-file.pe-coff"; + static ConstString g_name("pe-coff"); + return g_name; } const char * @@ -954,14 +955,8 @@ ObjectFilePECOFF::CalculateStrata() //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +ConstString ObjectFilePECOFF::GetPluginName() -{ - return "ObjectFilePECOFF"; -} - -const char * -ObjectFilePECOFF::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h index 33973abad02c..d980006eab6e 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h @@ -28,7 +28,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -106,12 +106,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); // diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 1af044e00e22..67b5c4f70888 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -69,10 +69,11 @@ OperatingSystemPython::CreateInstance (Process *process, bool force) } -const char * +ConstString OperatingSystemPython::GetPluginNameStatic() { - return "python"; + static ConstString g_name("python"); + return g_name; } const char * @@ -152,14 +153,8 @@ OperatingSystemPython::GetDynamicRegisterInfo () //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +ConstString OperatingSystemPython::GetPluginName() -{ - return "OperatingSystemPython"; -} - -const char * -OperatingSystemPython::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h index 0055058192cc..077039e50d56 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h @@ -34,7 +34,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -52,12 +52,9 @@ public: //------------------------------------------------------------------ // lldb_private::PluginInterface Methods //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index 07846c81cc7b..0c2c46f84dda 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -85,19 +85,19 @@ PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch) } -const char * -PlatformFreeBSD::GetPluginNameStatic() -{ - return "plugin.platform.freebsd"; -} - -const char * -PlatformFreeBSD::GetShortPluginNameStatic (bool is_host) +lldb_private::ConstString +PlatformFreeBSD::GetPluginNameStatic (bool is_host) { if (is_host) - return Platform::GetHostPlatformName (); + { + static ConstString g_host_name(Platform::GetHostPlatformName ()); + return g_host_name; + } else - return "remote-freebsd"; + { + static ConstString g_remote_name("remote-freebsd"); + return g_remote_name; + } } const char * @@ -122,7 +122,7 @@ PlatformFreeBSD::Initialize () default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif - PluginManager::RegisterPlugin(PlatformFreeBSD::GetShortPluginNameStatic(false), + PluginManager::RegisterPlugin(PlatformFreeBSD::GetPluginNameStatic(false), PlatformFreeBSD::GetDescriptionStatic(false), PlatformFreeBSD::CreateInstance); } @@ -269,7 +269,7 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, { error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", exe_file.GetPath().c_str(), - GetShortPluginName(), + GetPluginName().GetCString(), arch_names.GetString().c_str()); } } @@ -377,7 +377,7 @@ PlatformFreeBSD::ConnectRemote (Args& args) Error error; if (IsHost()) { - error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetShortPluginName()); + error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString()); } else { @@ -415,7 +415,7 @@ PlatformFreeBSD::DisconnectRemote () if (IsHost()) { - error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetShortPluginName()); + error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetPluginName().GetCString()); } else { diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h index 80c4a63e0a81..4aa158eb6e87 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -33,14 +33,11 @@ public: static void Terminate (); - static const char * - GetPluginNameStatic(); - - static const char * - GetShortPluginNameStatic(bool is_host); + static lldb_private::ConstString + GetPluginNameStatic (bool is_host); static const char * - GetDescriptionStatic(bool is_host); + GetDescriptionStatic (bool is_host); //------------------------------------------------------------ // Class Methods @@ -53,16 +50,10 @@ public: //------------------------------------------------------------ // lldb_private::PluginInterface functions //------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName() { - return GetPluginNameStatic(); - } - - virtual const char * - GetShortPluginName() - { - return GetShortPluginNameStatic (IsHost()); + return GetPluginNameStatic (IsHost()); } virtual uint32_t diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 1078a23443f9..ef4bd41dc783 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -86,19 +86,20 @@ PlatformLinux::CreateInstance (bool force, const ArchSpec *arch) return NULL; } -const char * -PlatformLinux::GetPluginNameStatic() -{ - return "plugin.platform.linux"; -} -const char * -PlatformLinux::GetShortPluginNameStatic (bool is_host) +lldb_private::ConstString +PlatformLinux::GetPluginNameStatic (bool is_host) { if (is_host) - return Platform::GetHostPlatformName (); + { + static ConstString g_host_name(Platform::GetHostPlatformName ()); + return g_host_name; + } else - return "remote-linux"; + { + static ConstString g_remote_name("remote-linux"); + return g_remote_name; + } } const char * @@ -110,6 +111,12 @@ PlatformLinux::GetPluginDescriptionStatic (bool is_host) return "Remote Linux user platform plug-in."; } +lldb_private::ConstString +PlatformLinux::GetPluginName() +{ + return GetPluginNameStatic(IsHost()); +} + void PlatformLinux::Initialize () { @@ -120,7 +127,7 @@ PlatformLinux::Initialize () default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif - PluginManager::RegisterPlugin(PlatformLinux::GetShortPluginNameStatic(false), + PluginManager::RegisterPlugin(PlatformLinux::GetPluginNameStatic(false), PlatformLinux::GetPluginDescriptionStatic(false), PlatformLinux::CreateInstance); } @@ -242,7 +249,7 @@ PlatformLinux::ResolveExecutable (const FileSpec &exe_file, { error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", exe_file.GetPath().c_str(), - GetShortPluginName(), + GetPluginName().GetCString(), arch_names.GetString().c_str()); } } diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h index 8b43def165b3..a77780d59a2c 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h @@ -39,26 +39,14 @@ namespace lldb_private { static Platform * CreateInstance (bool force, const lldb_private::ArchSpec *arch); - static const char * - GetPluginNameStatic(); - - static const char * - GetShortPluginNameStatic(bool is_host); + static lldb_private::ConstString + GetPluginNameStatic (bool is_host); static const char * - GetPluginDescriptionStatic(bool is_host); + GetPluginDescriptionStatic (bool is_host); - virtual const char * - GetPluginName() - { - return GetPluginNameStatic(); - } - - virtual const char * - GetShortPluginName() - { - return "PlatformLinux"; - } + virtual lldb_private::ConstString + GetPluginName(); virtual uint32_t GetPluginVersion() diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index b3775d410ae3..b958e0fe8706 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -232,7 +232,7 @@ PlatformDarwin::ResolveExecutable (const FileSpec &exe_file, { error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", exe_file.GetPath().c_str(), - GetShortPluginName(), + GetPluginName().GetCString(), arch_names.GetString().c_str()); } } @@ -501,7 +501,7 @@ PlatformDarwin::ConnectRemote (Args& args) Error error; if (IsHost()) { - error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetShortPluginName()); + error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString()); } else { @@ -539,7 +539,7 @@ PlatformDarwin::DisconnectRemote () if (IsHost()) { - error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetShortPluginName()); + error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetPluginName().GetCString()); } else { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index 6b6b80306083..104285f19b60 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -53,7 +53,7 @@ PlatformDarwinKernel::Initialize () { if (g_initialize_count++ == 0) { - PluginManager::RegisterPlugin (PlatformDarwinKernel::GetShortPluginNameStatic(), + PluginManager::RegisterPlugin (PlatformDarwinKernel::GetPluginNameStatic(), PlatformDarwinKernel::GetDescriptionStatic(), PlatformDarwinKernel::CreateInstance, PlatformDarwinKernel::DebuggerInitialize); @@ -147,16 +147,11 @@ PlatformDarwinKernel::CreateInstance (bool force, const ArchSpec *arch) } -const char * +lldb_private::ConstString PlatformDarwinKernel::GetPluginNameStatic () { - return "PlatformDarwinKernel"; -} - -const char * -PlatformDarwinKernel::GetShortPluginNameStatic() -{ - return "darwin-kernel"; + static ConstString g_name("darwin-kernel"); + return g_name; } const char * diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h index 0b9b93677e5c..3d2035f64f97 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h @@ -40,12 +40,9 @@ public: static void Terminate (); - static const char * + static lldb_private::ConstString GetPluginNameStatic (); - static const char * - GetShortPluginNameStatic(); - static const char * GetDescriptionStatic(); @@ -60,18 +57,12 @@ public: //------------------------------------------------------------ // lldb_private::PluginInterface functions //------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName() { return GetPluginNameStatic(); } - virtual const char * - GetShortPluginName() - { - return GetShortPluginNameStatic(); - } - virtual uint32_t GetPluginVersion() { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index cf783119a1df..16bcafd97b85 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -41,7 +41,7 @@ PlatformMacOSX::Initialize () default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif - PluginManager::RegisterPlugin (PlatformMacOSX::GetShortPluginNameStatic(false), + PluginManager::RegisterPlugin (PlatformMacOSX::GetPluginNameStatic(false), PlatformMacOSX::GetDescriptionStatic(false), PlatformMacOSX::CreateInstance); } @@ -115,20 +115,19 @@ PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch) return NULL; } - -const char * -PlatformMacOSX::GetPluginNameStatic () -{ - return "PlatformMacOSX"; -} - -const char * -PlatformMacOSX::GetShortPluginNameStatic (bool is_host) +lldb_private::ConstString +PlatformMacOSX::GetPluginNameStatic (bool is_host) { if (is_host) - return Platform::GetHostPlatformName (); + { + static ConstString g_host_name(Platform::GetHostPlatformName ()); + return g_host_name; + } else - return "remote-macosx"; + { + static ConstString g_remote_name("remote-macosx"); + return g_remote_name; + } } const char * diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h index 3a5eaf0072a9..b93c5fa69219 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h @@ -32,11 +32,8 @@ public: static void Terminate (); - static const char * - GetPluginNameStatic (); - - static const char * - GetShortPluginNameStatic(bool is_host); + static lldb_private::ConstString + GetPluginNameStatic (bool is_host); static const char * GetDescriptionStatic(bool is_host); @@ -52,16 +49,10 @@ public: //------------------------------------------------------------ // lldb_private::PluginInterface functions //------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName() { - return GetPluginNameStatic (); - } - - virtual const char * - GetShortPluginName() - { - return GetShortPluginNameStatic (IsHost()); + return GetPluginNameStatic (IsHost()); } virtual uint32_t diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index fe6d358e6fc7..7969aa819cfd 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -65,7 +65,7 @@ PlatformRemoteiOS::Initialize () { if (g_initialize_count++ == 0) { - PluginManager::RegisterPlugin (PlatformRemoteiOS::GetShortPluginNameStatic(), + PluginManager::RegisterPlugin (PlatformRemoteiOS::GetPluginNameStatic(), PlatformRemoteiOS::GetDescriptionStatic(), PlatformRemoteiOS::CreateInstance); } @@ -148,16 +148,11 @@ PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch) } -const char * +lldb_private::ConstString PlatformRemoteiOS::GetPluginNameStatic () { - return "PlatformRemoteiOS"; -} - -const char * -PlatformRemoteiOS::GetShortPluginNameStatic() -{ - return "remote-ios"; + static ConstString g_name("remote-ios"); + return g_name; } const char * @@ -279,7 +274,7 @@ PlatformRemoteiOS::ResolveExecutable (const FileSpec &exe_file, { error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", exe_file.GetPath().c_str(), - GetShortPluginName(), + GetPluginName().GetCString(), arch_names.GetString().c_str()); } } @@ -661,7 +656,7 @@ PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file, error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'", platform_file_path, - GetPluginName()); + GetPluginName().GetCString()); } else { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h index d52c6b09df72..ef59b124d8eb 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -34,12 +34,9 @@ public: static void Terminate (); - static const char * + static lldb_private::ConstString GetPluginNameStatic (); - static const char * - GetShortPluginNameStatic(); - static const char * GetDescriptionStatic(); @@ -54,18 +51,12 @@ public: //------------------------------------------------------------ // lldb_private::PluginInterface functions //------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName() { return GetPluginNameStatic(); } - virtual const char * - GetShortPluginName() - { - return GetShortPluginNameStatic(); - } - virtual uint32_t GetPluginVersion() { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp index 5f1cfc8dc86f..806eb7d60ea8 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -42,7 +42,7 @@ PlatformiOSSimulator::Initialize () { if (g_initialize_count++ == 0) { - PluginManager::RegisterPlugin (PlatformiOSSimulator::GetShortPluginNameStatic(), + PluginManager::RegisterPlugin (PlatformiOSSimulator::GetPluginNameStatic(), PlatformiOSSimulator::GetDescriptionStatic(), PlatformiOSSimulator::CreateInstance); } @@ -124,16 +124,11 @@ PlatformiOSSimulator::CreateInstance (bool force, const ArchSpec *arch) } -const char * +lldb_private::ConstString PlatformiOSSimulator::GetPluginNameStatic () { - return "PlatformiOSSimulator"; -} - -const char * -PlatformiOSSimulator::GetShortPluginNameStatic() -{ - return "ios-simulator"; + static ConstString g_name("ios-simulator"); + return g_name; } const char * @@ -242,7 +237,7 @@ PlatformiOSSimulator::ResolveExecutable (const FileSpec &exe_file, { error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", exe_file.GetPath().c_str(), - GetShortPluginName(), + GetPluginName().GetCString(), arch_names.GetString().c_str()); } } @@ -352,7 +347,7 @@ PlatformiOSSimulator::GetFile (const FileSpec &platform_file, } error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'", platform_file_path, - GetPluginName()); + GetPluginName().GetCString()); } else { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h index 36b554b54045..ce818c431a77 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h @@ -32,12 +32,9 @@ public: static void Terminate (); - static const char * + static lldb_private::ConstString GetPluginNameStatic (); - static const char * - GetShortPluginNameStatic(); - static const char * GetDescriptionStatic(); @@ -52,18 +49,12 @@ public: //------------------------------------------------------------ // lldb_private::PluginInterface functions //------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName() { return GetPluginNameStatic(); } - virtual const char * - GetShortPluginName() - { - return GetShortPluginNameStatic(); - } - virtual uint32_t GetPluginVersion() { diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index cc7a21938671..221001b7ca02 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -41,7 +41,7 @@ PlatformRemoteGDBServer::Initialize () if (g_initialized == false) { g_initialized = true; - PluginManager::RegisterPlugin (PlatformRemoteGDBServer::GetShortPluginNameStatic(), + PluginManager::RegisterPlugin (PlatformRemoteGDBServer::GetPluginNameStatic(), PlatformRemoteGDBServer::GetDescriptionStatic(), PlatformRemoteGDBServer::CreateInstance); } @@ -71,10 +71,11 @@ PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpe } -const char * -PlatformRemoteGDBServer::GetShortPluginNameStatic() +lldb_private::ConstString +PlatformRemoteGDBServer::GetPluginNameStatic() { - return "remote-gdb-server"; + static ConstString g_name("remote-gdb-server"); + return g_name; } const char * diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h index ad2ffa53194c..22b3dd49be54 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -32,8 +32,8 @@ public: static lldb_private::Platform* CreateInstance (bool force, const lldb_private::ArchSpec *arch); - static const char * - GetShortPluginNameStatic(); + static lldb_private::ConstString + GetPluginNameStatic(); static const char * GetDescriptionStatic(); @@ -47,16 +47,10 @@ public: //------------------------------------------------------------ // lldb_private::PluginInterface functions //------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName() { - return "PlatformRemoteGDBServer"; - } - - virtual const char * - GetShortPluginName() - { - return GetShortPluginNameStatic(); + return GetPluginNameStatic(); } virtual uint32_t diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index 19e332e2a51a..ea26d972b860 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -64,10 +64,11 @@ ProcessFreeBSD::Initialize() } } -const char * +lldb_private::ConstString ProcessFreeBSD::GetPluginNameStatic() { - return "freebsd"; + static ConstString g_name("freebsd"); + return g_name; } const char * @@ -79,16 +80,10 @@ ProcessFreeBSD::GetPluginDescriptionStatic() //------------------------------------------------------------------------------ // ProcessInterface protocol. -const char * +lldb_private::ConstString ProcessFreeBSD::GetPluginName() { - return "process.freebsd"; -} - -const char * -ProcessFreeBSD::GetShortPluginName() -{ - return "process.freebsd"; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h index 74996f131271..5f79b74cad30 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -42,7 +42,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -60,12 +60,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp index 6118a0976f7d..5d93502823e0 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp @@ -81,10 +81,11 @@ void ProcessLinux::Terminate() { } -const char * +lldb_private::ConstString ProcessLinux::GetPluginNameStatic() { - return "linux"; + static ConstString g_name("linux"); + return g_name; } const char * @@ -105,16 +106,10 @@ ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thre //------------------------------------------------------------------------------ // ProcessInterface protocol. -const char * +lldb_private::ConstString ProcessLinux::GetPluginName() { - return "process.linux"; -} - -const char * -ProcessLinux::GetShortPluginName() -{ - return "process.linux"; + return GetPluginNameStatic(); } uint32_t diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/lldb/source/Plugins/Process/Linux/ProcessLinux.h index 9acbf49f5f01..e65f1fac8b7c 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.h +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.h @@ -41,7 +41,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -58,12 +58,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 18007369e831..ef97079dca38 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -46,10 +46,11 @@ using namespace lldb_private; static const lldb::tid_t g_kernel_tid = 1; -const char * +ConstString ProcessKDP::GetPluginNameStatic() { - return "kdp-remote"; + static ConstString g_name("kdp-remote"); + return g_name; } const char * @@ -141,14 +142,8 @@ ProcessKDP::~ProcessKDP() //---------------------------------------------------------------------- // PluginInterface //---------------------------------------------------------------------- -const char * +lldb_private::ConstString ProcessKDP::GetPluginName() -{ - return "Process debugging plug-in that uses the Darwin KDP remote protocol"; -} - -const char * -ProcessKDP::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h index 1dff43f1090b..0075c7ce188a 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h @@ -49,7 +49,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -113,12 +113,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp index a9f572c090b4..79cb62aa0066 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp @@ -167,7 +167,8 @@ ProcessKDPLog::ListLogCategories (Stream *strm) " thread - log thread events and activities\n" " step - log step related activities\n" " verbose - enable verbose logging\n" - " watch - log watchpoint related activities\n", ProcessKDP::GetPluginNameStatic()); + " watch - log watchpoint related activities\n", + ProcessKDP::GetPluginNameStatic().GetCString()); } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 0008dbfa2888..3475bab3bca3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -116,10 +116,11 @@ get_random_port () } -const char * +lldb_private::ConstString ProcessGDBRemote::GetPluginNameStatic() { - return "gdb-remote"; + static ConstString g_name("gdb-remote"); + return g_name; } const char * @@ -233,14 +234,8 @@ ProcessGDBRemote::~ProcessGDBRemote() //---------------------------------------------------------------------- // PluginInterface //---------------------------------------------------------------------- -const char * +ConstString ProcessGDBRemote::GetPluginName() -{ - return "Process debugging plug-in that uses the GDB remote protocol"; -} - -const char * -ProcessGDBRemote::GetShortPluginName() { return GetPluginNameStatic(); } @@ -1746,7 +1741,7 @@ ProcessGDBRemote::DoDestroy () // FIXME: These should be ConstStrings so we aren't doing strcmp'ing. if (platform_sp && platform_sp->GetName() - && strcmp (platform_sp->GetName(), PlatformRemoteiOS::GetShortPluginNameStatic()) == 0) + && platform_sp->GetName() == PlatformRemoteiOS::GetPluginNameStatic()) { if (m_destroy_tried_resuming) { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 5cbb13f49146..51924c553af7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -50,7 +50,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -119,12 +119,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp index 2bb6826e2239..15b861feaa82 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp @@ -178,7 +178,7 @@ ProcessGDBRemoteLog::ListLogCategories (Stream *strm) " thread - log thread events and activities\n" " step - log step related activities\n" " verbose - enable verbose logging\n" - " watch - log watchpoint related activities\n", ProcessGDBRemote::GetPluginNameStatic()); + " watch - log watchpoint related activities\n", ProcessGDBRemote::GetPluginNameStatic().GetCString()); } diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 0e19ebe7afd2..abf3b673e680 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -38,10 +38,11 @@ using namespace lldb; using namespace lldb_private; -const char * +ConstString ProcessMachCore::GetPluginNameStatic() { - return "mach-o-core"; + static ConstString g_name("mach-o-core"); + return g_name; } const char * @@ -125,14 +126,8 @@ ProcessMachCore::~ProcessMachCore() //---------------------------------------------------------------------- // PluginInterface //---------------------------------------------------------------------- -const char * +ConstString ProcessMachCore::GetPluginName() -{ - return "Process debugging plug-in that loads mach-o core files."; -} - -const char * -ProcessMachCore::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h index 246d5722d5a7..5048a549f8c5 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h @@ -39,7 +39,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -74,12 +74,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp index 54e789e1fefb..27fa261813bb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp @@ -51,7 +51,7 @@ LogChannelDWARF::CreateInstance () return new LogChannelDWARF (); } -const char * +lldb_private::ConstString LogChannelDWARF::GetPluginNameStatic() { return SymbolFileDWARF::GetPluginNameStatic(); @@ -63,14 +63,8 @@ LogChannelDWARF::GetPluginDescriptionStatic() return "DWARF log channel for debugging plug-in issues."; } -const char * +lldb_private::ConstString LogChannelDWARF::GetPluginName() -{ - return GetPluginDescriptionStatic(); -} - -const char * -LogChannelDWARF::GetShortPluginName() { return GetPluginNameStatic(); } @@ -187,7 +181,7 @@ LogChannelDWARF::ListCategories (Stream *strm) " lookups - log any lookups that happen by name, regex, or address\n" " completion - log struct/unions/class type completions\n" " map - log insertions of object files into DWARF debug maps\n", - SymbolFileDWARF::GetPluginNameStatic()); + SymbolFileDWARF::GetPluginNameStatic().GetCString()); } Log * diff --git a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h index 6a6375cc8060..2091a8414f58 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h @@ -43,7 +43,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -52,12 +52,9 @@ public: static lldb_private::LogChannel * CreateInstance (); - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index d0b1a5ac00d4..9a8030a0fe44 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -207,10 +207,11 @@ SymbolFileDWARF::Terminate() } -const char * +lldb_private::ConstString SymbolFileDWARF::GetPluginNameStatic() { - return "dwarf"; + static ConstString g_name("dwarf"); + return g_name; } const char * @@ -7557,14 +7558,8 @@ SymbolFileDWARF::ParseVariables //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +ConstString SymbolFileDWARF::GetPluginName() -{ - return "SymbolFileDWARF"; -} - -const char * -SymbolFileDWARF::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 08dfc9632ee2..87f86b80bbb2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -74,7 +74,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -181,12 +181,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 941484ea3a51..3afe396f2231 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -179,8 +179,9 @@ public: const FileSpec& file_spec, const ArchSpec& arch, const ConstString *object_name, - off_t object_offset) : - Module (file_spec, arch, object_name, object_offset), + off_t object_offset, + const TimeValue *object_mod_time_ptr) : + Module (file_spec, arch, object_name, object_offset, object_mod_time_ptr), m_exe_module_wp (exe_module_sp), m_cu_idx (cu_idx) { @@ -213,7 +214,7 @@ public: // Set a a pointer to this class to set our OSO DWARF file know // that the DWARF is being used along with a debug map and that // it will have the remapped sections that we do below. - SymbolFileDWARF *oso_symfile = (SymbolFileDWARF *)symbol_vendor->GetSymbolFile(); + SymbolFileDWARF *oso_symfile = SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(symbol_vendor->GetSymbolFile()); if (!oso_symfile) return NULL; @@ -263,10 +264,11 @@ SymbolFileDWARFDebugMap::Terminate() } -const char * +lldb_private::ConstString SymbolFileDWARFDebugMap::GetPluginNameStatic() { - return "dwarf-debugmap"; + static ConstString g_name("dwarf-debugmap"); + return g_name; } const char * @@ -381,6 +383,9 @@ SymbolFileDWARFDebugMap::InitOSO() { m_compile_unit_infos[i].so_file.SetFile(so_symbol->GetName().AsCString(), false); m_compile_unit_infos[i].oso_path = oso_symbol->GetName(); + TimeValue oso_mod_time; + oso_mod_time.OffsetWithSeconds(oso_symbol->GetAddress().GetOffset()); + m_compile_unit_infos[i].oso_mod_time = oso_mod_time; uint32_t sibling_idx = so_symbol->GetSiblingIndex(); // The sibling index can't be less that or equal to the current index "i" if (sibling_idx <= i) @@ -436,12 +441,26 @@ SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_inf } else { + ObjectFile *obj_file = GetObjectFile(); comp_unit_info->oso_sp.reset (new OSOInfo()); m_oso_map[comp_unit_info->oso_path] = comp_unit_info->oso_sp; const char *oso_path = comp_unit_info->oso_path.GetCString(); FileSpec oso_file (oso_path, false); ConstString oso_object; - if (!oso_file.Exists()) + if (oso_file.Exists()) + { + TimeValue oso_mod_time (oso_file.GetModificationTime()); + if (oso_mod_time != comp_unit_info->oso_mod_time) + { + obj_file->GetModule()->ReportError ("debug map object file '%s' has changed (actual time is 0x%" PRIx64 ", debug map time is 0x%" PRIx64 ") since this executable was linked, file will be ignored", + oso_file.GetPath().c_str(), + oso_mod_time.GetAsSecondsSinceJan1_1970(), + comp_unit_info->oso_mod_time.GetAsSecondsSinceJan1_1970()); + return NULL; + } + + } + else { const bool must_exist = true; @@ -450,7 +469,6 @@ SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_inf oso_object, must_exist)) { - comp_unit_info->oso_sp->symbol_file_supported = false; return NULL; } } @@ -458,12 +476,13 @@ SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_inf // use the debug map, to add new sections to each .o file and // even though a .o file might not have changed, the sections // that get added to the .o file can change. - comp_unit_info->oso_sp->module_sp.reset (new DebugMapModule (GetObjectFile()->GetModule(), + comp_unit_info->oso_sp->module_sp.reset (new DebugMapModule (obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), oso_file, m_obj_file->GetModule()->GetArchitecture(), oso_object ? &oso_object : NULL, - 0)); + 0, + oso_object ? &comp_unit_info->oso_mod_time : NULL)); } } if (comp_unit_info->oso_sp) @@ -537,6 +556,14 @@ SymbolFileDWARFDebugMap::GetSymbolFileByOSOIndex (uint32_t oso_idx) return NULL; } +SymbolFileDWARF * +SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF (SymbolFile *sym_file) +{ + if (sym_file && sym_file->GetPluginName() == SymbolFileDWARF::GetPluginNameStatic()) + return (SymbolFileDWARF *)sym_file; + return NULL; +} + SymbolFileDWARF * SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo (CompileUnitInfo *comp_unit_info) { @@ -545,7 +572,7 @@ SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo (CompileUnitInfo *comp_unit { SymbolVendor *sym_vendor = oso_module->GetSymbolVendor(); if (sym_vendor) - return (SymbolFileDWARF *)sym_vendor->GetSymbolFile(); + return GetSymbolFileAsSymbolFileDWARF (sym_vendor->GetSymbolFile()); } return NULL; } @@ -1219,14 +1246,8 @@ SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc, //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString SymbolFileDWARFDebugMap::GetPluginName() -{ - return "SymbolFileDWARFDebugMap"; -} - -const char * -SymbolFileDWARFDebugMap::GetShortPluginName() { return GetPluginNameStatic(); } @@ -1454,7 +1475,7 @@ SymbolFileDWARFDebugMap::LinkOSOAddress (Address &addr) if (addr_module == exe_module) return true; // Address is already in terms of the main executable module - CompileUnitInfo *cu_info = GetCompileUnitInfo ((SymbolFileDWARF *)addr_module->GetSymbolVendor()->GetSymbolFile()); + CompileUnitInfo *cu_info = GetCompileUnitInfo (GetSymbolFileAsSymbolFileDWARF(addr_module->GetSymbolVendor()->GetSymbolFile())); if (cu_info) { const lldb::addr_t oso_file_addr = addr.GetFileAddress(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index aa21778222e1..07f8e415c788 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -40,7 +40,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -112,12 +112,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); @@ -133,11 +130,9 @@ protected: struct OSOInfo { lldb::ModuleSP module_sp; - bool symbol_file_supported; OSOInfo() : - module_sp (), - symbol_file_supported (true) + module_sp () { } }; @@ -153,6 +148,7 @@ protected: { lldb_private::FileSpec so_file; lldb_private::ConstString oso_path; + lldb_private::TimeValue oso_mod_time; OSOInfoSP oso_sp; lldb::CompUnitSP compile_unit_sp; uint32_t first_symbol_index; @@ -166,6 +162,7 @@ protected: CompileUnitInfo() : so_file (), oso_path (), + oso_mod_time (), oso_sp (), compile_unit_sp (), first_symbol_index (UINT32_MAX), @@ -192,6 +189,10 @@ protected: { return (uint32_t)((uid >> 32ull) - 1ull); } + + static SymbolFileDWARF * + GetSymbolFileAsSymbolFileDWARF (SymbolFile *sym_file); + bool GetFileSpecForSO (uint32_t oso_idx, lldb_private::FileSpec &file_spec); diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 87e40daec6f7..46460fe79d53 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -40,10 +40,11 @@ SymbolFileSymtab::Terminate() } -const char * +lldb_private::ConstString SymbolFileSymtab::GetPluginNameStatic() { - return "symbol-file.symtab"; + static ConstString g_name("symtab"); + return g_name; } const char * @@ -387,14 +388,8 @@ SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString SymbolFileSymtab::GetPluginName() -{ - return "SymbolFileSymtab"; -} - -const char * -SymbolFileSymtab::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index 3c90b112d80f..ede3447ee997 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -26,7 +26,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -113,12 +113,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index 56c04ba17b6b..a598cf7d8890 100644 --- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -141,10 +141,11 @@ SymbolVendorMacOSX::Terminate() } -const char * +lldb_private::ConstString SymbolVendorMacOSX::GetPluginNameStatic() { - return "symbol-vendor.macosx"; + static ConstString g_name("macosx"); + return g_name; } const char * @@ -332,14 +333,8 @@ SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp, lldb_privat //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +ConstString SymbolVendorMacOSX::GetPluginName() -{ - return "SymbolVendorMacOSX"; -} - -const char * -SymbolVendorMacOSX::GetShortPluginName() { return GetPluginNameStatic(); } diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h index 2c16148ace8e..31a842ade86f 100644 --- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h +++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h @@ -25,7 +25,7 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * @@ -45,12 +45,9 @@ public: //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp index d2301b617aa1..b20f732133b7 100644 --- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp +++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp @@ -309,20 +309,12 @@ UnwindAssemblyInstEmulation::CreateInstance (const ArchSpec &arch) //------------------------------------------------------------------ // PluginInterface protocol in UnwindAssemblyParser_x86 //------------------------------------------------------------------ - -const char * +ConstString UnwindAssemblyInstEmulation::GetPluginName() { - return "UnwindAssemblyInstEmulation"; -} - -const char * -UnwindAssemblyInstEmulation::GetShortPluginName() -{ - return "unwindassembly.inst-emulation"; + return GetPluginNameStatic(); } - uint32_t UnwindAssemblyInstEmulation::GetPluginVersion() { @@ -344,10 +336,11 @@ UnwindAssemblyInstEmulation::Terminate() } -const char * +ConstString UnwindAssemblyInstEmulation::GetPluginNameStatic() { - return "UnwindAssemblyInstEmulation"; + static ConstString g_name("inst-emulation"); + return g_name; } const char * diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h index 653c75a5f0ff..6a02f0a55104 100644 --- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h +++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h @@ -53,18 +53,15 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * GetPluginDescriptionStatic(); - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp index 7a18373e30fe..d491683f6875 100644 --- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp +++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp @@ -931,16 +931,10 @@ UnwindAssembly_x86::CreateInstance (const ArchSpec &arch) // PluginInterface protocol in UnwindAssemblyParser_x86 //------------------------------------------------------------------ -const char * +ConstString UnwindAssembly_x86::GetPluginName() { - return "UnwindAssembly_x86"; -} - -const char * -UnwindAssembly_x86::GetShortPluginName() -{ - return "unwindassembly.x86"; + return GetPluginNameStatic(); } @@ -965,10 +959,11 @@ UnwindAssembly_x86::Terminate() } -const char * +lldb_private::ConstString UnwindAssembly_x86::GetPluginNameStatic() { - return "UnwindAssembly_x86"; + static ConstString g_name("x86"); + return g_name; } const char * diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h index 2619f6558dc0..eebaa7b6c803 100644 --- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h +++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h @@ -50,18 +50,15 @@ public: static void Terminate(); - static const char * + static lldb_private::ConstString GetPluginNameStatic(); static const char * GetPluginDescriptionStatic(); - virtual const char * + virtual lldb_private::ConstString GetPluginName(); - virtual const char * - GetShortPluginName(); - virtual uint32_t GetPluginVersion(); diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index c991b1005b4b..c39261903fa7 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -433,16 +433,11 @@ SymbolVendor::GetCompileUnitAtIndex(size_t idx) //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -const char * +lldb_private::ConstString SymbolVendor::GetPluginName() { - return "SymbolVendor"; -} - -const char * -SymbolVendor::GetShortPluginName() -{ - return "vendor-default"; + static ConstString g_name("vendor-default"); + return g_name; } uint32_t diff --git a/lldb/source/Target/OperatingSystem.cpp b/lldb/source/Target/OperatingSystem.cpp index 3fecb4a6d2c5..8ba526838777 100644 --- a/lldb/source/Target/OperatingSystem.cpp +++ b/lldb/source/Target/OperatingSystem.cpp @@ -25,7 +25,8 @@ OperatingSystem::FindPlugin (Process *process, const char *plugin_name) OperatingSystemCreateInstance create_callback = NULL; if (plugin_name) { - create_callback = PluginManager::GetOperatingSystemCreateCallbackForPluginName (plugin_name); + ConstString const_plugin_name(plugin_name); + create_callback = PluginManager::GetOperatingSystemCreateCallbackForPluginName (const_plugin_name); if (create_callback) { std::unique_ptr instance_ap(create_callback(process, true)); diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index c1834d2bd87a..1293691d12a3 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -96,7 +96,7 @@ Platform::LocateExecutableScriptingResources (Target *target, Module &module) } Platform* -Platform::FindPlugin (Process *process, const char *plugin_name) +Platform::FindPlugin (Process *process, const ConstString &plugin_name) { PlatformCreateInstance create_callback = NULL; if (plugin_name) @@ -156,7 +156,8 @@ Platform::Create (const char *platform_name, Error &error) lldb::PlatformSP platform_sp; if (platform_name && platform_name[0]) { - create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (platform_name); + ConstString const_platform_name (platform_name); + create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (const_platform_name); if (create_callback) platform_sp.reset(create_callback(true, NULL)); else @@ -273,7 +274,7 @@ Platform::GetStatus (Stream &strm) uint32_t minor = UINT32_MAX; uint32_t update = UINT32_MAX; std::string s; - strm.Printf (" Platform: %s\n", GetShortPluginName()); + strm.Printf (" Platform: %s\n", GetPluginName().GetCString()); ArchSpec arch (GetSystemArchitecture()); if (arch.IsValid()) @@ -388,13 +389,13 @@ Platform::GetOSKernelDescription (std::string &s) return GetRemoteOSKernelDescription (s); } -const char * +ConstString Platform::GetName () { const char *name = GetHostname(); if (name == NULL || name[0] == '\0') - name = GetShortPluginName(); - return name; + return GetPluginName(); + return ConstString (name); } const char * @@ -592,9 +593,9 @@ Platform::ConnectRemote (Args& args) { Error error; if (IsHost()) - error.SetErrorStringWithFormat ("The currently selected platform (%s) is the host platform and is always connected.", GetShortPluginName()); + error.SetErrorStringWithFormat ("The currently selected platform (%s) is the host platform and is always connected.", GetPluginName().GetCString()); else - error.SetErrorStringWithFormat ("Platform::ConnectRemote() is not supported by %s", GetShortPluginName()); + error.SetErrorStringWithFormat ("Platform::ConnectRemote() is not supported by %s", GetPluginName().GetCString()); return error; } @@ -603,9 +604,9 @@ Platform::DisconnectRemote () { Error error; if (IsHost()) - error.SetErrorStringWithFormat ("The currently selected platform (%s) is the host platform and is always connected.", GetShortPluginName()); + error.SetErrorStringWithFormat ("The currently selected platform (%s) is the host platform and is always connected.", GetPluginName().GetCString()); else - error.SetErrorStringWithFormat ("Platform::DisconnectRemote() is not supported by %s", GetShortPluginName()); + error.SetErrorStringWithFormat ("Platform::DisconnectRemote() is not supported by %s", GetPluginName().GetCString()); return error; } diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 01ee7e482d18..f4733c38d768 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -946,7 +946,8 @@ Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener ProcessCreateInstance create_callback = NULL; if (plugin_name) { - create_callback = PluginManager::GetProcessCreateCallbackForPluginName (plugin_name); + ConstString const_plugin_name(plugin_name); + create_callback = PluginManager::GetProcessCreateCallbackForPluginName (const_plugin_name); if (create_callback) { process_sp = create_callback(target, listener, crash_file_path); -- GitLab From a1e813dcd4ecbfb74fd8ae010cfea1f71fd980d2 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 10 May 2013 21:52:07 +0000 Subject: [PATCH 198/467] PR14492: Debug Info: Support for values of non-integer non-type template parameters. This is only tested for global variables at the moment (& includes tests for the unnamed parameter case, since apparently this entire function was completely untested previously) llvm-svn: 181632 --- llvm/include/llvm/DIBuilder.h | 7 +- llvm/include/llvm/DebugInfo.h | 2 +- .../CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 20 ++++- llvm/lib/IR/DIBuilder.cpp | 4 +- llvm/lib/IR/DebugInfo.cpp | 4 + llvm/test/DebugInfo/template.ll | 84 +++++++++++++++++++ 6 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 llvm/test/DebugInfo/template.ll diff --git a/llvm/include/llvm/DIBuilder.h b/llvm/include/llvm/DIBuilder.h index 4ce884b73682..bb1bdd701723 100644 --- a/llvm/include/llvm/DIBuilder.h +++ b/llvm/include/llvm/DIBuilder.h @@ -332,10 +332,9 @@ namespace llvm { /// @param LineNo Line number. /// @param ColumnNo Column Number. DITemplateValueParameter - createTemplateValueParameter(DIDescriptor Scope, StringRef Name, DIType Ty, - uint64_t Value, - MDNode *File = 0, unsigned LineNo = 0, - unsigned ColumnNo = 0); + createTemplateValueParameter(DIDescriptor Scope, StringRef Name, + DIType Ty, Value *Val, MDNode *File = 0, + unsigned LineNo = 0, unsigned ColumnNo = 0); /// createArrayType - Create debugging information entry for an array. /// @param Size Array size. diff --git a/llvm/include/llvm/DebugInfo.h b/llvm/include/llvm/DebugInfo.h index 5f92ca22ecc4..91c306633836 100644 --- a/llvm/include/llvm/DebugInfo.h +++ b/llvm/include/llvm/DebugInfo.h @@ -401,7 +401,7 @@ namespace llvm { DIScope getContext() const { return getFieldAs(1); } StringRef getName() const { return getStringField(2); } DIType getType() const { return getFieldAs(3); } - uint64_t getValue() const { return getUInt64Field(4); } + Value *getValue() const; StringRef getFilename() const { return getFieldAs(5).getFilename(); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index c38ada6b66be..7f0c33bb05c5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -588,6 +588,9 @@ static bool isTypeSigned(DIType Ty, int *SizeInBits) { /// addConstantValue - Add constant value entry in variable DIE. bool CompileUnit::addConstantValue(DIE *Die, const MachineOperand &MO, DIType Ty) { + // FIXME: This is a bit conservative/simple - it emits negative values at + // their maximum bit width which is a bit unfortunate (& doesn't prefer + // udata/sdata over dataN as suggested by the DWARF spec) assert(MO.isImm() && "Invalid machine operand!"); DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); int SizeInBits = -1; @@ -1095,8 +1098,21 @@ CompileUnit::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TPV){ addType(ParamDIE, TPV.getType()); if (!TPV.getName().empty()) addString(ParamDIE, dwarf::DW_AT_name, TPV.getName()); - addUInt(ParamDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata, - TPV.getValue()); + if (Value *Val = TPV.getValue()) { + if (ConstantInt *CI = dyn_cast(Val)) + addConstantValue(ParamDIE, CI, TPV.getType().isUnsignedDIType()); + else if (GlobalValue *GV = dyn_cast(Val)) { + // For declaration non-type template parameters (such as global values and + // functions) + DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); + addOpAddress(Block, Asm->Mang->getSymbol(GV)); + // Emit DW_OP_stack_value to use the address as the immediate value of the + // parameter, rather than a pointer to it. + addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value); + addBlock(ParamDIE, dwarf::DW_AT_location, 0, Block); + } + } + return ParamDIE; } diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index eb220b2349c8..4bb87c9afb77 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -502,7 +502,7 @@ DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name, /// value parameter. DITemplateValueParameter DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name, - DIType Ty, uint64_t Val, + DIType Ty, Value *Val, MDNode *File, unsigned LineNo, unsigned ColumnNo) { Value *Elts[] = { @@ -510,7 +510,7 @@ DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name, getNonCompileUnitScope(Context), MDString::get(VMContext, Name), Ty, - ConstantInt::get(Type::getInt64Ty(VMContext), Val), + Val, File, ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo) diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 38fc90f865ee..8a0fb8d5b10e 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -695,6 +695,10 @@ DIArray DISubprogram::getVariables() const { return DIArray(); } +Value *DITemplateValueParameter::getValue() const { + return getField(DbgNode, 4); +} + void DIScope::setFilename(StringRef Name, LLVMContext &Context) { if (!DbgNode) return; diff --git a/llvm/test/DebugInfo/template.ll b/llvm/test/DebugInfo/template.ll new file mode 100644 index 000000000000..47173550c686 --- /dev/null +++ b/llvm/test/DebugInfo/template.ll @@ -0,0 +1,84 @@ +; REQUIRES: object-emission + +; RUN: llc -O0 -filetype=obj < %s > %t +; RUN: llvm-dwarfdump %t | FileCheck %s + +; IR generated with `clang++ -g -emit-llvm -S` from the following code: +; template func() { } +; int glbl = func<3, &glbl>(); + +; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type +; CHECK-NEXT: DW_AT_name{{.*}} = "int" + +; CHECK: DW_AT_name{{.*}}"func<3, &glbl>" +; CHECK-NOT: NULL +; CHECK: DW_TAG_template_value_parameter +; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]} +; CHECK-NEXT: DW_AT_name{{.*}}= "x" + +; This could be made shorter by encoding it as _sdata rather than data4, or +; even as data1. DWARF strongly urges implementations to prefer +; _sdata/_udata rather than dataN + +; CHECK-NEXT: DW_AT_const_value [DW_FORM_data4]{{.*}}(0x00000003) + +; CHECK: DW_TAG_template_value_parameter +; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]} + +; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use +; the value immediately, rather than indirecting through the address. + +; CHECK-NEXT: DW_AT_location [DW_FORM_block1]{{ *}}(<0x0a> 03 00 00 00 00 00 00 00 00 9f ) + +; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type +; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]} + +@glbl = global i32 0, align 4 +@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] + +define internal void @__cxx_global_var_init() section ".text.startup" { +entry: + %call = call i32 @_Z4funcILi3EXadL_Z4glblEEEiv(), !dbg !20 + store i32 %call, i32* @glbl, align 4, !dbg !20 + ret void, !dbg !20 +} + +; Function Attrs: nounwind uwtable +define linkonce_odr i32 @_Z4funcILi3EXadL_Z4glblEEEiv() #0 { +entry: + ret i32 3, !dbg !21 +} + +define internal void @_GLOBAL__I_a() section ".text.startup" { +entry: + call void @__cxx_global_var_init(), !dbg !22 + ret void, !dbg !22 +} + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !18, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/scratch/templ.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"templ.cpp", metadata !"/usr/local/google/home/blaikie/dev/scratch"} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4, metadata !8, metadata !16} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"__cxx_global_var_init", metadata !"__cxx_global_var_init", metadata !"", i32 2, metadata !6, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @__cxx_global_var_init, null, null, metadata !2, i32 2} ; [ DW_TAG_subprogram ] [line 2] [local] [def] [__cxx_global_var_init] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/usr/local/google/home/blaikie/dev/scratch/templ.cpp] +!6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{null} +!8 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"func<3, &glbl>", metadata !"func<3, &glbl>", metadata !"_Z4funcILi3EXadL_Z4glblEEEiv", i32 1, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z4funcILi3EXadL_Z4glblEEEiv, metadata !12, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [func<3, &glbl>] +!9 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!10 = metadata !{metadata !11} +!11 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!12 = metadata !{metadata !13, metadata !14} +!13 = metadata !{i32 786480, null, metadata !"x", metadata !11, i32 3, null, i32 0, i32 0} ; [ DW_TAG_template_value_parameter ] +!14 = metadata !{i32 786480, null, metadata !"", metadata !15, i32* @glbl, null, i32 0, i32 0} ; [ DW_TAG_template_value_parameter ] +!15 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +!16 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"_GLOBAL__I_a", metadata !"_GLOBAL__I_a", metadata !"", i32 1, metadata !17, i1 true, i1 true, i32 0, i32 0, null, i32 64, i1 false, void ()* @_GLOBAL__I_a, null, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [local] [def] [_GLOBAL__I_a] +!17 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !2, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!18 = metadata !{metadata !19} +!19 = metadata !{i32 786484, i32 0, null, metadata !"glbl", metadata !"glbl", metadata !"", metadata !5, i32 2, metadata !11, i32 0, i32 1, i32* @glbl, null} ; [ DW_TAG_variable ] [glbl] [line 2] [def] +!20 = metadata !{i32 2, i32 0, metadata !4, null} +!21 = metadata !{i32 1, i32 0, metadata !8, null} +!22 = metadata !{i32 1, i32 0, metadata !16, null} -- GitLab From 38079fd26f150b3b43b99f720c93efe91e0760bb Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 10 May 2013 21:53:14 +0000 Subject: [PATCH 199/467] PR14992: Debug Info: Support more non-type template parameters * Provide DW_TAG_template_value_parameter for pointers, function pointers, member pointers, and member function pointers (still missing support for template template parameters which GCC encodes as a DW_TAG_GNU_template_template_param) * Provide values for all but the (member & non-member) function pointer case. Simple constant integer values for member pointers (offset within the object) and address for the value pointer case. GCC doesn't provide a value for the member function pointer case so I'm not sure how, if at all, GDB supports encoding that. & non-member function pointers should follow shortly in a subsequent patch. * Null pointer value encodings of all of these types, including correctly encoding null data member pointers as -1. llvm-svn: 181634 --- clang/lib/CodeGen/CGDebugInfo.cpp | 82 +++++++++++++++++-- clang/test/CodeGenCXX/debug-info-template.cpp | 61 ++++++++++++-- 2 files changed, 129 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index d9ab0902e355..f236d169bf51 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -13,6 +13,7 @@ #include "CGDebugInfo.h" #include "CGBlocks.h" +#include "CGCXXABI.h" #include "CGObjCRuntime.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" @@ -1188,17 +1189,88 @@ CollectTemplateParams(const TemplateParameterList *TPList, for (unsigned i = 0, e = TAList.size(); i != e; ++i) { const TemplateArgument &TA = TAList[i]; const NamedDecl *ND = TPList->getParam(i); - if (TA.getKind() == TemplateArgument::Type) { + switch (TA.getKind()) { + case TemplateArgument::Type: { llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit); llvm::DITemplateTypeParameter TTP = DBuilder.createTemplateTypeParameter(TheCU, ND->getName(), TTy); TemplateParams.push_back(TTP); - } else if (TA.getKind() == TemplateArgument::Integral) { + } break; + case TemplateArgument::Integral: { llvm::DIType TTy = getOrCreateType(TA.getIntegralType(), Unit); llvm::DITemplateValueParameter TVP = - DBuilder.createTemplateValueParameter(TheCU, ND->getName(), TTy, - TA.getAsIntegral().getZExtValue()); - TemplateParams.push_back(TVP); + DBuilder.createTemplateValueParameter( + TheCU, ND->getName(), TTy, + llvm::ConstantInt::get(CGM.getLLVMContext(), TA.getAsIntegral())); + TemplateParams.push_back(TVP); + } break; + case TemplateArgument::Declaration: { + const ValueDecl *D = TA.getAsDecl(); + bool InstanceMember = D->isCXXInstanceMember(); + QualType T = InstanceMember + ? CGM.getContext().getMemberPointerType( + D->getType(), cast(D->getDeclContext()) + ->getTypeForDecl()) + : CGM.getContext().getPointerType(D->getType()); + llvm::DIType TTy = getOrCreateType(T, Unit); + llvm::Value *V = 0; + // Variable pointer template parameters have a value that is the address + // of the variable. + if (const VarDecl *VD = dyn_cast(D)) + V = CGM.GetAddrOfGlobalVar(VD); + // Member function pointers have special support for building them, though + // this is currently unsupported in LLVM CodeGen. + if (InstanceMember) + if (const CXXMethodDecl *method = dyn_cast(D)) + V = CGM.getCXXABI().EmitMemberPointer(method); + // Member data pointers have special handling too to compute the fixed + // offset within the object. + if (isa(D)) { + // These five lines (& possibly the above member function pointer + // handling) might be able to be refactored to use similar code in + // CodeGenModule::getMemberPointerConstant + uint64_t fieldOffset = CGM.getContext().getFieldOffset(D); + CharUnits chars = + CGM.getContext().toCharUnitsFromBits((int64_t) fieldOffset); + V = CGM.getCXXABI().EmitMemberDataPointer( + cast(T.getTypePtr()), chars); + } + llvm::DITemplateValueParameter TVP = + DBuilder.createTemplateValueParameter(TheCU, ND->getName(), TTy, V); + TemplateParams.push_back(TVP); + } break; + case TemplateArgument::NullPtr: { + QualType T = TA.getNullPtrType(); + llvm::DIType TTy = getOrCreateType(T, Unit); + llvm::Value *V = 0; + // Special case member data pointer null values since they're actually -1 + // instead of zero. + if (const MemberPointerType *MPT = + dyn_cast(T.getTypePtr())) + // But treat member function pointers as simple zero integers because + // it's easier than having a special case in LLVM's CodeGen. If LLVM + // CodeGen grows handling for values of non-null member function + // pointers then perhaps we could remove this special case and rely on + // EmitNullMemberPointer for member function pointers. + if (MPT->isMemberDataPointer()) + V = CGM.getCXXABI().EmitNullMemberPointer(MPT); + if (!V) + V = llvm::ConstantInt::get(CGM.Int8Ty, 0); + llvm::DITemplateValueParameter TVP = + DBuilder.createTemplateValueParameter(TheCU, ND->getName(), TTy, V); + TemplateParams.push_back(TVP); + } break; + case TemplateArgument::Template: + // We could support this with the GCC extension + // DW_TAG_GNU_template_template_param + break; + // these next 4 should never occur + case TemplateArgument::Expression: + case TemplateArgument::TemplateExpansion: + case TemplateArgument::Pack: + case TemplateArgument::Null: + llvm_unreachable( + "These argument types shouldn't exist in concrete types"); } } return DBuilder.getOrCreateArray(TemplateParams); diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp index 9bb75ffa3ba2..7b987ef97c10 100644 --- a/clang/test/CodeGenCXX/debug-info-template.cpp +++ b/clang/test/CodeGenCXX/debug-info-template.cpp @@ -1,26 +1,69 @@ -// RUN: %clang_cc1 -emit-llvm -g %s -o - -std=c++11 | FileCheck %s +// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s // CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] // CHECK: metadata [[TCI:![0-9]*]], i32 0, i32 1, %class.TC* @tci, null} ; [ DW_TAG_variable ] [tci] -// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] -// CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]]} +// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] +// CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]], metadata [[TCARG3:![0-9]*]], metadata [[TCARG4:![0-9]*]], metadata [[TCARG5:![0-9]*]]} // // We seem to be missing file/line/col info on template value parameters - -// metadata supports it but it's not populated. +// metadata supports it but it's not populated. GCC doesn't emit it either, +// perhaps we should just drop it from the metadata. // -// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] -// CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT:![0-9]*]], i64 2, {{.*}} ; [ DW_TAG_template_value_parameter ] -// CHECK: [[UINT]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] +// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[UINT:![0-9]*]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[UINT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int] +// CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT:![0-9]*]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCARG3]] = {{.*}}metadata !"x", metadata [[INTPTR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[INTPTR]] = {{.*}}, metadata [[INT]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +// CHECK: [[TCARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR:![0-9]*]], i64 8, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[MEMINTPTR]] = {{.*}}, metadata [[FOO:![0-9]*]]} ; [ DW_TAG_ptr_to_member_type ] {{.*}}[from int] +// +// We could just emit a declaration of 'foo' here, rather than the entire +// definition (same goes for any time we emit a member (function or data) +// pointer type) +// CHECK: [[FOO]] = {{.*}} ; [ DW_TAG_structure_type ] [foo] +// CHECK: metadata !"f", metadata !"_ZN3foo1fEv", i32 {{[0-9]*}}, metadata [[FTYPE:![0-9]*]], +// CHECK: [[FTYPE:![0-9]*]] = {{.*}}, metadata [[FARGS:![0-9]*]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +// CHECK: [[FARGS]] = metadata !{null, metadata [[FARG1:![0-9]*]]} +// CHECK: [[FARG1]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from foo] +// +// Currently Clang emits the pointer-to-member-function value, but LLVM doesn't +// use it (GCC doesn't emit a value for pointers to member functions either - so +// it's not clear what, if any, format would be acceptable to GDB) +// +// CHECK: [[TCARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR:![0-9]*]], { i64, i64 } { i64 ptrtoint (void (%struct.foo*)* @_ZN3foo1fEv to i64), i64 0 }, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[MEMFUNPTR]] = {{.*}}, metadata [[FTYPE]], metadata [[FOO]]} ; [ DW_TAG_ptr_to_member_type ] + +// CHECK: metadata [[TCNT:![0-9]*]], i32 0, i32 1, %class.TC.0* @tcn, null} ; [ DW_TAG_variable ] [tcn] +// CHECK: [[TCNT:![0-9]*]] = {{.*}}, metadata [[TCNARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] +// CHECK: [[TCNARGS]] = metadata !{metadata [[TCNARG1:![0-9]*]], metadata [[TCNARG2:![0-9]*]], metadata [[TCNARG3:![0-9]*]], metadata [[TCNARG4:![0-9]*]], metadata [[TCNARG5:![0-9]*]]} +// CHECK: [[TCNARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] +// CHECK: [[TCNARG2]] = {{.*}}metadata !"", metadata [[INT]], i32 -3, {{.*}} ; [ DW_TAG_template_value_parameter ] +// CHECK: [[TCNARG3]] = {{.*}}metadata !"x", metadata [[INTPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] + +// The interesting null pointer: -1 for member data pointers (since they are +// just an offset in an object, they can be zero and non-null for the first +// member) + +// CHECK: [[TCNARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR]], i64 -1, {{.*}} ; [ DW_TAG_template_value_parameter ] +// +// In some future iteration we could possibly emit the value of a null member +// function pointer as '{ i64, i64 } zeroinitializer' as it may be handled +// naturally from the LLVM CodeGen side once we decide how to handle non-null +// member function pointers. For now, it's simpler just to emit the 'i8 0'. +// +// CHECK: [[TCNARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR:![0-9]*]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ] struct foo { + char pad[8]; // make the member pointer to 'e' a bit more interesting (nonzero) int e; void f(); }; -template +template class TC { }; int glb; -TC tci; +TC tci; +TC tcn; -- GitLab From d7193795bd48bbacf3ab3f4d41801ad84c97d803 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 10 May 2013 21:54:08 +0000 Subject: [PATCH 200/467] [Modules] Extend Darwin hack to include the modification time of SystemVersion.plist. Fixes . llvm-svn: 181635 --- clang/lib/Frontend/CompilerInvocation.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 9c8eea10ad72..6af36630019a 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -30,6 +30,7 @@ #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" #include "llvm/Support/system_error.h" +#include using namespace clang; //===----------------------------------------------------------------------===// @@ -1689,7 +1690,8 @@ std::string CompilerInvocation::getModuleHash() const { hsOpts.UseStandardCXXIncludes, hsOpts.UseLibcxx); - // Darwin-specific hack: if we have a sysroot, use the contents of + // Darwin-specific hack: if we have a sysroot, use the contents and + // modification time of // $sysroot/System/Library/CoreServices/SystemVersion.plist // as part of the module hash. if (!hsOpts.Sysroot.empty()) { @@ -1702,6 +1704,10 @@ std::string CompilerInvocation::getModuleHash() const { llvm::sys::path::append(systemVersionFile, "SystemVersion.plist"); if (!llvm::MemoryBuffer::getFile(systemVersionFile, buffer)) { code = hash_combine(code, buffer.get()->getBuffer()); + + struct stat statBuf; + if (stat(systemVersionFile.c_str(), &statBuf) == 0) + code = hash_combine(code, statBuf.st_mtime); } } -- GitLab From ec537a24eb9b97549dff3739bbaf249221d85f09 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Fri, 10 May 2013 21:58:45 +0000 Subject: [PATCH 201/467] Hardened LLDB against NULL conditions being passed to breakpoints. llvm-svn: 181636 --- lldb/source/Breakpoint/BreakpointLocation.cpp | 3 +++ lldb/source/Breakpoint/BreakpointOptions.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 04142b268e48..fe8267dcacd5 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -254,7 +254,10 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) const char *condition_text = GetConditionText(&condition_hash); if (!condition_text) + { + m_user_expression_sp.reset(); return false; + } if (condition_hash != m_condition_hash || !m_user_expression_sp || diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp index d0aaf47d8a63..3a4a117695fc 100644 --- a/lldb/source/Breakpoint/BreakpointOptions.cpp +++ b/lldb/source/Breakpoint/BreakpointOptions.cpp @@ -162,6 +162,9 @@ BreakpointOptions::HasCallback () void BreakpointOptions::SetCondition (const char *condition) { + if (!condition) + condition = ""; + m_condition_text.assign(condition); std::hash hasher; m_condition_text_hash = hasher(m_condition_text); -- GitLab From f95485a69ef689d769fb197e65683d848c7dde43 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 10 May 2013 22:14:39 +0000 Subject: [PATCH 202/467] Give the test from r181632 a target triple. llvm-svn: 181637 --- llvm/test/DebugInfo/{ => X86}/template.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename llvm/test/DebugInfo/{ => X86}/template.ll (98%) diff --git a/llvm/test/DebugInfo/template.ll b/llvm/test/DebugInfo/X86/template.ll similarity index 98% rename from llvm/test/DebugInfo/template.ll rename to llvm/test/DebugInfo/X86/template.ll index 47173550c686..817bdc9cf702 100644 --- a/llvm/test/DebugInfo/template.ll +++ b/llvm/test/DebugInfo/X86/template.ll @@ -1,6 +1,6 @@ ; REQUIRES: object-emission -; RUN: llc -O0 -filetype=obj < %s > %t +; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s > %t ; RUN: llvm-dwarfdump %t | FileCheck %s ; IR generated with `clang++ -g -emit-llvm -S` from the following code: -- GitLab From 940e80502e5746e0cc6342990c5d1f2e42cf1612 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 10 May 2013 22:15:13 +0000 Subject: [PATCH 203/467] [Modules] When things go horribly wrong when reading a module, point at the module cache. Sometimes people hack on their system headers. In such cases, they'll need to delete their module cache, but may not know where it is. Add a note to show them where it is. llvm-svn: 181638 --- clang/include/clang/Basic/DiagnosticSerializationKinds.td | 4 +++- clang/lib/Serialization/ASTReader.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index 1b45b10c1221..9f630ae5c1c4 100644 --- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td @@ -14,7 +14,7 @@ def err_fe_unable_to_read_pch_file : Error< def err_fe_not_a_pch_file : Error< "input is not a PCH file: '%0'">; def err_fe_pch_malformed : Error< - "malformed or corrupted PCH file: '%0'">, DefaultFatal; + "malformed or corrupted AST file: '%0'">, DefaultFatal; def err_fe_pch_malformed_block : Error< "malformed block record in PCH file: '%0'">, DefaultFatal; def err_fe_pch_file_modified : Error< @@ -22,6 +22,8 @@ def err_fe_pch_file_modified : Error< DefaultFatal; def err_fe_pch_file_overridden : Error< "file '%0' from the precompiled header has been overridden">; +def note_module_cache_path : Note< + "after modifying system headers, please delete the module cache at '%0'">; def err_pch_targetopt_mismatch : Error< "PCH file was compiled for the %0 '%1' but the current translation " diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 4a1ad260e329..17f01380ed04 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -759,6 +759,10 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M, void ASTReader::Error(StringRef Msg) { Error(diag::err_fe_pch_malformed, Msg); + if (Context.getLangOpts().Modules && !Diags.isDiagnosticInFlight()) { + Diag(diag::note_module_cache_path) + << PP.getHeaderSearchInfo().getModuleCachePath(); + } } void ASTReader::Error(unsigned DiagID, @@ -1715,6 +1719,10 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) { )) { if (Complain) { Error(diag::err_fe_pch_file_modified, Filename, F.FileName); + if (Context.getLangOpts().Modules && !Diags.isDiagnosticInFlight()) { + Diag(diag::note_module_cache_path) + << PP.getHeaderSearchInfo().getModuleCachePath(); + } } IsOutOfDate = true; -- GitLab From 6ac4ba23fdfc3ea91e21372b73a4f6e2f3410a39 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 10 May 2013 22:17:10 +0000 Subject: [PATCH 204/467] Micro-optimization: don't shift an entire bitcode record over to get the code. Previously, BitstreamCursor read an abbreviated record by splatting the whole thing into a data vector, then extracting and removing the /first/ element. Now, it reads the first element--the record code--separately from the actual field values. No (intended) functionality change. llvm-svn: 181639 --- llvm/lib/Bitcode/Reader/BitstreamReader.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp index 9dafe2a03670..1fd9abd8b180 100644 --- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp @@ -204,7 +204,16 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID); - for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { + // Read the record code first. + assert(Abbv->getNumOperandInfos() != 0 && "no record code in abbreviation?"); + const BitCodeAbbrevOp &CodeOp = Abbv->getOperandInfo(0); + if (CodeOp.isLiteral()) + readAbbreviatedLiteral(CodeOp, Vals); + else + readAbbreviatedField(CodeOp, Vals); + unsigned Code = (unsigned)Vals.pop_back_val(); + + for (unsigned i = 1, e = Abbv->getNumOperandInfos(); i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral()) { readAbbreviatedLiteral(Op, Vals); @@ -264,8 +273,6 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, JumpToBit(NewEnd); } - unsigned Code = (unsigned)Vals[0]; - Vals.erase(Vals.begin()); return Code; } -- GitLab From eaadec3a3918772601aac0a592bc6cc92c878c8e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 10 May 2013 22:19:28 +0000 Subject: [PATCH 205/467] [lld] Document about how to enable debug output. llvm-svn: 181640 --- lld/docs/development.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lld/docs/development.rst b/lld/docs/development.rst index 4716ba1795df..4a0af4141554 100644 --- a/lld/docs/development.rst +++ b/lld/docs/development.rst @@ -22,6 +22,15 @@ Modifying the Driver See :doc:`Driver`. +Debugging +--------- + +You can run lld with ``-mllvm=-debug`` command line option to enable debugging +printouts. If you want to enable debug information for some specific pass, you +can run it with ``-mllvm='-debug-only '``, where pass is a name used in +the ``DEBUG_WITH_TYPE()`` macro. + + Documentation ------------- -- GitLab From 783c79446b96d712da9f0bcaaba82481a36b7712 Mon Sep 17 00:00:00 2001 From: Reed Kotler Date: Fri, 10 May 2013 22:25:39 +0000 Subject: [PATCH 206/467] Checkin in of first of several patches to finish implementation of mips16/mips32 floating point interoperability. This patch fixes returns from mips16 functions so that if the function was in fact called by a mips32 hard float routine, then values that would have been returned in floating point registers are so returned. Mips16 mode has no floating point instructions so there is no way to load values into floating point registers. This is needed when returning float, double, single complex, double complex in the Mips ABI. Helper functions in libc for mips16 are available to do this. For efficiency purposes, these helper functions have a different calling convention from normal Mips calls. Registers v0,v1,a0,a1 are used to pass parameters instead of a0,a1,a2,a3. This is because v0,v1,a0,a1 are the natural registers used to return floating point values in soft float. These values can then be moved to the appropriate floating point registers with no extra cost. The only register that is modified is ra in this call. The helper functions make sure that the return values are in the floating point registers that they would be in if soft float was not in effect (which it is for mips16, though the soft float is implemented using a mips32 library that uses hard float). llvm-svn: 181641 --- llvm/lib/Target/Mips/CMakeLists.txt | 1 + llvm/lib/Target/Mips/Mips16HardFloat.cpp | 141 ++++++++++++++++++++ llvm/lib/Target/Mips/Mips16HardFloat.h | 54 ++++++++ llvm/lib/Target/Mips/Mips16ISelLowering.cpp | 11 +- llvm/lib/Target/Mips/MipsCallingConv.td | 10 ++ llvm/lib/Target/Mips/MipsISelLowering.cpp | 40 +++++- llvm/lib/Target/Mips/MipsISelLowering.h | 14 +- llvm/lib/Target/Mips/MipsRegisterInfo.cpp | 4 + llvm/lib/Target/Mips/MipsRegisterInfo.h | 1 + llvm/lib/Target/Mips/MipsSubtarget.cpp | 8 +- llvm/lib/Target/Mips/MipsSubtarget.h | 11 +- llvm/lib/Target/Mips/MipsTargetMachine.cpp | 3 + llvm/test/CodeGen/Mips/mips16_fpret.ll | 77 +++++++++++ 13 files changed, 359 insertions(+), 16 deletions(-) create mode 100644 llvm/lib/Target/Mips/Mips16HardFloat.cpp create mode 100644 llvm/lib/Target/Mips/Mips16HardFloat.h create mode 100644 llvm/test/CodeGen/Mips/mips16_fpret.ll diff --git a/llvm/lib/Target/Mips/CMakeLists.txt b/llvm/lib/Target/Mips/CMakeLists.txt index 78a9f70c6681..8be68c5b4f78 100644 --- a/llvm/lib/Target/Mips/CMakeLists.txt +++ b/llvm/lib/Target/Mips/CMakeLists.txt @@ -15,6 +15,7 @@ add_public_tablegen_target(MipsCommonTableGen) add_llvm_target(MipsCodeGen Mips16FrameLowering.cpp + Mips16HardFloat.cpp Mips16InstrInfo.cpp Mips16ISelDAGToDAG.cpp Mips16ISelLowering.cpp diff --git a/llvm/lib/Target/Mips/Mips16HardFloat.cpp b/llvm/lib/Target/Mips/Mips16HardFloat.cpp new file mode 100644 index 000000000000..4d1e61bb99c4 --- /dev/null +++ b/llvm/lib/Target/Mips/Mips16HardFloat.cpp @@ -0,0 +1,141 @@ +//===---- Mips16HardFloat.cpp for Mips16 Hard Float --------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines a pass needed for Mips16 Hard Float +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "mips16-hard-float" +#include "Mips16HardFloat.h" +#include "llvm/IR/Module.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" +#include + +// +// Return types that matter for hard float are: +// float, double, complex float, and complex double +// +enum FPReturnVariant { + FRet, DRet, CFRet, CDRet, NoFPRet +}; + +// +// Determine which FP return type this function has +// +static FPReturnVariant whichFPReturnVariant(Type *T) { + switch (T->getTypeID()) { + case Type::FloatTyID: + return FRet; + case Type::DoubleTyID: + return DRet; + case Type::StructTyID: + if (T->getStructNumElements() != 2) + break; + if ((T->getContainedType(0)->isFloatTy()) && + (T->getContainedType(1)->isFloatTy())) + return CFRet; + if ((T->getContainedType(0)->isDoubleTy()) && + (T->getContainedType(1)->isDoubleTy())) + return CDRet; + break; + default: + break; + } + return NoFPRet; +} + +// +// Returns of float, double and complex need to be handled with a helper +// function. The "AndCal" part is coming in a later patch. +// +static bool fixupFPReturnAndCall + (Function &F, Module *M, const MipsSubtarget &Subtarget) { + bool Modified = false; + LLVMContext &C = M->getContext(); + Type *MyVoid = Type::getVoidTy(C); + for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); + I != E; ++I) { + Instruction &Inst = *I; + if (const ReturnInst *RI = dyn_cast(I)) { + Value *RVal = RI->getReturnValue(); + if (!RVal) continue; + // + // If there is a return value and it needs a helper function, + // figure out which one and add a call before the actual + // return to this helper. The purpose of the helper is to move + // floating point values from their soft float return mapping to + // where they would have been mapped to in floating point registers. + // + Type *T = RVal->getType(); + FPReturnVariant RV = whichFPReturnVariant(T); + if (RV == NoFPRet) continue; + static const char* Helper[NoFPRet] = + {"__mips16_ret_sf", "__mips16_ret_df", "__mips16_ret_sc", + "__mips16_ret_dc"}; + const char *Name = Helper[RV]; + AttributeSet A; + Value *Params[] = {RVal}; + Modified = true; + // + // These helper functions have a different calling ABI so + // this __Mips16RetHelper indicates that so that later + // during call setup, the proper call lowering to the helper + // functions will take place. + // + A = A.addAttribute(C, AttributeSet::FunctionIndex, + "__Mips16RetHelper"); + A = A.addAttribute(C, AttributeSet::FunctionIndex, + Attribute::ReadNone); + Value *F = (M->getOrInsertFunction(Name, A, MyVoid, T, NULL)); + CallInst::Create(F, Params, "", &Inst ); + } + } + return Modified; +} + +namespace llvm { + +// +// This pass only makes sense when the underlying chip has floating point but +// we are compiling as mips16. +// For all mips16 functions (that are not stubs we have already generated), or +// declared via attributes as nomips16, we must: +// 1) fixup all returns of float, double, single and double complex +// by calling a helper function before the actual return. +// 2) generate helper functions (stubs) that can be called by mips32 functions +// that will move parameters passed normally passed in floating point +// registers the soft float equivalents. (Coming in a later patch). +// 3) in the case of static relocation, generate helper functions so that +// mips16 functions can call extern functions of unknown type (mips16 or +// mips32). (Coming in a later patch). +// 4) TBD. For pic, calls to extern functions of unknown type are handled by +// predefined helper functions in libc but this work is currently done +// during call lowering but it should be moved here in the future. +// +bool Mips16HardFloat::runOnModule(Module &M) { + DEBUG(errs() << "Run on Module Mips16HardFloat\n"); + bool Modified = false; + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { + if (F->isDeclaration() || F->hasFnAttribute("mips16_fp_stub") || + F->hasFnAttribute("nomips16")) continue; + Modified |= fixupFPReturnAndCall(*F, &M, Subtarget); + } + return Modified; +} + +char Mips16HardFloat::ID = 0; + +} + +ModulePass *llvm::createMips16HardFloat(MipsTargetMachine &TM) { + return new Mips16HardFloat(TM); +} + diff --git a/llvm/lib/Target/Mips/Mips16HardFloat.h b/llvm/lib/Target/Mips/Mips16HardFloat.h new file mode 100644 index 000000000000..b7f712af5b28 --- /dev/null +++ b/llvm/lib/Target/Mips/Mips16HardFloat.h @@ -0,0 +1,54 @@ +//===---- Mips16HardFloat.h for Mips16 Hard Float --------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines a phase which implements part of the floating point +// interoperability between Mips16 and Mips32 code. +// +//===----------------------------------------------------------------------===// + +#include "MCTargetDesc/MipsMCTargetDesc.h" +#include "MipsTargetMachine.h" +#include "llvm/Pass.h" +#include "llvm/Target/TargetMachine.h" + + +#ifndef MIPS16HARDFLOAT_H +#define MIPS16HARDFLOAT_H + +using namespace llvm; + +namespace llvm { + +class Mips16HardFloat : public ModulePass { + +public: + static char ID; + + Mips16HardFloat(MipsTargetMachine &TM_) : ModulePass(ID), + TM(TM_), Subtarget(TM.getSubtarget()) { + } + + virtual const char *getPassName() const { + return "MIPS16 Hard Float Pass"; + } + + virtual bool runOnModule(Module &M); + +protected: + /// Keep a pointer to the MipsSubtarget around so that we can make the right + /// decision when generating code for different targets. + const TargetMachine &TM; + const MipsSubtarget &Subtarget; + +}; + +ModulePass *createMips16HardFloat(MipsTargetMachine &TM); + +} +#endif diff --git a/llvm/lib/Target/Mips/Mips16ISelLowering.cpp b/llvm/lib/Target/Mips/Mips16ISelLowering.cpp index f63318f1e6de..c633d312bbba 100644 --- a/llvm/lib/Target/Mips/Mips16ISelLowering.cpp +++ b/llvm/lib/Target/Mips/Mips16ISelLowering.cpp @@ -13,6 +13,7 @@ #define DEBUG_TYPE "mips-lower" #include "Mips16ISelLowering.h" #include "MipsRegisterInfo.h" +#include "MipsTargetMachine.h" #include "MCTargetDesc/MipsBaseInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Support/CommandLine.h" @@ -21,11 +22,6 @@ using namespace llvm; -static cl::opt -Mips16HardFloat("mips16-hard-float", cl::NotHidden, - cl::desc("MIPS: mips16 hard float enable."), - cl::init(false)); - static cl::opt DontExpandCondPseudos16( "mips16-dont-expand-cond-pseudo", cl::init(false), @@ -50,7 +46,7 @@ Mips16TargetLowering::Mips16TargetLowering(MipsTargetMachine &TM) // Set up the register classes addRegisterClass(MVT::i32, &Mips::CPU16RegsRegClass); - if (Mips16HardFloat) + if (Subtarget->inMips16HardFloat()) setMips16HardFloatLibCalls(); setOperationAction(ISD::ATOMIC_FENCE, MVT::Other, Expand); @@ -374,7 +370,8 @@ getOpndList(SmallVectorImpl &Ops, const char* Mips16HelperFunction = 0; bool NeedMips16Helper = false; - if (getTargetMachine().Options.UseSoftFloat && Mips16HardFloat) { + if (getTargetMachine().Options.UseSoftFloat && + Subtarget->inMips16HardFloat()) { // // currently we don't have symbols tagged with the mips16 or mips32 // qualifier so we will assume that we don't know what kind it is. diff --git a/llvm/lib/Target/Mips/MipsCallingConv.td b/llvm/lib/Target/Mips/MipsCallingConv.td index 462def76cc80..6e8c5d24a84c 100644 --- a/llvm/lib/Target/Mips/MipsCallingConv.td +++ b/llvm/lib/Target/Mips/MipsCallingConv.td @@ -196,6 +196,13 @@ def CC_Mips_FastCC : CallingConv<[ CCDelegateTo ]>; +//== + +def CC_Mips16RetHelper : CallingConv<[ + // Integer arguments are passed in integer registers. + CCIfType<[i32], CCAssignToReg<[V0, V1, A0, A1]>> +]>; + //===----------------------------------------------------------------------===// // Mips Calling Convention Dispatch //===----------------------------------------------------------------------===// @@ -223,3 +230,6 @@ def CSR_N32 : CalleeSavedRegs<(add D31_64, D29_64, D27_64, D25_64, D24_64, def CSR_N64 : CalleeSavedRegs<(add (sequence "D%u_64", 31, 24), RA_64, FP_64, GP_64, (sequence "S%u_64", 7, 0))>; + +def CSR_Mips16RetHelper : + CalleeSavedRegs<(add V0, V1, (sequence "A%u", 3, 0), S0, S1)>; diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index 4d76181f9215..ab105b365540 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -2229,6 +2229,15 @@ getOpndList(SmallVectorImpl &Ops, const TargetRegisterInfo *TRI = getTargetMachine().getRegisterInfo(); const uint32_t *Mask = TRI->getCallPreservedMask(CLI.CallConv); assert(Mask && "Missing call preserved mask for calling convention"); + if (Subtarget->inMips16HardFloat()) { + if (GlobalAddressSDNode *G = dyn_cast(CLI.Callee)) { + llvm::StringRef Sym = G->getGlobal()->getName(); + Function *F = G->getGlobal()->getParent()->getFunction(Sym); + if (F->hasFnAttribute("__Mips16RetHelper")) { + Mask = MipsRegisterInfo::getMips16RetHelperMask(); + } + } + } Ops.push_back(CLI.DAG.getRegisterMask(Mask)); if (InFlag.getNode()) @@ -2260,7 +2269,9 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVector ArgLocs; CCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), getTargetMachine(), ArgLocs, *DAG.getContext()); - MipsCC MipsCCInfo(CallConv, IsO32, CCInfo); + MipsCC::SpecialCallingConvType SpecialCallingConv = + getSpecialCallingConv(Callee); + MipsCC MipsCCInfo(CallConv, IsO32, CCInfo, SpecialCallingConv); MipsCCInfo.analyzeCallOperands(Outs, IsVarArg, getTargetMachine().Options.UseSoftFloat, @@ -3029,13 +3040,32 @@ static bool originalTypeIsF128(const Type *Ty, const SDNode *CallNode) { return (ES && Ty->isIntegerTy(128) && isF128SoftLibCall(ES->getSymbol())); } -MipsTargetLowering::MipsCC::MipsCC(CallingConv::ID CC, bool IsO32_, - CCState &Info) - : CCInfo(Info), CallConv(CC), IsO32(IsO32_) { +MipsTargetLowering::MipsCC::SpecialCallingConvType + MipsTargetLowering::getSpecialCallingConv(SDValue Callee) const { + MipsCC::SpecialCallingConvType SpecialCallingConv = + MipsCC::NoSpecialCallingConv;; + if (Subtarget->inMips16HardFloat()) { + if (GlobalAddressSDNode *G = dyn_cast(Callee)) { + llvm::StringRef Sym = G->getGlobal()->getName(); + Function *F = G->getGlobal()->getParent()->getFunction(Sym); + if (F->hasFnAttribute("__Mips16RetHelper")) { + SpecialCallingConv = MipsCC::Mips16RetHelperConv; + } + } + } + return SpecialCallingConv; +} + +MipsTargetLowering::MipsCC::MipsCC( + CallingConv::ID CC, bool IsO32_, CCState &Info, + MipsCC::SpecialCallingConvType SpecialCallingConv_) + : CCInfo(Info), CallConv(CC), IsO32(IsO32_), + SpecialCallingConv(SpecialCallingConv_){ // Pre-allocate reserved argument area. CCInfo.AllocateStack(reservedArgArea(), 1); } + void MipsTargetLowering::MipsCC:: analyzeCallOperands(const SmallVectorImpl &Args, bool IsVarArg, bool IsSoftFloat, const SDNode *CallNode, @@ -3183,6 +3213,8 @@ llvm::CCAssignFn *MipsTargetLowering::MipsCC::fixedArgFn() const { if (CallConv == CallingConv::Fast) return CC_Mips_FastCC; + if (SpecialCallingConv == Mips16RetHelperConv) + return CC_Mips16RetHelper; return IsO32 ? CC_MipsO32 : CC_MipsN; } diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h index 5587e8f58147..233c11f78981 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.h +++ b/llvm/lib/Target/Mips/MipsISelLowering.h @@ -240,7 +240,14 @@ namespace llvm { /// arguments and inquire about calling convention information. class MipsCC { public: - MipsCC(CallingConv::ID CallConv, bool IsO32, CCState &Info); + enum SpecialCallingConvType { + Mips16RetHelperConv, NoSpecialCallingConv + }; + + MipsCC( + CallingConv::ID CallConv, bool IsO32, CCState &Info, + SpecialCallingConvType SpecialCallingConv = NoSpecialCallingConv); + void analyzeCallOperands(const SmallVectorImpl &Outs, bool IsVarArg, bool IsSoftFloat, @@ -313,15 +320,18 @@ namespace llvm { CCState &CCInfo; CallingConv::ID CallConv; bool IsO32; + SpecialCallingConvType SpecialCallingConv; SmallVector ByValArgs; }; - + protected: // Subtarget Info const MipsSubtarget *Subtarget; bool HasMips64, IsN64, IsO32; private: + + MipsCC::SpecialCallingConvType getSpecialCallingConv(SDValue Callee) const; // Lower Operand helpers SDValue LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, diff --git a/llvm/lib/Target/Mips/MipsRegisterInfo.cpp b/llvm/lib/Target/Mips/MipsRegisterInfo.cpp index dead07bacd5e..ae25e456d511 100644 --- a/llvm/lib/Target/Mips/MipsRegisterInfo.cpp +++ b/llvm/lib/Target/Mips/MipsRegisterInfo.cpp @@ -100,6 +100,10 @@ MipsRegisterInfo::getCallPreservedMask(CallingConv::ID) const { return CSR_N64_RegMask; } +const uint32_t *MipsRegisterInfo::getMips16RetHelperMask() { + return CSR_Mips16RetHelper_RegMask; +} + BitVector MipsRegisterInfo:: getReservedRegs(const MachineFunction &MF) const { static const uint16_t ReservedCPURegs[] = { diff --git a/llvm/lib/Target/Mips/MipsRegisterInfo.h b/llvm/lib/Target/Mips/MipsRegisterInfo.h index 5ed51241391f..20ba41d7fd79 100644 --- a/llvm/lib/Target/Mips/MipsRegisterInfo.h +++ b/llvm/lib/Target/Mips/MipsRegisterInfo.h @@ -46,6 +46,7 @@ public: MachineFunction &MF) const; const uint16_t *getCalleeSavedRegs(const MachineFunction *MF = 0) const; const uint32_t *getCallPreservedMask(CallingConv::ID) const; + static const uint32_t *getMips16RetHelperMask(); BitVector getReservedRegs(const MachineFunction &MF) const; diff --git a/llvm/lib/Target/Mips/MipsSubtarget.cpp b/llvm/lib/Target/Mips/MipsSubtarget.cpp index 14a2b2779512..259e68df325c 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.cpp +++ b/llvm/lib/Target/Mips/MipsSubtarget.cpp @@ -48,6 +48,11 @@ static cl::opt Mips_Os16( "floating point as Mips 16"), cl::Hidden); +static cl::opt +Mips16HardFloat("mips16-hard-float", cl::NotHidden, + cl::desc("MIPS: mips16 hard float enable."), + cl::init(false)); + void MipsSubtarget::anchor() { } MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU, @@ -58,7 +63,8 @@ MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU, IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false), IsLinux(true), HasSEInReg(false), HasCondMov(false), HasSwap(false), HasBitCount(false), HasFPIdx(false), - InMips16Mode(false), InMicroMipsMode(false), HasDSP(false), HasDSPR2(false), + InMips16Mode(false), InMips16HardFloat(Mips16HardFloat), + InMicroMipsMode(false), HasDSP(false), HasDSPR2(false), AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16), RM(_RM), OverrideMode(NoOverride), TM(_TM) { diff --git a/llvm/lib/Target/Mips/MipsSubtarget.h b/llvm/lib/Target/Mips/MipsSubtarget.h index f2f0e15887e4..ef7568a81383 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.h +++ b/llvm/lib/Target/Mips/MipsSubtarget.h @@ -93,6 +93,9 @@ protected: // InMips16 -- can process Mips16 instructions bool InMips16Mode; + // Mips16 hard float + bool InMips16HardFloat; + // PreviousInMips16 -- the function we just processed was in Mips 16 Mode bool PreviousInMips16Mode; @@ -170,9 +173,12 @@ public: } llvm_unreachable("Unexpected mode"); } - bool inMips16ModeDefault() { + bool inMips16ModeDefault() const { return InMips16Mode; } + bool inMips16HardFloat() const { + return inMips16Mode() && InMips16HardFloat; + } bool inMicroMipsMode() const { return InMicroMipsMode; } bool hasDSP() const { return HasDSP; } bool hasDSPR2() const { return HasDSPR2; } @@ -188,7 +194,8 @@ public: bool hasBitCount() const { return HasBitCount; } bool hasFPIdx() const { return HasFPIdx; } - bool allowMixed16_32() const { return AllowMixed16_32;}; + bool allowMixed16_32() const { return inMips16ModeDefault() | + AllowMixed16_32;} bool os16() const { return Os16;}; diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp b/llvm/lib/Target/Mips/MipsTargetMachine.cpp index ee28e2a122dd..a876f1c7f041 100644 --- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp +++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp @@ -22,6 +22,7 @@ #include "MipsSEISelLowering.h" #include "MipsSEISelDAGToDAG.h" #include "Mips16FrameLowering.h" +#include "Mips16HardFloat.h" #include "Mips16InstrInfo.h" #include "Mips16ISelDAGToDAG.h" #include "Mips16ISelLowering.h" @@ -156,6 +157,8 @@ void MipsPassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); if (getMipsSubtarget().os16()) addPass(createMipsOs16(getMipsTargetMachine())); + if (getMipsSubtarget().inMips16HardFloat()) + addPass(createMips16HardFloat(getMipsTargetMachine())); } // Install an instruction selector pass using // the ISelDag to gen Mips code. diff --git a/llvm/test/CodeGen/Mips/mips16_fpret.ll b/llvm/test/CodeGen/Mips/mips16_fpret.ll new file mode 100644 index 000000000000..ae0d1b44ae19 --- /dev/null +++ b/llvm/test/CodeGen/Mips/mips16_fpret.ll @@ -0,0 +1,77 @@ +; RUN: llc -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=1 +; RUN: llc -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=2 +; RUN: llc -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=3 +; RUN: llc -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=4 + + +@x = global float 0x41F487E980000000, align 4 +@dx = global double 0x41CDCC8BC4800000, align 8 +@cx = global { float, float } { float 1.000000e+00, float 9.900000e+01 }, align 4 +@dcx = global { double, double } { double 0x42CE5E14A412B480, double 0x423AA4C580DB0000 }, align 8 + +define float @foox() { +entry: + %0 = load float* @x, align 4 + ret float %0 +; 1: .ent foox +; 1: lw $2, %lo(x)(${{[0-9]+}}) +; 1: jal __mips16_ret_sf +} + +define double @foodx() { +entry: + %0 = load double* @dx, align 8 + ret double %0 +; 1: .ent foodx +; 1: lw $2, %lo(dx)(${{[0-9]+}}) +; 1: jal __mips16_ret_df +; 2: .ent foodx +; 2: lw $3, 4(${{[0-9]+}}) +; 2: jal __mips16_ret_df + +} + +define { float, float } @foocx() { +entry: + %retval = alloca { float, float }, align 4 + %cx.real = load float* getelementptr inbounds ({ float, float }* @cx, i32 0, i32 0) + %cx.imag = load float* getelementptr inbounds ({ float, float }* @cx, i32 0, i32 1) + %real = getelementptr inbounds { float, float }* %retval, i32 0, i32 0 + %imag = getelementptr inbounds { float, float }* %retval, i32 0, i32 1 + store float %cx.real, float* %real + store float %cx.imag, float* %imag + %0 = load { float, float }* %retval + ret { float, float } %0 +; 1: .ent foocx +; 1: lw $2, %lo(cx)(${{[0-9]+}}) +; 1: jal __mips16_ret_sc +; 2: .ent foocx +; 2: lw $3, 4(${{[0-9]+}}) +; 2: jal __mips16_ret_sc +} + +define { double, double } @foodcx() { +entry: + %retval = alloca { double, double }, align 8 + %dcx.real = load double* getelementptr inbounds ({ double, double }* @dcx, i32 0, i32 0) + %dcx.imag = load double* getelementptr inbounds ({ double, double }* @dcx, i32 0, i32 1) + %real = getelementptr inbounds { double, double }* %retval, i32 0, i32 0 + %imag = getelementptr inbounds { double, double }* %retval, i32 0, i32 1 + store double %dcx.real, double* %real + store double %dcx.imag, double* %imag + %0 = load { double, double }* %retval + ret { double, double } %0 +; 1: .ent foodcx +; 1: lw $2, %lo(dcx)(${{[0-9]+}}) +; 1: jal __mips16_ret_dc +; 2: .ent foodcx +; 2: lw $3, 4(${{[0-9]+}}) +; 2: jal __mips16_ret_dc +; 3: .ent foodcx +; 3: lw $4, 8(${{[0-9]+}}) +; 3: jal __mips16_ret_dc +; 4: .ent foodcx +; 4: lw $5, 12(${{[0-9]+}}) +; 4: jal __mips16_ret_dc +} + -- GitLab From 64a1fa5cdaab414c06ef8ca7bd851ade5a34dae6 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 10 May 2013 22:52:27 +0000 Subject: [PATCH 207/467] [Modules] Make r180934 more efficient by only loading top-level module maps in system header directories. llvm-svn: 181643 --- clang/include/clang/Lex/HeaderSearch.h | 5 ++++- clang/lib/Lex/HeaderSearch.cpp | 14 ++++++++++++++ clang/lib/Lex/ModuleMap.cpp | 3 +-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h index 446a3810461f..c46c8ce6ef01 100644 --- a/clang/include/clang/Lex/HeaderSearch.h +++ b/clang/include/clang/Lex/HeaderSearch.h @@ -492,7 +492,10 @@ public: /// /// \param Modules Will be filled with the set of known, top-level modules. void collectAllModules(SmallVectorImpl &Modules); - + + /// \brief Load all known, top-level system modules. + void loadTopLevelSystemModules(); + private: /// \brief Retrieve a module with the given name, which may be part of the /// given framework. diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index b8556dde0b20..8a99ed298836 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1146,6 +1146,20 @@ void HeaderSearch::collectAllModules(SmallVectorImpl &Modules) { } } +void HeaderSearch::loadTopLevelSystemModules() { + // Load module maps for each of the header search directories. + for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) { + // We only care about normal system header directories. + if (!SearchDirs[Idx].isNormalDir() || + SearchDirs[Idx].getDirCharacteristic() != SrcMgr::C_System) { + continue; + } + + // Try to load a module map file for the search directory. + loadModuleMapFile(SearchDirs[Idx].getDir()); + } +} + void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) { if (SearchDir.haveSearchedAllModuleMaps()) return; diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index de234853fbf3..62b1fc73c809 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -183,8 +183,7 @@ Module *ModuleMap::findModuleForHeader(const FileEntry *File) { // specific module (e.g., in /usr/include). if (File->getDir() == BuiltinIncludeDir && isBuiltinHeader(llvm::sys::path::filename(File->getName()))) { - SmallVector AllModules; - HeaderInfo.collectAllModules(AllModules); + HeaderInfo.loadTopLevelSystemModules(); // Check again. Known = Headers.find(File); -- GitLab From 7e4c8b06424cc76caaa88f89f20cc88772844a5e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 10 May 2013 22:53:25 +0000 Subject: [PATCH 208/467] Debug Info: Silently accept template argument packs We could support the GCC extension DW_TAG_GNU_template_parameter_pack if we're feeling adventurous, at some point - but I don't think GDB's doing anything useful with it yet anyway. llvm-svn: 181644 --- clang/lib/CodeGen/CGDebugInfo.cpp | 4 +++- clang/test/CodeGenCXX/debug-info-template.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index f236d169bf51..dbae6e969920 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1264,10 +1264,12 @@ CollectTemplateParams(const TemplateParameterList *TPList, // We could support this with the GCC extension // DW_TAG_GNU_template_template_param break; + case TemplateArgument::Pack: + // And this with DW_TAG_GNU_template_parameter_pack + break; // these next 4 should never occur case TemplateArgument::Expression: case TemplateArgument::TemplateExpansion: - case TemplateArgument::Pack: case TemplateArgument::Null: llvm_unreachable( "These argument types shouldn't exist in concrete types"); diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp index 7b987ef97c10..1d2dc10cf259 100644 --- a/clang/test/CodeGenCXX/debug-info-template.cpp +++ b/clang/test/CodeGenCXX/debug-info-template.cpp @@ -1,5 +1,12 @@ // RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s +// CHECK: [[EMPTY:![0-9]*]] = metadata !{i32 0} + +// func<...> doesn't have any template arguments listed since we don't support +// packs yet. This could be encoded with GNU's +// DW_TAG_GNU_template_parameter_pack extension. +// CHECK: {{.*}}, metadata [[EMPTY]], i32 {{[0-9]*}}} ; [ DW_TAG_subprogram ] {{.*}} [func] + // CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] // CHECK: metadata [[TCI:![0-9]*]], i32 0, i32 1, %class.TC* @tci, null} ; [ DW_TAG_variable ] [tci] // CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] @@ -67,3 +74,6 @@ int glb; TC tci; TC tcn; + +template int func() { return 0; } +int anchor = func(); -- GitLab From a189d497f09a19f109dc0799f3c17ce6a9eaf39b Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Fri, 10 May 2013 22:55:24 +0000 Subject: [PATCH 209/467] Use mangled and demangled names when checking for a function in a namespace and a function in an anonymous namespace, respectively. llvm-svn: 181645 --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 9a8030a0fe44..9b363b14711a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3563,9 +3563,10 @@ SymbolFileDWARF::FindFunctions (const ConstString &name, { if (temp_sc_list.GetContextAtIndex(i, sc)) { - ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); - if (!strncmp(name.GetCString(), "_ZN", 3) || - strncmp(name.GetCString(), "(anonymous namespace)", 21)) + ConstString mangled_name = sc.GetFunctionName(Mangled::ePreferMangled); + ConstString demangled_name = sc.GetFunctionName(Mangled::ePreferDemangled); + if (!strncmp(mangled_name.GetCString(), "_ZN", 3) || + strncmp(demangled_name.GetCString(), "(anonymous namespace)", 21)) { sc_list.Append(sc); } -- GitLab From 5ff6db11533e2b1474952e7ddb89fb4fb815bdb1 Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Fri, 10 May 2013 22:55:44 +0000 Subject: [PATCH 210/467] Add an additional testcase for PR15882. llvm-svn: 181646 --- .../Transforms/LoopVectorize/reverse_iter.ll | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 llvm/test/Transforms/LoopVectorize/reverse_iter.ll diff --git a/llvm/test/Transforms/LoopVectorize/reverse_iter.ll b/llvm/test/Transforms/LoopVectorize/reverse_iter.ll new file mode 100644 index 000000000000..6ff4f1f8d1f4 --- /dev/null +++ b/llvm/test/Transforms/LoopVectorize/reverse_iter.ll @@ -0,0 +1,45 @@ +; RUN: opt < %s -loop-vectorize -force-vector-unroll=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.8.0" + +; Make sure that the reverse iterators are calculated using 64bit arithmetic, not 32. +; +; int foo(int n, int *A) { +; int sum; +; for (int i=n; i > 0; i--) +; sum += A[i*2]; +; return sum; +; } +; + +;CHECK: @foo +;CHECK: +;CHECK: ret +define i32 @foo(i32 %n, i32* nocapture %A) { + %1 = icmp sgt i32 %n, 0 + br i1 %1, label %.lr.ph, label %._crit_edge + +.lr.ph: ; preds = %0 + %2 = sext i32 %n to i64 + br label %3 + +;