r352181 - Disable PIC/PIE for MSP430 target by default.

Anton Korobeynikov via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 25 01:41:20 PST 2019


Author: asl
Date: Fri Jan 25 01:41:20 2019
New Revision: 352181

URL: http://llvm.org/viewvc/llvm-project?rev=352181&view=rev
Log:
Disable PIC/PIE for MSP430 target by default.

Relocatable code generation is meaningless on MSP430, as the platform is too small to use shared libraries.

Patch by Dmitry Mikushev!

Differential Revision: https://reviews.llvm.org/D56927

Added:
    cfe/trunk/test/CodeGen/msp430-reloc.c
Modified:
    cfe/trunk/lib/Driver/ToolChains/MSP430.h

Modified: cfe/trunk/lib/Driver/ToolChains/MSP430.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSP430.h?rev=352181&r1=352180&r2=352181&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/MSP430.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSP430.h Fri Jan 25 01:41:20 2019
@@ -36,6 +36,10 @@ public:
                              llvm::opt::ArgStringList &CC1Args,
                              Action::OffloadKind) const override;
 
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
+
 protected:
   Tool *buildLinker() const override;
 

Added: cfe/trunk/test/CodeGen/msp430-reloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/msp430-reloc.c?rev=352181&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/msp430-reloc.c (added)
+++ cfe/trunk/test/CodeGen/msp430-reloc.c Fri Jan 25 01:41:20 2019
@@ -0,0 +1,29 @@
+// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s
+
+// Check the compilation does not crash as it was crashing before with "-fPIC" enabled
+
+void *alloca(unsigned int size);
+
+// CHECK: .globl foo
+short foo(char** data, char encoding)
+{
+	char* encoding_addr = alloca(sizeof(char));
+	*encoding_addr = encoding;
+
+	char tmp3 = *encoding_addr;
+	short conv2 = tmp3;
+	short and = conv2 & 0xf;
+
+	switch (and)
+	{
+	case 0 :
+	case 4 :
+	case 10 :
+		return 1;
+	case 11 :
+		return 2;
+	}
+
+	return 0;
+}
+




More information about the cfe-commits mailing list