r353877 - Disable PIC/PIE for MSP430 target
Anton Korobeynikov via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 12 12:46:01 PST 2019
Author: asl
Date: Tue Feb 12 12:46:00 2019
New Revision: 353877
URL: http://llvm.org/viewvc/llvm-project?rev=353877&view=rev
Log:
Disable PIC/PIE for MSP430 target
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=353877&r1=353876&r2=353877&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/MSP430.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSP430.h Tue Feb 12 12:46:00 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=353877&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/msp430-reloc.c (added)
+++ cfe/trunk/test/CodeGen/msp430-reloc.c Tue Feb 12 12:46:00 2019
@@ -0,0 +1,30 @@
+// REQUIRES: msp430-registered-target
+// 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