diff -u llvm-2.7-2.7/debian/changelog llvm-2.7-2.7/debian/changelog --- llvm-2.7-2.7/debian/changelog +++ llvm-2.7-2.7/debian/changelog @@ -1,3 +1,13 @@ +llvm-2.7 (2.7-3ubuntu3) maverick; urgency=low + + * debian/patches/0032-x86-fast-isel-fs-load.patch, + debian/patches/0033-stack-protector-linux.patch: Take upstream r106031 + and r107640 to fix clang -fstack-protector link errors. (LP: #610992) + * debian/rules.d/control.mk: Do not update diffstats on clean. That + code corrupted file deletion patches, and stripped DEP-3 headers. + + -- Anders Kaseorg Mon, 16 Aug 2010 12:53:06 -0400 + llvm-2.7 (2.7-3ubuntu2) maverick; urgency=low * Re-add 0011-gcc-4.4-thumb.patch to fix build failure on ARM. diff -u llvm-2.7-2.7/debian/rules.d/control.mk llvm-2.7-2.7/debian/rules.d/control.mk --- llvm-2.7-2.7/debian/rules.d/control.mk +++ llvm-2.7-2.7/debian/rules.d/control.mk @@ -31,5 +31,5 @@ done -clean: control diffstats +clean: control .PHONY: clean control debian/control diffstats only in patch2: unchanged: --- llvm-2.7-2.7.orig/debian/patches/0033-stack-protector-linux.patch +++ llvm-2.7-2.7/debian/patches/0033-stack-protector-linux.patch @@ -0,0 +1,293 @@ +Description: Fix up -fstack-protector on linux to use the segment registers +Origin: upstream, http://llvm.org/viewvc/llvm-project?view=rev&revision=107640 +Author: Nelson Elhage +Bug: http://llvm.org/bugs/show_bug.cgi?id=5094 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/clang/+bug/610992 +Last-Update: 2010-08-05 + +--- + a/test/CodeGen/Generic/stack-protector.ll | 25 ------------------------- + include/llvm/Target/TargetLowering.h | 8 ++++++++ + lib/CodeGen/StackProtector.cpp | 17 +++++++++++++++-- + lib/Target/X86/X86ISelLowering.cpp | 21 +++++++++++++++++++++ + lib/Target/X86/X86ISelLowering.h | 6 ++++++ + lib/Target/X86/X86Subtarget.cpp | 3 ++- + lib/Target/X86/X86Subtarget.h | 7 +++++++ + test/CodeGen/PowerPC/stack-protector.ll | 25 +++++++++++++++++++++++++ + test/CodeGen/X86/stack-protector-linux.ll | 28 ++++++++++++++++++++++++++++ + test/CodeGen/X86/stack-protector.ll | 25 +++++++++++++++++++++++++ + 10 files changed, 137 insertions(+), 28 deletions(-) + +Index: lib/Target/X86/X86Subtarget.cpp +=================================================================== +--- a/lib/Target/X86/X86Subtarget.cpp ++++ b/lib/Target/X86/X86Subtarget.cpp +@@ -292,7 +292,8 @@ + // FIXME: this is a known good value for Yonah. How about others? + , MaxInlineSizeThreshold(128) + , Is64Bit(is64Bit) +- , TargetType(isELF) { // Default to ELF unless otherwise specified. ++ , TargetType(isELF) // Default to ELF unless otherwise specified. ++ , TargetTriple(TT) { + + // default to hard float ABI + if (FloatABIType == FloatABI::Default) +Index: lib/Target/X86/X86Subtarget.h +=================================================================== +--- a/lib/Target/X86/X86Subtarget.h ++++ b/lib/Target/X86/X86Subtarget.h +@@ -14,6 +14,7 @@ + #ifndef X86SUBTARGET_H + #define X86SUBTARGET_H + ++#include "llvm/ADT/Triple.h" + #include "llvm/Target/TargetSubtarget.h" + #include + +@@ -95,6 +96,8 @@ + /// + unsigned MaxInlineSizeThreshold; + ++ Triple TargetTriple; ++ + private: + /// Is64Bit - True if the processor supports 64-bit instructions and + /// pointer size is 64 bit. +@@ -169,6 +172,10 @@ + return Is64Bit && (TargetType == isMingw || TargetType == isWindows); + } + ++ bool isTargetLinux() const { ++ return TargetTriple.getOS() == Triple::Linux; ++ } ++ + std::string getDataLayout() const { + const char *p; + if (is64Bit()) +Index: test/CodeGen/PowerPC/stack-protector.ll +=================================================================== +--- a/test/CodeGen/PowerPC/stack-protector.ll ++++ b/test/CodeGen/PowerPC/stack-protector.ll +@@ -0,0 +1,25 @@ ++; RUN: llc -march=ppc32 < %s -o - | grep {__stack_chk_guard} ++; RUN: llc -march=ppc32 < %s -o - | grep {__stack_chk_fail} ++ ++@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] ++ ++define void @test(i8* %a) nounwind ssp { ++entry: ++ %a_addr = alloca i8* ; [#uses=2] ++ %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] ++ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] ++ store i8* %a, i8** %a_addr ++ %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] ++ %0 = load i8** %a_addr, align 4 ; [#uses=1] ++ %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] ++ %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] ++ %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] ++ br label %return ++ ++return: ; preds = %entry ++ ret void ++} ++ ++declare i8* @strcpy(i8*, i8*) nounwind ++ ++declare i32 @printf(i8*, ...) nounwind +Index: test/CodeGen/X86/stack-protector-linux.ll +=================================================================== +--- a/test/CodeGen/X86/stack-protector-linux.ll ++++ b/test/CodeGen/X86/stack-protector-linux.ll +@@ -0,0 +1,28 @@ ++; RUN: llc -mtriple=i386-pc-linux-gnu < %s -o - | grep %gs: ++; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s -o - | grep %fs: ++; RUN: llc -code-model=kernel -mtriple=x86_64-pc-linux-gnu < %s -o - | grep %gs: ++; RUN: llc -mtriple=x86_64-apple-darwin < %s -o - | grep {__stack_chk_guard} ++; RUN: llc -mtriple=x86_64-apple-darwin < %s -o - | grep {__stack_chk_fail} ++ ++@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] ++ ++define void @test(i8* %a) nounwind ssp { ++entry: ++ %a_addr = alloca i8* ; [#uses=2] ++ %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] ++ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] ++ store i8* %a, i8** %a_addr ++ %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] ++ %0 = load i8** %a_addr, align 4 ; [#uses=1] ++ %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] ++ %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] ++ %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] ++ br label %return ++ ++return: ; preds = %entry ++ ret void ++} ++ ++declare i8* @strcpy(i8*, i8*) nounwind ++ ++declare i32 @printf(i8*, ...) nounwind +Index: test/CodeGen/X86/stack-protector.ll +=================================================================== +--- a/test/CodeGen/X86/stack-protector.ll ++++ b/test/CodeGen/X86/stack-protector.ll +@@ -0,0 +1,25 @@ ++; RUN: llc -march=x86 < %s -o - | grep {__stack_chk_guard} ++; RUN: llc -march=x86 < %s -o - | grep {__stack_chk_fail} ++ ++@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] ++ ++define void @test(i8* %a) nounwind ssp { ++entry: ++ %a_addr = alloca i8* ; [#uses=2] ++ %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] ++ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] ++ store i8* %a, i8** %a_addr ++ %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] ++ %0 = load i8** %a_addr, align 4 ; [#uses=1] ++ %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] ++ %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] ++ %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] ++ br label %return ++ ++return: ; preds = %entry ++ ret void ++} ++ ++declare i8* @strcpy(i8*, i8*) nounwind ++ ++declare i32 @printf(i8*, ...) nounwind +Index: test/CodeGen/Generic/stack-protector.ll +=================================================================== +--- a/test/CodeGen/Generic/stack-protector.ll ++++ /dev/null +@@ -1,25 +0,0 @@ +-; RUN: llc < %s -o - | grep {__stack_chk_guard} +-; RUN: llc < %s -o - | grep {__stack_chk_fail} +- +-@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] +- +-define void @test(i8* %a) nounwind ssp { +-entry: +- %a_addr = alloca i8* ; [#uses=2] +- %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] +- %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] +- store i8* %a, i8** %a_addr +- %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] +- %0 = load i8** %a_addr, align 4 ; [#uses=1] +- %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] +- %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] +- %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] +- br label %return +- +-return: ; preds = %entry +- ret void +-} +- +-declare i8* @strcpy(i8*, i8*) nounwind +- +-declare i32 @printf(i8*, ...) nounwind +Index: include/llvm/Target/TargetLowering.h +=================================================================== +--- a/include/llvm/Target/TargetLowering.h ++++ b/include/llvm/Target/TargetLowering.h +@@ -749,6 +749,14 @@ + /// getFunctionAlignment - Return the Log2 alignment of this function. + virtual unsigned getFunctionAlignment(const Function *) const = 0; + ++ /// getStackCookieLocation - Return true if the target stores stack ++ /// protector cookies at a fixed offset in some non-standard address ++ /// space, and populates the address space and offset as ++ /// appropriate. ++ virtual bool getStackCookieLocation(unsigned &AddressSpace, unsigned &Offset) const { ++ return false; ++ } ++ + //===--------------------------------------------------------------------===// + // TargetLowering Optimization Methods + // +Index: lib/CodeGen/StackProtector.cpp +=================================================================== +--- a/lib/CodeGen/StackProtector.cpp ++++ b/lib/CodeGen/StackProtector.cpp +@@ -136,7 +136,7 @@ + bool StackProtector::InsertStackProtectors() { + BasicBlock *FailBB = 0; // The basic block to jump to if check fails. + AllocaInst *AI = 0; // Place on stack that stores the stack guard. +- Constant *StackGuardVar = 0; // The stack guard variable. ++ Value *StackGuardVar = 0; // The stack guard variable. + + for (Function::iterator I = F->begin(), E = F->end(); I != E; ) { + BasicBlock *BB = I++; +@@ -155,8 +155,21 @@ + // + PointerType *PtrTy = PointerType::getUnqual( + Type::getInt8Ty(RI->getContext())); +- StackGuardVar = M->getOrInsertGlobal("__stack_chk_guard", PtrTy); + ++ unsigned AddressSpace, Offset; ++ if (TLI->getStackCookieLocation(AddressSpace, Offset)) { ++ Constant *ASPtr = Constant::getNullValue( ++ PointerType::get(Type::getInt8Ty(RI->getContext()), AddressSpace)); ++ APInt OffsetInt(32, Offset); ++ Constant *OffsetVal = Constant::getIntegerValue( ++ Type::getInt32Ty(RI->getContext()), OffsetInt); ++ StackGuardVar = ConstantExpr::getPointerCast( ++ ConstantExpr::getGetElementPtr(ASPtr, &OffsetVal, 1), ++ PointerType::get(PtrTy, AddressSpace)); ++ } else { ++ StackGuardVar = M->getOrInsertGlobal("__stack_chk_guard", PtrTy); ++ } ++ + BasicBlock &Entry = F->getEntryBlock(); + Instruction *InsPt = &Entry.front(); + +Index: lib/Target/X86/X86ISelLowering.cpp +=================================================================== +--- a/lib/Target/X86/X86ISelLowering.cpp ++++ b/lib/Target/X86/X86ISelLowering.cpp +@@ -1189,6 +1189,27 @@ + return F->hasFnAttr(Attribute::OptimizeForSize) ? 0 : 4; + } + ++bool X86TargetLowering::getStackCookieLocation(unsigned &AddressSpace, ++ unsigned &Offset) const { ++ if (!Subtarget->isTargetLinux()) ++ return false; ++ ++ if (Subtarget->is64Bit()) { ++ // %fs:0x28, unless we're using a Kernel code model, in which case it's %gs: ++ Offset = 0x28; ++ if (getTargetMachine().getCodeModel() == CodeModel::Kernel) ++ AddressSpace = 256; ++ else ++ AddressSpace = 257; ++ } else { ++ // %gs:0x14 on i386 ++ Offset = 0x14; ++ AddressSpace = 256; ++ } ++ return true; ++} ++ ++ + //===----------------------------------------------------------------------===// + // Return Value Calling Convention Implementation + //===----------------------------------------------------------------------===// +Index: lib/Target/X86/X86ISelLowering.h +=================================================================== +--- a/lib/Target/X86/X86ISelLowering.h ++++ b/lib/Target/X86/X86ISelLowering.h +@@ -593,6 +593,12 @@ + /// getFunctionAlignment - Return the Log2 alignment of this function. + virtual unsigned getFunctionAlignment(const Function *F) const; + ++ /// getStackCookieLocation - Return true if the target stores stack ++ /// protector cookies at a fixed offset in some non-standard address ++ /// space, and populates the address space and offset as ++ /// appropriate. ++ virtual bool getStackCookieLocation(unsigned &AddressSpace, unsigned &Offset) const; ++ + private: + /// Subtarget - Keep a pointer to the X86Subtarget around so that we can + /// make the right decision when generating code for different targets. only in patch2: unchanged: --- llvm-2.7-2.7.orig/debian/patches/0032-x86-fast-isel-fs-load.patch +++ llvm-2.7-2.7/debian/patches/0032-x86-fast-isel-fs-load.patch @@ -0,0 +1,39 @@ +Description: fix fastisel to handle GS and FS relative pointers +Origin: upstream, http://llvm.org/viewvc/llvm-project?view=rev&revision=106031 +Author: Nelson Elhage +Bug: http://llvm.org/bugs/show_bug.cgi?id=5094 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/clang/+bug/610992 +Last-Update: 2010-08-05 + +--- + lib/Target/X86/X86FastISel.cpp | 5 +++++ + test/CodeGen/X86/2010-06-14-fast-isel-fs-load.ll | 6 ++++++ + 2 files changed, 11 insertions(+) + +Index: test/CodeGen/X86/2010-06-14-fast-isel-fs-load.ll +=================================================================== +--- a/test/CodeGen/X86/2010-06-14-fast-isel-fs-load.ll ++++ b/test/CodeGen/X86/2010-06-14-fast-isel-fs-load.ll +@@ -0,0 +1,6 @@ ++; RUN: llc -fast-isel -march=x86 < %s | grep %fs: ++ ++define i32 @test1(i32 addrspace(257)* %arg) nounwind { ++ %tmp = load i32 addrspace(257)* %arg ++ ret i32 %tmp ++} +Index: lib/Target/X86/X86FastISel.cpp +=================================================================== +--- a/lib/Target/X86/X86FastISel.cpp ++++ b/lib/Target/X86/X86FastISel.cpp +@@ -349,6 +349,11 @@ + U = C; + } + ++ if (const PointerType *Ty = dyn_cast(V->getType())) ++ if (Ty->getAddressSpace() > 255) ++ // Fast instruction selection doesn't support pointers through %fs or %gs ++ return false; ++ + switch (Opcode) { + default: break; + case Instruction::BitCast: